Completed
Push — master ( d488ab...6453e7 )
by Stephen
53:31
created
src/wp-admin/includes/ms-admin-filters.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Multisite Administration hooks
4
- *
5
- * @package WordPress
6
- *
7
- * @since 4.3.0
8
- */
3
+	 * Multisite Administration hooks
4
+	 *
5
+	 * @package WordPress
6
+	 *
7
+	 * @since 4.3.0
8
+	 */
9 9
 
10 10
 // Media Hooks.
11 11
 add_filter( 'wp_handle_upload_prefilter', 'check_upload_size' );
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -8,35 +8,35 @@
 block discarded – undo
8 8
  */
9 9
 
10 10
 // Media Hooks.
11
-add_filter( 'wp_handle_upload_prefilter', 'check_upload_size' );
11
+add_filter('wp_handle_upload_prefilter', 'check_upload_size');
12 12
 
13 13
 // User Hooks
14
-add_action( 'admin_notices', 'new_user_email_admin_notice' );
14
+add_action('admin_notices', 'new_user_email_admin_notice');
15 15
 
16
-add_action( 'admin_page_access_denied', '_access_denied_splash', 99 );
16
+add_action('admin_page_access_denied', '_access_denied_splash', 99);
17 17
 
18
-add_action( 'add_option_new_admin_email', 'update_option_new_admin_email', 10, 2 );
18
+add_action('add_option_new_admin_email', 'update_option_new_admin_email', 10, 2);
19 19
 
20
-add_action( 'personal_options_update', 'send_confirmation_on_profile_email' );
20
+add_action('personal_options_update', 'send_confirmation_on_profile_email');
21 21
 
22
-add_action( 'update_option_new_admin_email', 'update_option_new_admin_email', 10, 2 );
22
+add_action('update_option_new_admin_email', 'update_option_new_admin_email', 10, 2);
23 23
 
24 24
 // Site Hooks.
25
-add_action( 'wpmueditblogaction', 'upload_space_setting' );
25
+add_action('wpmueditblogaction', 'upload_space_setting');
26 26
 
27 27
 // Taxonomy Hooks
28
-add_filter( 'get_term', 'sync_category_tag_slugs', 10, 2 );
28
+add_filter('get_term', 'sync_category_tag_slugs', 10, 2);
29 29
 
30 30
 // Post Hooks.
31
-add_filter( 'wp_insert_post_data', 'avoid_blog_page_permalink_collision', 10, 2 );
31
+add_filter('wp_insert_post_data', 'avoid_blog_page_permalink_collision', 10, 2);
32 32
 
33 33
 // Tools Hooks.
34
-add_filter( 'import_allow_create_users', 'check_import_new_users' );
34
+add_filter('import_allow_create_users', 'check_import_new_users');
35 35
 
36 36
 // Notices Hooks
37
-add_action( 'admin_notices',         'site_admin_notice' );
38
-add_action( 'network_admin_notices', 'site_admin_notice' );
37
+add_action('admin_notices', 'site_admin_notice');
38
+add_action('network_admin_notices', 'site_admin_notice');
39 39
 
40 40
 // Update Hooks
41
-add_action( 'network_admin_notices', 'update_nag',      3  );
42
-add_action( 'network_admin_notices', 'maintenance_nag', 10 );
41
+add_action('network_admin_notices', 'update_nag', 3);
42
+add_action('network_admin_notices', 'maintenance_nag', 10);
Please login to merge, or discard this patch.
src/wp-admin/includes/theme-install.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * WordPress Theme Install Administration API
4
- *
5
- * @package WordPress
6
- * @subpackage Administration
7
- */
3
+	 * WordPress Theme Install Administration API
4
+	 *
5
+	 * @package WordPress
6
+	 * @subpackage Administration
7
+	 */
8 8
 
9 9
 $themes_allowedtags = array('a' => array('href' => array(), 'title' => array(), 'target' => array()),
10 10
 	'abbr' => array('title' => array()), 'acronym' => array('title' => array()),
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 	'img' => array('src' => array(), 'class' => array(), 'alt' => array())
15 15
 );
16 16
 
17
-$theme_field_defaults = array( 'description' => true, 'sections' => false, 'tested' => true, 'requires' => true,
17
+$theme_field_defaults = array('description' => true, 'sections' => false, 'tested' => true, 'requires' => true,
18 18
 	'rating' => true, 'downloaded' => true, 'downloadlink' => true, 'last_updated' => true, 'homepage' => true,
19 19
 	'tags' => true, 'num_ratings' => true
20 20
 );
@@ -29,19 +29,19 @@  discard block
 block discarded – undo
29 29
  * @return array
30 30
  */
31 31
 function install_themes_feature_list() {
32
-	_deprecated_function( __FUNCTION__, '3.1', 'get_theme_feature_list()' );
32
+	_deprecated_function(__FUNCTION__, '3.1', 'get_theme_feature_list()');
33 33
 
34
-	if ( !$cache = get_transient( 'wporg_theme_feature_list' ) )
35
-		set_transient( 'wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS );
34
+	if ( ! $cache = get_transient('wporg_theme_feature_list'))
35
+		set_transient('wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS);
36 36
 
37
-	if ( $cache )
37
+	if ($cache)
38 38
 		return $cache;
39 39
 
40
-	$feature_list = themes_api( 'feature_list', array() );
41
-	if ( is_wp_error( $feature_list ) )
40
+	$feature_list = themes_api('feature_list', array());
41
+	if (is_wp_error($feature_list))
42 42
 		return array();
43 43
 
44
-	set_transient( 'wporg_theme_feature_list', $feature_list, 3 * HOUR_IN_SECONDS );
44
+	set_transient('wporg_theme_feature_list', $feature_list, 3 * HOUR_IN_SECONDS);
45 45
 
46 46
 	return $feature_list;
47 47
 }
@@ -53,15 +53,15 @@  discard block
 block discarded – undo
53 53
  *
54 54
  * @param bool $type_selector
55 55
  */
56
-function install_theme_search_form( $type_selector = true ) {
57
-	$type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term';
58
-	$term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : '';
59
-	if ( ! $type_selector )
60
-		echo '<p class="install-help">' . __( 'Search for themes by keyword.' ) . '</p>';
56
+function install_theme_search_form($type_selector = true) {
57
+	$type = isset($_REQUEST['type']) ? wp_unslash($_REQUEST['type']) : 'term';
58
+	$term = isset($_REQUEST['s']) ? wp_unslash($_REQUEST['s']) : '';
59
+	if ( ! $type_selector)
60
+		echo '<p class="install-help">'.__('Search for themes by keyword.').'</p>';
61 61
 	?>
62 62
 <form id="search-themes" method="get">
63 63
 	<input type="hidden" name="tab" value="search" />
64
-	<?php if ( $type_selector ) : ?>
64
+	<?php if ($type_selector) : ?>
65 65
 	<label class="screen-reader-text" for="typeselector"><?php _e('Type of search'); ?></label>
66 66
 	<select	name="type" id="typeselector">
67 67
 	<option value="term" <?php selected('term', $type) ?>><?php _e('Keyword'); ?></option>
@@ -69,15 +69,15 @@  discard block
 block discarded – undo
69 69
 	<option value="tag" <?php selected('tag', $type) ?>><?php _ex('Tag', 'Theme Installer'); ?></option>
70 70
 	</select>
71 71
 	<label class="screen-reader-text" for="s"><?php
72
-	switch ( $type ) {
72
+	switch ($type) {
73 73
 		case 'term':
74
-			_e( 'Search by keyword' );
74
+			_e('Search by keyword');
75 75
 			break;
76 76
 		case 'author':
77
-			_e( 'Search by author' );
77
+			_e('Search by author');
78 78
 			break;
79 79
 		case 'tag':
80
-			_e( 'Search by tag' );
80
+			_e('Search by tag');
81 81
 			break;
82 82
 	}
83 83
 	?></label>
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	<label class="screen-reader-text" for="s"><?php _e('Search by keyword'); ?></label>
86 86
 	<?php endif; ?>
87 87
 	<input type="search" name="s" id="s" size="30" value="<?php echo esc_attr($term) ?>" autofocus="autofocus" />
88
-	<?php submit_button( __( 'Search' ), 'button', 'search', false ); ?>
88
+	<?php submit_button(__('Search'), 'button', 'search', false); ?>
89 89
 </form>
90 90
 <?php
91 91
 }
@@ -96,10 +96,10 @@  discard block
 block discarded – undo
96 96
  * @since 2.8.0
97 97
  */
98 98
 function install_themes_dashboard() {
99
-	install_theme_search_form( false );
99
+	install_theme_search_form(false);
100 100
 ?>
101 101
 <h4><?php _e('Feature Filter') ?></h4>
102
-<p class="install-help"><?php _e( 'Find a theme based on specific features.' ); ?></p>
102
+<p class="install-help"><?php _e('Find a theme based on specific features.'); ?></p>
103 103
 
104 104
 <form method="get">
105 105
 	<input type="hidden" name="tab" value="search" />
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
 	$feature_list = get_theme_feature_list();
108 108
 	echo '<div class="feature-filter">';
109 109
 
110
-	foreach ( (array) $feature_list as $feature_name => $features ) {
111
-		$feature_name = esc_html( $feature_name );
112
-		echo '<div class="feature-name">' . $feature_name . '</div>';
110
+	foreach ((array) $feature_list as $feature_name => $features) {
111
+		$feature_name = esc_html($feature_name);
112
+		echo '<div class="feature-name">'.$feature_name.'</div>';
113 113
 
114 114
 		echo '<ol class="feature-group">';
115
-		foreach ( $features as $feature => $feature_name ) {
116
-			$feature_name = esc_html( $feature_name );
115
+		foreach ($features as $feature => $feature_name) {
116
+			$feature_name = esc_html($feature_name);
117 117
 			$feature = esc_attr($feature);
118 118
 ?>
119 119
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 
131 131
 </div>
132 132
 <br class="clear" />
133
-<?php submit_button( __( 'Find Themes' ), 'button', 'search' ); ?>
133
+<?php submit_button(__('Find Themes'), 'button', 'search'); ?>
134 134
 </form>
135 135
 <?php
136 136
 }
@@ -142,9 +142,9 @@  discard block
 block discarded – undo
142 142
 ?>
143 143
 <p class="install-help"><?php _e('If you have a theme in a .zip format, you may install it by uploading it here.'); ?></p>
144 144
 <form method="post" enctype="multipart/form-data" class="wp-upload-form" action="<?php echo self_admin_url('update.php?action=upload-theme'); ?>">
145
-	<?php wp_nonce_field( 'theme-upload'); ?>
145
+	<?php wp_nonce_field('theme-upload'); ?>
146 146
 	<input type="file" name="themezip" />
147
-	<?php submit_button( __( 'Install Now' ), 'button', 'install-theme-submit', false ); ?>
147
+	<?php submit_button(__('Install Now'), 'button', 'install-theme-submit', false); ?>
148 148
 </form>
149 149
 	<?php
150 150
 }
@@ -158,14 +158,14 @@  discard block
 block discarded – undo
158 158
  *
159 159
  * @param object $theme
160 160
  */
161
-function display_theme( $theme ) {
162
-	_deprecated_function( __FUNCTION__, '3.4' );
161
+function display_theme($theme) {
162
+	_deprecated_function(__FUNCTION__, '3.4');
163 163
 	global $wp_list_table;
164
-	if ( ! isset( $wp_list_table ) ) {
164
+	if ( ! isset($wp_list_table)) {
165 165
 		$wp_list_table = _get_list_table('WP_Theme_Install_List_Table');
166 166
 	}
167 167
 	$wp_list_table->prepare_items();
168
-	$wp_list_table->single_row( $theme );
168
+	$wp_list_table->single_row($theme);
169 169
 }
170 170
 
171 171
 /**
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 function display_themes() {
179 179
 	global $wp_list_table;
180 180
 
181
-	if ( ! isset( $wp_list_table ) ) {
181
+	if ( ! isset($wp_list_table)) {
182 182
 		$wp_list_table = _get_list_table('WP_Theme_Install_List_Table');
183 183
 	}
184 184
 	$wp_list_table->prepare_items();
@@ -196,16 +196,16 @@  discard block
 block discarded – undo
196 196
 function install_theme_information() {
197 197
 	global $wp_list_table;
198 198
 
199
-	$theme = themes_api( 'theme_information', array( 'slug' => wp_unslash( $_REQUEST['theme'] ) ) );
199
+	$theme = themes_api('theme_information', array('slug' => wp_unslash($_REQUEST['theme'])));
200 200
 
201
-	if ( is_wp_error( $theme ) )
202
-		wp_die( $theme );
201
+	if (is_wp_error($theme))
202
+		wp_die($theme);
203 203
 
204
-	iframe_header( __('Theme Install') );
205
-	if ( ! isset( $wp_list_table ) ) {
204
+	iframe_header(__('Theme Install'));
205
+	if ( ! isset($wp_list_table)) {
206 206
 		$wp_list_table = _get_list_table('WP_Theme_Install_List_Table');
207 207
 	}
208
-	$wp_list_table->theme_installer_single( $theme );
208
+	$wp_list_table->theme_installer_single($theme);
209 209
 	iframe_footer();
210 210
 	exit;
211 211
 }
Please login to merge, or discard this patch.
Braces   +20 added lines, -12 removed lines patch added patch discarded remove patch
@@ -31,15 +31,18 @@  discard block
 block discarded – undo
31 31
 function install_themes_feature_list() {
32 32
 	_deprecated_function( __FUNCTION__, '3.1', 'get_theme_feature_list()' );
33 33
 
34
-	if ( !$cache = get_transient( 'wporg_theme_feature_list' ) )
35
-		set_transient( 'wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS );
34
+	if ( !$cache = get_transient( 'wporg_theme_feature_list' ) ) {
35
+			set_transient( 'wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS );
36
+	}
36 37
 
37
-	if ( $cache )
38
-		return $cache;
38
+	if ( $cache ) {
39
+			return $cache;
40
+	}
39 41
 
40 42
 	$feature_list = themes_api( 'feature_list', array() );
41
-	if ( is_wp_error( $feature_list ) )
42
-		return array();
43
+	if ( is_wp_error( $feature_list ) ) {
44
+			return array();
45
+	}
43 46
 
44 47
 	set_transient( 'wporg_theme_feature_list', $feature_list, 3 * HOUR_IN_SECONDS );
45 48
 
@@ -56,8 +59,9 @@  discard block
 block discarded – undo
56 59
 function install_theme_search_form( $type_selector = true ) {
57 60
 	$type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term';
58 61
 	$term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : '';
59
-	if ( ! $type_selector )
60
-		echo '<p class="install-help">' . __( 'Search for themes by keyword.' ) . '</p>';
62
+	if ( ! $type_selector ) {
63
+			echo '<p class="install-help">' . __( 'Search for themes by keyword.' ) . '</p>';
64
+	}
61 65
 	?>
62 66
 <form id="search-themes" method="get">
63 67
 	<input type="hidden" name="tab" value="search" />
@@ -81,8 +85,11 @@  discard block
 block discarded – undo
81 85
 			break;
82 86
 	}
83 87
 	?></label>
84
-	<?php else : ?>
85
-	<label class="screen-reader-text" for="s"><?php _e('Search by keyword'); ?></label>
88
+	<?php else {
89
+	: ?>
90
+	<label class="screen-reader-text" for="s"><?php _e('Search by keyword');
91
+}
92
+?></label>
86 93
 	<?php endif; ?>
87 94
 	<input type="search" name="s" id="s" size="30" value="<?php echo esc_attr($term) ?>" autofocus="autofocus" />
88 95
 	<?php submit_button( __( 'Search' ), 'button', 'search', false ); ?>
@@ -198,8 +205,9 @@  discard block
 block discarded – undo
198 205
 
199 206
 	$theme = themes_api( 'theme_information', array( 'slug' => wp_unslash( $_REQUEST['theme'] ) ) );
200 207
 
201
-	if ( is_wp_error( $theme ) )
202
-		wp_die( $theme );
208
+	if ( is_wp_error( $theme ) ) {
209
+			wp_die( $theme );
210
+	}
203 211
 
204 212
 	iframe_header( __('Theme Install') );
205 213
 	if ( ! isset( $wp_list_table ) ) {
Please login to merge, or discard this patch.
src/wp-admin/includes/post.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * WordPress Post Administration API.
4
- *
5
- * @package WordPress
6
- * @subpackage Administration
7
- */
3
+	 * WordPress Post Administration API.
4
+	 *
5
+	 * @package WordPress
6
+	 * @subpackage Administration
7
+	 */
8 8
 
9 9
 /**
10 10
  * Rename $_POST data from form names to DB post columns.
Please login to merge, or discard this patch.
Spacing   +499 added lines, -499 removed lines patch added patch discarded remove patch
@@ -18,151 +18,151 @@  discard block
 block discarded – undo
18 18
  * @param array $post_data Array of post data. Defaults to the contents of $_POST.
19 19
  * @return object|bool WP_Error on failure, true on success.
20 20
  */
21
-function _wp_translate_postdata( $update = false, $post_data = null ) {
21
+function _wp_translate_postdata($update = false, $post_data = null) {
22 22
 
23
-	if ( empty($post_data) )
23
+	if (empty($post_data))
24 24
 		$post_data = &$_POST;
25 25
 
26
-	if ( $update )
26
+	if ($update)
27 27
 		$post_data['ID'] = (int) $post_data['post_ID'];
28 28
 
29
-	$ptype = get_post_type_object( $post_data['post_type'] );
29
+	$ptype = get_post_type_object($post_data['post_type']);
30 30
 
31
-	if ( $update && ! current_user_can( 'edit_post', $post_data['ID'] ) ) {
32
-		if ( 'page' == $post_data['post_type'] )
33
-			return new WP_Error( 'edit_others_pages', __( 'You are not allowed to edit pages as this user.' ) );
31
+	if ($update && ! current_user_can('edit_post', $post_data['ID'])) {
32
+		if ('page' == $post_data['post_type'])
33
+			return new WP_Error('edit_others_pages', __('You are not allowed to edit pages as this user.'));
34 34
 		else
35
-			return new WP_Error( 'edit_others_posts', __( 'You are not allowed to edit posts as this user.' ) );
36
-	} elseif ( ! $update && ! current_user_can( $ptype->cap->create_posts ) ) {
37
-		if ( 'page' == $post_data['post_type'] )
38
-			return new WP_Error( 'edit_others_pages', __( 'You are not allowed to create pages as this user.' ) );
35
+			return new WP_Error('edit_others_posts', __('You are not allowed to edit posts as this user.'));
36
+	} elseif ( ! $update && ! current_user_can($ptype->cap->create_posts)) {
37
+		if ('page' == $post_data['post_type'])
38
+			return new WP_Error('edit_others_pages', __('You are not allowed to create pages as this user.'));
39 39
 		else
40
-			return new WP_Error( 'edit_others_posts', __( 'You are not allowed to create posts as this user.' ) );
40
+			return new WP_Error('edit_others_posts', __('You are not allowed to create posts as this user.'));
41 41
 	}
42 42
 
43
-	if ( isset( $post_data['content'] ) )
43
+	if (isset($post_data['content']))
44 44
 		$post_data['post_content'] = $post_data['content'];
45 45
 
46
-	if ( isset( $post_data['excerpt'] ) )
46
+	if (isset($post_data['excerpt']))
47 47
 		$post_data['post_excerpt'] = $post_data['excerpt'];
48 48
 
49
-	if ( isset( $post_data['parent_id'] ) )
49
+	if (isset($post_data['parent_id']))
50 50
 		$post_data['post_parent'] = (int) $post_data['parent_id'];
51 51
 
52
-	if ( isset($post_data['trackback_url']) )
52
+	if (isset($post_data['trackback_url']))
53 53
 		$post_data['to_ping'] = $post_data['trackback_url'];
54 54
 
55 55
 	$post_data['user_ID'] = get_current_user_id();
56 56
 
57
-	if (!empty ( $post_data['post_author_override'] ) ) {
57
+	if ( ! empty ($post_data['post_author_override'])) {
58 58
 		$post_data['post_author'] = (int) $post_data['post_author_override'];
59 59
 	} else {
60
-		if (!empty ( $post_data['post_author'] ) ) {
60
+		if ( ! empty ($post_data['post_author'])) {
61 61
 			$post_data['post_author'] = (int) $post_data['post_author'];
62 62
 		} else {
63 63
 			$post_data['post_author'] = (int) $post_data['user_ID'];
64 64
 		}
65 65
 	}
66 66
 
67
-	if ( isset( $post_data['user_ID'] ) && ( $post_data['post_author'] != $post_data['user_ID'] )
68
-		 && ! current_user_can( $ptype->cap->edit_others_posts ) ) {
69
-		if ( $update ) {
70
-			if ( 'page' == $post_data['post_type'] )
71
-				return new WP_Error( 'edit_others_pages', __( 'You are not allowed to edit pages as this user.' ) );
67
+	if (isset($post_data['user_ID']) && ($post_data['post_author'] != $post_data['user_ID'])
68
+		 && ! current_user_can($ptype->cap->edit_others_posts)) {
69
+		if ($update) {
70
+			if ('page' == $post_data['post_type'])
71
+				return new WP_Error('edit_others_pages', __('You are not allowed to edit pages as this user.'));
72 72
 			else
73
-				return new WP_Error( 'edit_others_posts', __( 'You are not allowed to edit posts as this user.' ) );
73
+				return new WP_Error('edit_others_posts', __('You are not allowed to edit posts as this user.'));
74 74
 		} else {
75
-			if ( 'page' == $post_data['post_type'] )
76
-				return new WP_Error( 'edit_others_pages', __( 'You are not allowed to create pages as this user.' ) );
75
+			if ('page' == $post_data['post_type'])
76
+				return new WP_Error('edit_others_pages', __('You are not allowed to create pages as this user.'));
77 77
 			else
78
-				return new WP_Error( 'edit_others_posts', __( 'You are not allowed to create posts as this user.' ) );
78
+				return new WP_Error('edit_others_posts', __('You are not allowed to create posts as this user.'));
79 79
 		}
80 80
 	}
81 81
 
82
-	if ( ! empty( $post_data['post_status'] ) ) {
83
-		$post_data['post_status'] = sanitize_key( $post_data['post_status'] );
82
+	if ( ! empty($post_data['post_status'])) {
83
+		$post_data['post_status'] = sanitize_key($post_data['post_status']);
84 84
 
85 85
 		// No longer an auto-draft
86
-		if ( 'auto-draft' === $post_data['post_status'] ) {
86
+		if ('auto-draft' === $post_data['post_status']) {
87 87
 			$post_data['post_status'] = 'draft';
88 88
 		}
89 89
 
90
-		if ( ! get_post_status_object( $post_data['post_status'] ) ) {
91
-			unset( $post_data['post_status'] );
90
+		if ( ! get_post_status_object($post_data['post_status'])) {
91
+			unset($post_data['post_status']);
92 92
 		}
93 93
 	}
94 94
 
95 95
 	// What to do based on which button they pressed
96
-	if ( isset($post_data['saveasdraft']) && '' != $post_data['saveasdraft'] )
96
+	if (isset($post_data['saveasdraft']) && '' != $post_data['saveasdraft'])
97 97
 		$post_data['post_status'] = 'draft';
98
-	if ( isset($post_data['saveasprivate']) && '' != $post_data['saveasprivate'] )
98
+	if (isset($post_data['saveasprivate']) && '' != $post_data['saveasprivate'])
99 99
 		$post_data['post_status'] = 'private';
100
-	if ( isset($post_data['publish']) && ( '' != $post_data['publish'] ) && ( !isset($post_data['post_status']) || $post_data['post_status'] != 'private' ) )
100
+	if (isset($post_data['publish']) && ('' != $post_data['publish']) && ( ! isset($post_data['post_status']) || $post_data['post_status'] != 'private'))
101 101
 		$post_data['post_status'] = 'publish';
102
-	if ( isset($post_data['advanced']) && '' != $post_data['advanced'] )
102
+	if (isset($post_data['advanced']) && '' != $post_data['advanced'])
103 103
 		$post_data['post_status'] = 'draft';
104
-	if ( isset($post_data['pending']) && '' != $post_data['pending'] )
104
+	if (isset($post_data['pending']) && '' != $post_data['pending'])
105 105
 		$post_data['post_status'] = 'pending';
106 106
 
107
-	if ( isset( $post_data['ID'] ) )
107
+	if (isset($post_data['ID']))
108 108
 		$post_id = $post_data['ID'];
109 109
 	else
110 110
 		$post_id = false;
111
-	$previous_status = $post_id ? get_post_field( 'post_status', $post_id ) : false;
111
+	$previous_status = $post_id ? get_post_field('post_status', $post_id) : false;
112 112
 
113
-	if ( isset( $post_data['post_status'] ) && 'private' == $post_data['post_status'] && ! current_user_can( $ptype->cap->publish_posts ) ) {
113
+	if (isset($post_data['post_status']) && 'private' == $post_data['post_status'] && ! current_user_can($ptype->cap->publish_posts)) {
114 114
 		$post_data['post_status'] = $previous_status ? $previous_status : 'pending';
115 115
 	}
116 116
 
117
-	$published_statuses = array( 'publish', 'future' );
117
+	$published_statuses = array('publish', 'future');
118 118
 
119 119
 	// Posts 'submitted for approval' present are submitted to $_POST the same as if they were being published.
120 120
 	// Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts.
121
-	if ( isset($post_data['post_status']) && (in_array( $post_data['post_status'], $published_statuses ) && !current_user_can( $ptype->cap->publish_posts )) )
122
-		if ( ! in_array( $previous_status, $published_statuses ) || !current_user_can( 'edit_post', $post_id ) )
121
+	if (isset($post_data['post_status']) && (in_array($post_data['post_status'], $published_statuses) && ! current_user_can($ptype->cap->publish_posts)))
122
+		if ( ! in_array($previous_status, $published_statuses) || ! current_user_can('edit_post', $post_id))
123 123
 			$post_data['post_status'] = 'pending';
124 124
 
125
-	if ( ! isset( $post_data['post_status'] ) ) {
125
+	if ( ! isset($post_data['post_status'])) {
126 126
 		$post_data['post_status'] = 'auto-draft' === $previous_status ? 'draft' : $previous_status;
127 127
 	}
128 128
 
129
-	if ( isset( $post_data['post_password'] ) && ! current_user_can( $ptype->cap->publish_posts ) ) {
130
-		unset( $post_data['post_password'] );
129
+	if (isset($post_data['post_password']) && ! current_user_can($ptype->cap->publish_posts)) {
130
+		unset($post_data['post_password']);
131 131
 	}
132 132
 
133
-	if (!isset( $post_data['comment_status'] ))
133
+	if ( ! isset($post_data['comment_status']))
134 134
 		$post_data['comment_status'] = 'closed';
135 135
 
136
-	if (!isset( $post_data['ping_status'] ))
136
+	if ( ! isset($post_data['ping_status']))
137 137
 		$post_data['ping_status'] = 'closed';
138 138
 
139
-	foreach ( array('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) {
140
-		if ( !empty( $post_data['hidden_' . $timeunit] ) && $post_data['hidden_' . $timeunit] != $post_data[$timeunit] ) {
139
+	foreach (array('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit) {
140
+		if ( ! empty($post_data['hidden_'.$timeunit]) && $post_data['hidden_'.$timeunit] != $post_data[$timeunit]) {
141 141
 			$post_data['edit_date'] = '1';
142 142
 			break;
143 143
 		}
144 144
 	}
145 145
 
146
-	if ( !empty( $post_data['edit_date'] ) ) {
146
+	if ( ! empty($post_data['edit_date'])) {
147 147
 		$aa = $post_data['aa'];
148 148
 		$mm = $post_data['mm'];
149 149
 		$jj = $post_data['jj'];
150 150
 		$hh = $post_data['hh'];
151 151
 		$mn = $post_data['mn'];
152 152
 		$ss = $post_data['ss'];
153
-		$aa = ($aa <= 0 ) ? date('Y') : $aa;
154
-		$mm = ($mm <= 0 ) ? date('n') : $mm;
155
-		$jj = ($jj > 31 ) ? 31 : $jj;
156
-		$jj = ($jj <= 0 ) ? date('j') : $jj;
157
-		$hh = ($hh > 23 ) ? $hh -24 : $hh;
158
-		$mn = ($mn > 59 ) ? $mn -60 : $mn;
159
-		$ss = ($ss > 59 ) ? $ss -60 : $ss;
160
-		$post_data['post_date'] = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss );
161
-		$valid_date = wp_checkdate( $mm, $jj, $aa, $post_data['post_date'] );
162
-		if ( !$valid_date ) {
163
-			return new WP_Error( 'invalid_date', __( 'Whoops, the provided date is invalid.' ) );
153
+		$aa = ($aa <= 0) ? date('Y') : $aa;
154
+		$mm = ($mm <= 0) ? date('n') : $mm;
155
+		$jj = ($jj > 31) ? 31 : $jj;
156
+		$jj = ($jj <= 0) ? date('j') : $jj;
157
+		$hh = ($hh > 23) ? $hh - 24 : $hh;
158
+		$mn = ($mn > 59) ? $mn - 60 : $mn;
159
+		$ss = ($ss > 59) ? $ss - 60 : $ss;
160
+		$post_data['post_date'] = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss);
161
+		$valid_date = wp_checkdate($mm, $jj, $aa, $post_data['post_date']);
162
+		if ( ! $valid_date) {
163
+			return new WP_Error('invalid_date', __('Whoops, the provided date is invalid.'));
164 164
 		}
165
-		$post_data['post_date_gmt'] = get_gmt_from_date( $post_data['post_date'] );
165
+		$post_data['post_date_gmt'] = get_gmt_from_date($post_data['post_date']);
166 166
 	}
167 167
 
168 168
 	return $post_data;
@@ -178,149 +178,149 @@  discard block
 block discarded – undo
178 178
  * @param array $post_data Optional.
179 179
  * @return int Post ID.
180 180
  */
181
-function edit_post( $post_data = null ) {
181
+function edit_post($post_data = null) {
182 182
 	global $wpdb;
183 183
 
184
-	if ( empty($post_data) )
184
+	if (empty($post_data))
185 185
 		$post_data = &$_POST;
186 186
 
187 187
 	// Clear out any data in internal vars.
188
-	unset( $post_data['filter'] );
188
+	unset($post_data['filter']);
189 189
 
190 190
 	$post_ID = (int) $post_data['post_ID'];
191
-	$post = get_post( $post_ID );
191
+	$post = get_post($post_ID);
192 192
 	$post_data['post_type'] = $post->post_type;
193 193
 	$post_data['post_mime_type'] = $post->post_mime_type;
194 194
 
195
-	if ( ! empty( $post_data['post_status'] ) ) {
196
-		$post_data['post_status'] = sanitize_key( $post_data['post_status'] );
195
+	if ( ! empty($post_data['post_status'])) {
196
+		$post_data['post_status'] = sanitize_key($post_data['post_status']);
197 197
 
198
-		if ( 'inherit' == $post_data['post_status'] ) {
199
-			unset( $post_data['post_status'] );
198
+		if ('inherit' == $post_data['post_status']) {
199
+			unset($post_data['post_status']);
200 200
 		}
201 201
 	}
202 202
 
203 203
 	$ptype = get_post_type_object($post_data['post_type']);
204
-	if ( !current_user_can( 'edit_post', $post_ID ) ) {
205
-		if ( 'page' == $post_data['post_type'] )
206
-			wp_die( __('You are not allowed to edit this page.' ));
204
+	if ( ! current_user_can('edit_post', $post_ID)) {
205
+		if ('page' == $post_data['post_type'])
206
+			wp_die(__('You are not allowed to edit this page.'));
207 207
 		else
208
-			wp_die( __('You are not allowed to edit this post.' ));
208
+			wp_die(__('You are not allowed to edit this post.'));
209 209
 	}
210 210
 
211
-	if ( post_type_supports( $ptype->name, 'revisions' ) ) {
212
-		$revisions = wp_get_post_revisions( $post_ID, array( 'order' => 'ASC', 'posts_per_page' => 1 ) );
213
-		$revision = current( $revisions );
211
+	if (post_type_supports($ptype->name, 'revisions')) {
212
+		$revisions = wp_get_post_revisions($post_ID, array('order' => 'ASC', 'posts_per_page' => 1));
213
+		$revision = current($revisions);
214 214
 
215 215
 		// Check if the revisions have been upgraded
216
-		if ( $revisions && _wp_get_post_revision_version( $revision ) < 1 )
217
-			_wp_upgrade_revisions_of_post( $post, wp_get_post_revisions( $post_ID ) );
216
+		if ($revisions && _wp_get_post_revision_version($revision) < 1)
217
+			_wp_upgrade_revisions_of_post($post, wp_get_post_revisions($post_ID));
218 218
 	}
219 219
 
220
-	if ( isset($post_data['visibility']) ) {
221
-		switch ( $post_data['visibility'] ) {
220
+	if (isset($post_data['visibility'])) {
221
+		switch ($post_data['visibility']) {
222 222
 			case 'public' :
223 223
 				$post_data['post_password'] = '';
224 224
 				break;
225 225
 			case 'password' :
226
-				unset( $post_data['sticky'] );
226
+				unset($post_data['sticky']);
227 227
 				break;
228 228
 			case 'private' :
229 229
 				$post_data['post_status'] = 'private';
230 230
 				$post_data['post_password'] = '';
231
-				unset( $post_data['sticky'] );
231
+				unset($post_data['sticky']);
232 232
 				break;
233 233
 		}
234 234
 	}
235 235
 
236
-	$post_data = _wp_translate_postdata( true, $post_data );
237
-	if ( is_wp_error($post_data) )
238
-		wp_die( $post_data->get_error_message() );
236
+	$post_data = _wp_translate_postdata(true, $post_data);
237
+	if (is_wp_error($post_data))
238
+		wp_die($post_data->get_error_message());
239 239
 
240 240
 	// Post Formats
241
-	if ( isset( $post_data['post_format'] ) )
242
-		set_post_format( $post_ID, $post_data['post_format'] );
241
+	if (isset($post_data['post_format']))
242
+		set_post_format($post_ID, $post_data['post_format']);
243 243
 
244
-	$format_meta_urls = array( 'url', 'link_url', 'quote_source_url' );
245
-	foreach ( $format_meta_urls as $format_meta_url ) {
246
-		$keyed = '_format_' . $format_meta_url;
247
-		if ( isset( $post_data[ $keyed ] ) )
248
-			update_post_meta( $post_ID, $keyed, wp_slash( esc_url_raw( wp_unslash( $post_data[ $keyed ] ) ) ) );
244
+	$format_meta_urls = array('url', 'link_url', 'quote_source_url');
245
+	foreach ($format_meta_urls as $format_meta_url) {
246
+		$keyed = '_format_'.$format_meta_url;
247
+		if (isset($post_data[$keyed]))
248
+			update_post_meta($post_ID, $keyed, wp_slash(esc_url_raw(wp_unslash($post_data[$keyed]))));
249 249
 	}
250 250
 
251
-	$format_keys = array( 'quote', 'quote_source_name', 'image', 'gallery', 'audio_embed', 'video_embed' );
251
+	$format_keys = array('quote', 'quote_source_name', 'image', 'gallery', 'audio_embed', 'video_embed');
252 252
 
253
-	foreach ( $format_keys as $key ) {
254
-		$keyed = '_format_' . $key;
255
-		if ( isset( $post_data[ $keyed ] ) ) {
256
-			if ( current_user_can( 'unfiltered_html' ) )
257
-				update_post_meta( $post_ID, $keyed, $post_data[ $keyed ] );
253
+	foreach ($format_keys as $key) {
254
+		$keyed = '_format_'.$key;
255
+		if (isset($post_data[$keyed])) {
256
+			if (current_user_can('unfiltered_html'))
257
+				update_post_meta($post_ID, $keyed, $post_data[$keyed]);
258 258
 			else
259
-				update_post_meta( $post_ID, $keyed, wp_filter_post_kses( $post_data[ $keyed ] ) );
259
+				update_post_meta($post_ID, $keyed, wp_filter_post_kses($post_data[$keyed]));
260 260
 		}
261 261
 	}
262 262
 
263
-	if ( 'attachment' === $post_data['post_type'] && preg_match( '#^(audio|video)/#', $post_data['post_mime_type'] ) ) {
264
-		$id3data = wp_get_attachment_metadata( $post_ID );
265
-		if ( ! is_array( $id3data ) ) {
263
+	if ('attachment' === $post_data['post_type'] && preg_match('#^(audio|video)/#', $post_data['post_mime_type'])) {
264
+		$id3data = wp_get_attachment_metadata($post_ID);
265
+		if ( ! is_array($id3data)) {
266 266
 			$id3data = array();
267 267
 		}
268 268
 
269
-		foreach ( wp_get_attachment_id3_keys( $post, 'edit' ) as $key => $label ) {
270
-			if ( isset( $post_data[ 'id3_' . $key ] ) ) {
271
-				$id3data[ $key ] = sanitize_text_field( wp_unslash( $post_data[ 'id3_' . $key ] ) );
269
+		foreach (wp_get_attachment_id3_keys($post, 'edit') as $key => $label) {
270
+			if (isset($post_data['id3_'.$key])) {
271
+				$id3data[$key] = sanitize_text_field(wp_unslash($post_data['id3_'.$key]));
272 272
 			}
273 273
 		}
274
-		wp_update_attachment_metadata( $post_ID, $id3data );
274
+		wp_update_attachment_metadata($post_ID, $id3data);
275 275
 	}
276 276
 
277 277
 	// Meta Stuff
278
-	if ( isset($post_data['meta']) && $post_data['meta'] ) {
279
-		foreach ( $post_data['meta'] as $key => $value ) {
280
-			if ( !$meta = get_post_meta_by_id( $key ) )
278
+	if (isset($post_data['meta']) && $post_data['meta']) {
279
+		foreach ($post_data['meta'] as $key => $value) {
280
+			if ( ! $meta = get_post_meta_by_id($key))
281 281
 				continue;
282
-			if ( $meta->post_id != $post_ID )
282
+			if ($meta->post_id != $post_ID)
283 283
 				continue;
284
-			if ( is_protected_meta( $value['key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $value['key'] ) )
284
+			if (is_protected_meta($value['key'], 'post') || ! current_user_can('edit_post_meta', $post_ID, $value['key']))
285 285
 				continue;
286
-			update_meta( $key, $value['key'], $value['value'] );
286
+			update_meta($key, $value['key'], $value['value']);
287 287
 		}
288 288
 	}
289 289
 
290
-	if ( isset($post_data['deletemeta']) && $post_data['deletemeta'] ) {
291
-		foreach ( $post_data['deletemeta'] as $key => $value ) {
292
-			if ( !$meta = get_post_meta_by_id( $key ) )
290
+	if (isset($post_data['deletemeta']) && $post_data['deletemeta']) {
291
+		foreach ($post_data['deletemeta'] as $key => $value) {
292
+			if ( ! $meta = get_post_meta_by_id($key))
293 293
 				continue;
294
-			if ( $meta->post_id != $post_ID )
294
+			if ($meta->post_id != $post_ID)
295 295
 				continue;
296
-			if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $post_ID, $meta->meta_key ) )
296
+			if (is_protected_meta($meta->meta_key, 'post') || ! current_user_can('delete_post_meta', $post_ID, $meta->meta_key))
297 297
 				continue;
298
-			delete_meta( $key );
298
+			delete_meta($key);
299 299
 		}
300 300
 	}
301 301
 
302 302
 	// Attachment stuff
303
-	if ( 'attachment' == $post_data['post_type'] ) {
304
-		if ( isset( $post_data[ '_wp_attachment_image_alt' ] ) ) {
305
-			$image_alt = wp_unslash( $post_data['_wp_attachment_image_alt'] );
306
-			if ( $image_alt != get_post_meta( $post_ID, '_wp_attachment_image_alt', true ) ) {
307
-				$image_alt = wp_strip_all_tags( $image_alt, true );
303
+	if ('attachment' == $post_data['post_type']) {
304
+		if (isset($post_data['_wp_attachment_image_alt'])) {
305
+			$image_alt = wp_unslash($post_data['_wp_attachment_image_alt']);
306
+			if ($image_alt != get_post_meta($post_ID, '_wp_attachment_image_alt', true)) {
307
+				$image_alt = wp_strip_all_tags($image_alt, true);
308 308
 				// update_meta expects slashed.
309
-				update_post_meta( $post_ID, '_wp_attachment_image_alt', wp_slash( $image_alt ) );
309
+				update_post_meta($post_ID, '_wp_attachment_image_alt', wp_slash($image_alt));
310 310
 			}
311 311
 		}
312 312
 
313
-		$attachment_data = isset( $post_data['attachments'][ $post_ID ] ) ? $post_data['attachments'][ $post_ID ] : array();
313
+		$attachment_data = isset($post_data['attachments'][$post_ID]) ? $post_data['attachments'][$post_ID] : array();
314 314
 
315 315
 		/** This filter is documented in wp-admin/includes/media.php */
316
-		$post_data = apply_filters( 'attachment_fields_to_save', $post_data, $attachment_data );
316
+		$post_data = apply_filters('attachment_fields_to_save', $post_data, $attachment_data);
317 317
 	}
318 318
 
319 319
 	// Convert taxonomy input to term IDs, to avoid ambiguity.
320
-	if ( isset( $post_data['tax_input'] ) ) {
321
-		foreach ( (array) $post_data['tax_input'] as $taxonomy => $terms ) {
320
+	if (isset($post_data['tax_input'])) {
321
+		foreach ((array) $post_data['tax_input'] as $taxonomy => $terms) {
322 322
 			// Hierarchical taxonomy data is already sent as term IDs, so no conversion is necessary.
323
-			if ( is_taxonomy_hierarchical( $taxonomy ) ) {
323
+			if (is_taxonomy_hierarchical($taxonomy)) {
324 324
 				continue;
325 325
 			}
326 326
 
@@ -329,67 +329,67 @@  discard block
 block discarded – undo
329 329
 			 * Some languages may use a character other than a comma as a delimiter, so we standardize on
330 330
 			 * commas before parsing the list.
331 331
 			 */
332
-			if ( ! is_array( $terms ) ) {
333
-				$comma = _x( ',', 'tag delimiter' );
334
-				if ( ',' !== $comma ) {
335
-					$terms = str_replace( $comma, ',', $terms );
332
+			if ( ! is_array($terms)) {
333
+				$comma = _x(',', 'tag delimiter');
334
+				if (',' !== $comma) {
335
+					$terms = str_replace($comma, ',', $terms);
336 336
 				}
337
-				$terms = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) );
337
+				$terms = explode(',', trim($terms, " \n\t\r\0\x0B,"));
338 338
 			}
339 339
 
340 340
 			$clean_terms = array();
341
-			foreach ( $terms as $term ) {
341
+			foreach ($terms as $term) {
342 342
 				// Empty terms are invalid input.
343
-				if ( empty( $term ) ) {
343
+				if (empty($term)) {
344 344
 					continue;
345 345
 				}
346 346
 
347
-				$_term = get_terms( $taxonomy, array(
347
+				$_term = get_terms($taxonomy, array(
348 348
 					'name' => $term,
349 349
 					'fields' => 'ids',
350 350
 					'hide_empty' => false,
351
-				) );
351
+				));
352 352
 
353
-				if ( ! empty( $_term ) ) {
354
-					$clean_terms[] = intval( $_term[0] );
353
+				if ( ! empty($_term)) {
354
+					$clean_terms[] = intval($_term[0]);
355 355
 				} else {
356 356
 					// No existing term was found, so pass the string. A new term will be created.
357 357
 					$clean_terms[] = $term;
358 358
 				}
359 359
 			}
360 360
 
361
-			$post_data['tax_input'][ $taxonomy ] = $clean_terms;
361
+			$post_data['tax_input'][$taxonomy] = $clean_terms;
362 362
 		}
363 363
 	}
364 364
 
365
-	add_meta( $post_ID );
365
+	add_meta($post_ID);
366 366
 
367
-	update_post_meta( $post_ID, '_edit_last', get_current_user_id() );
367
+	update_post_meta($post_ID, '_edit_last', get_current_user_id());
368 368
 
369
-	$success = wp_update_post( $post_data );
369
+	$success = wp_update_post($post_data);
370 370
 	// If the save failed, see if we can sanity check the main fields and try again
371
-	if ( ! $success && is_callable( array( $wpdb, 'strip_invalid_text_for_column' ) ) ) {
372
-		$fields = array( 'post_title', 'post_content', 'post_excerpt' );
371
+	if ( ! $success && is_callable(array($wpdb, 'strip_invalid_text_for_column'))) {
372
+		$fields = array('post_title', 'post_content', 'post_excerpt');
373 373
 
374
-		foreach( $fields as $field ) {
375
-			if ( isset( $post_data[ $field ] ) ) {
376
-				$post_data[ $field ] = $wpdb->strip_invalid_text_for_column( $wpdb->posts, $field, $post_data[ $field ] );
374
+		foreach ($fields as $field) {
375
+			if (isset($post_data[$field])) {
376
+				$post_data[$field] = $wpdb->strip_invalid_text_for_column($wpdb->posts, $field, $post_data[$field]);
377 377
 			}
378 378
 		}
379 379
 
380
-		wp_update_post( $post_data );
380
+		wp_update_post($post_data);
381 381
 	}
382 382
 
383 383
 	// Now that we have an ID we can fix any attachment anchor hrefs
384
-	_fix_attachment_links( $post_ID );
384
+	_fix_attachment_links($post_ID);
385 385
 
386
-	wp_set_post_lock( $post_ID );
386
+	wp_set_post_lock($post_ID);
387 387
 
388
-	if ( current_user_can( $ptype->cap->edit_others_posts ) && current_user_can( $ptype->cap->publish_posts ) ) {
389
-		if ( ! empty( $post_data['sticky'] ) )
390
-			stick_post( $post_ID );
388
+	if (current_user_can($ptype->cap->edit_others_posts) && current_user_can($ptype->cap->publish_posts)) {
389
+		if ( ! empty($post_data['sticky']))
390
+			stick_post($post_ID);
391 391
 		else
392
-			unstick_post( $post_ID );
392
+			unstick_post($post_ID);
393 393
 	}
394 394
 
395 395
 	return $post_ID;
@@ -408,22 +408,22 @@  discard block
 block discarded – undo
408 408
  * @param array $post_data Optional, the array of post data to process if not provided will use $_POST superglobal.
409 409
  * @return array
410 410
  */
411
-function bulk_edit_posts( $post_data = null ) {
411
+function bulk_edit_posts($post_data = null) {
412 412
 	global $wpdb;
413 413
 
414
-	if ( empty($post_data) )
414
+	if (empty($post_data))
415 415
 		$post_data = &$_POST;
416 416
 
417
-	if ( isset($post_data['post_type']) )
417
+	if (isset($post_data['post_type']))
418 418
 		$ptype = get_post_type_object($post_data['post_type']);
419 419
 	else
420 420
 		$ptype = get_post_type_object('post');
421 421
 
422
-	if ( !current_user_can( $ptype->cap->edit_posts ) ) {
423
-		if ( 'page' == $ptype->name )
424
-			wp_die( __('You are not allowed to edit pages.'));
422
+	if ( ! current_user_can($ptype->cap->edit_posts)) {
423
+		if ('page' == $ptype->name)
424
+			wp_die(__('You are not allowed to edit pages.'));
425 425
 		else
426
-			wp_die( __('You are not allowed to edit posts.'));
426
+			wp_die(__('You are not allowed to edit posts.'));
427 427
 	}
428 428
 
429 429
 	if ( -1 == $post_data['_status'] ) {
@@ -434,15 +434,15 @@  discard block
 block discarded – undo
434 434
 	}
435 435
 	unset($post_data['_status']);
436 436
 
437
-	if ( ! empty( $post_data['post_status'] ) ) {
438
-		$post_data['post_status'] = sanitize_key( $post_data['post_status'] );
437
+	if ( ! empty($post_data['post_status'])) {
438
+		$post_data['post_status'] = sanitize_key($post_data['post_status']);
439 439
 
440
-		if ( 'inherit' == $post_data['post_status'] ) {
441
-			unset( $post_data['post_status'] );
440
+		if ('inherit' == $post_data['post_status']) {
441
+			unset($post_data['post_status']);
442 442
 		}
443 443
 	}
444 444
 
445
-	$post_IDs = array_map( 'intval', (array) $post_data['post'] );
445
+	$post_IDs = array_map('intval', (array) $post_data['post']);
446 446
 
447 447
 	$reset = array(
448 448
 		'post_author', 'post_status', 'post_password',
@@ -451,43 +451,43 @@  discard block
 block discarded – undo
451 451
 		'post_category', 'sticky', 'post_format',
452 452
 	);
453 453
 
454
-	foreach ( $reset as $field ) {
455
-		if ( isset($post_data[$field]) && ( '' == $post_data[$field] || -1 == $post_data[$field] ) )
454
+	foreach ($reset as $field) {
455
+		if (isset($post_data[$field]) && ('' == $post_data[$field] || -1 == $post_data[$field]))
456 456
 			unset($post_data[$field]);
457 457
 	}
458 458
 
459
-	if ( isset($post_data['post_category']) ) {
460
-		if ( is_array($post_data['post_category']) && ! empty($post_data['post_category']) )
461
-			$new_cats = array_map( 'absint', $post_data['post_category'] );
459
+	if (isset($post_data['post_category'])) {
460
+		if (is_array($post_data['post_category']) && ! empty($post_data['post_category']))
461
+			$new_cats = array_map('absint', $post_data['post_category']);
462 462
 		else
463 463
 			unset($post_data['post_category']);
464 464
 	}
465 465
 
466 466
 	$tax_input = array();
467
-	if ( isset($post_data['tax_input'])) {
468
-		foreach ( $post_data['tax_input'] as $tax_name => $terms ) {
469
-			if ( empty($terms) )
467
+	if (isset($post_data['tax_input'])) {
468
+		foreach ($post_data['tax_input'] as $tax_name => $terms) {
469
+			if (empty($terms))
470 470
 				continue;
471
-			if ( is_taxonomy_hierarchical( $tax_name ) ) {
472
-				$tax_input[ $tax_name ] = array_map( 'absint', $terms );
471
+			if (is_taxonomy_hierarchical($tax_name)) {
472
+				$tax_input[$tax_name] = array_map('absint', $terms);
473 473
 			} else {
474
-				$comma = _x( ',', 'tag delimiter' );
475
-				if ( ',' !== $comma )
476
-					$terms = str_replace( $comma, ',', $terms );
477
-				$tax_input[ $tax_name ] = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) );
474
+				$comma = _x(',', 'tag delimiter');
475
+				if (',' !== $comma)
476
+					$terms = str_replace($comma, ',', $terms);
477
+				$tax_input[$tax_name] = explode(',', trim($terms, " \n\t\r\0\x0B,"));
478 478
 			}
479 479
 		}
480 480
 	}
481 481
 
482
-	if ( isset($post_data['post_parent']) && ($parent = (int) $post_data['post_parent']) ) {
482
+	if (isset($post_data['post_parent']) && ($parent = (int) $post_data['post_parent'])) {
483 483
 		$pages = $wpdb->get_results("SELECT ID, post_parent FROM $wpdb->posts WHERE post_type = 'page'");
484 484
 		$children = array();
485 485
 
486
-		for ( $i = 0; $i < 50 && $parent > 0; $i++ ) {
486
+		for ($i = 0; $i < 50 && $parent > 0; $i++) {
487 487
 			$children[] = $parent;
488 488
 
489
-			foreach ( $pages as $page ) {
490
-				if ( $page->ID == $parent ) {
489
+			foreach ($pages as $page) {
490
+				if ($page->ID == $parent) {
491 491
 					$parent = $page->post_parent;
492 492
 					break;
493 493
 				}
@@ -498,78 +498,78 @@  discard block
 block discarded – undo
498 498
 	$updated = $skipped = $locked = array();
499 499
 	$shared_post_data = $post_data;
500 500
 
501
-	foreach ( $post_IDs as $post_ID ) {
501
+	foreach ($post_IDs as $post_ID) {
502 502
 		// Start with fresh post data with each iteration.
503 503
 		$post_data = $shared_post_data;
504 504
 
505
-		$post_type_object = get_post_type_object( get_post_type( $post_ID ) );
505
+		$post_type_object = get_post_type_object(get_post_type($post_ID));
506 506
 
507
-		if ( !isset( $post_type_object ) || ( isset($children) && in_array($post_ID, $children) ) || !current_user_can( 'edit_post', $post_ID ) ) {
507
+		if ( ! isset($post_type_object) || (isset($children) && in_array($post_ID, $children)) || ! current_user_can('edit_post', $post_ID)) {
508 508
 			$skipped[] = $post_ID;
509 509
 			continue;
510 510
 		}
511 511
 
512
-		if ( wp_check_post_lock( $post_ID ) ) {
512
+		if (wp_check_post_lock($post_ID)) {
513 513
 			$locked[] = $post_ID;
514 514
 			continue;
515 515
 		}
516 516
 
517
-		$post = get_post( $post_ID );
518
-		$tax_names = get_object_taxonomies( $post );
519
-		foreach ( $tax_names as $tax_name ) {
517
+		$post = get_post($post_ID);
518
+		$tax_names = get_object_taxonomies($post);
519
+		foreach ($tax_names as $tax_name) {
520 520
 			$taxonomy_obj = get_taxonomy($tax_name);
521
-			if ( isset( $tax_input[$tax_name]) && current_user_can( $taxonomy_obj->cap->assign_terms ) )
521
+			if (isset($tax_input[$tax_name]) && current_user_can($taxonomy_obj->cap->assign_terms))
522 522
 				$new_terms = $tax_input[$tax_name];
523 523
 			else
524 524
 				$new_terms = array();
525 525
 
526
-			if ( $taxonomy_obj->hierarchical )
527
-				$current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'ids') );
526
+			if ($taxonomy_obj->hierarchical)
527
+				$current_terms = (array) wp_get_object_terms($post_ID, $tax_name, array('fields' => 'ids'));
528 528
 			else
529
-				$current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'names') );
529
+				$current_terms = (array) wp_get_object_terms($post_ID, $tax_name, array('fields' => 'names'));
530 530
 
531
-			$post_data['tax_input'][$tax_name] = array_merge( $current_terms, $new_terms );
531
+			$post_data['tax_input'][$tax_name] = array_merge($current_terms, $new_terms);
532 532
 		}
533 533
 
534
-		if ( isset($new_cats) && in_array( 'category', $tax_names ) ) {
534
+		if (isset($new_cats) && in_array('category', $tax_names)) {
535 535
 			$cats = (array) wp_get_post_categories($post_ID);
536
-			$post_data['post_category'] = array_unique( array_merge($cats, $new_cats) );
537
-			unset( $post_data['tax_input']['category'] );
536
+			$post_data['post_category'] = array_unique(array_merge($cats, $new_cats));
537
+			unset($post_data['tax_input']['category']);
538 538
 		}
539 539
 
540 540
 		$post_data['post_type'] = $post->post_type;
541 541
 		$post_data['post_mime_type'] = $post->post_mime_type;
542 542
 		$post_data['guid'] = $post->guid;
543 543
 
544
-		foreach ( array( 'comment_status', 'ping_status', 'post_author' ) as $field ) {
545
-			if ( ! isset( $post_data[ $field ] ) ) {
546
-				$post_data[ $field ] = $post->$field;
544
+		foreach (array('comment_status', 'ping_status', 'post_author') as $field) {
545
+			if ( ! isset($post_data[$field])) {
546
+				$post_data[$field] = $post->$field;
547 547
 			}
548 548
 		}
549 549
 
550 550
 		$post_data['ID'] = $post_ID;
551 551
 		$post_data['post_ID'] = $post_ID;
552 552
 
553
-		$post_data = _wp_translate_postdata( true, $post_data );
554
-		if ( is_wp_error( $post_data ) ) {
553
+		$post_data = _wp_translate_postdata(true, $post_data);
554
+		if (is_wp_error($post_data)) {
555 555
 			$skipped[] = $post_ID;
556 556
 			continue;
557 557
 		}
558 558
 
559
-		$updated[] = wp_update_post( $post_data );
559
+		$updated[] = wp_update_post($post_data);
560 560
 
561
-		if ( isset( $post_data['sticky'] ) && current_user_can( $ptype->cap->edit_others_posts ) ) {
562
-			if ( 'sticky' == $post_data['sticky'] )
563
-				stick_post( $post_ID );
561
+		if (isset($post_data['sticky']) && current_user_can($ptype->cap->edit_others_posts)) {
562
+			if ('sticky' == $post_data['sticky'])
563
+				stick_post($post_ID);
564 564
 			else
565
-				unstick_post( $post_ID );
565
+				unstick_post($post_ID);
566 566
 		}
567 567
 
568
-		if ( isset( $post_data['post_format'] ) )
569
-			set_post_format( $post_ID, $post_data['post_format'] );
568
+		if (isset($post_data['post_format']))
569
+			set_post_format($post_ID, $post_data['post_format']);
570 570
 	}
571 571
 
572
-	return array( 'updated' => $updated, 'skipped' => $skipped, 'locked' => $locked );
572
+	return array('updated' => $updated, 'skipped' => $skipped, 'locked' => $locked);
573 573
 }
574 574
 
575 575
 /**
@@ -580,24 +580,24 @@  discard block
 block discarded – undo
580 580
  * @param string $post_type A post type string, defaults to 'post'.
581 581
  * @return WP_Post Post object containing all the default post data as attributes
582 582
  */
583
-function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) {
583
+function get_default_post_to_edit($post_type = 'post', $create_in_db = false) {
584 584
 	$post_title = '';
585
-	if ( !empty( $_REQUEST['post_title'] ) )
586
-		$post_title = esc_html( wp_unslash( $_REQUEST['post_title'] ));
585
+	if ( ! empty($_REQUEST['post_title']))
586
+		$post_title = esc_html(wp_unslash($_REQUEST['post_title']));
587 587
 
588 588
 	$post_content = '';
589
-	if ( !empty( $_REQUEST['content'] ) )
590
-		$post_content = esc_html( wp_unslash( $_REQUEST['content'] ));
589
+	if ( ! empty($_REQUEST['content']))
590
+		$post_content = esc_html(wp_unslash($_REQUEST['content']));
591 591
 
592 592
 	$post_excerpt = '';
593
-	if ( !empty( $_REQUEST['excerpt'] ) )
594
-		$post_excerpt = esc_html( wp_unslash( $_REQUEST['excerpt'] ));
595
-
596
-	if ( $create_in_db ) {
597
-		$post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) );
598
-		$post = get_post( $post_id );
599
-		if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) )
600
-			set_post_format( $post, get_option( 'default_post_format' ) );
593
+	if ( ! empty($_REQUEST['excerpt']))
594
+		$post_excerpt = esc_html(wp_unslash($_REQUEST['excerpt']));
595
+
596
+	if ($create_in_db) {
597
+		$post_id = wp_insert_post(array('post_title' => __('Auto Draft'), 'post_type' => $post_type, 'post_status' => 'auto-draft'));
598
+		$post = get_post($post_id);
599
+		if (current_theme_supports('post-formats') && post_type_supports($post->post_type, 'post-formats') && get_option('default_post_format'))
600
+			set_post_format($post, get_option('default_post_format'));
601 601
 	} else {
602 602
 		$post = new stdClass;
603 603
 		$post->ID = 0;
@@ -610,14 +610,14 @@  discard block
 block discarded – undo
610 610
 		$post->post_status = 'draft';
611 611
 		$post->to_ping = '';
612 612
 		$post->pinged = '';
613
-		$post->comment_status = get_default_comment_status( $post_type );
614
-		$post->ping_status = get_default_comment_status( $post_type, 'pingback' );
615
-		$post->post_pingback = get_option( 'default_pingback_flag' );
616
-		$post->post_category = get_option( 'default_category' );
613
+		$post->comment_status = get_default_comment_status($post_type);
614
+		$post->ping_status = get_default_comment_status($post_type, 'pingback');
615
+		$post->post_pingback = get_option('default_pingback_flag');
616
+		$post->post_category = get_option('default_category');
617 617
 		$post->page_template = 'default';
618 618
 		$post->post_parent = 0;
619 619
 		$post->menu_order = 0;
620
-		$post = new WP_Post( $post );
620
+		$post = new WP_Post($post);
621 621
 	}
622 622
 
623 623
 	/**
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
 	 * @param string  $post_content Default post content.
629 629
 	 * @param WP_Post $post         Post object.
630 630
 	 */
631
-	$post->post_content = apply_filters( 'default_content', $post_content, $post );
631
+	$post->post_content = apply_filters('default_content', $post_content, $post);
632 632
 
633 633
 	/**
634 634
 	 * Filter the default post title initially used in the "Write Post" form.
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
 	 * @param string  $post_title Default post title.
639 639
 	 * @param WP_Post $post       Post object.
640 640
 	 */
641
-	$post->post_title = apply_filters( 'default_title', $post_title, $post );
641
+	$post->post_title = apply_filters('default_title', $post_title, $post);
642 642
 
643 643
 	/**
644 644
 	 * Filter the default post excerpt initially used in the "Write Post" form.
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
 	 * @param string  $post_excerpt Default post excerpt.
649 649
 	 * @param WP_Post $post         Post object.
650 650
 	 */
651
-	$post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt, $post );
651
+	$post->post_excerpt = apply_filters('default_excerpt', $post_excerpt, $post);
652 652
 
653 653
 	return $post;
654 654
 }
@@ -668,30 +668,30 @@  discard block
 block discarded – undo
668 668
 function post_exists($title, $content = '', $date = '') {
669 669
 	global $wpdb;
670 670
 
671
-	$post_title = wp_unslash( sanitize_post_field( 'post_title', $title, 0, 'db' ) );
672
-	$post_content = wp_unslash( sanitize_post_field( 'post_content', $content, 0, 'db' ) );
673
-	$post_date = wp_unslash( sanitize_post_field( 'post_date', $date, 0, 'db' ) );
671
+	$post_title = wp_unslash(sanitize_post_field('post_title', $title, 0, 'db'));
672
+	$post_content = wp_unslash(sanitize_post_field('post_content', $content, 0, 'db'));
673
+	$post_date = wp_unslash(sanitize_post_field('post_date', $date, 0, 'db'));
674 674
 
675 675
 	$query = "SELECT ID FROM $wpdb->posts WHERE 1=1";
676 676
 	$args = array();
677 677
 
678
-	if ( !empty ( $date ) ) {
678
+	if ( ! empty ($date)) {
679 679
 		$query .= ' AND post_date = %s';
680 680
 		$args[] = $post_date;
681 681
 	}
682 682
 
683
-	if ( !empty ( $title ) ) {
683
+	if ( ! empty ($title)) {
684 684
 		$query .= ' AND post_title = %s';
685 685
 		$args[] = $post_title;
686 686
 	}
687 687
 
688
-	if ( !empty ( $content ) ) {
688
+	if ( ! empty ($content)) {
689 689
 		$query .= 'AND post_content = %s';
690 690
 		$args[] = $post_content;
691 691
 	}
692 692
 
693
-	if ( !empty ( $args ) )
694
-		return (int) $wpdb->get_var( $wpdb->prepare($query, $args) );
693
+	if ( ! empty ($args))
694
+		return (int) $wpdb->get_var($wpdb->prepare($query, $args));
695 695
 
696 696
 	return 0;
697 697
 }
@@ -706,63 +706,63 @@  discard block
 block discarded – undo
706 706
  * @return int|WP_Error
707 707
  */
708 708
 function wp_write_post() {
709
-	if ( isset($_POST['post_type']) )
709
+	if (isset($_POST['post_type']))
710 710
 		$ptype = get_post_type_object($_POST['post_type']);
711 711
 	else
712 712
 		$ptype = get_post_type_object('post');
713 713
 
714
-	if ( !current_user_can( $ptype->cap->edit_posts ) ) {
715
-		if ( 'page' == $ptype->name )
716
-			return new WP_Error( 'edit_pages', __( 'You are not allowed to create pages on this site.' ) );
714
+	if ( ! current_user_can($ptype->cap->edit_posts)) {
715
+		if ('page' == $ptype->name)
716
+			return new WP_Error('edit_pages', __('You are not allowed to create pages on this site.'));
717 717
 		else
718
-			return new WP_Error( 'edit_posts', __( 'You are not allowed to create posts or drafts on this site.' ) );
718
+			return new WP_Error('edit_posts', __('You are not allowed to create posts or drafts on this site.'));
719 719
 	}
720 720
 
721 721
 	$_POST['post_mime_type'] = '';
722 722
 
723 723
 	// Clear out any data in internal vars.
724
-	unset( $_POST['filter'] );
724
+	unset($_POST['filter']);
725 725
 
726 726
 	// Edit don't write if we have a post id.
727
-	if ( isset( $_POST['post_ID'] ) )
727
+	if (isset($_POST['post_ID']))
728 728
 		return edit_post();
729 729
 
730
-	if ( isset($_POST['visibility']) ) {
731
-		switch ( $_POST['visibility'] ) {
730
+	if (isset($_POST['visibility'])) {
731
+		switch ($_POST['visibility']) {
732 732
 			case 'public' :
733 733
 				$_POST['post_password'] = '';
734 734
 				break;
735 735
 			case 'password' :
736
-				unset( $_POST['sticky'] );
736
+				unset($_POST['sticky']);
737 737
 				break;
738 738
 			case 'private' :
739 739
 				$_POST['post_status'] = 'private';
740 740
 				$_POST['post_password'] = '';
741
-				unset( $_POST['sticky'] );
741
+				unset($_POST['sticky']);
742 742
 				break;
743 743
 		}
744 744
 	}
745 745
 
746
-	$translated = _wp_translate_postdata( false );
747
-	if ( is_wp_error($translated) )
746
+	$translated = _wp_translate_postdata(false);
747
+	if (is_wp_error($translated))
748 748
 		return $translated;
749 749
 
750 750
 	// Create the post.
751
-	$post_ID = wp_insert_post( $_POST );
752
-	if ( is_wp_error( $post_ID ) )
751
+	$post_ID = wp_insert_post($_POST);
752
+	if (is_wp_error($post_ID))
753 753
 		return $post_ID;
754 754
 
755
-	if ( empty($post_ID) )
755
+	if (empty($post_ID))
756 756
 		return 0;
757 757
 
758
-	add_meta( $post_ID );
758
+	add_meta($post_ID);
759 759
 
760
-	add_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID );
760
+	add_post_meta($post_ID, '_edit_last', $GLOBALS['current_user']->ID);
761 761
 
762 762
 	// Now that we have an ID we can fix any attachment anchor hrefs
763
-	_fix_attachment_links( $post_ID );
763
+	_fix_attachment_links($post_ID);
764 764
 
765
-	wp_set_post_lock( $post_ID );
765
+	wp_set_post_lock($post_ID);
766 766
 
767 767
 	return $post_ID;
768 768
 }
@@ -776,8 +776,8 @@  discard block
 block discarded – undo
776 776
  */
777 777
 function write_post() {
778 778
 	$result = wp_write_post();
779
-	if ( is_wp_error( $result ) )
780
-		wp_die( $result->get_error_message() );
779
+	if (is_wp_error($result))
780
+		wp_die($result->get_error_message());
781 781
 	else
782 782
 		return $result;
783 783
 }
@@ -794,32 +794,32 @@  discard block
 block discarded – undo
794 794
  * @param int $post_ID
795 795
  * @return int|bool
796 796
  */
797
-function add_meta( $post_ID ) {
797
+function add_meta($post_ID) {
798 798
 	$post_ID = (int) $post_ID;
799 799
 
800
-	$metakeyselect = isset($_POST['metakeyselect']) ? wp_unslash( trim( $_POST['metakeyselect'] ) ) : '';
801
-	$metakeyinput = isset($_POST['metakeyinput']) ? wp_unslash( trim( $_POST['metakeyinput'] ) ) : '';
800
+	$metakeyselect = isset($_POST['metakeyselect']) ? wp_unslash(trim($_POST['metakeyselect'])) : '';
801
+	$metakeyinput = isset($_POST['metakeyinput']) ? wp_unslash(trim($_POST['metakeyinput'])) : '';
802 802
 	$metavalue = isset($_POST['metavalue']) ? $_POST['metavalue'] : '';
803
-	if ( is_string( $metavalue ) )
804
-		$metavalue = trim( $metavalue );
803
+	if (is_string($metavalue))
804
+		$metavalue = trim($metavalue);
805 805
 
806
-	if ( ('0' === $metavalue || ! empty ( $metavalue ) ) && ( ( ( '#NONE#' != $metakeyselect ) && !empty ( $metakeyselect) ) || !empty ( $metakeyinput ) ) ) {
806
+	if (('0' === $metavalue || ! empty ($metavalue)) && ((('#NONE#' != $metakeyselect) && ! empty ($metakeyselect)) || ! empty ($metakeyinput))) {
807 807
 		/*
808 808
 		 * We have a key/value pair. If both the select and the input
809 809
 		 * for the key have data, the input takes precedence.
810 810
 		 */
811
- 		if ( '#NONE#' != $metakeyselect )
811
+ 		if ('#NONE#' != $metakeyselect)
812 812
 			$metakey = $metakeyselect;
813 813
 
814
-		if ( $metakeyinput )
814
+		if ($metakeyinput)
815 815
 			$metakey = $metakeyinput; // default
816 816
 
817
-		if ( is_protected_meta( $metakey, 'post' ) || ! current_user_can( 'add_post_meta', $post_ID, $metakey ) )
817
+		if (is_protected_meta($metakey, 'post') || ! current_user_can('add_post_meta', $post_ID, $metakey))
818 818
 			return false;
819 819
 
820
-		$metakey = wp_slash( $metakey );
820
+		$metakey = wp_slash($metakey);
821 821
 
822
-		return add_post_meta( $post_ID, $metakey, $metavalue );
822
+		return add_post_meta($post_ID, $metakey, $metavalue);
823 823
 	}
824 824
 
825 825
 	return false;
@@ -833,8 +833,8 @@  discard block
 block discarded – undo
833 833
  * @param int $mid
834 834
  * @return bool
835 835
  */
836
-function delete_meta( $mid ) {
837
-	return delete_metadata_by_mid( 'post' , $mid );
836
+function delete_meta($mid) {
837
+	return delete_metadata_by_mid('post', $mid);
838 838
 }
839 839
 
840 840
 /**
@@ -849,11 +849,11 @@  discard block
 block discarded – undo
849 849
 function get_meta_keys() {
850 850
 	global $wpdb;
851 851
 
852
-	$keys = $wpdb->get_col( "
852
+	$keys = $wpdb->get_col("
853 853
 			SELECT meta_key
854 854
 			FROM $wpdb->postmeta
855 855
 			GROUP BY meta_key
856
-			ORDER BY meta_key" );
856
+			ORDER BY meta_key");
857 857
 
858 858
 	return $keys;
859 859
 }
@@ -866,8 +866,8 @@  discard block
 block discarded – undo
866 866
  * @param int $mid
867 867
  * @return object|bool
868 868
  */
869
-function get_post_meta_by_id( $mid ) {
870
-	return get_metadata_by_mid( 'post', $mid );
869
+function get_post_meta_by_id($mid) {
870
+	return get_metadata_by_mid('post', $mid);
871 871
 }
872 872
 
873 873
 /**
@@ -880,12 +880,12 @@  discard block
 block discarded – undo
880 880
  * @param int $postid
881 881
  * @return mixed
882 882
  */
883
-function has_meta( $postid ) {
883
+function has_meta($postid) {
884 884
 	global $wpdb;
885 885
 
886
-	return $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value, meta_id, post_id
886
+	return $wpdb->get_results($wpdb->prepare("SELECT meta_key, meta_value, meta_id, post_id
887 887
 			FROM $wpdb->postmeta WHERE post_id = %d
888
-			ORDER BY meta_key,meta_id", $postid), ARRAY_A );
888
+			ORDER BY meta_key,meta_id", $postid), ARRAY_A);
889 889
 }
890 890
 
891 891
 /**
@@ -898,11 +898,11 @@  discard block
 block discarded – undo
898 898
  * @param string $meta_value Expect Slashed
899 899
  * @return bool
900 900
  */
901
-function update_meta( $meta_id, $meta_key, $meta_value ) {
902
-	$meta_key = wp_unslash( $meta_key );
903
-	$meta_value = wp_unslash( $meta_value );
901
+function update_meta($meta_id, $meta_key, $meta_value) {
902
+	$meta_key = wp_unslash($meta_key);
903
+	$meta_value = wp_unslash($meta_value);
904 904
 
905
-	return update_metadata_by_mid( 'post', $meta_id, $meta_value, $meta_key );
905
+	return update_metadata_by_mid('post', $meta_id, $meta_value, $meta_key);
906 906
 }
907 907
 
908 908
 //
@@ -918,42 +918,42 @@  discard block
 block discarded – undo
918 918
  * @param int|object $post Post ID or post object.
919 919
  * @return void|int|WP_Error Void if nothing fixed. 0 or WP_Error on update failure. The post ID on update success.
920 920
  */
921
-function _fix_attachment_links( $post ) {
922
-	$post = get_post( $post, ARRAY_A );
921
+function _fix_attachment_links($post) {
922
+	$post = get_post($post, ARRAY_A);
923 923
 	$content = $post['post_content'];
924 924
 
925 925
 	// Don't run if no pretty permalinks or post is not published, scheduled, or privately published.
926
-	if ( ! get_option( 'permalink_structure' ) || ! in_array( $post['post_status'], array( 'publish', 'future', 'private' ) ) )
926
+	if ( ! get_option('permalink_structure') || ! in_array($post['post_status'], array('publish', 'future', 'private')))
927 927
 		return;
928 928
 
929 929
 	// Short if there aren't any links or no '?attachment_id=' strings (strpos cannot be zero)
930
-	if ( !strpos($content, '?attachment_id=') || !preg_match_all( '/<a ([^>]+)>[\s\S]+?<\/a>/', $content, $link_matches ) )
930
+	if ( ! strpos($content, '?attachment_id=') || ! preg_match_all('/<a ([^>]+)>[\s\S]+?<\/a>/', $content, $link_matches))
931 931
 		return;
932 932
 
933 933
 	$site_url = get_bloginfo('url');
934
-	$site_url = substr( $site_url, (int) strpos($site_url, '://') ); // remove the http(s)
934
+	$site_url = substr($site_url, (int) strpos($site_url, '://')); // remove the http(s)
935 935
 	$replace = '';
936 936
 
937
-	foreach ( $link_matches[1] as $key => $value ) {
938
-		if ( !strpos($value, '?attachment_id=') || !strpos($value, 'wp-att-')
939
-			|| !preg_match( '/href=(["\'])[^"\']*\?attachment_id=(\d+)[^"\']*\\1/', $value, $url_match )
940
-			|| !preg_match( '/rel=["\'][^"\']*wp-att-(\d+)/', $value, $rel_match ) )
937
+	foreach ($link_matches[1] as $key => $value) {
938
+		if ( ! strpos($value, '?attachment_id=') || ! strpos($value, 'wp-att-')
939
+			|| ! preg_match('/href=(["\'])[^"\']*\?attachment_id=(\d+)[^"\']*\\1/', $value, $url_match)
940
+			|| ! preg_match('/rel=["\'][^"\']*wp-att-(\d+)/', $value, $rel_match))
941 941
 				continue;
942 942
 
943 943
 		$quote = $url_match[1]; // the quote (single or double)
944 944
 		$url_id = (int) $url_match[2];
945 945
 		$rel_id = (int) $rel_match[1];
946 946
 
947
-		if ( !$url_id || !$rel_id || $url_id != $rel_id || strpos($url_match[0], $site_url) === false )
947
+		if ( ! $url_id || ! $rel_id || $url_id != $rel_id || strpos($url_match[0], $site_url) === false)
948 948
 			continue;
949 949
 
950 950
 		$link = $link_matches[0][$key];
951
-		$replace = str_replace( $url_match[0], 'href=' . $quote . get_attachment_link( $url_id ) . $quote, $link );
951
+		$replace = str_replace($url_match[0], 'href='.$quote.get_attachment_link($url_id).$quote, $link);
952 952
 
953
-		$content = str_replace( $link, $replace, $content );
953
+		$content = str_replace($link, $replace, $content);
954 954
 	}
955 955
 
956
-	if ( $replace ) {
956
+	if ($replace) {
957 957
 		$post['post_content'] = $content;
958 958
 		// Escape data pulled from DB.
959 959
 		$post = add_magic_quotes($post);
@@ -984,38 +984,38 @@  discard block
 block discarded – undo
984 984
  * @param array|bool $q Array of query variables to use to build the query or false to use $_GET superglobal.
985 985
  * @return array
986 986
  */
987
-function wp_edit_posts_query( $q = false ) {
988
-	if ( false === $q )
987
+function wp_edit_posts_query($q = false) {
988
+	if (false === $q)
989 989
 		$q = $_GET;
990 990
 	$q['m'] = isset($q['m']) ? (int) $q['m'] : 0;
991 991
 	$q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0;
992
-	$post_stati  = get_post_stati();
992
+	$post_stati = get_post_stati();
993 993
 
994
-	if ( isset($q['post_type']) && in_array( $q['post_type'], get_post_types() ) )
994
+	if (isset($q['post_type']) && in_array($q['post_type'], get_post_types()))
995 995
 		$post_type = $q['post_type'];
996 996
 	else
997 997
 		$post_type = 'post';
998 998
 
999 999
 	$avail_post_stati = get_available_post_statuses($post_type);
1000 1000
 
1001
-	if ( isset($q['post_status']) && in_array( $q['post_status'], $post_stati ) ) {
1001
+	if (isset($q['post_status']) && in_array($q['post_status'], $post_stati)) {
1002 1002
 		$post_status = $q['post_status'];
1003 1003
 		$perm = 'readable';
1004 1004
 	}
1005 1005
 
1006
-	if ( isset($q['orderby']) )
1006
+	if (isset($q['orderby']))
1007 1007
 		$orderby = $q['orderby'];
1008
-	elseif ( isset($q['post_status']) && in_array($q['post_status'], array('pending', 'draft')) )
1008
+	elseif (isset($q['post_status']) && in_array($q['post_status'], array('pending', 'draft')))
1009 1009
 		$orderby = 'modified';
1010 1010
 
1011
-	if ( isset($q['order']) )
1011
+	if (isset($q['order']))
1012 1012
 		$order = $q['order'];
1013
-	elseif ( isset($q['post_status']) && 'pending' == $q['post_status'] )
1013
+	elseif (isset($q['post_status']) && 'pending' == $q['post_status'])
1014 1014
 		$order = 'ASC';
1015 1015
 
1016 1016
 	$per_page = "edit_{$post_type}_per_page";
1017
-	$posts_per_page = (int) get_user_option( $per_page );
1018
-	if ( empty( $posts_per_page ) || $posts_per_page < 1 )
1017
+	$posts_per_page = (int) get_user_option($per_page);
1018
+	if (empty($posts_per_page) || $posts_per_page < 1)
1019 1019
 		$posts_per_page = 20;
1020 1020
 
1021 1021
 	/**
@@ -1031,7 +1031,7 @@  discard block
 block discarded – undo
1031 1031
 	 * @param int $posts_per_page Number of posts to display per page for the given post
1032 1032
 	 *                            type. Default 20.
1033 1033
 	 */
1034
-	$posts_per_page = apply_filters( "edit_{$post_type}_per_page", $posts_per_page );
1034
+	$posts_per_page = apply_filters("edit_{$post_type}_per_page", $posts_per_page);
1035 1035
 
1036 1036
 	/**
1037 1037
 	 * Filter the number of posts displayed per page when specifically listing "posts".
@@ -1041,12 +1041,12 @@  discard block
 block discarded – undo
1041 1041
 	 * @param int    $posts_per_page Number of posts to be displayed. Default 20.
1042 1042
 	 * @param string $post_type      The post type.
1043 1043
 	 */
1044
-	$posts_per_page = apply_filters( 'edit_posts_per_page', $posts_per_page, $post_type );
1044
+	$posts_per_page = apply_filters('edit_posts_per_page', $posts_per_page, $post_type);
1045 1045
 
1046 1046
 	$query = compact('post_type', 'post_status', 'perm', 'order', 'orderby', 'posts_per_page');
1047 1047
 
1048 1048
 	// Hierarchical types require special args.
1049
-	if ( is_post_type_hierarchical( $post_type ) && !isset($orderby) ) {
1049
+	if (is_post_type_hierarchical($post_type) && ! isset($orderby)) {
1050 1050
 		$query['orderby'] = 'menu_order title';
1051 1051
 		$query['order'] = 'asc';
1052 1052
 		$query['posts_per_page'] = -1;
@@ -1054,10 +1054,10 @@  discard block
 block discarded – undo
1054 1054
 		$query['fields'] = 'id=>parent';
1055 1055
 	}
1056 1056
 
1057
-	if ( ! empty( $q['show_sticky'] ) )
1058
-		$query['post__in'] = (array) get_option( 'sticky_posts' );
1057
+	if ( ! empty($q['show_sticky']))
1058
+		$query['post__in'] = (array) get_option('sticky_posts');
1059 1059
 
1060
-	wp( $query );
1060
+	wp($query);
1061 1061
 
1062 1062
 	return $avail_post_stati;
1063 1063
 }
@@ -1088,24 +1088,24 @@  discard block
 block discarded – undo
1088 1088
  *                       to use $_GET superglobal. Default false.
1089 1089
  * @return array The parsed query vars.
1090 1090
  */
1091
-function wp_edit_attachments_query_vars( $q = false ) {
1092
-	if ( false === $q ) {
1091
+function wp_edit_attachments_query_vars($q = false) {
1092
+	if (false === $q) {
1093 1093
 		$q = $_GET;
1094 1094
 	}
1095
-	$q['m']   = isset( $q['m'] ) ? (int) $q['m'] : 0;
1096
-	$q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0;
1095
+	$q['m']   = isset($q['m']) ? (int) $q['m'] : 0;
1096
+	$q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0;
1097 1097
 	$q['post_type'] = 'attachment';
1098
-	$post_type = get_post_type_object( 'attachment' );
1098
+	$post_type = get_post_type_object('attachment');
1099 1099
 	$states = 'inherit';
1100
-	if ( current_user_can( $post_type->cap->read_private_posts ) ) {
1100
+	if (current_user_can($post_type->cap->read_private_posts)) {
1101 1101
 		$states .= ',private';
1102 1102
 	}
1103 1103
 
1104
-	$q['post_status'] = isset( $q['status'] ) && 'trash' == $q['status'] ? 'trash' : $states;
1105
-	$q['post_status'] = isset( $q['attachment-filter'] ) && 'trash' == $q['attachment-filter'] ? 'trash' : $states;
1104
+	$q['post_status'] = isset($q['status']) && 'trash' == $q['status'] ? 'trash' : $states;
1105
+	$q['post_status'] = isset($q['attachment-filter']) && 'trash' == $q['attachment-filter'] ? 'trash' : $states;
1106 1106
 
1107
-	$media_per_page = (int) get_user_option( 'upload_per_page' );
1108
-	if ( empty( $media_per_page ) || $media_per_page < 1 ) {
1107
+	$media_per_page = (int) get_user_option('upload_per_page');
1108
+	if (empty($media_per_page) || $media_per_page < 1) {
1109 1109
 		$media_per_page = 20;
1110 1110
 	}
1111 1111
 
@@ -1116,21 +1116,21 @@  discard block
 block discarded – undo
1116 1116
 	 *
1117 1117
 	 * @param int $media_per_page Number of media to list. Default 20.
1118 1118
 	 */
1119
-	$q['posts_per_page'] = apply_filters( 'upload_per_page', $media_per_page );
1119
+	$q['posts_per_page'] = apply_filters('upload_per_page', $media_per_page);
1120 1120
 
1121 1121
 	$post_mime_types = get_post_mime_types();
1122
-	if ( isset($q['post_mime_type']) && !array_intersect( (array) $q['post_mime_type'], array_keys($post_mime_types) ) ) {
1122
+	if (isset($q['post_mime_type']) && ! array_intersect((array) $q['post_mime_type'], array_keys($post_mime_types))) {
1123 1123
 		unset($q['post_mime_type']);
1124 1124
 	}
1125 1125
 
1126
-	foreach( array_keys( $post_mime_types ) as $type ) {
1127
-		if ( isset( $q['attachment-filter'] ) && "post_mime_type:$type" == $q['attachment-filter'] ) {
1126
+	foreach (array_keys($post_mime_types) as $type) {
1127
+		if (isset($q['attachment-filter']) && "post_mime_type:$type" == $q['attachment-filter']) {
1128 1128
 			$q['post_mime_type'] = $type;
1129 1129
 			break;
1130 1130
 		}
1131 1131
 	}
1132 1132
 
1133
-	if ( isset( $q['detached'] ) || ( isset( $q['attachment-filter'] ) && 'detached' == $q['attachment-filter'] ) ) {
1133
+	if (isset($q['detached']) || (isset($q['attachment-filter']) && 'detached' == $q['attachment-filter'])) {
1134 1134
 		$q['post_parent'] = 0;
1135 1135
 	}
1136 1136
 
@@ -1146,13 +1146,13 @@  discard block
 block discarded – undo
1146 1146
  * @param array|false $q Array of query variables to use to build the query or false to use $_GET superglobal.
1147 1147
  * @return array
1148 1148
  */
1149
-function wp_edit_attachments_query( $q = false ) {
1150
-	wp( wp_edit_attachments_query_vars( $q ) );
1149
+function wp_edit_attachments_query($q = false) {
1150
+	wp(wp_edit_attachments_query_vars($q));
1151 1151
 
1152 1152
 	$post_mime_types = get_post_mime_types();
1153
-	$avail_post_mime_types = get_available_post_mime_types( 'attachment' );
1153
+	$avail_post_mime_types = get_available_post_mime_types('attachment');
1154 1154
 
1155
-	return array( $post_mime_types, $avail_post_mime_types );
1155
+	return array($post_mime_types, $avail_post_mime_types);
1156 1156
 }
1157 1157
 
1158 1158
 /**
@@ -1164,17 +1164,17 @@  discard block
 block discarded – undo
1164 1164
  * @param string $page
1165 1165
  * @return string
1166 1166
  */
1167
-function postbox_classes( $id, $page ) {
1168
-	if ( isset( $_GET['edit'] ) && $_GET['edit'] == $id ) {
1169
-		$classes = array( '' );
1170
-	} elseif ( $closed = get_user_option('closedpostboxes_'.$page ) ) {
1171
-		if ( !is_array( $closed ) ) {
1172
-			$classes = array( '' );
1167
+function postbox_classes($id, $page) {
1168
+	if (isset($_GET['edit']) && $_GET['edit'] == $id) {
1169
+		$classes = array('');
1170
+	} elseif ($closed = get_user_option('closedpostboxes_'.$page)) {
1171
+		if ( ! is_array($closed)) {
1172
+			$classes = array('');
1173 1173
 		} else {
1174
-			$classes = in_array( $id, $closed ) ? array( 'closed' ) : array( '' );
1174
+			$classes = in_array($id, $closed) ? array('closed') : array('');
1175 1175
 		}
1176 1176
 	} else {
1177
-		$classes = array( '' );
1177
+		$classes = array('');
1178 1178
 	}
1179 1179
 
1180 1180
 	/**
@@ -1187,8 +1187,8 @@  discard block
 block discarded – undo
1187 1187
 	 *
1188 1188
 	 * @param array $classes An array of postbox classes.
1189 1189
 	 */
1190
-	$classes = apply_filters( "postbox_classes_{$page}_{$id}", $classes );
1191
-	return implode( ' ', $classes );
1190
+	$classes = apply_filters("postbox_classes_{$page}_{$id}", $classes);
1191
+	return implode(' ', $classes);
1192 1192
 }
1193 1193
 
1194 1194
 /**
@@ -1202,9 +1202,9 @@  discard block
 block discarded – undo
1202 1202
  * @return array Array with two entries of type string.
1203 1203
  */
1204 1204
 function get_sample_permalink($id, $title = null, $name = null) {
1205
-	$post = get_post( $id );
1206
-	if ( ! $post )
1207
-		return array( '', '' );
1205
+	$post = get_post($id);
1206
+	if ( ! $post)
1207
+		return array('', '');
1208 1208
 
1209 1209
 	$ptype = get_post_type_object($post->post_type);
1210 1210
 
@@ -1213,14 +1213,14 @@  discard block
 block discarded – undo
1213 1213
 	$original_name = $post->post_name;
1214 1214
 
1215 1215
 	// Hack: get_permalink() would return ugly permalink for drafts, so we will fake that our post is published.
1216
-	if ( in_array( $post->post_status, array( 'draft', 'pending', 'future' ) ) ) {
1216
+	if (in_array($post->post_status, array('draft', 'pending', 'future'))) {
1217 1217
 		$post->post_status = 'publish';
1218 1218
 		$post->post_name = sanitize_title($post->post_name ? $post->post_name : $post->post_title, $post->ID);
1219 1219
 	}
1220 1220
 
1221 1221
 	// If the user wants to set a new name -- override the current one
1222 1222
 	// Note: if empty name is supplied -- use the title instead, see #6072
1223
-	if ( !is_null($name) )
1223
+	if ( ! is_null($name))
1224 1224
 		$post->post_name = sanitize_title($name ? $name : $title, $post->ID);
1225 1225
 
1226 1226
 	$post->post_name = wp_unique_post_slug($post->post_name, $post->ID, $post->post_status, $post->post_type, $post->post_parent);
@@ -1233,23 +1233,23 @@  discard block
 block discarded – undo
1233 1233
 	$permalink = str_replace("%$post->post_type%", '%pagename%', $permalink);
1234 1234
 
1235 1235
 	// Handle page hierarchy
1236
-	if ( $ptype->hierarchical ) {
1236
+	if ($ptype->hierarchical) {
1237 1237
 		$uri = get_page_uri($post);
1238
-		if ( $uri ) {
1238
+		if ($uri) {
1239 1239
 			$uri = untrailingslashit($uri);
1240
-			$uri = strrev( stristr( strrev( $uri ), '/' ) );
1240
+			$uri = strrev(stristr(strrev($uri), '/'));
1241 1241
 			$uri = untrailingslashit($uri);
1242 1242
 		}
1243 1243
 
1244 1244
 		/** This filter is documented in wp-admin/edit-tag-form.php */
1245
-		$uri = apply_filters( 'editable_slug', $uri );
1246
-		if ( !empty($uri) )
1245
+		$uri = apply_filters('editable_slug', $uri);
1246
+		if ( ! empty($uri))
1247 1247
 			$uri .= '/';
1248 1248
 		$permalink = str_replace('%pagename%', "{$uri}%pagename%", $permalink);
1249 1249
 	}
1250 1250
 
1251 1251
 	/** This filter is documented in wp-admin/edit-tag-form.php */
1252
-	$permalink = array( $permalink, apply_filters( 'editable_slug', $post->post_name ) );
1252
+	$permalink = array($permalink, apply_filters('editable_slug', $post->post_name));
1253 1253
 	$post->post_status = $original_status;
1254 1254
 	$post->post_date = $original_date;
1255 1255
 	$post->post_name = $original_name;
@@ -1268,67 +1268,67 @@  discard block
 block discarded – undo
1268 1268
  * @param string $new_slug  Optional. New slug. Default null.
1269 1269
  * @return string The HTML of the sample permalink slug editor.
1270 1270
  */
1271
-function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
1272
-	$post = get_post( $id );
1273
-	if ( ! $post )
1271
+function get_sample_permalink_html($id, $new_title = null, $new_slug = null) {
1272
+	$post = get_post($id);
1273
+	if ( ! $post)
1274 1274
 		return '';
1275 1275
 
1276 1276
 	list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug);
1277 1277
 
1278
-	if ( current_user_can( 'read_post', $post->ID ) ) {
1279
-		$ptype = get_post_type_object( $post->post_type );
1278
+	if (current_user_can('read_post', $post->ID)) {
1279
+		$ptype = get_post_type_object($post->post_type);
1280 1280
 		$view_post = $ptype->labels->view_item;
1281 1281
 	}
1282 1282
 
1283
-	if ( 'publish' == get_post_status( $post ) ) {
1283
+	if ('publish' == get_post_status($post)) {
1284 1284
 		$title = __('Click to edit this part of the permalink');
1285 1285
 	} else {
1286 1286
 		$title = __('Temporary permalink. Click to edit this part.');
1287 1287
 	}
1288 1288
 
1289
-	if ( false === strpos( $permalink, '%postname%' ) && false === strpos( $permalink, '%pagename%' ) ) {
1290
-		$return = '<strong>' . __('Permalink:') . "</strong>\n" . '<span id="sample-permalink" tabindex="-1">' . $permalink . "</span>\n";
1291
-		if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && !( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) ) {
1292
-			$return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small" target="_blank">' . __('Change Permalinks') . "</a></span>\n";
1289
+	if (false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%')) {
1290
+		$return = '<strong>'.__('Permalink:')."</strong>\n".'<span id="sample-permalink" tabindex="-1">'.$permalink."</span>\n";
1291
+		if ('' == get_option('permalink_structure') && current_user_can('manage_options') && ! ('page' == get_option('show_on_front') && $id == get_option('page_on_front'))) {
1292
+			$return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small" target="_blank">'.__('Change Permalinks')."</a></span>\n";
1293 1293
 		}
1294 1294
 	} else {
1295
-		if ( function_exists( 'mb_strlen' ) ) {
1296
-			if ( mb_strlen( $post_name ) > 30 ) {
1297
-				$post_name_abridged = mb_substr( $post_name, 0, 14 ) . '&hellip;' . mb_substr( $post_name, -14 );
1295
+		if (function_exists('mb_strlen')) {
1296
+			if (mb_strlen($post_name) > 30) {
1297
+				$post_name_abridged = mb_substr($post_name, 0, 14).'&hellip;'.mb_substr($post_name, -14);
1298 1298
 			} else {
1299 1299
 				$post_name_abridged = $post_name;
1300 1300
 			}
1301 1301
 		} else {
1302
-			if ( strlen( $post_name ) > 30 ) {
1303
-				$post_name_abridged = substr( $post_name, 0, 14 ) . '&hellip;' . substr( $post_name, -14 );
1302
+			if (strlen($post_name) > 30) {
1303
+				$post_name_abridged = substr($post_name, 0, 14).'&hellip;'.substr($post_name, -14);
1304 1304
 			} else {
1305 1305
 				$post_name_abridged = $post_name;
1306 1306
 			}
1307 1307
 		}
1308 1308
 
1309
-		$post_name_html = '<span id="editable-post-name" title="' . $title . '">' . $post_name_abridged . '</span>';
1310
-		$display_link = str_replace( array( '%pagename%', '%postname%' ), $post_name_html, urldecode( $permalink ) );
1311
-		$pretty_permalink = str_replace( array( '%pagename%', '%postname%' ), $post_name, urldecode( $permalink ) );
1309
+		$post_name_html = '<span id="editable-post-name" title="'.$title.'">'.$post_name_abridged.'</span>';
1310
+		$display_link = str_replace(array('%pagename%', '%postname%'), $post_name_html, urldecode($permalink));
1311
+		$pretty_permalink = str_replace(array('%pagename%', '%postname%'), $post_name, urldecode($permalink));
1312 1312
 
1313
-		$return =  '<strong>' . __( 'Permalink:' ) . "</strong>\n";
1314
-		$return .= '<span id="sample-permalink" tabindex="-1">' . $display_link . "</span>\n";
1313
+		$return = '<strong>'.__('Permalink:')."</strong>\n";
1314
+		$return .= '<span id="sample-permalink" tabindex="-1">'.$display_link."</span>\n";
1315 1315
 		$return .= '&lrm;'; // Fix bi-directional text display defect in RTL languages.
1316
-		$return .= '<span id="edit-slug-buttons"><a href="#post_name" class="edit-slug button button-small hide-if-no-js" onclick="editPermalink(' . $id . '); return false;">' . __( 'Edit' ) . "</a></span>\n";
1317
-		$return .= '<span id="editable-post-name-full">' . $post_name . "</span>\n";
1316
+		$return .= '<span id="edit-slug-buttons"><a href="#post_name" class="edit-slug button button-small hide-if-no-js" onclick="editPermalink('.$id.'); return false;">'.__('Edit')."</a></span>\n";
1317
+		$return .= '<span id="editable-post-name-full">'.$post_name."</span>\n";
1318 1318
 	}
1319 1319
 
1320
-	if ( isset( $view_post ) ) {
1321
-		if ( 'draft' == $post->post_status ) {
1322
-			$preview_link = set_url_scheme( get_permalink( $post->ID ) );
1320
+	if (isset($view_post)) {
1321
+		if ('draft' == $post->post_status) {
1322
+			$preview_link = set_url_scheme(get_permalink($post->ID));
1323 1323
 			/** This filter is documented in wp-admin/includes/meta-boxes.php */
1324
-			$preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post );
1325
-			$return .= "<span id='view-post-btn'><a href='" . esc_url( $preview_link ) . "' class='button button-small' target='wp-preview-{$post->ID}'>$view_post</a></span>\n";
1324
+			$preview_link = apply_filters('preview_post_link', add_query_arg('preview', 'true', $preview_link), $post);
1325
+			$return .= "<span id='view-post-btn'><a href='".esc_url($preview_link)."' class='button button-small' target='wp-preview-{$post->ID}'>$view_post</a></span>\n";
1326 1326
 		} else {
1327
-			if ( empty( $pretty_permalink ) ) {
1327
+			if (empty($pretty_permalink)) {
1328 1328
 				$pretty_permalink = $permalink;
1329 1329
 			}
1330 1330
 
1331
-			$return .= "<span id='view-post-btn'><a href='" . $pretty_permalink . "' class='button button-small'>$view_post</a></span>\n";
1331
+			$return .= "<span id='view-post-btn'><a href='".$pretty_permalink."' class='button button-small'>$view_post</a></span>\n";
1332 1332
 		}
1333 1333
 	}
1334 1334
 
@@ -1342,7 +1342,7 @@  discard block
 block discarded – undo
1342 1342
 	 * @param string      $new_title New sample permalink title.
1343 1343
 	 * @param string      $new_slug  New sample permalink slug.
1344 1344
 	 */
1345
-	$return = apply_filters( 'get_sample_permalink_html', $return, $id, $new_title, $new_slug );
1345
+	$return = apply_filters('get_sample_permalink_html', $return, $id, $new_title, $new_slug);
1346 1346
 
1347 1347
 	return $return;
1348 1348
 }
@@ -1359,35 +1359,35 @@  discard block
 block discarded – undo
1359 1359
  * @param mixed $post The post ID or object associated with the thumbnail, defaults to global $post.
1360 1360
  * @return string html
1361 1361
  */
1362
-function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) {
1362
+function _wp_post_thumbnail_html($thumbnail_id = null, $post = null) {
1363 1363
 	global $content_width, $_wp_additional_image_sizes;
1364 1364
 
1365
-	$post               = get_post( $post );
1366
-	$post_type_object   = get_post_type_object( $post->post_type );
1365
+	$post               = get_post($post);
1366
+	$post_type_object   = get_post_type_object($post->post_type);
1367 1367
 	$set_thumbnail_link = '<p class="hide-if-no-js"><a title="%s" href="%s" id="set-post-thumbnail" class="thickbox">%s</a></p>';
1368
-	$upload_iframe_src  = get_upload_iframe_src( 'image', $post->ID );
1368
+	$upload_iframe_src  = get_upload_iframe_src('image', $post->ID);
1369 1369
 
1370
-	$content = sprintf( $set_thumbnail_link,
1371
-		esc_attr( $post_type_object->labels->set_featured_image ),
1372
-		esc_url( $upload_iframe_src ),
1373
-		esc_html( $post_type_object->labels->set_featured_image )
1370
+	$content = sprintf($set_thumbnail_link,
1371
+		esc_attr($post_type_object->labels->set_featured_image),
1372
+		esc_url($upload_iframe_src),
1373
+		esc_html($post_type_object->labels->set_featured_image)
1374 1374
 	);
1375 1375
 
1376
-	if ( $thumbnail_id && get_post( $thumbnail_id ) ) {
1376
+	if ($thumbnail_id && get_post($thumbnail_id)) {
1377 1377
 		$old_content_width = $content_width;
1378 1378
 		$content_width = 266;
1379
-		if ( !isset( $_wp_additional_image_sizes['post-thumbnail'] ) )
1380
-			$thumbnail_html = wp_get_attachment_image( $thumbnail_id, array( $content_width, $content_width ) );
1379
+		if ( ! isset($_wp_additional_image_sizes['post-thumbnail']))
1380
+			$thumbnail_html = wp_get_attachment_image($thumbnail_id, array($content_width, $content_width));
1381 1381
 		else
1382
-			$thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'post-thumbnail' );
1383
-		if ( !empty( $thumbnail_html ) ) {
1384
-			$ajax_nonce = wp_create_nonce( 'set_post_thumbnail-' . $post->ID );
1385
-			$content = sprintf( $set_thumbnail_link,
1386
-				esc_attr( $post_type_object->labels->set_featured_image ),
1387
-				esc_url( $upload_iframe_src ),
1382
+			$thumbnail_html = wp_get_attachment_image($thumbnail_id, 'post-thumbnail');
1383
+		if ( ! empty($thumbnail_html)) {
1384
+			$ajax_nonce = wp_create_nonce('set_post_thumbnail-'.$post->ID);
1385
+			$content = sprintf($set_thumbnail_link,
1386
+				esc_attr($post_type_object->labels->set_featured_image),
1387
+				esc_url($upload_iframe_src),
1388 1388
 				$thumbnail_html
1389 1389
 			);
1390
-			$content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail(\'' . $ajax_nonce . '\');return false;">' . esc_html( $post_type_object->labels->remove_featured_image ) . '</a></p>';
1390
+			$content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail(\''.$ajax_nonce.'\');return false;">'.esc_html($post_type_object->labels->remove_featured_image).'</a></p>';
1391 1391
 		}
1392 1392
 		$content_width = $old_content_width;
1393 1393
 	}
@@ -1400,7 +1400,7 @@  discard block
 block discarded – undo
1400 1400
 	 * @param string $content Admin post thumbnail HTML markup.
1401 1401
 	 * @param int    $post_id Post ID.
1402 1402
 	 */
1403
-	return apply_filters( 'admin_post_thumbnail_html', $content, $post->ID );
1403
+	return apply_filters('admin_post_thumbnail_html', $content, $post->ID);
1404 1404
 }
1405 1405
 
1406 1406
 /**
@@ -1411,21 +1411,21 @@  discard block
 block discarded – undo
1411 1411
  * @param int $post_id ID of the post to check for editing
1412 1412
  * @return integer False: not locked or locked by current user. Int: user ID of user with lock.
1413 1413
  */
1414
-function wp_check_post_lock( $post_id ) {
1415
-	if ( !$post = get_post( $post_id ) )
1414
+function wp_check_post_lock($post_id) {
1415
+	if ( ! $post = get_post($post_id))
1416 1416
 		return false;
1417 1417
 
1418
-	if ( !$lock = get_post_meta( $post->ID, '_edit_lock', true ) )
1418
+	if ( ! $lock = get_post_meta($post->ID, '_edit_lock', true))
1419 1419
 		return false;
1420 1420
 
1421
-	$lock = explode( ':', $lock );
1421
+	$lock = explode(':', $lock);
1422 1422
 	$time = $lock[0];
1423
-	$user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true );
1423
+	$user = isset($lock[1]) ? $lock[1] : get_post_meta($post->ID, '_edit_last', true);
1424 1424
 
1425 1425
 	/** This filter is documented in wp-admin/includes/ajax-actions.php */
1426
-	$time_window = apply_filters( 'wp_check_post_lock_window', 150 );
1426
+	$time_window = apply_filters('wp_check_post_lock_window', 150);
1427 1427
 
1428
-	if ( $time && $time > time() - $time_window && $user != get_current_user_id() )
1428
+	if ($time && $time > time() - $time_window && $user != get_current_user_id())
1429 1429
 		return $user;
1430 1430
 	return false;
1431 1431
 }
@@ -1439,17 +1439,17 @@  discard block
 block discarded – undo
1439 1439
  * @return bool|array Returns false if the post doesn't exist of there is no current user, or
1440 1440
  * 	an array of the lock time and the user ID.
1441 1441
  */
1442
-function wp_set_post_lock( $post_id ) {
1443
-	if ( !$post = get_post( $post_id ) )
1442
+function wp_set_post_lock($post_id) {
1443
+	if ( ! $post = get_post($post_id))
1444 1444
 		return false;
1445
-	if ( 0 == ($user_id = get_current_user_id()) )
1445
+	if (0 == ($user_id = get_current_user_id()))
1446 1446
 		return false;
1447 1447
 
1448 1448
 	$now = time();
1449 1449
 	$lock = "$now:$user_id";
1450 1450
 
1451
-	update_post_meta( $post->ID, '_edit_lock', $lock );
1452
-	return array( $now, $user_id );
1451
+	update_post_meta($post->ID, '_edit_lock', $lock);
1452
+	return array($now, $user_id);
1453 1453
 }
1454 1454
 
1455 1455
 /**
@@ -1459,14 +1459,14 @@  discard block
 block discarded – undo
1459 1459
  * @return none
1460 1460
  */
1461 1461
 function _admin_notice_post_locked() {
1462
-	if ( ! $post = get_post() )
1462
+	if ( ! $post = get_post())
1463 1463
 		return;
1464 1464
 
1465 1465
 	$user = null;
1466
-	if (  $user_id = wp_check_post_lock( $post->ID ) )
1467
-		$user = get_userdata( $user_id );
1466
+	if ($user_id = wp_check_post_lock($post->ID))
1467
+		$user = get_userdata($user_id);
1468 1468
 
1469
-	if ( $user ) {
1469
+	if ($user) {
1470 1470
 
1471 1471
 		/**
1472 1472
 		 * Filter whether to show the post locked dialog.
@@ -1478,7 +1478,7 @@  discard block
 block discarded – undo
1478 1478
 		 * @param bool         $display Whether to display the dialog. Default true.
1479 1479
 		 * @param WP_User|bool $user    WP_User object on success, false otherwise.
1480 1480
 		 */
1481
-		if ( ! apply_filters( 'show_post_locked_dialog', true, $post, $user ) )
1481
+		if ( ! apply_filters('show_post_locked_dialog', true, $post, $user))
1482 1482
 			return;
1483 1483
 
1484 1484
 		$locked = true;
@@ -1486,17 +1486,17 @@  discard block
 block discarded – undo
1486 1486
 		$locked = false;
1487 1487
 	}
1488 1488
 
1489
-	if ( $locked && ( $sendback = wp_get_referer() ) &&
1490
-		false === strpos( $sendback, 'post.php' ) && false === strpos( $sendback, 'post-new.php' ) ) {
1489
+	if ($locked && ($sendback = wp_get_referer()) &&
1490
+		false === strpos($sendback, 'post.php') && false === strpos($sendback, 'post-new.php')) {
1491 1491
 
1492 1492
 		$sendback_text = __('Go back');
1493 1493
 	} else {
1494
-		$sendback = admin_url( 'edit.php' );
1494
+		$sendback = admin_url('edit.php');
1495 1495
 
1496
-		if ( 'post' != $post->post_type )
1497
-			$sendback = add_query_arg( 'post_type', $post->post_type, $sendback );
1496
+		if ('post' != $post->post_type)
1497
+			$sendback = add_query_arg('post_type', $post->post_type, $sendback);
1498 1498
 
1499
-		$sendback_text = get_post_type_object( $post->post_type )->labels->all_items;
1499
+		$sendback_text = get_post_type_object($post->post_type)->labels->all_items;
1500 1500
 	}
1501 1501
 
1502 1502
 	$hidden = $locked ? '' : ' hidden';
@@ -1507,21 +1507,21 @@  discard block
 block discarded – undo
1507 1507
 	<div class="notification-dialog">
1508 1508
 	<?php
1509 1509
 
1510
-	if ( $locked ) {
1511
-		if ( get_post_type_object( $post->post_type )->public ) {
1512
-			$preview_link = set_url_scheme( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) );
1510
+	if ($locked) {
1511
+		if (get_post_type_object($post->post_type)->public) {
1512
+			$preview_link = set_url_scheme(add_query_arg('preview', 'true', get_permalink($post->ID)));
1513 1513
 
1514
-			if ( 'publish' == $post->post_status || $user->ID != $post->post_author ) {
1514
+			if ('publish' == $post->post_status || $user->ID != $post->post_author) {
1515 1515
 				// Latest content is in autosave
1516
-				$nonce = wp_create_nonce( 'post_preview_' . $post->ID );
1517
-				$preview_link = add_query_arg( array( 'preview_id' => $post->ID, 'preview_nonce' => $nonce ), $preview_link );
1516
+				$nonce = wp_create_nonce('post_preview_'.$post->ID);
1517
+				$preview_link = add_query_arg(array('preview_id' => $post->ID, 'preview_nonce' => $nonce), $preview_link);
1518 1518
 			}
1519 1519
 		} else {
1520 1520
 			$preview_link = '';
1521 1521
 		}
1522 1522
 
1523 1523
 		/** This filter is documented in wp-admin/includes/meta-boxes.php */
1524
-		$preview_link = apply_filters( 'preview_post_link', $preview_link, $post );
1524
+		$preview_link = apply_filters('preview_post_link', $preview_link, $post);
1525 1525
 
1526 1526
 		/**
1527 1527
 		 * Filter whether to allow the post lock to be overridden.
@@ -1535,17 +1535,17 @@  discard block
 block discarded – undo
1535 1535
 		 * @param WP_Post $post     Post object.
1536 1536
 		 * @param WP_User $user     User object.
1537 1537
 		 */
1538
-		$override = apply_filters( 'override_post_lock', true, $post, $user );
1538
+		$override = apply_filters('override_post_lock', true, $post, $user);
1539 1539
 		$tab_last = $override ? '' : ' wp-tab-last';
1540 1540
 
1541 1541
 		?>
1542 1542
 		<div class="post-locked-message">
1543
-		<div class="post-locked-avatar"><?php echo get_avatar( $user->ID, 64 ); ?></div>
1543
+		<div class="post-locked-avatar"><?php echo get_avatar($user->ID, 64); ?></div>
1544 1544
 		<p class="currently-editing wp-tab-first" tabindex="0">
1545 1545
 		<?php
1546
-			_e( 'This content is currently locked.' );
1547
-			if ( $override )
1548
-				printf( ' ' . __( 'If you take over, %s will be blocked from continuing to edit.' ), esc_html( $user->display_name ) );
1546
+			_e('This content is currently locked.');
1547
+			if ($override)
1548
+				printf(' '.__('If you take over, %s will be blocked from continuing to edit.'), esc_html($user->display_name));
1549 1549
 		?>
1550 1550
 		</p>
1551 1551
 		<?php
@@ -1556,19 +1556,19 @@  discard block
 block discarded – undo
1556 1556
 		 *
1557 1557
 		 * @param WP_Post $post Post object.
1558 1558
 		 */
1559
-		do_action( 'post_locked_dialog', $post );
1559
+		do_action('post_locked_dialog', $post);
1560 1560
 		?>
1561 1561
 		<p>
1562
-		<a class="button" href="<?php echo esc_url( $sendback ); ?>"><?php echo $sendback_text; ?></a>
1563
-		<?php if ( $preview_link ) { ?>
1564
-		<a class="button<?php echo $tab_last; ?>" href="<?php echo esc_url( $preview_link ); ?>"><?php _e('Preview'); ?></a>
1562
+		<a class="button" href="<?php echo esc_url($sendback); ?>"><?php echo $sendback_text; ?></a>
1563
+		<?php if ($preview_link) { ?>
1564
+		<a class="button<?php echo $tab_last; ?>" href="<?php echo esc_url($preview_link); ?>"><?php _e('Preview'); ?></a>
1565 1565
 		<?php
1566 1566
 		}
1567 1567
 
1568 1568
 		// Allow plugins to prevent some users overriding the post lock
1569
-		if ( $override ) {
1569
+		if ($override) {
1570 1570
 			?>
1571
-			<a class="button button-primary wp-tab-last" href="<?php echo esc_url( add_query_arg( 'get-post-lock', '1', wp_nonce_url( get_edit_post_link( $post->ID, 'url' ), 'lock-post_' . $post->ID ) ) ); ?>"><?php _e('Take over'); ?></a>
1571
+			<a class="button button-primary wp-tab-last" href="<?php echo esc_url(add_query_arg('get-post-lock', '1', wp_nonce_url(get_edit_post_link($post->ID, 'url'), 'lock-post_'.$post->ID))); ?>"><?php _e('Take over'); ?></a>
1572 1572
 			<?php
1573 1573
 		}
1574 1574
 
@@ -1582,7 +1582,7 @@  discard block
 block discarded – undo
1582 1582
 			<div class="post-locked-avatar"></div>
1583 1583
 			<p class="wp-tab-first" tabindex="0">
1584 1584
 			<span class="currently-editing"></span><br />
1585
-			<span class="locked-saving hidden"><img src="<?php echo esc_url( admin_url( 'images/spinner-2x.gif' ) ); ?>" width="16" height="16" /> <?php _e('Saving revision...'); ?></span>
1585
+			<span class="locked-saving hidden"><img src="<?php echo esc_url(admin_url('images/spinner-2x.gif')); ?>" width="16" height="16" /> <?php _e('Saving revision...'); ?></span>
1586 1586
 			<span class="locked-saved hidden"><?php _e('Your latest changes were saved as a revision.'); ?></span>
1587 1587
 			</p>
1588 1588
 			<?php
@@ -1593,9 +1593,9 @@  discard block
 block discarded – undo
1593 1593
 			 *
1594 1594
 			 * @param WP_Post $post Post object.
1595 1595
 			 */
1596
-			do_action( 'post_lock_lost_dialog', $post );
1596
+			do_action('post_lock_lost_dialog', $post);
1597 1597
 			?>
1598
-			<p><a class="button button-primary wp-tab-last" href="<?php echo esc_url( $sendback ); ?>"><?php echo $sendback_text; ?></a></p>
1598
+			<p><a class="button button-primary wp-tab-last" href="<?php echo esc_url($sendback); ?>"><?php echo $sendback_text; ?></a></p>
1599 1599
 		</div>
1600 1600
 		<?php
1601 1601
 	}
@@ -1616,38 +1616,38 @@  discard block
 block discarded – undo
1616 1616
  * @param mixed $post_data Associative array containing the post data or int post ID.
1617 1617
  * @return mixed The autosave revision ID. WP_Error or 0 on error.
1618 1618
  */
1619
-function wp_create_post_autosave( $post_data ) {
1620
-	if ( is_numeric( $post_data ) ) {
1619
+function wp_create_post_autosave($post_data) {
1620
+	if (is_numeric($post_data)) {
1621 1621
 		$post_id = $post_data;
1622 1622
 		$post_data = &$_POST;
1623 1623
 	} else {
1624 1624
 		$post_id = (int) $post_data['post_ID'];
1625 1625
 	}
1626 1626
 
1627
-	$post_data = _wp_translate_postdata( true, $post_data );
1628
-	if ( is_wp_error( $post_data ) )
1627
+	$post_data = _wp_translate_postdata(true, $post_data);
1628
+	if (is_wp_error($post_data))
1629 1629
 		return $post_data;
1630 1630
 
1631 1631
 	$post_author = get_current_user_id();
1632 1632
 
1633 1633
 	// Store one autosave per author. If there is already an autosave, overwrite it.
1634
-	if ( $old_autosave = wp_get_post_autosave( $post_id, $post_author ) ) {
1635
-		$new_autosave = _wp_post_revision_fields( $post_data, true );
1634
+	if ($old_autosave = wp_get_post_autosave($post_id, $post_author)) {
1635
+		$new_autosave = _wp_post_revision_fields($post_data, true);
1636 1636
 		$new_autosave['ID'] = $old_autosave->ID;
1637 1637
 		$new_autosave['post_author'] = $post_author;
1638 1638
 
1639 1639
 		// If the new autosave has the same content as the post, delete the autosave.
1640
-		$post = get_post( $post_id );
1640
+		$post = get_post($post_id);
1641 1641
 		$autosave_is_different = false;
1642
-		foreach ( array_intersect( array_keys( $new_autosave ), array_keys( _wp_post_revision_fields() ) ) as $field ) {
1643
-			if ( normalize_whitespace( $new_autosave[ $field ] ) != normalize_whitespace( $post->$field ) ) {
1642
+		foreach (array_intersect(array_keys($new_autosave), array_keys(_wp_post_revision_fields())) as $field) {
1643
+			if (normalize_whitespace($new_autosave[$field]) != normalize_whitespace($post->$field)) {
1644 1644
 				$autosave_is_different = true;
1645 1645
 				break;
1646 1646
 			}
1647 1647
 		}
1648 1648
 
1649
-		if ( ! $autosave_is_different ) {
1650
-			wp_delete_post_revision( $old_autosave->ID );
1649
+		if ( ! $autosave_is_different) {
1650
+			wp_delete_post_revision($old_autosave->ID);
1651 1651
 			return 0;
1652 1652
 		}
1653 1653
 
@@ -1658,16 +1658,16 @@  discard block
 block discarded – undo
1658 1658
 		 *
1659 1659
 		 * @param array $new_autosave Post array - the autosave that is about to be saved.
1660 1660
 		 */
1661
-		do_action( 'wp_creating_autosave', $new_autosave );
1661
+		do_action('wp_creating_autosave', $new_autosave);
1662 1662
 
1663
-		return wp_update_post( $new_autosave );
1663
+		return wp_update_post($new_autosave);
1664 1664
 	}
1665 1665
 
1666 1666
 	// _wp_put_post_revision() expects unescaped.
1667
-	$post_data = wp_unslash( $post_data );
1667
+	$post_data = wp_unslash($post_data);
1668 1668
 
1669 1669
 	// Otherwise create the new autosave as a special post revision
1670
-	return _wp_put_post_revision( $post_data, true );
1670
+	return _wp_put_post_revision($post_data, true);
1671 1671
 }
1672 1672
 
1673 1673
 /**
@@ -1683,44 +1683,44 @@  discard block
 block discarded – undo
1683 1683
 	$post_ID = (int) $_POST['post_ID'];
1684 1684
 	$_POST['ID'] = $post_ID;
1685 1685
 
1686
-	if ( ! $post = get_post( $post_ID ) ) {
1687
-		wp_die( __( 'You are not allowed to edit this post.' ) );
1686
+	if ( ! $post = get_post($post_ID)) {
1687
+		wp_die(__('You are not allowed to edit this post.'));
1688 1688
 	}
1689 1689
 
1690
-	if ( ! current_user_can( 'edit_post', $post->ID ) ) {
1691
-		wp_die( __( 'You are not allowed to edit this post.' ) );
1690
+	if ( ! current_user_can('edit_post', $post->ID)) {
1691
+		wp_die(__('You are not allowed to edit this post.'));
1692 1692
 	}
1693 1693
 
1694 1694
 	$is_autosave = false;
1695 1695
 
1696
-	if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author && ( 'draft' == $post->post_status || 'auto-draft' == $post->post_status ) ) {
1696
+	if ( ! wp_check_post_lock($post->ID) && get_current_user_id() == $post->post_author && ('draft' == $post->post_status || 'auto-draft' == $post->post_status)) {
1697 1697
 		$saved_post_id = edit_post();
1698 1698
 	} else {
1699 1699
 		$is_autosave = true;
1700 1700
 
1701
-		if ( isset( $_POST['post_status'] ) && 'auto-draft' == $_POST['post_status'] )
1701
+		if (isset($_POST['post_status']) && 'auto-draft' == $_POST['post_status'])
1702 1702
 			$_POST['post_status'] = 'draft';
1703 1703
 
1704
-		$saved_post_id = wp_create_post_autosave( $post->ID );
1704
+		$saved_post_id = wp_create_post_autosave($post->ID);
1705 1705
 	}
1706 1706
 
1707
-	if ( is_wp_error( $saved_post_id ) )
1708
-		wp_die( $saved_post_id->get_error_message() );
1707
+	if (is_wp_error($saved_post_id))
1708
+		wp_die($saved_post_id->get_error_message());
1709 1709
 
1710
-	$query_args = array( 'preview' => 'true' );
1710
+	$query_args = array('preview' => 'true');
1711 1711
 
1712
-	if ( $is_autosave && $saved_post_id ) {
1712
+	if ($is_autosave && $saved_post_id) {
1713 1713
 		$query_args['preview_id'] = $post->ID;
1714
-		$query_args['preview_nonce'] = wp_create_nonce( 'post_preview_' . $post->ID );
1714
+		$query_args['preview_nonce'] = wp_create_nonce('post_preview_'.$post->ID);
1715 1715
 
1716
-		if ( isset( $_POST['post_format'] ) )
1717
-			$query_args['post_format'] = empty( $_POST['post_format'] ) ? 'standard' : sanitize_key( $_POST['post_format'] );
1716
+		if (isset($_POST['post_format']))
1717
+			$query_args['post_format'] = empty($_POST['post_format']) ? 'standard' : sanitize_key($_POST['post_format']);
1718 1718
 	}
1719 1719
 
1720
-	$url = add_query_arg( $query_args, get_permalink( $post->ID ) );
1720
+	$url = add_query_arg($query_args, get_permalink($post->ID));
1721 1721
 
1722 1722
 	/** This filter is documented in wp-admin/includes/meta-boxes.php */
1723
-	return apply_filters( 'preview_post_link', $url, $post );
1723
+	return apply_filters('preview_post_link', $url, $post);
1724 1724
 }
1725 1725
 
1726 1726
 /**
@@ -1734,35 +1734,35 @@  discard block
 block discarded – undo
1734 1734
  * @return mixed The value 0 or WP_Error on failure. The saved post ID on success.
1735 1735
  *               Te ID can be the draft post_id or the autosave revision post_id.
1736 1736
  */
1737
-function wp_autosave( $post_data ) {
1737
+function wp_autosave($post_data) {
1738 1738
 	// Back-compat
1739
-	if ( ! defined( 'DOING_AUTOSAVE' ) )
1740
-		define( 'DOING_AUTOSAVE', true );
1739
+	if ( ! defined('DOING_AUTOSAVE'))
1740
+		define('DOING_AUTOSAVE', true);
1741 1741
 
1742 1742
 	$post_id = (int) $post_data['post_id'];
1743 1743
 	$post_data['ID'] = $post_data['post_ID'] = $post_id;
1744 1744
 
1745
-	if ( false === wp_verify_nonce( $post_data['_wpnonce'], 'update-post_' . $post_id ) ) {
1746
-		return new WP_Error( 'invalid_nonce', __( 'Error while saving.' ) );
1745
+	if (false === wp_verify_nonce($post_data['_wpnonce'], 'update-post_'.$post_id)) {
1746
+		return new WP_Error('invalid_nonce', __('Error while saving.'));
1747 1747
 	}
1748 1748
 
1749
-	$post = get_post( $post_id );
1749
+	$post = get_post($post_id);
1750 1750
 
1751
-	if ( ! current_user_can( 'edit_post', $post->ID ) ) {
1752
-		return new WP_Error( 'edit_posts', __( 'You are not allowed to edit this item.' ) );
1751
+	if ( ! current_user_can('edit_post', $post->ID)) {
1752
+		return new WP_Error('edit_posts', __('You are not allowed to edit this item.'));
1753 1753
 	}
1754 1754
 
1755
-	if ( 'auto-draft' == $post->post_status )
1755
+	if ('auto-draft' == $post->post_status)
1756 1756
 		$post_data['post_status'] = 'draft';
1757 1757
 
1758
-	if ( $post_data['post_type'] != 'page' && ! empty( $post_data['catslist'] ) )
1759
-		$post_data['post_category'] = explode( ',', $post_data['catslist'] );
1758
+	if ($post_data['post_type'] != 'page' && ! empty($post_data['catslist']))
1759
+		$post_data['post_category'] = explode(',', $post_data['catslist']);
1760 1760
 
1761
-	if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author && ( 'auto-draft' == $post->post_status || 'draft' == $post->post_status ) ) {
1761
+	if ( ! wp_check_post_lock($post->ID) && get_current_user_id() == $post->post_author && ('auto-draft' == $post->post_status || 'draft' == $post->post_status)) {
1762 1762
 		// Drafts and auto-drafts are just overwritten by autosave for the same user if the post is not locked
1763
-		return edit_post( wp_slash( $post_data ) );
1763
+		return edit_post(wp_slash($post_data));
1764 1764
 	} else {
1765 1765
 		// Non drafts or other users drafts are not overwritten. The autosave is stored in a special post revision for each user.
1766
-		return wp_create_post_autosave( wp_slash( $post_data ) );
1766
+		return wp_create_post_autosave(wp_slash($post_data));
1767 1767
 	}
1768 1768
 }
Please login to merge, or discard this patch.
Braces   +321 added lines, -228 removed lines patch added patch discarded remove patch
@@ -20,37 +20,45 @@  discard block
 block discarded – undo
20 20
  */
21 21
 function _wp_translate_postdata( $update = false, $post_data = null ) {
22 22
 
23
-	if ( empty($post_data) )
24
-		$post_data = &$_POST;
23
+	if ( empty($post_data) ) {
24
+			$post_data = &$_POST;
25
+	}
25 26
 
26
-	if ( $update )
27
-		$post_data['ID'] = (int) $post_data['post_ID'];
27
+	if ( $update ) {
28
+			$post_data['ID'] = (int) $post_data['post_ID'];
29
+	}
28 30
 
29 31
 	$ptype = get_post_type_object( $post_data['post_type'] );
30 32
 
31 33
 	if ( $update && ! current_user_can( 'edit_post', $post_data['ID'] ) ) {
32
-		if ( 'page' == $post_data['post_type'] )
33
-			return new WP_Error( 'edit_others_pages', __( 'You are not allowed to edit pages as this user.' ) );
34
-		else
35
-			return new WP_Error( 'edit_others_posts', __( 'You are not allowed to edit posts as this user.' ) );
34
+		if ( 'page' == $post_data['post_type'] ) {
35
+					return new WP_Error( 'edit_others_pages', __( 'You are not allowed to edit pages as this user.' ) );
36
+		} else {
37
+					return new WP_Error( 'edit_others_posts', __( 'You are not allowed to edit posts as this user.' ) );
38
+		}
36 39
 	} elseif ( ! $update && ! current_user_can( $ptype->cap->create_posts ) ) {
37
-		if ( 'page' == $post_data['post_type'] )
38
-			return new WP_Error( 'edit_others_pages', __( 'You are not allowed to create pages as this user.' ) );
39
-		else
40
-			return new WP_Error( 'edit_others_posts', __( 'You are not allowed to create posts as this user.' ) );
40
+		if ( 'page' == $post_data['post_type'] ) {
41
+					return new WP_Error( 'edit_others_pages', __( 'You are not allowed to create pages as this user.' ) );
42
+		} else {
43
+					return new WP_Error( 'edit_others_posts', __( 'You are not allowed to create posts as this user.' ) );
44
+		}
41 45
 	}
42 46
 
43
-	if ( isset( $post_data['content'] ) )
44
-		$post_data['post_content'] = $post_data['content'];
47
+	if ( isset( $post_data['content'] ) ) {
48
+			$post_data['post_content'] = $post_data['content'];
49
+	}
45 50
 
46
-	if ( isset( $post_data['excerpt'] ) )
47
-		$post_data['post_excerpt'] = $post_data['excerpt'];
51
+	if ( isset( $post_data['excerpt'] ) ) {
52
+			$post_data['post_excerpt'] = $post_data['excerpt'];
53
+	}
48 54
 
49
-	if ( isset( $post_data['parent_id'] ) )
50
-		$post_data['post_parent'] = (int) $post_data['parent_id'];
55
+	if ( isset( $post_data['parent_id'] ) ) {
56
+			$post_data['post_parent'] = (int) $post_data['parent_id'];
57
+	}
51 58
 
52
-	if ( isset($post_data['trackback_url']) )
53
-		$post_data['to_ping'] = $post_data['trackback_url'];
59
+	if ( isset($post_data['trackback_url']) ) {
60
+			$post_data['to_ping'] = $post_data['trackback_url'];
61
+	}
54 62
 
55 63
 	$post_data['user_ID'] = get_current_user_id();
56 64
 
@@ -67,15 +75,17 @@  discard block
 block discarded – undo
67 75
 	if ( isset( $post_data['user_ID'] ) && ( $post_data['post_author'] != $post_data['user_ID'] )
68 76
 		 && ! current_user_can( $ptype->cap->edit_others_posts ) ) {
69 77
 		if ( $update ) {
70
-			if ( 'page' == $post_data['post_type'] )
71
-				return new WP_Error( 'edit_others_pages', __( 'You are not allowed to edit pages as this user.' ) );
72
-			else
73
-				return new WP_Error( 'edit_others_posts', __( 'You are not allowed to edit posts as this user.' ) );
78
+			if ( 'page' == $post_data['post_type'] ) {
79
+							return new WP_Error( 'edit_others_pages', __( 'You are not allowed to edit pages as this user.' ) );
80
+			} else {
81
+							return new WP_Error( 'edit_others_posts', __( 'You are not allowed to edit posts as this user.' ) );
82
+			}
74 83
 		} else {
75
-			if ( 'page' == $post_data['post_type'] )
76
-				return new WP_Error( 'edit_others_pages', __( 'You are not allowed to create pages as this user.' ) );
77
-			else
78
-				return new WP_Error( 'edit_others_posts', __( 'You are not allowed to create posts as this user.' ) );
84
+			if ( 'page' == $post_data['post_type'] ) {
85
+							return new WP_Error( 'edit_others_pages', __( 'You are not allowed to create pages as this user.' ) );
86
+			} else {
87
+							return new WP_Error( 'edit_others_posts', __( 'You are not allowed to create posts as this user.' ) );
88
+			}
79 89
 		}
80 90
 	}
81 91
 
@@ -93,21 +103,27 @@  discard block
 block discarded – undo
93 103
 	}
94 104
 
95 105
 	// What to do based on which button they pressed
96
-	if ( isset($post_data['saveasdraft']) && '' != $post_data['saveasdraft'] )
97
-		$post_data['post_status'] = 'draft';
98
-	if ( isset($post_data['saveasprivate']) && '' != $post_data['saveasprivate'] )
99
-		$post_data['post_status'] = 'private';
100
-	if ( isset($post_data['publish']) && ( '' != $post_data['publish'] ) && ( !isset($post_data['post_status']) || $post_data['post_status'] != 'private' ) )
101
-		$post_data['post_status'] = 'publish';
102
-	if ( isset($post_data['advanced']) && '' != $post_data['advanced'] )
103
-		$post_data['post_status'] = 'draft';
104
-	if ( isset($post_data['pending']) && '' != $post_data['pending'] )
105
-		$post_data['post_status'] = 'pending';
106
-
107
-	if ( isset( $post_data['ID'] ) )
108
-		$post_id = $post_data['ID'];
109
-	else
110
-		$post_id = false;
106
+	if ( isset($post_data['saveasdraft']) && '' != $post_data['saveasdraft'] ) {
107
+			$post_data['post_status'] = 'draft';
108
+	}
109
+	if ( isset($post_data['saveasprivate']) && '' != $post_data['saveasprivate'] ) {
110
+			$post_data['post_status'] = 'private';
111
+	}
112
+	if ( isset($post_data['publish']) && ( '' != $post_data['publish'] ) && ( !isset($post_data['post_status']) || $post_data['post_status'] != 'private' ) ) {
113
+			$post_data['post_status'] = 'publish';
114
+	}
115
+	if ( isset($post_data['advanced']) && '' != $post_data['advanced'] ) {
116
+			$post_data['post_status'] = 'draft';
117
+	}
118
+	if ( isset($post_data['pending']) && '' != $post_data['pending'] ) {
119
+			$post_data['post_status'] = 'pending';
120
+	}
121
+
122
+	if ( isset( $post_data['ID'] ) ) {
123
+			$post_id = $post_data['ID'];
124
+	} else {
125
+			$post_id = false;
126
+	}
111 127
 	$previous_status = $post_id ? get_post_field( 'post_status', $post_id ) : false;
112 128
 
113 129
 	if ( isset( $post_data['post_status'] ) && 'private' == $post_data['post_status'] && ! current_user_can( $ptype->cap->publish_posts ) ) {
@@ -118,9 +134,10 @@  discard block
 block discarded – undo
118 134
 
119 135
 	// Posts 'submitted for approval' present are submitted to $_POST the same as if they were being published.
120 136
 	// Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts.
121
-	if ( isset($post_data['post_status']) && (in_array( $post_data['post_status'], $published_statuses ) && !current_user_can( $ptype->cap->publish_posts )) )
122
-		if ( ! in_array( $previous_status, $published_statuses ) || !current_user_can( 'edit_post', $post_id ) )
137
+	if ( isset($post_data['post_status']) && (in_array( $post_data['post_status'], $published_statuses ) && !current_user_can( $ptype->cap->publish_posts )) ) {
138
+			if ( ! in_array( $previous_status, $published_statuses ) || !current_user_can( 'edit_post', $post_id ) )
123 139
 			$post_data['post_status'] = 'pending';
140
+	}
124 141
 
125 142
 	if ( ! isset( $post_data['post_status'] ) ) {
126 143
 		$post_data['post_status'] = 'auto-draft' === $previous_status ? 'draft' : $previous_status;
@@ -130,11 +147,13 @@  discard block
 block discarded – undo
130 147
 		unset( $post_data['post_password'] );
131 148
 	}
132 149
 
133
-	if (!isset( $post_data['comment_status'] ))
134
-		$post_data['comment_status'] = 'closed';
150
+	if (!isset( $post_data['comment_status'] )) {
151
+			$post_data['comment_status'] = 'closed';
152
+	}
135 153
 
136
-	if (!isset( $post_data['ping_status'] ))
137
-		$post_data['ping_status'] = 'closed';
154
+	if (!isset( $post_data['ping_status'] )) {
155
+			$post_data['ping_status'] = 'closed';
156
+	}
138 157
 
139 158
 	foreach ( array('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) {
140 159
 		if ( !empty( $post_data['hidden_' . $timeunit] ) && $post_data['hidden_' . $timeunit] != $post_data[$timeunit] ) {
@@ -181,8 +200,9 @@  discard block
 block discarded – undo
181 200
 function edit_post( $post_data = null ) {
182 201
 	global $wpdb;
183 202
 
184
-	if ( empty($post_data) )
185
-		$post_data = &$_POST;
203
+	if ( empty($post_data) ) {
204
+			$post_data = &$_POST;
205
+	}
186 206
 
187 207
 	// Clear out any data in internal vars.
188 208
 	unset( $post_data['filter'] );
@@ -202,10 +222,11 @@  discard block
 block discarded – undo
202 222
 
203 223
 	$ptype = get_post_type_object($post_data['post_type']);
204 224
 	if ( !current_user_can( 'edit_post', $post_ID ) ) {
205
-		if ( 'page' == $post_data['post_type'] )
206
-			wp_die( __('You are not allowed to edit this page.' ));
207
-		else
208
-			wp_die( __('You are not allowed to edit this post.' ));
225
+		if ( 'page' == $post_data['post_type'] ) {
226
+					wp_die( __('You are not allowed to edit this page.' ));
227
+		} else {
228
+					wp_die( __('You are not allowed to edit this post.' ));
229
+		}
209 230
 	}
210 231
 
211 232
 	if ( post_type_supports( $ptype->name, 'revisions' ) ) {
@@ -213,8 +234,9 @@  discard block
 block discarded – undo
213 234
 		$revision = current( $revisions );
214 235
 
215 236
 		// Check if the revisions have been upgraded
216
-		if ( $revisions && _wp_get_post_revision_version( $revision ) < 1 )
217
-			_wp_upgrade_revisions_of_post( $post, wp_get_post_revisions( $post_ID ) );
237
+		if ( $revisions && _wp_get_post_revision_version( $revision ) < 1 ) {
238
+					_wp_upgrade_revisions_of_post( $post, wp_get_post_revisions( $post_ID ) );
239
+		}
218 240
 	}
219 241
 
220 242
 	if ( isset($post_data['visibility']) ) {
@@ -234,18 +256,21 @@  discard block
 block discarded – undo
234 256
 	}
235 257
 
236 258
 	$post_data = _wp_translate_postdata( true, $post_data );
237
-	if ( is_wp_error($post_data) )
238
-		wp_die( $post_data->get_error_message() );
259
+	if ( is_wp_error($post_data) ) {
260
+			wp_die( $post_data->get_error_message() );
261
+	}
239 262
 
240 263
 	// Post Formats
241
-	if ( isset( $post_data['post_format'] ) )
242
-		set_post_format( $post_ID, $post_data['post_format'] );
264
+	if ( isset( $post_data['post_format'] ) ) {
265
+			set_post_format( $post_ID, $post_data['post_format'] );
266
+	}
243 267
 
244 268
 	$format_meta_urls = array( 'url', 'link_url', 'quote_source_url' );
245 269
 	foreach ( $format_meta_urls as $format_meta_url ) {
246 270
 		$keyed = '_format_' . $format_meta_url;
247
-		if ( isset( $post_data[ $keyed ] ) )
248
-			update_post_meta( $post_ID, $keyed, wp_slash( esc_url_raw( wp_unslash( $post_data[ $keyed ] ) ) ) );
271
+		if ( isset( $post_data[ $keyed ] ) ) {
272
+					update_post_meta( $post_ID, $keyed, wp_slash( esc_url_raw( wp_unslash( $post_data[ $keyed ] ) ) ) );
273
+		}
249 274
 	}
250 275
 
251 276
 	$format_keys = array( 'quote', 'quote_source_name', 'image', 'gallery', 'audio_embed', 'video_embed' );
@@ -253,10 +278,11 @@  discard block
 block discarded – undo
253 278
 	foreach ( $format_keys as $key ) {
254 279
 		$keyed = '_format_' . $key;
255 280
 		if ( isset( $post_data[ $keyed ] ) ) {
256
-			if ( current_user_can( 'unfiltered_html' ) )
257
-				update_post_meta( $post_ID, $keyed, $post_data[ $keyed ] );
258
-			else
259
-				update_post_meta( $post_ID, $keyed, wp_filter_post_kses( $post_data[ $keyed ] ) );
281
+			if ( current_user_can( 'unfiltered_html' ) ) {
282
+							update_post_meta( $post_ID, $keyed, $post_data[ $keyed ] );
283
+			} else {
284
+							update_post_meta( $post_ID, $keyed, wp_filter_post_kses( $post_data[ $keyed ] ) );
285
+			}
260 286
 		}
261 287
 	}
262 288
 
@@ -277,24 +303,30 @@  discard block
 block discarded – undo
277 303
 	// Meta Stuff
278 304
 	if ( isset($post_data['meta']) && $post_data['meta'] ) {
279 305
 		foreach ( $post_data['meta'] as $key => $value ) {
280
-			if ( !$meta = get_post_meta_by_id( $key ) )
281
-				continue;
282
-			if ( $meta->post_id != $post_ID )
283
-				continue;
284
-			if ( is_protected_meta( $value['key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $value['key'] ) )
285
-				continue;
306
+			if ( !$meta = get_post_meta_by_id( $key ) ) {
307
+							continue;
308
+			}
309
+			if ( $meta->post_id != $post_ID ) {
310
+							continue;
311
+			}
312
+			if ( is_protected_meta( $value['key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $value['key'] ) ) {
313
+							continue;
314
+			}
286 315
 			update_meta( $key, $value['key'], $value['value'] );
287 316
 		}
288 317
 	}
289 318
 
290 319
 	if ( isset($post_data['deletemeta']) && $post_data['deletemeta'] ) {
291 320
 		foreach ( $post_data['deletemeta'] as $key => $value ) {
292
-			if ( !$meta = get_post_meta_by_id( $key ) )
293
-				continue;
294
-			if ( $meta->post_id != $post_ID )
295
-				continue;
296
-			if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $post_ID, $meta->meta_key ) )
297
-				continue;
321
+			if ( !$meta = get_post_meta_by_id( $key ) ) {
322
+							continue;
323
+			}
324
+			if ( $meta->post_id != $post_ID ) {
325
+							continue;
326
+			}
327
+			if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $post_ID, $meta->meta_key ) ) {
328
+							continue;
329
+			}
298 330
 			delete_meta( $key );
299 331
 		}
300 332
 	}
@@ -386,10 +418,11 @@  discard block
 block discarded – undo
386 418
 	wp_set_post_lock( $post_ID );
387 419
 
388 420
 	if ( current_user_can( $ptype->cap->edit_others_posts ) && current_user_can( $ptype->cap->publish_posts ) ) {
389
-		if ( ! empty( $post_data['sticky'] ) )
390
-			stick_post( $post_ID );
391
-		else
392
-			unstick_post( $post_ID );
421
+		if ( ! empty( $post_data['sticky'] ) ) {
422
+					stick_post( $post_ID );
423
+		} else {
424
+					unstick_post( $post_ID );
425
+		}
393 426
 	}
394 427
 
395 428
 	return $post_ID;
@@ -411,19 +444,22 @@  discard block
 block discarded – undo
411 444
 function bulk_edit_posts( $post_data = null ) {
412 445
 	global $wpdb;
413 446
 
414
-	if ( empty($post_data) )
415
-		$post_data = &$_POST;
447
+	if ( empty($post_data) ) {
448
+			$post_data = &$_POST;
449
+	}
416 450
 
417
-	if ( isset($post_data['post_type']) )
418
-		$ptype = get_post_type_object($post_data['post_type']);
419
-	else
420
-		$ptype = get_post_type_object('post');
451
+	if ( isset($post_data['post_type']) ) {
452
+			$ptype = get_post_type_object($post_data['post_type']);
453
+	} else {
454
+			$ptype = get_post_type_object('post');
455
+	}
421 456
 
422 457
 	if ( !current_user_can( $ptype->cap->edit_posts ) ) {
423
-		if ( 'page' == $ptype->name )
424
-			wp_die( __('You are not allowed to edit pages.'));
425
-		else
426
-			wp_die( __('You are not allowed to edit posts.'));
458
+		if ( 'page' == $ptype->name ) {
459
+					wp_die( __('You are not allowed to edit pages.'));
460
+		} else {
461
+					wp_die( __('You are not allowed to edit posts.'));
462
+		}
427 463
 	}
428 464
 
429 465
 	if ( -1 == $post_data['_status'] ) {
@@ -452,28 +488,32 @@  discard block
 block discarded – undo
452 488
 	);
453 489
 
454 490
 	foreach ( $reset as $field ) {
455
-		if ( isset($post_data[$field]) && ( '' == $post_data[$field] || -1 == $post_data[$field] ) )
456
-			unset($post_data[$field]);
491
+		if ( isset($post_data[$field]) && ( '' == $post_data[$field] || -1 == $post_data[$field] ) ) {
492
+					unset($post_data[$field]);
493
+		}
457 494
 	}
458 495
 
459 496
 	if ( isset($post_data['post_category']) ) {
460
-		if ( is_array($post_data['post_category']) && ! empty($post_data['post_category']) )
461
-			$new_cats = array_map( 'absint', $post_data['post_category'] );
462
-		else
463
-			unset($post_data['post_category']);
497
+		if ( is_array($post_data['post_category']) && ! empty($post_data['post_category']) ) {
498
+					$new_cats = array_map( 'absint', $post_data['post_category'] );
499
+		} else {
500
+					unset($post_data['post_category']);
501
+		}
464 502
 	}
465 503
 
466 504
 	$tax_input = array();
467 505
 	if ( isset($post_data['tax_input'])) {
468 506
 		foreach ( $post_data['tax_input'] as $tax_name => $terms ) {
469
-			if ( empty($terms) )
470
-				continue;
507
+			if ( empty($terms) ) {
508
+							continue;
509
+			}
471 510
 			if ( is_taxonomy_hierarchical( $tax_name ) ) {
472 511
 				$tax_input[ $tax_name ] = array_map( 'absint', $terms );
473 512
 			} else {
474 513
 				$comma = _x( ',', 'tag delimiter' );
475
-				if ( ',' !== $comma )
476
-					$terms = str_replace( $comma, ',', $terms );
514
+				if ( ',' !== $comma ) {
515
+									$terms = str_replace( $comma, ',', $terms );
516
+				}
477 517
 				$tax_input[ $tax_name ] = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) );
478 518
 			}
479 519
 		}
@@ -518,15 +558,17 @@  discard block
 block discarded – undo
518 558
 		$tax_names = get_object_taxonomies( $post );
519 559
 		foreach ( $tax_names as $tax_name ) {
520 560
 			$taxonomy_obj = get_taxonomy($tax_name);
521
-			if ( isset( $tax_input[$tax_name]) && current_user_can( $taxonomy_obj->cap->assign_terms ) )
522
-				$new_terms = $tax_input[$tax_name];
523
-			else
524
-				$new_terms = array();
561
+			if ( isset( $tax_input[$tax_name]) && current_user_can( $taxonomy_obj->cap->assign_terms ) ) {
562
+							$new_terms = $tax_input[$tax_name];
563
+			} else {
564
+							$new_terms = array();
565
+			}
525 566
 
526
-			if ( $taxonomy_obj->hierarchical )
527
-				$current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'ids') );
528
-			else
529
-				$current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'names') );
567
+			if ( $taxonomy_obj->hierarchical ) {
568
+							$current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'ids') );
569
+			} else {
570
+							$current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'names') );
571
+			}
530 572
 
531 573
 			$post_data['tax_input'][$tax_name] = array_merge( $current_terms, $new_terms );
532 574
 		}
@@ -559,14 +601,16 @@  discard block
 block discarded – undo
559 601
 		$updated[] = wp_update_post( $post_data );
560 602
 
561 603
 		if ( isset( $post_data['sticky'] ) && current_user_can( $ptype->cap->edit_others_posts ) ) {
562
-			if ( 'sticky' == $post_data['sticky'] )
563
-				stick_post( $post_ID );
564
-			else
565
-				unstick_post( $post_ID );
604
+			if ( 'sticky' == $post_data['sticky'] ) {
605
+							stick_post( $post_ID );
606
+			} else {
607
+							unstick_post( $post_ID );
608
+			}
566 609
 		}
567 610
 
568
-		if ( isset( $post_data['post_format'] ) )
569
-			set_post_format( $post_ID, $post_data['post_format'] );
611
+		if ( isset( $post_data['post_format'] ) ) {
612
+					set_post_format( $post_ID, $post_data['post_format'] );
613
+		}
570 614
 	}
571 615
 
572 616
 	return array( 'updated' => $updated, 'skipped' => $skipped, 'locked' => $locked );
@@ -582,22 +626,26 @@  discard block
 block discarded – undo
582 626
  */
583 627
 function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) {
584 628
 	$post_title = '';
585
-	if ( !empty( $_REQUEST['post_title'] ) )
586
-		$post_title = esc_html( wp_unslash( $_REQUEST['post_title'] ));
629
+	if ( !empty( $_REQUEST['post_title'] ) ) {
630
+			$post_title = esc_html( wp_unslash( $_REQUEST['post_title'] ));
631
+	}
587 632
 
588 633
 	$post_content = '';
589
-	if ( !empty( $_REQUEST['content'] ) )
590
-		$post_content = esc_html( wp_unslash( $_REQUEST['content'] ));
634
+	if ( !empty( $_REQUEST['content'] ) ) {
635
+			$post_content = esc_html( wp_unslash( $_REQUEST['content'] ));
636
+	}
591 637
 
592 638
 	$post_excerpt = '';
593
-	if ( !empty( $_REQUEST['excerpt'] ) )
594
-		$post_excerpt = esc_html( wp_unslash( $_REQUEST['excerpt'] ));
639
+	if ( !empty( $_REQUEST['excerpt'] ) ) {
640
+			$post_excerpt = esc_html( wp_unslash( $_REQUEST['excerpt'] ));
641
+	}
595 642
 
596 643
 	if ( $create_in_db ) {
597 644
 		$post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) );
598 645
 		$post = get_post( $post_id );
599
-		if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) )
600
-			set_post_format( $post, get_option( 'default_post_format' ) );
646
+		if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) ) {
647
+					set_post_format( $post, get_option( 'default_post_format' ) );
648
+		}
601 649
 	} else {
602 650
 		$post = new stdClass;
603 651
 		$post->ID = 0;
@@ -690,8 +738,9 @@  discard block
 block discarded – undo
690 738
 		$args[] = $post_content;
691 739
 	}
692 740
 
693
-	if ( !empty ( $args ) )
694
-		return (int) $wpdb->get_var( $wpdb->prepare($query, $args) );
741
+	if ( !empty ( $args ) ) {
742
+			return (int) $wpdb->get_var( $wpdb->prepare($query, $args) );
743
+	}
695 744
 
696 745
 	return 0;
697 746
 }
@@ -706,16 +755,18 @@  discard block
 block discarded – undo
706 755
  * @return int|WP_Error
707 756
  */
708 757
 function wp_write_post() {
709
-	if ( isset($_POST['post_type']) )
710
-		$ptype = get_post_type_object($_POST['post_type']);
711
-	else
712
-		$ptype = get_post_type_object('post');
758
+	if ( isset($_POST['post_type']) ) {
759
+			$ptype = get_post_type_object($_POST['post_type']);
760
+	} else {
761
+			$ptype = get_post_type_object('post');
762
+	}
713 763
 
714 764
 	if ( !current_user_can( $ptype->cap->edit_posts ) ) {
715
-		if ( 'page' == $ptype->name )
716
-			return new WP_Error( 'edit_pages', __( 'You are not allowed to create pages on this site.' ) );
717
-		else
718
-			return new WP_Error( 'edit_posts', __( 'You are not allowed to create posts or drafts on this site.' ) );
765
+		if ( 'page' == $ptype->name ) {
766
+					return new WP_Error( 'edit_pages', __( 'You are not allowed to create pages on this site.' ) );
767
+		} else {
768
+					return new WP_Error( 'edit_posts', __( 'You are not allowed to create posts or drafts on this site.' ) );
769
+		}
719 770
 	}
720 771
 
721 772
 	$_POST['post_mime_type'] = '';
@@ -724,8 +775,9 @@  discard block
 block discarded – undo
724 775
 	unset( $_POST['filter'] );
725 776
 
726 777
 	// Edit don't write if we have a post id.
727
-	if ( isset( $_POST['post_ID'] ) )
728
-		return edit_post();
778
+	if ( isset( $_POST['post_ID'] ) ) {
779
+			return edit_post();
780
+	}
729 781
 
730 782
 	if ( isset($_POST['visibility']) ) {
731 783
 		switch ( $_POST['visibility'] ) {
@@ -744,16 +796,19 @@  discard block
 block discarded – undo
744 796
 	}
745 797
 
746 798
 	$translated = _wp_translate_postdata( false );
747
-	if ( is_wp_error($translated) )
748
-		return $translated;
799
+	if ( is_wp_error($translated) ) {
800
+			return $translated;
801
+	}
749 802
 
750 803
 	// Create the post.
751 804
 	$post_ID = wp_insert_post( $_POST );
752
-	if ( is_wp_error( $post_ID ) )
753
-		return $post_ID;
805
+	if ( is_wp_error( $post_ID ) ) {
806
+			return $post_ID;
807
+	}
754 808
 
755
-	if ( empty($post_ID) )
756
-		return 0;
809
+	if ( empty($post_ID) ) {
810
+			return 0;
811
+	}
757 812
 
758 813
 	add_meta( $post_ID );
759 814
 
@@ -776,11 +831,12 @@  discard block
 block discarded – undo
776 831
  */
777 832
 function write_post() {
778 833
 	$result = wp_write_post();
779
-	if ( is_wp_error( $result ) )
780
-		wp_die( $result->get_error_message() );
781
-	else
782
-		return $result;
783
-}
834
+	if ( is_wp_error( $result ) ) {
835
+			wp_die( $result->get_error_message() );
836
+	} else {
837
+			return $result;
838
+	}
839
+	}
784 840
 
785 841
 //
786 842
 // Post Meta
@@ -800,22 +856,27 @@  discard block
 block discarded – undo
800 856
 	$metakeyselect = isset($_POST['metakeyselect']) ? wp_unslash( trim( $_POST['metakeyselect'] ) ) : '';
801 857
 	$metakeyinput = isset($_POST['metakeyinput']) ? wp_unslash( trim( $_POST['metakeyinput'] ) ) : '';
802 858
 	$metavalue = isset($_POST['metavalue']) ? $_POST['metavalue'] : '';
803
-	if ( is_string( $metavalue ) )
804
-		$metavalue = trim( $metavalue );
859
+	if ( is_string( $metavalue ) ) {
860
+			$metavalue = trim( $metavalue );
861
+	}
805 862
 
806 863
 	if ( ('0' === $metavalue || ! empty ( $metavalue ) ) && ( ( ( '#NONE#' != $metakeyselect ) && !empty ( $metakeyselect) ) || !empty ( $metakeyinput ) ) ) {
807 864
 		/*
808 865
 		 * We have a key/value pair. If both the select and the input
809 866
 		 * for the key have data, the input takes precedence.
810 867
 		 */
811
- 		if ( '#NONE#' != $metakeyselect )
812
-			$metakey = $metakeyselect;
868
+ 		if ( '#NONE#' != $metakeyselect ) {
869
+ 					$metakey = $metakeyselect;
870
+ 		}
813 871
 
814
-		if ( $metakeyinput )
815
-			$metakey = $metakeyinput; // default
872
+		if ( $metakeyinput ) {
873
+					$metakey = $metakeyinput;
874
+		}
875
+		// default
816 876
 
817
-		if ( is_protected_meta( $metakey, 'post' ) || ! current_user_can( 'add_post_meta', $post_ID, $metakey ) )
818
-			return false;
877
+		if ( is_protected_meta( $metakey, 'post' ) || ! current_user_can( 'add_post_meta', $post_ID, $metakey ) ) {
878
+					return false;
879
+		}
819 880
 
820 881
 		$metakey = wp_slash( $metakey );
821 882
 
@@ -923,12 +984,14 @@  discard block
 block discarded – undo
923 984
 	$content = $post['post_content'];
924 985
 
925 986
 	// Don't run if no pretty permalinks or post is not published, scheduled, or privately published.
926
-	if ( ! get_option( 'permalink_structure' ) || ! in_array( $post['post_status'], array( 'publish', 'future', 'private' ) ) )
927
-		return;
987
+	if ( ! get_option( 'permalink_structure' ) || ! in_array( $post['post_status'], array( 'publish', 'future', 'private' ) ) ) {
988
+			return;
989
+	}
928 990
 
929 991
 	// Short if there aren't any links or no '?attachment_id=' strings (strpos cannot be zero)
930
-	if ( !strpos($content, '?attachment_id=') || !preg_match_all( '/<a ([^>]+)>[\s\S]+?<\/a>/', $content, $link_matches ) )
931
-		return;
992
+	if ( !strpos($content, '?attachment_id=') || !preg_match_all( '/<a ([^>]+)>[\s\S]+?<\/a>/', $content, $link_matches ) ) {
993
+			return;
994
+	}
932 995
 
933 996
 	$site_url = get_bloginfo('url');
934 997
 	$site_url = substr( $site_url, (int) strpos($site_url, '://') ); // remove the http(s)
@@ -937,15 +1000,17 @@  discard block
 block discarded – undo
937 1000
 	foreach ( $link_matches[1] as $key => $value ) {
938 1001
 		if ( !strpos($value, '?attachment_id=') || !strpos($value, 'wp-att-')
939 1002
 			|| !preg_match( '/href=(["\'])[^"\']*\?attachment_id=(\d+)[^"\']*\\1/', $value, $url_match )
940
-			|| !preg_match( '/rel=["\'][^"\']*wp-att-(\d+)/', $value, $rel_match ) )
941
-				continue;
1003
+			|| !preg_match( '/rel=["\'][^"\']*wp-att-(\d+)/', $value, $rel_match ) ) {
1004
+						continue;
1005
+		}
942 1006
 
943 1007
 		$quote = $url_match[1]; // the quote (single or double)
944 1008
 		$url_id = (int) $url_match[2];
945 1009
 		$rel_id = (int) $rel_match[1];
946 1010
 
947
-		if ( !$url_id || !$rel_id || $url_id != $rel_id || strpos($url_match[0], $site_url) === false )
948
-			continue;
1011
+		if ( !$url_id || !$rel_id || $url_id != $rel_id || strpos($url_match[0], $site_url) === false ) {
1012
+					continue;
1013
+		}
949 1014
 
950 1015
 		$link = $link_matches[0][$key];
951 1016
 		$replace = str_replace( $url_match[0], 'href=' . $quote . get_attachment_link( $url_id ) . $quote, $link );
@@ -985,16 +1050,18 @@  discard block
 block discarded – undo
985 1050
  * @return array
986 1051
  */
987 1052
 function wp_edit_posts_query( $q = false ) {
988
-	if ( false === $q )
989
-		$q = $_GET;
1053
+	if ( false === $q ) {
1054
+			$q = $_GET;
1055
+	}
990 1056
 	$q['m'] = isset($q['m']) ? (int) $q['m'] : 0;
991 1057
 	$q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0;
992 1058
 	$post_stati  = get_post_stati();
993 1059
 
994
-	if ( isset($q['post_type']) && in_array( $q['post_type'], get_post_types() ) )
995
-		$post_type = $q['post_type'];
996
-	else
997
-		$post_type = 'post';
1060
+	if ( isset($q['post_type']) && in_array( $q['post_type'], get_post_types() ) ) {
1061
+			$post_type = $q['post_type'];
1062
+	} else {
1063
+			$post_type = 'post';
1064
+	}
998 1065
 
999 1066
 	$avail_post_stati = get_available_post_statuses($post_type);
1000 1067
 
@@ -1003,20 +1070,23 @@  discard block
 block discarded – undo
1003 1070
 		$perm = 'readable';
1004 1071
 	}
1005 1072
 
1006
-	if ( isset($q['orderby']) )
1007
-		$orderby = $q['orderby'];
1008
-	elseif ( isset($q['post_status']) && in_array($q['post_status'], array('pending', 'draft')) )
1009
-		$orderby = 'modified';
1073
+	if ( isset($q['orderby']) ) {
1074
+			$orderby = $q['orderby'];
1075
+	} elseif ( isset($q['post_status']) && in_array($q['post_status'], array('pending', 'draft')) ) {
1076
+			$orderby = 'modified';
1077
+	}
1010 1078
 
1011
-	if ( isset($q['order']) )
1012
-		$order = $q['order'];
1013
-	elseif ( isset($q['post_status']) && 'pending' == $q['post_status'] )
1014
-		$order = 'ASC';
1079
+	if ( isset($q['order']) ) {
1080
+			$order = $q['order'];
1081
+	} elseif ( isset($q['post_status']) && 'pending' == $q['post_status'] ) {
1082
+			$order = 'ASC';
1083
+	}
1015 1084
 
1016 1085
 	$per_page = "edit_{$post_type}_per_page";
1017 1086
 	$posts_per_page = (int) get_user_option( $per_page );
1018
-	if ( empty( $posts_per_page ) || $posts_per_page < 1 )
1019
-		$posts_per_page = 20;
1087
+	if ( empty( $posts_per_page ) || $posts_per_page < 1 ) {
1088
+			$posts_per_page = 20;
1089
+	}
1020 1090
 
1021 1091
 	/**
1022 1092
 	 * Filter the number of items per page to show for a specific 'per_page' type.
@@ -1054,8 +1124,9 @@  discard block
 block discarded – undo
1054 1124
 		$query['fields'] = 'id=>parent';
1055 1125
 	}
1056 1126
 
1057
-	if ( ! empty( $q['show_sticky'] ) )
1058
-		$query['post__in'] = (array) get_option( 'sticky_posts' );
1127
+	if ( ! empty( $q['show_sticky'] ) ) {
1128
+			$query['post__in'] = (array) get_option( 'sticky_posts' );
1129
+	}
1059 1130
 
1060 1131
 	wp( $query );
1061 1132
 
@@ -1203,8 +1274,9 @@  discard block
 block discarded – undo
1203 1274
  */
1204 1275
 function get_sample_permalink($id, $title = null, $name = null) {
1205 1276
 	$post = get_post( $id );
1206
-	if ( ! $post )
1207
-		return array( '', '' );
1277
+	if ( ! $post ) {
1278
+			return array( '', '' );
1279
+	}
1208 1280
 
1209 1281
 	$ptype = get_post_type_object($post->post_type);
1210 1282
 
@@ -1220,8 +1292,9 @@  discard block
 block discarded – undo
1220 1292
 
1221 1293
 	// If the user wants to set a new name -- override the current one
1222 1294
 	// Note: if empty name is supplied -- use the title instead, see #6072
1223
-	if ( !is_null($name) )
1224
-		$post->post_name = sanitize_title($name ? $name : $title, $post->ID);
1295
+	if ( !is_null($name) ) {
1296
+			$post->post_name = sanitize_title($name ? $name : $title, $post->ID);
1297
+	}
1225 1298
 
1226 1299
 	$post->post_name = wp_unique_post_slug($post->post_name, $post->ID, $post->post_status, $post->post_type, $post->post_parent);
1227 1300
 
@@ -1243,8 +1316,9 @@  discard block
 block discarded – undo
1243 1316
 
1244 1317
 		/** This filter is documented in wp-admin/edit-tag-form.php */
1245 1318
 		$uri = apply_filters( 'editable_slug', $uri );
1246
-		if ( !empty($uri) )
1247
-			$uri .= '/';
1319
+		if ( !empty($uri) ) {
1320
+					$uri .= '/';
1321
+		}
1248 1322
 		$permalink = str_replace('%pagename%', "{$uri}%pagename%", $permalink);
1249 1323
 	}
1250 1324
 
@@ -1270,8 +1344,9 @@  discard block
 block discarded – undo
1270 1344
  */
1271 1345
 function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
1272 1346
 	$post = get_post( $id );
1273
-	if ( ! $post )
1274
-		return '';
1347
+	if ( ! $post ) {
1348
+			return '';
1349
+	}
1275 1350
 
1276 1351
 	list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug);
1277 1352
 
@@ -1376,10 +1451,11 @@  discard block
 block discarded – undo
1376 1451
 	if ( $thumbnail_id && get_post( $thumbnail_id ) ) {
1377 1452
 		$old_content_width = $content_width;
1378 1453
 		$content_width = 266;
1379
-		if ( !isset( $_wp_additional_image_sizes['post-thumbnail'] ) )
1380
-			$thumbnail_html = wp_get_attachment_image( $thumbnail_id, array( $content_width, $content_width ) );
1381
-		else
1382
-			$thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'post-thumbnail' );
1454
+		if ( !isset( $_wp_additional_image_sizes['post-thumbnail'] ) ) {
1455
+					$thumbnail_html = wp_get_attachment_image( $thumbnail_id, array( $content_width, $content_width ) );
1456
+		} else {
1457
+					$thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'post-thumbnail' );
1458
+		}
1383 1459
 		if ( !empty( $thumbnail_html ) ) {
1384 1460
 			$ajax_nonce = wp_create_nonce( 'set_post_thumbnail-' . $post->ID );
1385 1461
 			$content = sprintf( $set_thumbnail_link,
@@ -1412,11 +1488,13 @@  discard block
 block discarded – undo
1412 1488
  * @return integer False: not locked or locked by current user. Int: user ID of user with lock.
1413 1489
  */
1414 1490
 function wp_check_post_lock( $post_id ) {
1415
-	if ( !$post = get_post( $post_id ) )
1416
-		return false;
1491
+	if ( !$post = get_post( $post_id ) ) {
1492
+			return false;
1493
+	}
1417 1494
 
1418
-	if ( !$lock = get_post_meta( $post->ID, '_edit_lock', true ) )
1419
-		return false;
1495
+	if ( !$lock = get_post_meta( $post->ID, '_edit_lock', true ) ) {
1496
+			return false;
1497
+	}
1420 1498
 
1421 1499
 	$lock = explode( ':', $lock );
1422 1500
 	$time = $lock[0];
@@ -1425,8 +1503,9 @@  discard block
 block discarded – undo
1425 1503
 	/** This filter is documented in wp-admin/includes/ajax-actions.php */
1426 1504
 	$time_window = apply_filters( 'wp_check_post_lock_window', 150 );
1427 1505
 
1428
-	if ( $time && $time > time() - $time_window && $user != get_current_user_id() )
1429
-		return $user;
1506
+	if ( $time && $time > time() - $time_window && $user != get_current_user_id() ) {
1507
+			return $user;
1508
+	}
1430 1509
 	return false;
1431 1510
 }
1432 1511
 
@@ -1440,10 +1519,12 @@  discard block
 block discarded – undo
1440 1519
  * 	an array of the lock time and the user ID.
1441 1520
  */
1442 1521
 function wp_set_post_lock( $post_id ) {
1443
-	if ( !$post = get_post( $post_id ) )
1444
-		return false;
1445
-	if ( 0 == ($user_id = get_current_user_id()) )
1446
-		return false;
1522
+	if ( !$post = get_post( $post_id ) ) {
1523
+			return false;
1524
+	}
1525
+	if ( 0 == ($user_id = get_current_user_id()) ) {
1526
+			return false;
1527
+	}
1447 1528
 
1448 1529
 	$now = time();
1449 1530
 	$lock = "$now:$user_id";
@@ -1459,12 +1540,14 @@  discard block
 block discarded – undo
1459 1540
  * @return none
1460 1541
  */
1461 1542
 function _admin_notice_post_locked() {
1462
-	if ( ! $post = get_post() )
1463
-		return;
1543
+	if ( ! $post = get_post() ) {
1544
+			return;
1545
+	}
1464 1546
 
1465 1547
 	$user = null;
1466
-	if (  $user_id = wp_check_post_lock( $post->ID ) )
1467
-		$user = get_userdata( $user_id );
1548
+	if (  $user_id = wp_check_post_lock( $post->ID ) ) {
1549
+			$user = get_userdata( $user_id );
1550
+	}
1468 1551
 
1469 1552
 	if ( $user ) {
1470 1553
 
@@ -1478,8 +1561,9 @@  discard block
 block discarded – undo
1478 1561
 		 * @param bool         $display Whether to display the dialog. Default true.
1479 1562
 		 * @param WP_User|bool $user    WP_User object on success, false otherwise.
1480 1563
 		 */
1481
-		if ( ! apply_filters( 'show_post_locked_dialog', true, $post, $user ) )
1482
-			return;
1564
+		if ( ! apply_filters( 'show_post_locked_dialog', true, $post, $user ) ) {
1565
+					return;
1566
+		}
1483 1567
 
1484 1568
 		$locked = true;
1485 1569
 	} else {
@@ -1493,8 +1577,9 @@  discard block
 block discarded – undo
1493 1577
 	} else {
1494 1578
 		$sendback = admin_url( 'edit.php' );
1495 1579
 
1496
-		if ( 'post' != $post->post_type )
1497
-			$sendback = add_query_arg( 'post_type', $post->post_type, $sendback );
1580
+		if ( 'post' != $post->post_type ) {
1581
+					$sendback = add_query_arg( 'post_type', $post->post_type, $sendback );
1582
+		}
1498 1583
 
1499 1584
 		$sendback_text = get_post_type_object( $post->post_type )->labels->all_items;
1500 1585
 	}
@@ -1544,8 +1629,9 @@  discard block
 block discarded – undo
1544 1629
 		<p class="currently-editing wp-tab-first" tabindex="0">
1545 1630
 		<?php
1546 1631
 			_e( 'This content is currently locked.' );
1547
-			if ( $override )
1548
-				printf( ' ' . __( 'If you take over, %s will be blocked from continuing to edit.' ), esc_html( $user->display_name ) );
1632
+			if ( $override ) {
1633
+							printf( ' ' . __( 'If you take over, %s will be blocked from continuing to edit.' ), esc_html( $user->display_name ) );
1634
+			}
1549 1635
 		?>
1550 1636
 		</p>
1551 1637
 		<?php
@@ -1625,8 +1711,9 @@  discard block
 block discarded – undo
1625 1711
 	}
1626 1712
 
1627 1713
 	$post_data = _wp_translate_postdata( true, $post_data );
1628
-	if ( is_wp_error( $post_data ) )
1629
-		return $post_data;
1714
+	if ( is_wp_error( $post_data ) ) {
1715
+			return $post_data;
1716
+	}
1630 1717
 
1631 1718
 	$post_author = get_current_user_id();
1632 1719
 
@@ -1698,14 +1785,16 @@  discard block
 block discarded – undo
1698 1785
 	} else {
1699 1786
 		$is_autosave = true;
1700 1787
 
1701
-		if ( isset( $_POST['post_status'] ) && 'auto-draft' == $_POST['post_status'] )
1702
-			$_POST['post_status'] = 'draft';
1788
+		if ( isset( $_POST['post_status'] ) && 'auto-draft' == $_POST['post_status'] ) {
1789
+					$_POST['post_status'] = 'draft';
1790
+		}
1703 1791
 
1704 1792
 		$saved_post_id = wp_create_post_autosave( $post->ID );
1705 1793
 	}
1706 1794
 
1707
-	if ( is_wp_error( $saved_post_id ) )
1708
-		wp_die( $saved_post_id->get_error_message() );
1795
+	if ( is_wp_error( $saved_post_id ) ) {
1796
+			wp_die( $saved_post_id->get_error_message() );
1797
+	}
1709 1798
 
1710 1799
 	$query_args = array( 'preview' => 'true' );
1711 1800
 
@@ -1713,8 +1802,9 @@  discard block
 block discarded – undo
1713 1802
 		$query_args['preview_id'] = $post->ID;
1714 1803
 		$query_args['preview_nonce'] = wp_create_nonce( 'post_preview_' . $post->ID );
1715 1804
 
1716
-		if ( isset( $_POST['post_format'] ) )
1717
-			$query_args['post_format'] = empty( $_POST['post_format'] ) ? 'standard' : sanitize_key( $_POST['post_format'] );
1805
+		if ( isset( $_POST['post_format'] ) ) {
1806
+					$query_args['post_format'] = empty( $_POST['post_format'] ) ? 'standard' : sanitize_key( $_POST['post_format'] );
1807
+		}
1718 1808
 	}
1719 1809
 
1720 1810
 	$url = add_query_arg( $query_args, get_permalink( $post->ID ) );
@@ -1736,8 +1826,9 @@  discard block
 block discarded – undo
1736 1826
  */
1737 1827
 function wp_autosave( $post_data ) {
1738 1828
 	// Back-compat
1739
-	if ( ! defined( 'DOING_AUTOSAVE' ) )
1740
-		define( 'DOING_AUTOSAVE', true );
1829
+	if ( ! defined( 'DOING_AUTOSAVE' ) ) {
1830
+			define( 'DOING_AUTOSAVE', true );
1831
+	}
1741 1832
 
1742 1833
 	$post_id = (int) $post_data['post_id'];
1743 1834
 	$post_data['ID'] = $post_data['post_ID'] = $post_id;
@@ -1752,11 +1843,13 @@  discard block
 block discarded – undo
1752 1843
 		return new WP_Error( 'edit_posts', __( 'You are not allowed to edit this item.' ) );
1753 1844
 	}
1754 1845
 
1755
-	if ( 'auto-draft' == $post->post_status )
1756
-		$post_data['post_status'] = 'draft';
1846
+	if ( 'auto-draft' == $post->post_status ) {
1847
+			$post_data['post_status'] = 'draft';
1848
+	}
1757 1849
 
1758
-	if ( $post_data['post_type'] != 'page' && ! empty( $post_data['catslist'] ) )
1759
-		$post_data['post_category'] = explode( ',', $post_data['catslist'] );
1850
+	if ( $post_data['post_type'] != 'page' && ! empty( $post_data['catslist'] ) ) {
1851
+			$post_data['post_category'] = explode( ',', $post_data['catslist'] );
1852
+	}
1760 1853
 
1761 1854
 	if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author && ( 'auto-draft' == $post->post_status || 'draft' == $post->post_status ) ) {
1762 1855
 		// Drafts and auto-drafts are just overwritten by autosave for the same user if the post is not locked
Please login to merge, or discard this patch.
src/wp-admin/includes/ajax-actions.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * WordPress Core Ajax Handlers.
4
- *
5
- * @package WordPress
6
- * @subpackage Administration
7
- */
3
+	 * WordPress Core Ajax Handlers.
4
+	 *
5
+	 * @package WordPress
6
+	 * @subpackage Administration
7
+	 */
8 8
 
9 9
 //
10 10
 // No-privilege Ajax handlers.
Please login to merge, or discard this patch.
Spacing   +1004 added lines, -1004 removed lines patch added patch discarded remove patch
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
 	$response = array();
23 23
 
24 24
 	// screen_id is the same as $current_screen->id and the JS global 'pagenow'.
25
-	if ( ! empty($_POST['screen_id']) )
25
+	if ( ! empty($_POST['screen_id']))
26 26
 		$screen_id = sanitize_key($_POST['screen_id']);
27 27
 	else
28 28
 		$screen_id = 'front';
29 29
 
30
-	if ( ! empty($_POST['data']) ) {
31
-		$data = wp_unslash( (array) $_POST['data'] );
30
+	if ( ! empty($_POST['data'])) {
31
+		$data = wp_unslash((array) $_POST['data']);
32 32
 
33 33
 		/**
34 34
 		 * Filter Heartbeat AJAX response in no-privilege environments.
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 		 * @param array        $data      An array of data passed via $_POST.
40 40
 		 * @param string       $screen_id The screen id.
41 41
 		 */
42
-		$response = apply_filters( 'heartbeat_nopriv_received', $response, $data, $screen_id );
42
+		$response = apply_filters('heartbeat_nopriv_received', $response, $data, $screen_id);
43 43
 	}
44 44
 
45 45
 	/**
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 * @param array|object $response  The Heartbeat response object or array.
51 51
 	 * @param string       $screen_id The screen id.
52 52
 	 */
53
-	$response = apply_filters( 'heartbeat_nopriv_send', $response, $screen_id );
53
+	$response = apply_filters('heartbeat_nopriv_send', $response, $screen_id);
54 54
 
55 55
 	/**
56 56
 	 * Fires when Heartbeat ticks in no-privilege environments.
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 * @param array|object $response  The no-priv Heartbeat response.
63 63
 	 * @param string       $screen_id The screen id.
64 64
 	 */
65
-	do_action( 'heartbeat_nopriv_tick', $response, $screen_id );
65
+	do_action('heartbeat_nopriv_tick', $response, $screen_id);
66 66
 
67 67
 	// Send the current time according to the server.
68 68
 	$response['server_time'] = time();
@@ -85,18 +85,18 @@  discard block
 block discarded – undo
85 85
 	global $wp_list_table;
86 86
 
87 87
 	$list_class = $_GET['list_args']['class'];
88
-	check_ajax_referer( "fetch-list-$list_class", '_ajax_fetch_list_nonce' );
88
+	check_ajax_referer("fetch-list-$list_class", '_ajax_fetch_list_nonce');
89 89
 
90
-	$wp_list_table = _get_list_table( $list_class, array( 'screen' => $_GET['list_args']['screen']['id'] ) );
91
-	if ( ! $wp_list_table )
92
-		wp_die( 0 );
90
+	$wp_list_table = _get_list_table($list_class, array('screen' => $_GET['list_args']['screen']['id']));
91
+	if ( ! $wp_list_table)
92
+		wp_die(0);
93 93
 
94
-	if ( ! $wp_list_table->ajax_user_can() )
94
+	if ( ! $wp_list_table->ajax_user_can())
95 95
 		wp_die( -1 );
96 96
 
97 97
 	$wp_list_table->ajax_response();
98 98
 
99
-	wp_die( 0 );
99
+	wp_die(0);
100 100
 }
101 101
 
102 102
 /**
@@ -105,30 +105,30 @@  discard block
 block discarded – undo
105 105
  * @since 3.1.0
106 106
  */
107 107
 function wp_ajax_ajax_tag_search() {
108
-	if ( ! isset( $_GET['tax'] ) ) {
109
-		wp_die( 0 );
108
+	if ( ! isset($_GET['tax'])) {
109
+		wp_die(0);
110 110
 	}
111 111
 
112
-	$taxonomy = sanitize_key( $_GET['tax'] );
113
-	$tax = get_taxonomy( $taxonomy );
114
-	if ( ! $tax ) {
115
-		wp_die( 0 );
112
+	$taxonomy = sanitize_key($_GET['tax']);
113
+	$tax = get_taxonomy($taxonomy);
114
+	if ( ! $tax) {
115
+		wp_die(0);
116 116
 	}
117 117
 
118
-	if ( ! current_user_can( $tax->cap->assign_terms ) ) {
118
+	if ( ! current_user_can($tax->cap->assign_terms)) {
119 119
 		wp_die( -1 );
120 120
 	}
121 121
 
122
-	$s = wp_unslash( $_GET['q'] );
122
+	$s = wp_unslash($_GET['q']);
123 123
 
124
-	$comma = _x( ',', 'tag delimiter' );
125
-	if ( ',' !== $comma )
126
-		$s = str_replace( $comma, ',', $s );
127
-	if ( false !== strpos( $s, ',' ) ) {
128
-		$s = explode( ',', $s );
129
-		$s = $s[count( $s ) - 1];
124
+	$comma = _x(',', 'tag delimiter');
125
+	if (',' !== $comma)
126
+		$s = str_replace($comma, ',', $s);
127
+	if (false !== strpos($s, ',')) {
128
+		$s = explode(',', $s);
129
+		$s = $s[count($s) - 1];
130 130
 	}
131
-	$s = trim( $s );
131
+	$s = trim($s);
132 132
 
133 133
 	/**
134 134
 	 * Filter the minimum number of characters required to fire a tag search via AJAX.
@@ -139,19 +139,19 @@  discard block
 block discarded – undo
139 139
 	 * @param object $tax        The taxonomy object.
140 140
 	 * @param string $s          The search term.
141 141
 	 */
142
-	$term_search_min_chars = (int) apply_filters( 'term_search_min_chars', 2, $tax, $s );
142
+	$term_search_min_chars = (int) apply_filters('term_search_min_chars', 2, $tax, $s);
143 143
 
144 144
 	/*
145 145
 	 * Require $term_search_min_chars chars for matching (default: 2)
146 146
 	 * ensure it's a non-negative, non-zero integer.
147 147
 	 */
148
-	if ( ( $term_search_min_chars == 0 ) || ( strlen( $s ) < $term_search_min_chars ) ){
148
+	if (($term_search_min_chars == 0) || (strlen($s) < $term_search_min_chars)) {
149 149
 		wp_die();
150 150
 	}
151 151
 
152
-	$results = get_terms( $taxonomy, array( 'name__like' => $s, 'fields' => 'names', 'hide_empty' => false ) );
152
+	$results = get_terms($taxonomy, array('name__like' => $s, 'fields' => 'names', 'hide_empty' => false));
153 153
 
154
-	echo join( $results, "\n" );
154
+	echo join($results, "\n");
155 155
 	wp_die();
156 156
 }
157 157
 
@@ -161,48 +161,48 @@  discard block
 block discarded – undo
161 161
  * @since 3.1.0
162 162
  */
163 163
 function wp_ajax_wp_compression_test() {
164
-	if ( !current_user_can( 'manage_options' ) )
164
+	if ( ! current_user_can('manage_options'))
165 165
 		wp_die( -1 );
166 166
 
167
-	if ( ini_get('zlib.output_compression') || 'ob_gzhandler' == ini_get('output_handler') ) {
167
+	if (ini_get('zlib.output_compression') || 'ob_gzhandler' == ini_get('output_handler')) {
168 168
 		update_site_option('can_compress_scripts', 0);
169
-		wp_die( 0 );
169
+		wp_die(0);
170 170
 	}
171 171
 
172
-	if ( isset($_GET['test']) ) {
173
-		header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' );
174
-		header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
175
-		header( 'Cache-Control: no-cache, must-revalidate, max-age=0' );
176
-		header( 'Pragma: no-cache' );
172
+	if (isset($_GET['test'])) {
173
+		header('Expires: Wed, 11 Jan 1984 05:00:00 GMT');
174
+		header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
175
+		header('Cache-Control: no-cache, must-revalidate, max-age=0');
176
+		header('Pragma: no-cache');
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'] ) {
198
+		} elseif ('no' == $_GET['test']) {
199 199
 			update_site_option('can_compress_scripts', 0);
200
-		} elseif ( 'yes' == $_GET['test'] ) {
200
+		} elseif ('yes' == $_GET['test']) {
201 201
 			update_site_option('can_compress_scripts', 1);
202 202
 		}
203 203
 	}
204 204
 
205
-	wp_die( 0 );
205
+	wp_die(0);
206 206
 }
207 207
 
208 208
 /**
@@ -212,13 +212,13 @@  discard block
 block discarded – undo
212 212
  */
213 213
 function wp_ajax_imgedit_preview() {
214 214
 	$post_id = intval($_GET['postid']);
215
-	if ( empty($post_id) || !current_user_can('edit_post', $post_id) )
215
+	if (empty($post_id) || ! current_user_can('edit_post', $post_id))
216 216
 		wp_die( -1 );
217 217
 
218
-	check_ajax_referer( "image_editor-$post_id" );
218
+	check_ajax_referer("image_editor-$post_id");
219 219
 
220
-	include_once( ABSPATH . 'wp-admin/includes/image-edit.php' );
221
-	if ( ! stream_preview_image($post_id) )
220
+	include_once(ABSPATH.'wp-admin/includes/image-edit.php');
221
+	if ( ! stream_preview_image($post_id))
222 222
 		wp_die( -1 );
223 223
 
224 224
 	wp_die();
@@ -232,8 +232,8 @@  discard block
 block discarded – undo
232 232
  * @global WP_Embed $wp_embed
233 233
  */
234 234
 function wp_ajax_oembed_cache() {
235
-	$GLOBALS['wp_embed']->cache_oembed( $_GET['post'] );
236
-	wp_die( 0 );
235
+	$GLOBALS['wp_embed']->cache_oembed($_GET['post']);
236
+	wp_die(0);
237 237
 }
238 238
 
239 239
 /**
@@ -242,18 +242,18 @@  discard block
 block discarded – undo
242 242
  * @since 3.4.0
243 243
  */
244 244
 function wp_ajax_autocomplete_user() {
245
-	if ( ! is_multisite() || ! current_user_can( 'promote_users' ) || wp_is_large_network( 'users' ) )
245
+	if ( ! is_multisite() || ! current_user_can('promote_users') || wp_is_large_network('users'))
246 246
 		wp_die( -1 );
247 247
 
248 248
 	/** This filter is documented in wp-admin/user-new.php */
249
-	if ( ! is_super_admin() && ! apply_filters( 'autocomplete_users_for_site_admins', false ) )
249
+	if ( ! is_super_admin() && ! apply_filters('autocomplete_users_for_site_admins', false))
250 250
 		wp_die( -1 );
251 251
 
252 252
 	$return = array();
253 253
 
254 254
 	// Check the type of request
255 255
 	// Current allowed values are `add` and `search`
256
-	if ( isset( $_REQUEST['autocomplete_type'] ) && 'search' === $_REQUEST['autocomplete_type'] ) {
256
+	if (isset($_REQUEST['autocomplete_type']) && 'search' === $_REQUEST['autocomplete_type']) {
257 257
 		$type = $_REQUEST['autocomplete_type'];
258 258
 	} else {
259 259
 		$type = 'add';
@@ -261,39 +261,39 @@  discard block
 block discarded – undo
261 261
 
262 262
 	// Check the desired field for value
263 263
 	// Current allowed values are `user_email` and `user_login`
264
-	if ( isset( $_REQUEST['autocomplete_field'] ) && 'user_email' === $_REQUEST['autocomplete_field'] ) {
264
+	if (isset($_REQUEST['autocomplete_field']) && 'user_email' === $_REQUEST['autocomplete_field']) {
265 265
 		$field = $_REQUEST['autocomplete_field'];
266 266
 	} else {
267 267
 		$field = 'user_login';
268 268
 	}
269 269
 
270 270
 	// Exclude current users of this blog
271
-	if ( isset( $_REQUEST['site_id'] ) ) {
272
-		$id = absint( $_REQUEST['site_id'] );
271
+	if (isset($_REQUEST['site_id'])) {
272
+		$id = absint($_REQUEST['site_id']);
273 273
 	} else {
274 274
 		$id = get_current_blog_id();
275 275
 	}
276 276
 
277
-	$include_blog_users = ( $type == 'search' ? get_users( array( 'blog_id' => $id, 'fields' => 'ID' ) ) : array() );
278
-	$exclude_blog_users = ( $type == 'add' ? get_users( array( 'blog_id' => $id, 'fields' => 'ID' ) ) : array() );
277
+	$include_blog_users = ($type == 'search' ? get_users(array('blog_id' => $id, 'fields' => 'ID')) : array());
278
+	$exclude_blog_users = ($type == 'add' ? get_users(array('blog_id' => $id, 'fields' => 'ID')) : array());
279 279
 
280
-	$users = get_users( array(
280
+	$users = get_users(array(
281 281
 		'blog_id' => false,
282
-		'search'  => '*' . $_REQUEST['term'] . '*',
282
+		'search'  => '*'.$_REQUEST['term'].'*',
283 283
 		'include' => $include_blog_users,
284 284
 		'exclude' => $exclude_blog_users,
285
-		'search_columns' => array( 'user_login', 'user_nicename', 'user_email' ),
286
-	) );
285
+		'search_columns' => array('user_login', 'user_nicename', 'user_email'),
286
+	));
287 287
 
288
-	foreach ( $users as $user ) {
288
+	foreach ($users as $user) {
289 289
 		$return[] = array(
290 290
 			/* translators: 1: user_login, 2: user_email */
291
-			'label' => sprintf( __( '%1$s (%2$s)' ), $user->user_login, $user->user_email ),
291
+			'label' => sprintf(__('%1$s (%2$s)'), $user->user_login, $user->user_email),
292 292
 			'value' => $user->$field,
293 293
 		);
294 294
 	}
295 295
 
296
-	wp_die( wp_json_encode( $return ) );
296
+	wp_die(wp_json_encode($return));
297 297
 }
298 298
 
299 299
 /**
@@ -302,14 +302,14 @@  discard block
 block discarded – undo
302 302
  * @since 3.4.0
303 303
  */
304 304
 function wp_ajax_dashboard_widgets() {
305
-	require_once ABSPATH . 'wp-admin/includes/dashboard.php';
305
+	require_once ABSPATH.'wp-admin/includes/dashboard.php';
306 306
 
307 307
 	$pagenow = $_GET['pagenow'];
308
-	if ( $pagenow === 'dashboard-user' || $pagenow === 'dashboard-network' || $pagenow === 'dashboard' ) {
309
-		set_current_screen( $pagenow );
308
+	if ($pagenow === 'dashboard-user' || $pagenow === 'dashboard-network' || $pagenow === 'dashboard') {
309
+		set_current_screen($pagenow);
310 310
 	}
311 311
 
312
-	switch ( $_GET['widget'] ) {
312
+	switch ($_GET['widget']) {
313 313
 		case 'dashboard_primary' :
314 314
 			wp_dashboard_primary();
315 315
 			break;
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
  * @since 3.4.0
324 324
  */
325 325
 function wp_ajax_logged_in() {
326
-	wp_die( 1 );
326
+	wp_die(1);
327 327
 }
328 328
 
329 329
 //
@@ -340,18 +340,18 @@  discard block
 block discarded – undo
340 340
  * @param int $comment_id
341 341
  * @param int $delta
342 342
  */
343
-function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) {
344
-	$total    = isset( $_POST['_total'] )    ? (int) $_POST['_total']    : 0;
345
-	$per_page = isset( $_POST['_per_page'] ) ? (int) $_POST['_per_page'] : 0;
346
-	$page     = isset( $_POST['_page'] )     ? (int) $_POST['_page']     : 0;
347
-	$url      = isset( $_POST['_url'] )      ? esc_url_raw( $_POST['_url'] ) : '';
343
+function _wp_ajax_delete_comment_response($comment_id, $delta = -1) {
344
+	$total    = isset($_POST['_total']) ? (int) $_POST['_total'] : 0;
345
+	$per_page = isset($_POST['_per_page']) ? (int) $_POST['_per_page'] : 0;
346
+	$page     = isset($_POST['_page']) ? (int) $_POST['_page'] : 0;
347
+	$url      = isset($_POST['_url']) ? esc_url_raw($_POST['_url']) : '';
348 348
 
349 349
 	// JS didn't send us everything we need to know. Just die with success message
350
-	if ( ! $total || ! $per_page || ! $page || ! $url ) {
350
+	if ( ! $total || ! $per_page || ! $page || ! $url) {
351 351
 		$time = time();
352
-		$comment = get_comment( $comment_id );
352
+		$comment = get_comment($comment_id);
353 353
 
354
-		$x = new WP_Ajax_Response( array(
354
+		$x = new WP_Ajax_Response(array(
355 355
 			'what' => 'comment',
356 356
 			// Here for completeness - not used.
357 357
 			'id' => $comment_id,
@@ -360,53 +360,53 @@  discard block
 block discarded – undo
360 360
 				'postId' => $comment ? $comment->comment_post_ID : '',
361 361
 				'time' => $time
362 362
 			)
363
-		) );
363
+		));
364 364
 		$x->send();
365 365
 	}
366 366
 
367 367
 	$total += $delta;
368
-	if ( $total < 0 )
368
+	if ($total < 0)
369 369
 		$total = 0;
370 370
 
371 371
 	// Only do the expensive stuff on a page-break, and about 1 other time per page
372
-	if ( 0 == $total % $per_page || 1 == mt_rand( 1, $per_page ) ) {
372
+	if (0 == $total % $per_page || 1 == mt_rand(1, $per_page)) {
373 373
 		$post_id = 0;
374 374
 		$status = 'total_comments'; // What type of comment count are we looking for?
375
-		$parsed = parse_url( $url );
376
-		if ( isset( $parsed['query'] ) ) {
377
-			parse_str( $parsed['query'], $query_vars );
378
-			if ( !empty( $query_vars['comment_status'] ) )
375
+		$parsed = parse_url($url);
376
+		if (isset($parsed['query'])) {
377
+			parse_str($parsed['query'], $query_vars);
378
+			if ( ! empty($query_vars['comment_status']))
379 379
 				$status = $query_vars['comment_status'];
380
-			if ( !empty( $query_vars['p'] ) )
380
+			if ( ! empty($query_vars['p']))
381 381
 				$post_id = (int) $query_vars['p'];
382 382
 		}
383 383
 
384 384
 		$comment_count = wp_count_comments($post_id);
385 385
 
386 386
 		// We're looking for a known type of comment count.
387
-		if ( isset( $comment_count->$status ) )
387
+		if (isset($comment_count->$status))
388 388
 			$total = $comment_count->$status;
389 389
 			// Else use the decremented value from above.
390 390
 	}
391 391
 
392 392
 	// The time since the last comment count.
393 393
 	$time = time();
394
-	$comment = get_comment( $comment_id );
394
+	$comment = get_comment($comment_id);
395 395
 
396
-	$x = new WP_Ajax_Response( array(
396
+	$x = new WP_Ajax_Response(array(
397 397
 		'what' => 'comment',
398 398
 		// Here for completeness - not used.
399 399
 		'id' => $comment_id,
400 400
 		'supplemental' => array(
401 401
 			'status' => $comment ? $comment->comment_approved : '',
402 402
 			'postId' => $comment ? $comment->comment_post_ID : '',
403
-			'total_items_i18n' => sprintf( _n( '%s item', '%s items', $total ), number_format_i18n( $total ) ),
404
-			'total_pages' => ceil( $total / $per_page ),
405
-			'total_pages_i18n' => number_format_i18n( ceil( $total / $per_page ) ),
403
+			'total_items_i18n' => sprintf(_n('%s item', '%s items', $total), number_format_i18n($total)),
404
+			'total_pages' => ceil($total / $per_page),
405
+			'total_pages_i18n' => number_format_i18n(ceil($total / $per_page)),
406 406
 			'total' => $total,
407 407
 			'time' => $time
408 408
 		)
409
-	) );
409
+	));
410 410
 	$x->send();
411 411
 }
412 412
 
@@ -422,87 +422,87 @@  discard block
 block discarded – undo
422 422
 function _wp_ajax_add_hierarchical_term() {
423 423
 	$action = $_POST['action'];
424 424
 	$taxonomy = get_taxonomy(substr($action, 4));
425
-	check_ajax_referer( $action, '_ajax_nonce-add-' . $taxonomy->name );
426
-	if ( !current_user_can( $taxonomy->cap->edit_terms ) )
425
+	check_ajax_referer($action, '_ajax_nonce-add-'.$taxonomy->name);
426
+	if ( ! current_user_can($taxonomy->cap->edit_terms))
427 427
 		wp_die( -1 );
428 428
 	$names = explode(',', $_POST['new'.$taxonomy->name]);
429 429
 	$parent = isset($_POST['new'.$taxonomy->name.'_parent']) ? (int) $_POST['new'.$taxonomy->name.'_parent'] : 0;
430
-	if ( 0 > $parent )
430
+	if (0 > $parent)
431 431
 		$parent = 0;
432
-	if ( $taxonomy->name == 'category' )
432
+	if ($taxonomy->name == 'category')
433 433
 		$post_category = isset($_POST['post_category']) ? (array) $_POST['post_category'] : array();
434 434
 	else
435
-		$post_category = ( isset($_POST['tax_input']) && isset($_POST['tax_input'][$taxonomy->name]) ) ? (array) $_POST['tax_input'][$taxonomy->name] : array();
436
-	$checked_categories = array_map( 'absint', (array) $post_category );
435
+		$post_category = (isset($_POST['tax_input']) && isset($_POST['tax_input'][$taxonomy->name])) ? (array) $_POST['tax_input'][$taxonomy->name] : array();
436
+	$checked_categories = array_map('absint', (array) $post_category);
437 437
 	$popular_ids = wp_popular_terms_checklist($taxonomy->name, 0, 10, false);
438 438
 
439
-	foreach ( $names as $cat_name ) {
439
+	foreach ($names as $cat_name) {
440 440
 		$cat_name = trim($cat_name);
441 441
 		$category_nicename = sanitize_title($cat_name);
442
-		if ( '' === $category_nicename )
442
+		if ('' === $category_nicename)
443 443
 			continue;
444
-		if ( !$cat_id = term_exists( $cat_name, $taxonomy->name, $parent ) )
445
-			$cat_id = wp_insert_term( $cat_name, $taxonomy->name, array( 'parent' => $parent ) );
446
-		if ( is_wp_error( $cat_id ) ) {
444
+		if ( ! $cat_id = term_exists($cat_name, $taxonomy->name, $parent))
445
+			$cat_id = wp_insert_term($cat_name, $taxonomy->name, array('parent' => $parent));
446
+		if (is_wp_error($cat_id)) {
447 447
 			continue;
448
-		} elseif ( is_array( $cat_id ) ) {
448
+		} elseif (is_array($cat_id)) {
449 449
 			$cat_id = $cat_id['term_id'];
450 450
 		}
451 451
 		$checked_categories[] = $cat_id;
452
-		if ( $parent ) // Do these all at once in a second
452
+		if ($parent) // Do these all at once in a second
453 453
 			continue;
454 454
 
455 455
 		ob_start();
456 456
 
457
-		wp_terms_checklist( 0, array( 'taxonomy' => $taxonomy->name, 'descendants_and_self' => $cat_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids ));
457
+		wp_terms_checklist(0, array('taxonomy' => $taxonomy->name, 'descendants_and_self' => $cat_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids));
458 458
 
459 459
 		$data = ob_get_clean();
460 460
 
461 461
 		$add = array(
462 462
 			'what' => $taxonomy->name,
463 463
 			'id' => $cat_id,
464
-			'data' => str_replace( array("\n", "\t"), '', $data),
464
+			'data' => str_replace(array("\n", "\t"), '', $data),
465 465
 			'position' => -1
466 466
 		);
467 467
 	}
468 468
 
469
-	if ( $parent ) { // Foncy - replace the parent and all its children
470
-		$parent = get_term( $parent, $taxonomy->name );
469
+	if ($parent) { // Foncy - replace the parent and all its children
470
+		$parent = get_term($parent, $taxonomy->name);
471 471
 		$term_id = $parent->term_id;
472 472
 
473
-		while ( $parent->parent ) { // get the top parent
474
-			$parent = get_term( $parent->parent, $taxonomy->name );
475
-			if ( is_wp_error( $parent ) )
473
+		while ($parent->parent) { // get the top parent
474
+			$parent = get_term($parent->parent, $taxonomy->name);
475
+			if (is_wp_error($parent))
476 476
 				break;
477 477
 			$term_id = $parent->term_id;
478 478
 		}
479 479
 
480 480
 		ob_start();
481 481
 
482
-		wp_terms_checklist( 0, array('taxonomy' => $taxonomy->name, 'descendants_and_self' => $term_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids));
482
+		wp_terms_checklist(0, array('taxonomy' => $taxonomy->name, 'descendants_and_self' => $term_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids));
483 483
 
484 484
 		$data = ob_get_clean();
485 485
 
486 486
 		$add = array(
487 487
 			'what' => $taxonomy->name,
488 488
 			'id' => $term_id,
489
-			'data' => str_replace( array("\n", "\t"), '', $data),
489
+			'data' => str_replace(array("\n", "\t"), '', $data),
490 490
 			'position' => -1
491 491
 		);
492 492
 	}
493 493
 
494 494
 	ob_start();
495 495
 
496
-	wp_dropdown_categories( array(
496
+	wp_dropdown_categories(array(
497 497
 		'taxonomy' => $taxonomy->name, 'hide_empty' => 0, 'name' => 'new'.$taxonomy->name.'_parent', 'orderby' => 'name',
498 498
 		'hierarchical' => 1, 'show_option_none' => '&mdash; '.$taxonomy->labels->parent_item.' &mdash;'
499
-	) );
499
+	));
500 500
 
501 501
 	$sup = ob_get_clean();
502 502
 
503
-	$add['supplemental'] = array( 'newcat_parent' => $sup );
503
+	$add['supplemental'] = array('newcat_parent' => $sup);
504 504
 
505
-	$x = new WP_Ajax_Response( $add );
505
+	$x = new WP_Ajax_Response($add);
506 506
 	$x->send();
507 507
 }
508 508
 
@@ -512,46 +512,46 @@  discard block
 block discarded – undo
512 512
  * @since 3.1.0
513 513
  */
514 514
 function wp_ajax_delete_comment() {
515
-	$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
515
+	$id = isset($_POST['id']) ? (int) $_POST['id'] : 0;
516 516
 
517
-	if ( !$comment = get_comment( $id ) )
518
-		wp_die( time() );
519
-	if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) )
517
+	if ( ! $comment = get_comment($id))
518
+		wp_die(time());
519
+	if ( ! current_user_can('edit_comment', $comment->comment_ID))
520 520
 		wp_die( -1 );
521 521
 
522
-	check_ajax_referer( "delete-comment_$id" );
523
-	$status = wp_get_comment_status( $comment->comment_ID );
522
+	check_ajax_referer("delete-comment_$id");
523
+	$status = wp_get_comment_status($comment->comment_ID);
524 524
 
525 525
 	$delta = -1;
526
-	if ( isset($_POST['trash']) && 1 == $_POST['trash'] ) {
527
-		if ( 'trash' == $status )
528
-			wp_die( time() );
529
-		$r = wp_trash_comment( $comment->comment_ID );
530
-	} elseif ( isset($_POST['untrash']) && 1 == $_POST['untrash'] ) {
531
-		if ( 'trash' != $status )
532
-			wp_die( time() );
533
-		$r = wp_untrash_comment( $comment->comment_ID );
534
-		if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) // undo trash, not in trash
526
+	if (isset($_POST['trash']) && 1 == $_POST['trash']) {
527
+		if ('trash' == $status)
528
+			wp_die(time());
529
+		$r = wp_trash_comment($comment->comment_ID);
530
+	} elseif (isset($_POST['untrash']) && 1 == $_POST['untrash']) {
531
+		if ('trash' != $status)
532
+			wp_die(time());
533
+		$r = wp_untrash_comment($comment->comment_ID);
534
+		if ( ! isset($_POST['comment_status']) || $_POST['comment_status'] != 'trash') // undo trash, not in trash
535 535
 			$delta = 1;
536
-	} elseif ( isset($_POST['spam']) && 1 == $_POST['spam'] ) {
537
-		if ( 'spam' == $status )
538
-			wp_die( time() );
539
-		$r = wp_spam_comment( $comment->comment_ID );
540
-	} elseif ( isset($_POST['unspam']) && 1 == $_POST['unspam'] ) {
541
-		if ( 'spam' != $status )
542
-			wp_die( time() );
543
-		$r = wp_unspam_comment( $comment->comment_ID );
544
-		if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) // undo spam, not in spam
536
+	} elseif (isset($_POST['spam']) && 1 == $_POST['spam']) {
537
+		if ('spam' == $status)
538
+			wp_die(time());
539
+		$r = wp_spam_comment($comment->comment_ID);
540
+	} elseif (isset($_POST['unspam']) && 1 == $_POST['unspam']) {
541
+		if ('spam' != $status)
542
+			wp_die(time());
543
+		$r = wp_unspam_comment($comment->comment_ID);
544
+		if ( ! isset($_POST['comment_status']) || $_POST['comment_status'] != 'spam') // undo spam, not in spam
545 545
 			$delta = 1;
546
-	} elseif ( isset($_POST['delete']) && 1 == $_POST['delete'] ) {
547
-		$r = wp_delete_comment( $comment->comment_ID );
546
+	} elseif (isset($_POST['delete']) && 1 == $_POST['delete']) {
547
+		$r = wp_delete_comment($comment->comment_ID);
548 548
 	} else {
549 549
 		wp_die( -1 );
550 550
 	}
551 551
 
552
-	if ( $r ) // Decide if we need to send back '1' or a more complicated response including page links and comment counts
553
-		_wp_ajax_delete_comment_response( $comment->comment_ID, $delta );
554
-	wp_die( 0 );
552
+	if ($r) // Decide if we need to send back '1' or a more complicated response including page links and comment counts
553
+		_wp_ajax_delete_comment_response($comment->comment_ID, $delta);
554
+	wp_die(0);
555 555
 }
556 556
 
557 557
 /**
@@ -561,22 +561,22 @@  discard block
 block discarded – undo
561 561
  */
562 562
 function wp_ajax_delete_tag() {
563 563
 	$tag_id = (int) $_POST['tag_ID'];
564
-	check_ajax_referer( "delete-tag_$tag_id" );
564
+	check_ajax_referer("delete-tag_$tag_id");
565 565
 
566
-	$taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
566
+	$taxonomy = ! empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
567 567
 	$tax = get_taxonomy($taxonomy);
568 568
 
569
-	if ( !current_user_can( $tax->cap->delete_terms ) )
569
+	if ( ! current_user_can($tax->cap->delete_terms))
570 570
 		wp_die( -1 );
571 571
 
572
-	$tag = get_term( $tag_id, $taxonomy );
573
-	if ( !$tag || is_wp_error( $tag ) )
574
-		wp_die( 1 );
572
+	$tag = get_term($tag_id, $taxonomy);
573
+	if ( ! $tag || is_wp_error($tag))
574
+		wp_die(1);
575 575
 
576
-	if ( wp_delete_term($tag_id, $taxonomy))
577
-		wp_die( 1 );
576
+	if (wp_delete_term($tag_id, $taxonomy))
577
+		wp_die(1);
578 578
 	else
579
-		wp_die( 0 );
579
+		wp_die(0);
580 580
 }
581 581
 
582 582
 /**
@@ -585,20 +585,20 @@  discard block
 block discarded – undo
585 585
  * @since 3.1.0
586 586
  */
587 587
 function wp_ajax_delete_link() {
588
-	$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
588
+	$id = isset($_POST['id']) ? (int) $_POST['id'] : 0;
589 589
 
590
-	check_ajax_referer( "delete-bookmark_$id" );
591
-	if ( !current_user_can( 'manage_links' ) )
590
+	check_ajax_referer("delete-bookmark_$id");
591
+	if ( ! current_user_can('manage_links'))
592 592
 		wp_die( -1 );
593 593
 
594
-	$link = get_bookmark( $id );
595
-	if ( !$link || is_wp_error( $link ) )
596
-		wp_die( 1 );
594
+	$link = get_bookmark($id);
595
+	if ( ! $link || is_wp_error($link))
596
+		wp_die(1);
597 597
 
598
-	if ( wp_delete_link( $id ) )
599
-		wp_die( 1 );
598
+	if (wp_delete_link($id))
599
+		wp_die(1);
600 600
 	else
601
-		wp_die( 0 );
601
+		wp_die(0);
602 602
 }
603 603
 
604 604
 /**
@@ -607,17 +607,17 @@  discard block
 block discarded – undo
607 607
  * @since 3.1.0
608 608
  */
609 609
 function wp_ajax_delete_meta() {
610
-	$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
610
+	$id = isset($_POST['id']) ? (int) $_POST['id'] : 0;
611 611
 
612
-	check_ajax_referer( "delete-meta_$id" );
613
-	if ( !$meta = get_metadata_by_mid( 'post', $id ) )
614
-		wp_die( 1 );
612
+	check_ajax_referer("delete-meta_$id");
613
+	if ( ! $meta = get_metadata_by_mid('post', $id))
614
+		wp_die(1);
615 615
 
616
-	if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta',  $meta->post_id, $meta->meta_key ) )
616
+	if (is_protected_meta($meta->meta_key, 'post') || ! current_user_can('delete_post_meta', $meta->post_id, $meta->meta_key))
617 617
 		wp_die( -1 );
618
-	if ( delete_meta( $meta->meta_id ) )
619
-		wp_die( 1 );
620
-	wp_die( 0 );
618
+	if (delete_meta($meta->meta_id))
619
+		wp_die(1);
620
+	wp_die(0);
621 621
 }
622 622
 
623 623
 /**
@@ -627,22 +627,22 @@  discard block
 block discarded – undo
627 627
  *
628 628
  * @param string $action Action to perform.
629 629
  */
630
-function wp_ajax_delete_post( $action ) {
631
-	if ( empty( $action ) )
630
+function wp_ajax_delete_post($action) {
631
+	if (empty($action))
632 632
 		$action = 'delete-post';
633
-	$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
633
+	$id = isset($_POST['id']) ? (int) $_POST['id'] : 0;
634 634
 
635
-	check_ajax_referer( "{$action}_$id" );
636
-	if ( !current_user_can( 'delete_post', $id ) )
635
+	check_ajax_referer("{$action}_$id");
636
+	if ( ! current_user_can('delete_post', $id))
637 637
 		wp_die( -1 );
638 638
 
639
-	if ( !get_post( $id ) )
640
-		wp_die( 1 );
639
+	if ( ! get_post($id))
640
+		wp_die(1);
641 641
 
642
-	if ( wp_delete_post( $id ) )
643
-		wp_die( 1 );
642
+	if (wp_delete_post($id))
643
+		wp_die(1);
644 644
 	else
645
-		wp_die( 0 );
645
+		wp_die(0);
646 646
 }
647 647
 
648 648
 /**
@@ -652,27 +652,27 @@  discard block
 block discarded – undo
652 652
  *
653 653
  * @param string $action Action to perform.
654 654
  */
655
-function wp_ajax_trash_post( $action ) {
656
-	if ( empty( $action ) )
655
+function wp_ajax_trash_post($action) {
656
+	if (empty($action))
657 657
 		$action = 'trash-post';
658
-	$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
658
+	$id = isset($_POST['id']) ? (int) $_POST['id'] : 0;
659 659
 
660
-	check_ajax_referer( "{$action}_$id" );
661
-	if ( !current_user_can( 'delete_post', $id ) )
660
+	check_ajax_referer("{$action}_$id");
661
+	if ( ! current_user_can('delete_post', $id))
662 662
 		wp_die( -1 );
663 663
 
664
-	if ( !get_post( $id ) )
665
-		wp_die( 1 );
664
+	if ( ! get_post($id))
665
+		wp_die(1);
666 666
 
667
-	if ( 'trash-post' == $action )
668
-		$done = wp_trash_post( $id );
667
+	if ('trash-post' == $action)
668
+		$done = wp_trash_post($id);
669 669
 	else
670
-		$done = wp_untrash_post( $id );
670
+		$done = wp_untrash_post($id);
671 671
 
672
-	if ( $done )
673
-		wp_die( 1 );
672
+	if ($done)
673
+		wp_die(1);
674 674
 
675
-	wp_die( 0 );
675
+	wp_die(0);
676 676
 }
677 677
 
678 678
 /**
@@ -682,10 +682,10 @@  discard block
 block discarded – undo
682 682
  *
683 683
  * @param string $action Action to perform.
684 684
  */
685
-function wp_ajax_untrash_post( $action ) {
686
-	if ( empty( $action ) )
685
+function wp_ajax_untrash_post($action) {
686
+	if (empty($action))
687 687
 		$action = 'untrash-post';
688
-	wp_ajax_trash_post( $action );
688
+	wp_ajax_trash_post($action);
689 689
 }
690 690
 
691 691
 /**
@@ -693,22 +693,22 @@  discard block
 block discarded – undo
693 693
  *
694 694
  * @param string $action
695 695
  */
696
-function wp_ajax_delete_page( $action ) {
697
-	if ( empty( $action ) )
696
+function wp_ajax_delete_page($action) {
697
+	if (empty($action))
698 698
 		$action = 'delete-page';
699
-	$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
699
+	$id = isset($_POST['id']) ? (int) $_POST['id'] : 0;
700 700
 
701
-	check_ajax_referer( "{$action}_$id" );
702
-	if ( !current_user_can( 'delete_page', $id ) )
701
+	check_ajax_referer("{$action}_$id");
702
+	if ( ! current_user_can('delete_page', $id))
703 703
 		wp_die( -1 );
704 704
 
705
-	if ( ! get_post( $id ) )
706
-		wp_die( 1 );
705
+	if ( ! get_post($id))
706
+		wp_die(1);
707 707
 
708
-	if ( wp_delete_post( $id ) )
709
-		wp_die( 1 );
708
+	if (wp_delete_post($id))
709
+		wp_die(1);
710 710
 	else
711
-		wp_die( 0 );
711
+		wp_die(0);
712 712
 }
713 713
 
714 714
 /**
@@ -717,40 +717,40 @@  discard block
 block discarded – undo
717 717
  * @since 3.1.0
718 718
  */
719 719
 function wp_ajax_dim_comment() {
720
-	$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
720
+	$id = isset($_POST['id']) ? (int) $_POST['id'] : 0;
721 721
 
722
-	if ( !$comment = get_comment( $id ) ) {
723
-		$x = new WP_Ajax_Response( array(
722
+	if ( ! $comment = get_comment($id)) {
723
+		$x = new WP_Ajax_Response(array(
724 724
 			'what' => 'comment',
725 725
 			'id' => new WP_Error('invalid_comment', sprintf(__('Comment %d does not exist'), $id))
726
-		) );
726
+		));
727 727
 		$x->send();
728 728
 	}
729 729
 
730
-	if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) && ! current_user_can( 'moderate_comments' ) )
730
+	if ( ! current_user_can('edit_comment', $comment->comment_ID) && ! current_user_can('moderate_comments'))
731 731
 		wp_die( -1 );
732 732
 
733
-	$current = wp_get_comment_status( $comment->comment_ID );
734
-	if ( isset( $_POST['new'] ) && $_POST['new'] == $current )
735
-		wp_die( time() );
733
+	$current = wp_get_comment_status($comment->comment_ID);
734
+	if (isset($_POST['new']) && $_POST['new'] == $current)
735
+		wp_die(time());
736 736
 
737
-	check_ajax_referer( "approve-comment_$id" );
738
-	if ( in_array( $current, array( 'unapproved', 'spam' ) ) )
739
-		$result = wp_set_comment_status( $comment->comment_ID, 'approve', true );
737
+	check_ajax_referer("approve-comment_$id");
738
+	if (in_array($current, array('unapproved', 'spam')))
739
+		$result = wp_set_comment_status($comment->comment_ID, 'approve', true);
740 740
 	else
741
-		$result = wp_set_comment_status( $comment->comment_ID, 'hold', true );
741
+		$result = wp_set_comment_status($comment->comment_ID, 'hold', true);
742 742
 
743
-	if ( is_wp_error($result) ) {
744
-		$x = new WP_Ajax_Response( array(
743
+	if (is_wp_error($result)) {
744
+		$x = new WP_Ajax_Response(array(
745 745
 			'what' => 'comment',
746 746
 			'id' => $result
747
-		) );
747
+		));
748 748
 		$x->send();
749 749
 	}
750 750
 
751 751
 	// Decide if we need to send back '1' or a more complicated response including page links and comment counts
752
-	_wp_ajax_delete_comment_response( $comment->comment_ID );
753
-	wp_die( 0 );
752
+	_wp_ajax_delete_comment_response($comment->comment_ID);
753
+	wp_die(0);
754 754
 }
755 755
 
756 756
 /**
@@ -760,33 +760,33 @@  discard block
 block discarded – undo
760 760
  *
761 761
  * @param string $action Action to perform.
762 762
  */
763
-function wp_ajax_add_link_category( $action ) {
764
-	if ( empty( $action ) )
763
+function wp_ajax_add_link_category($action) {
764
+	if (empty($action))
765 765
 		$action = 'add-link-category';
766
-	check_ajax_referer( $action );
767
-	if ( !current_user_can( 'manage_categories' ) )
766
+	check_ajax_referer($action);
767
+	if ( ! current_user_can('manage_categories'))
768 768
 		wp_die( -1 );
769
-	$names = explode(',', wp_unslash( $_POST['newcat'] ) );
769
+	$names = explode(',', wp_unslash($_POST['newcat']));
770 770
 	$x = new WP_Ajax_Response();
771
-	foreach ( $names as $cat_name ) {
771
+	foreach ($names as $cat_name) {
772 772
 		$cat_name = trim($cat_name);
773 773
 		$slug = sanitize_title($cat_name);
774
-		if ( '' === $slug )
774
+		if ('' === $slug)
775 775
 			continue;
776
-		if ( !$cat_id = term_exists( $cat_name, 'link_category' ) )
777
-			$cat_id = wp_insert_term( $cat_name, 'link_category' );
778
-		if ( is_wp_error( $cat_id ) ) {
776
+		if ( ! $cat_id = term_exists($cat_name, 'link_category'))
777
+			$cat_id = wp_insert_term($cat_name, 'link_category');
778
+		if (is_wp_error($cat_id)) {
779 779
 			continue;
780
-		} elseif ( is_array( $cat_id ) ) {
780
+		} elseif (is_array($cat_id)) {
781 781
 			$cat_id = $cat_id['term_id'];
782 782
 		}
783
-		$cat_name = esc_html( $cat_name );
784
-		$x->add( array(
783
+		$cat_name = esc_html($cat_name);
784
+		$x->add(array(
785 785
 			'what' => 'link-category',
786 786
 			'id' => $cat_id,
787
-			'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>",
787
+			'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>",
788 788
 			'position' => -1
789
-		) );
789
+		));
790 790
 	}
791 791
 	$x->send();
792 792
 }
@@ -801,52 +801,52 @@  discard block
 block discarded – undo
801 801
 function wp_ajax_add_tag() {
802 802
 	global $wp_list_table;
803 803
 
804
-	check_ajax_referer( 'add-tag', '_wpnonce_add-tag' );
805
-	$taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
804
+	check_ajax_referer('add-tag', '_wpnonce_add-tag');
805
+	$taxonomy = ! empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
806 806
 	$tax = get_taxonomy($taxonomy);
807 807
 
808
-	if ( !current_user_can( $tax->cap->edit_terms ) )
808
+	if ( ! current_user_can($tax->cap->edit_terms))
809 809
 		wp_die( -1 );
810 810
 
811 811
 	$x = new WP_Ajax_Response();
812 812
 
813
-	$tag = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST );
813
+	$tag = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST);
814 814
 
815
-	if ( !$tag || is_wp_error($tag) || (!$tag = get_term( $tag['term_id'], $taxonomy )) ) {
815
+	if ( ! $tag || is_wp_error($tag) || ( ! $tag = get_term($tag['term_id'], $taxonomy))) {
816 816
 		$message = __('An error has occurred. Please reload the page and try again.');
817
-		if ( is_wp_error($tag) && $tag->get_error_message() )
817
+		if (is_wp_error($tag) && $tag->get_error_message())
818 818
 			$message = $tag->get_error_message();
819 819
 
820
-		$x->add( array(
820
+		$x->add(array(
821 821
 			'what' => 'taxonomy',
822
-			'data' => new WP_Error('error', $message )
823
-		) );
822
+			'data' => new WP_Error('error', $message)
823
+		));
824 824
 		$x->send();
825 825
 	}
826 826
 
827
-	$wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => $_POST['screen'] ) );
827
+	$wp_list_table = _get_list_table('WP_Terms_List_Table', array('screen' => $_POST['screen']));
828 828
 
829 829
 	$level = 0;
830
-	if ( is_taxonomy_hierarchical($taxonomy) ) {
831
-		$level = count( get_ancestors( $tag->term_id, $taxonomy, 'taxonomy' ) );
830
+	if (is_taxonomy_hierarchical($taxonomy)) {
831
+		$level = count(get_ancestors($tag->term_id, $taxonomy, 'taxonomy'));
832 832
 		ob_start();
833
-		$wp_list_table->single_row( $tag, $level );
833
+		$wp_list_table->single_row($tag, $level);
834 834
 		$noparents = ob_get_clean();
835 835
 	}
836 836
 
837 837
 	ob_start();
838
-	$wp_list_table->single_row( $tag );
838
+	$wp_list_table->single_row($tag);
839 839
 	$parents = ob_get_clean();
840 840
 
841
-	$x->add( array(
841
+	$x->add(array(
842 842
 		'what' => 'taxonomy',
843 843
 		'supplemental' => compact('parents', 'noparents')
844
-	) );
845
-	$x->add( array(
844
+	));
845
+	$x->add(array(
846 846
 		'what' => 'term',
847 847
 		'position' => $level,
848 848
 		'supplemental' => (array) $tag
849
-	) );
849
+	));
850 850
 	$x->send();
851 851
 }
852 852
 
@@ -856,38 +856,38 @@  discard block
 block discarded – undo
856 856
  * @since 3.1.0
857 857
  */
858 858
 function wp_ajax_get_tagcloud() {
859
-	if ( ! isset( $_POST['tax'] ) ) {
860
-		wp_die( 0 );
859
+	if ( ! isset($_POST['tax'])) {
860
+		wp_die(0);
861 861
 	}
862 862
 
863
-	$taxonomy = sanitize_key( $_POST['tax'] );
864
-	$tax = get_taxonomy( $taxonomy );
865
-	if ( ! $tax ) {
866
-		wp_die( 0 );
863
+	$taxonomy = sanitize_key($_POST['tax']);
864
+	$tax = get_taxonomy($taxonomy);
865
+	if ( ! $tax) {
866
+		wp_die(0);
867 867
 	}
868 868
 
869
-	if ( ! current_user_can( $tax->cap->assign_terms ) ) {
869
+	if ( ! current_user_can($tax->cap->assign_terms)) {
870 870
 		wp_die( -1 );
871 871
 	}
872 872
 
873
-	$tags = get_terms( $taxonomy, array( 'number' => 45, 'orderby' => 'count', 'order' => 'DESC' ) );
873
+	$tags = get_terms($taxonomy, array('number' => 45, 'orderby' => 'count', 'order' => 'DESC'));
874 874
 
875
-	if ( empty( $tags ) )
876
-		wp_die( $tax->labels->not_found );
875
+	if (empty($tags))
876
+		wp_die($tax->labels->not_found);
877 877
 
878
-	if ( is_wp_error( $tags ) )
879
-		wp_die( $tags->get_error_message() );
878
+	if (is_wp_error($tags))
879
+		wp_die($tags->get_error_message());
880 880
 
881
-	foreach ( $tags as $key => $tag ) {
882
-		$tags[ $key ]->link = '#';
883
-		$tags[ $key ]->id = $tag->term_id;
881
+	foreach ($tags as $key => $tag) {
882
+		$tags[$key]->link = '#';
883
+		$tags[$key]->id = $tag->term_id;
884 884
 	}
885 885
 
886 886
 	// We need raw tag names here, so don't filter the output
887
-	$return = wp_generate_tag_cloud( $tags, array('filter' => 0) );
887
+	$return = wp_generate_tag_cloud($tags, array('filter' => 0));
888 888
 
889
-	if ( empty($return) )
890
-		wp_die( 0 );
889
+	if (empty($return))
890
+		wp_die(0);
891 891
 
892 892
 	echo $return;
893 893
 
@@ -904,46 +904,46 @@  discard block
 block discarded – undo
904 904
  *
905 905
  * @param string $action Action to perform.
906 906
  */
907
-function wp_ajax_get_comments( $action ) {
907
+function wp_ajax_get_comments($action) {
908 908
 	global $wp_list_table, $post_id;
909
-	if ( empty( $action ) )
909
+	if (empty($action))
910 910
 		$action = 'get-comments';
911 911
 
912
-	check_ajax_referer( $action );
912
+	check_ajax_referer($action);
913 913
 
914
-	if ( empty( $post_id ) && ! empty( $_REQUEST['p'] ) ) {
915
-		$id = absint( $_REQUEST['p'] );
916
-		if ( ! empty( $id ) )
914
+	if (empty($post_id) && ! empty($_REQUEST['p'])) {
915
+		$id = absint($_REQUEST['p']);
916
+		if ( ! empty($id))
917 917
 			$post_id = $id;
918 918
 	}
919 919
 
920
-	if ( empty( $post_id ) )
920
+	if (empty($post_id))
921 921
 		wp_die( -1 );
922 922
 
923
-	$wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
923
+	$wp_list_table = _get_list_table('WP_Post_Comments_List_Table', array('screen' => 'edit-comments'));
924 924
 
925
-	if ( ! current_user_can( 'edit_post', $post_id ) )
925
+	if ( ! current_user_can('edit_post', $post_id))
926 926
 		wp_die( -1 );
927 927
 
928 928
 	$wp_list_table->prepare_items();
929 929
 
930
-	if ( !$wp_list_table->has_items() )
931
-		wp_die( 1 );
930
+	if ( ! $wp_list_table->has_items())
931
+		wp_die(1);
932 932
 
933 933
 	$x = new WP_Ajax_Response();
934 934
 	ob_start();
935
-	foreach ( $wp_list_table->items as $comment ) {
936
-		if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) )
935
+	foreach ($wp_list_table->items as $comment) {
936
+		if ( ! current_user_can('edit_comment', $comment->comment_ID))
937 937
 			continue;
938
-		get_comment( $comment );
939
-		$wp_list_table->single_row( $comment );
938
+		get_comment($comment);
939
+		$wp_list_table->single_row($comment);
940 940
 	}
941 941
 	$comment_list_item = ob_get_clean();
942 942
 
943
-	$x->add( array(
943
+	$x->add(array(
944 944
 		'what' => 'comments',
945 945
 		'data' => $comment_list_item
946
-	) );
946
+	));
947 947
 	$x->send();
948 948
 }
949 949
 
@@ -956,98 +956,98 @@  discard block
 block discarded – undo
956 956
  *
957 957
  * @param string $action Action to perform.
958 958
  */
959
-function wp_ajax_replyto_comment( $action ) {
959
+function wp_ajax_replyto_comment($action) {
960 960
 	global $wp_list_table;
961
-	if ( empty( $action ) )
961
+	if (empty($action))
962 962
 		$action = 'replyto-comment';
963 963
 
964
-	check_ajax_referer( $action, '_ajax_nonce-replyto-comment' );
964
+	check_ajax_referer($action, '_ajax_nonce-replyto-comment');
965 965
 
966 966
 	$comment_post_ID = (int) $_POST['comment_post_ID'];
967
-	$post = get_post( $comment_post_ID );
968
-	if ( ! $post )
967
+	$post = get_post($comment_post_ID);
968
+	if ( ! $post)
969 969
 		wp_die( -1 );
970 970
 
971
-	if ( !current_user_can( 'edit_post', $comment_post_ID ) )
971
+	if ( ! current_user_can('edit_post', $comment_post_ID))
972 972
 		wp_die( -1 );
973 973
 
974
-	if ( empty( $post->post_status ) )
975
-		wp_die( 1 );
976
-	elseif ( in_array($post->post_status, array('draft', 'pending', 'trash') ) )
977
-		wp_die( __('ERROR: you are replying to a comment on a draft post.') );
974
+	if (empty($post->post_status))
975
+		wp_die(1);
976
+	elseif (in_array($post->post_status, array('draft', 'pending', 'trash')))
977
+		wp_die(__('ERROR: you are replying to a comment on a draft post.'));
978 978
 
979 979
 	$user = wp_get_current_user();
980
-	if ( $user->exists() ) {
980
+	if ($user->exists()) {
981 981
 		$user_ID = $user->ID;
982
-		$comment_author       = wp_slash( $user->display_name );
983
-		$comment_author_email = wp_slash( $user->user_email );
984
-		$comment_author_url   = wp_slash( $user->user_url );
985
-		$comment_content      = trim( $_POST['content'] );
986
-		$comment_type         = isset( $_POST['comment_type'] ) ? trim( $_POST['comment_type'] ) : '';
987
-		if ( current_user_can( 'unfiltered_html' ) ) {
988
-			if ( ! isset( $_POST['_wp_unfiltered_html_comment'] ) )
982
+		$comment_author       = wp_slash($user->display_name);
983
+		$comment_author_email = wp_slash($user->user_email);
984
+		$comment_author_url   = wp_slash($user->user_url);
985
+		$comment_content      = trim($_POST['content']);
986
+		$comment_type         = isset($_POST['comment_type']) ? trim($_POST['comment_type']) : '';
987
+		if (current_user_can('unfiltered_html')) {
988
+			if ( ! isset($_POST['_wp_unfiltered_html_comment']))
989 989
 				$_POST['_wp_unfiltered_html_comment'] = '';
990 990
 
991
-			if ( wp_create_nonce( 'unfiltered-html-comment' ) != $_POST['_wp_unfiltered_html_comment'] ) {
991
+			if (wp_create_nonce('unfiltered-html-comment') != $_POST['_wp_unfiltered_html_comment']) {
992 992
 				kses_remove_filters(); // start with a clean slate
993 993
 				kses_init_filters(); // set up the filters
994 994
 			}
995 995
 		}
996 996
 	} else {
997
-		wp_die( __( 'Sorry, you must be logged in to reply to a comment.' ) );
997
+		wp_die(__('Sorry, you must be logged in to reply to a comment.'));
998 998
 	}
999 999
 
1000
-	if ( '' == $comment_content )
1001
-		wp_die( __( 'ERROR: please type a comment.' ) );
1000
+	if ('' == $comment_content)
1001
+		wp_die(__('ERROR: please type a comment.'));
1002 1002
 
1003 1003
 	$comment_parent = 0;
1004
-	if ( isset( $_POST['comment_ID'] ) )
1005
-		$comment_parent = absint( $_POST['comment_ID'] );
1004
+	if (isset($_POST['comment_ID']))
1005
+		$comment_parent = absint($_POST['comment_ID']);
1006 1006
 	$comment_auto_approved = false;
1007 1007
 	$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID');
1008 1008
 
1009 1009
 	// Automatically approve parent comment.
1010
-	if ( !empty($_POST['approve_parent']) ) {
1011
-		$parent = get_comment( $comment_parent );
1010
+	if ( ! empty($_POST['approve_parent'])) {
1011
+		$parent = get_comment($comment_parent);
1012 1012
 
1013
-		if ( $parent && $parent->comment_approved === '0' && $parent->comment_post_ID == $comment_post_ID ) {
1014
-			if ( wp_set_comment_status( $parent->comment_ID, 'approve' ) )
1013
+		if ($parent && $parent->comment_approved === '0' && $parent->comment_post_ID == $comment_post_ID) {
1014
+			if (wp_set_comment_status($parent->comment_ID, 'approve'))
1015 1015
 				$comment_auto_approved = true;
1016 1016
 		}
1017 1017
 	}
1018 1018
 
1019
-	$comment_id = wp_new_comment( $commentdata );
1019
+	$comment_id = wp_new_comment($commentdata);
1020 1020
 	$comment = get_comment($comment_id);
1021
-	if ( ! $comment ) wp_die( 1 );
1021
+	if ( ! $comment) wp_die(1);
1022 1022
 
1023
-	$position = ( isset($_POST['position']) && (int) $_POST['position'] ) ? (int) $_POST['position'] : '-1';
1023
+	$position = (isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1';
1024 1024
 
1025 1025
 	ob_start();
1026
-	if ( isset( $_REQUEST['mode'] ) && 'dashboard' == $_REQUEST['mode'] ) {
1027
-		require_once( ABSPATH . 'wp-admin/includes/dashboard.php' );
1028
-		_wp_dashboard_recent_comments_row( $comment );
1026
+	if (isset($_REQUEST['mode']) && 'dashboard' == $_REQUEST['mode']) {
1027
+		require_once(ABSPATH.'wp-admin/includes/dashboard.php');
1028
+		_wp_dashboard_recent_comments_row($comment);
1029 1029
 	} else {
1030
-		if ( isset( $_REQUEST['mode'] ) && 'single' == $_REQUEST['mode'] ) {
1031
-			$wp_list_table = _get_list_table('WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
1030
+		if (isset($_REQUEST['mode']) && 'single' == $_REQUEST['mode']) {
1031
+			$wp_list_table = _get_list_table('WP_Post_Comments_List_Table', array('screen' => 'edit-comments'));
1032 1032
 		} else {
1033
-			$wp_list_table = _get_list_table('WP_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
1033
+			$wp_list_table = _get_list_table('WP_Comments_List_Table', array('screen' => 'edit-comments'));
1034 1034
 		}
1035
-		$wp_list_table->single_row( $comment );
1035
+		$wp_list_table->single_row($comment);
1036 1036
 	}
1037 1037
 	$comment_list_item = ob_get_clean();
1038 1038
 
1039
-	$response =  array(
1039
+	$response = array(
1040 1040
 		'what' => 'comment',
1041 1041
 		'id' => $comment->comment_ID,
1042 1042
 		'data' => $comment_list_item,
1043 1043
 		'position' => $position
1044 1044
 	);
1045 1045
 
1046
-	if ( $comment_auto_approved )
1047
-		$response['supplemental'] = array( 'parent_approved' => $parent->comment_ID, 'parent_post_id' => $parent->comment_post_ID );
1046
+	if ($comment_auto_approved)
1047
+		$response['supplemental'] = array('parent_approved' => $parent->comment_ID, 'parent_post_id' => $parent->comment_post_ID);
1048 1048
 
1049 1049
 	$x = new WP_Ajax_Response();
1050
-	$x->add( $response );
1050
+	$x->add($response);
1051 1051
 	$x->send();
1052 1052
 }
1053 1053
 
@@ -1061,34 +1061,34 @@  discard block
 block discarded – undo
1061 1061
 function wp_ajax_edit_comment() {
1062 1062
 	global $wp_list_table;
1063 1063
 
1064
-	check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' );
1064
+	check_ajax_referer('replyto-comment', '_ajax_nonce-replyto-comment');
1065 1065
 
1066 1066
 	$comment_id = (int) $_POST['comment_ID'];
1067
-	if ( ! current_user_can( 'edit_comment', $comment_id ) )
1067
+	if ( ! current_user_can('edit_comment', $comment_id))
1068 1068
 		wp_die( -1 );
1069 1069
 
1070
-	if ( '' == $_POST['content'] )
1071
-		wp_die( __( 'ERROR: please type a comment.' ) );
1070
+	if ('' == $_POST['content'])
1071
+		wp_die(__('ERROR: please type a comment.'));
1072 1072
 
1073
-	if ( isset( $_POST['status'] ) )
1073
+	if (isset($_POST['status']))
1074 1074
 		$_POST['comment_status'] = $_POST['status'];
1075 1075
 	edit_comment();
1076 1076
 
1077
-	$position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1';
1078
-	$checkbox = ( isset($_POST['checkbox']) && true == $_POST['checkbox'] ) ? 1 : 0;
1079
-	$wp_list_table = _get_list_table( $checkbox ? 'WP_Comments_List_Table' : 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
1077
+	$position = (isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1';
1078
+	$checkbox = (isset($_POST['checkbox']) && true == $_POST['checkbox']) ? 1 : 0;
1079
+	$wp_list_table = _get_list_table($checkbox ? 'WP_Comments_List_Table' : 'WP_Post_Comments_List_Table', array('screen' => 'edit-comments'));
1080 1080
 
1081
-	$comment = get_comment( $comment_id );
1082
-	if ( empty( $comment->comment_ID ) )
1081
+	$comment = get_comment($comment_id);
1082
+	if (empty($comment->comment_ID))
1083 1083
 		wp_die( -1 );
1084 1084
 
1085 1085
 	ob_start();
1086
-	$wp_list_table->single_row( $comment );
1086
+	$wp_list_table->single_row($comment);
1087 1087
 	$comment_list_item = ob_get_clean();
1088 1088
 
1089 1089
 	$x = new WP_Ajax_Response();
1090 1090
 
1091
-	$x->add( array(
1091
+	$x->add(array(
1092 1092
 		'what' => 'edit_comment',
1093 1093
 		'id' => $comment->comment_ID,
1094 1094
 		'data' => $comment_list_item,
@@ -1104,35 +1104,35 @@  discard block
 block discarded – undo
1104 1104
  * @since 3.1.0
1105 1105
  */
1106 1106
 function wp_ajax_add_menu_item() {
1107
-	check_ajax_referer( 'add-menu_item', 'menu-settings-column-nonce' );
1107
+	check_ajax_referer('add-menu_item', 'menu-settings-column-nonce');
1108 1108
 
1109
-	if ( ! current_user_can( 'edit_theme_options' ) )
1109
+	if ( ! current_user_can('edit_theme_options'))
1110 1110
 		wp_die( -1 );
1111 1111
 
1112
-	require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
1112
+	require_once ABSPATH.'wp-admin/includes/nav-menu.php';
1113 1113
 
1114 1114
 	// For performance reasons, we omit some object properties from the checklist.
1115 1115
 	// The following is a hacky way to restore them when adding non-custom items.
1116 1116
 
1117 1117
 	$menu_items_data = array();
1118
-	foreach ( (array) $_POST['menu-item'] as $menu_item_data ) {
1118
+	foreach ((array) $_POST['menu-item'] as $menu_item_data) {
1119 1119
 		if (
1120
-			! empty( $menu_item_data['menu-item-type'] ) &&
1120
+			! empty($menu_item_data['menu-item-type']) &&
1121 1121
 			'custom' != $menu_item_data['menu-item-type'] &&
1122
-			! empty( $menu_item_data['menu-item-object-id'] )
1122
+			! empty($menu_item_data['menu-item-object-id'])
1123 1123
 		) {
1124
-			switch( $menu_item_data['menu-item-type'] ) {
1124
+			switch ($menu_item_data['menu-item-type']) {
1125 1125
 				case 'post_type' :
1126
-					$_object = get_post( $menu_item_data['menu-item-object-id'] );
1126
+					$_object = get_post($menu_item_data['menu-item-object-id']);
1127 1127
 				break;
1128 1128
 
1129 1129
 				case 'taxonomy' :
1130
-					$_object = get_term( $menu_item_data['menu-item-object-id'], $menu_item_data['menu-item-object'] );
1130
+					$_object = get_term($menu_item_data['menu-item-object-id'], $menu_item_data['menu-item-object']);
1131 1131
 				break;
1132 1132
 			}
1133 1133
 
1134
-			$_menu_items = array_map( 'wp_setup_nav_menu_item', array( $_object ) );
1135
-			$_menu_item = reset( $_menu_items );
1134
+			$_menu_items = array_map('wp_setup_nav_menu_item', array($_object));
1135
+			$_menu_item = reset($_menu_items);
1136 1136
 
1137 1137
 			// Restore the missing menu item properties
1138 1138
 			$menu_item_data['menu-item-description'] = $_menu_item->description;
@@ -1141,28 +1141,28 @@  discard block
 block discarded – undo
1141 1141
 		$menu_items_data[] = $menu_item_data;
1142 1142
 	}
1143 1143
 
1144
-	$item_ids = wp_save_nav_menu_items( 0, $menu_items_data );
1145
-	if ( is_wp_error( $item_ids ) )
1146
-		wp_die( 0 );
1144
+	$item_ids = wp_save_nav_menu_items(0, $menu_items_data);
1145
+	if (is_wp_error($item_ids))
1146
+		wp_die(0);
1147 1147
 
1148 1148
 	$menu_items = array();
1149 1149
 
1150
-	foreach ( (array) $item_ids as $menu_item_id ) {
1151
-		$menu_obj = get_post( $menu_item_id );
1152
-		if ( ! empty( $menu_obj->ID ) ) {
1153
-			$menu_obj = wp_setup_nav_menu_item( $menu_obj );
1150
+	foreach ((array) $item_ids as $menu_item_id) {
1151
+		$menu_obj = get_post($menu_item_id);
1152
+		if ( ! empty($menu_obj->ID)) {
1153
+			$menu_obj = wp_setup_nav_menu_item($menu_obj);
1154 1154
 			$menu_obj->label = $menu_obj->title; // don't show "(pending)" in ajax-added items
1155 1155
 			$menu_items[] = $menu_obj;
1156 1156
 		}
1157 1157
 	}
1158 1158
 
1159 1159
 	/** This filter is documented in wp-admin/includes/nav-menu.php */
1160
-	$walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $_POST['menu'] );
1160
+	$walker_class_name = apply_filters('wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $_POST['menu']);
1161 1161
 
1162
-	if ( ! class_exists( $walker_class_name ) )
1163
-		wp_die( 0 );
1162
+	if ( ! class_exists($walker_class_name))
1163
+		wp_die(0);
1164 1164
 
1165
-	if ( ! empty( $menu_items ) ) {
1165
+	if ( ! empty($menu_items)) {
1166 1166
 		$args = array(
1167 1167
 			'after' => '',
1168 1168
 			'before' => '',
@@ -1170,7 +1170,7 @@  discard block
 block discarded – undo
1170 1170
 			'link_before' => '',
1171 1171
 			'walker' => new $walker_class_name,
1172 1172
 		);
1173
-		echo walk_nav_menu_tree( $menu_items, 0, (object) $args );
1173
+		echo walk_nav_menu_tree($menu_items, 0, (object) $args);
1174 1174
 	}
1175 1175
 	wp_die();
1176 1176
 }
@@ -1181,19 +1181,19 @@  discard block
 block discarded – undo
1181 1181
  * @since 3.1.0
1182 1182
  */
1183 1183
 function wp_ajax_add_meta() {
1184
-	check_ajax_referer( 'add-meta', '_ajax_nonce-add-meta' );
1184
+	check_ajax_referer('add-meta', '_ajax_nonce-add-meta');
1185 1185
 	$c = 0;
1186 1186
 	$pid = (int) $_POST['post_id'];
1187
-	$post = get_post( $pid );
1187
+	$post = get_post($pid);
1188 1188
 
1189
-	if ( isset($_POST['metakeyselect']) || isset($_POST['metakeyinput']) ) {
1190
-		if ( !current_user_can( 'edit_post', $pid ) )
1189
+	if (isset($_POST['metakeyselect']) || isset($_POST['metakeyinput'])) {
1190
+		if ( ! current_user_can('edit_post', $pid))
1191 1191
 			wp_die( -1 );
1192
-		if ( isset($_POST['metakeyselect']) && '#NONE#' == $_POST['metakeyselect'] && empty($_POST['metakeyinput']) )
1193
-			wp_die( 1 );
1192
+		if (isset($_POST['metakeyselect']) && '#NONE#' == $_POST['metakeyselect'] && empty($_POST['metakeyinput']))
1193
+			wp_die(1);
1194 1194
 
1195 1195
 		// If the post is an autodraft, save the post as a draft and then attempt to save the meta.
1196
-		if ( $post->post_status == 'auto-draft' ) {
1196
+		if ($post->post_status == 'auto-draft') {
1197 1197
 			$save_POST = $_POST; // Backup $_POST
1198 1198
 			$_POST = array(); // Make it empty for edit_post()
1199 1199
 			$_POST['action'] = 'draft'; // Warning fix
@@ -1201,66 +1201,66 @@  discard block
 block discarded – undo
1201 1201
 			$_POST['post_type'] = $post->post_type;
1202 1202
 			$_POST['post_status'] = 'draft';
1203 1203
 			$now = current_time('timestamp', 1);
1204
-			$_POST['post_title'] = sprintf( __( 'Draft created on %1$s at %2$s' ), date( get_option( 'date_format' ), $now ), date( get_option( 'time_format' ), $now ) );
1204
+			$_POST['post_title'] = sprintf(__('Draft created on %1$s at %2$s'), date(get_option('date_format'), $now), date(get_option('time_format'), $now));
1205 1205
 
1206
-			if ( $pid = edit_post() ) {
1207
-				if ( is_wp_error( $pid ) ) {
1208
-					$x = new WP_Ajax_Response( array(
1206
+			if ($pid = edit_post()) {
1207
+				if (is_wp_error($pid)) {
1208
+					$x = new WP_Ajax_Response(array(
1209 1209
 						'what' => 'meta',
1210 1210
 						'data' => $pid
1211
-					) );
1211
+					));
1212 1212
 					$x->send();
1213 1213
 				}
1214 1214
 				$_POST = $save_POST; // Now we can restore original $_POST again
1215
-				if ( !$mid = add_meta( $pid ) )
1216
-					wp_die( __( 'Please provide a custom field value.' ) );
1215
+				if ( ! $mid = add_meta($pid))
1216
+					wp_die(__('Please provide a custom field value.'));
1217 1217
 			} else {
1218
-				wp_die( 0 );
1218
+				wp_die(0);
1219 1219
 			}
1220
-		} elseif ( ! $mid = add_meta( $pid ) ) {
1221
-			wp_die( __( 'Please provide a custom field value.' ) );
1220
+		} elseif ( ! $mid = add_meta($pid)) {
1221
+			wp_die(__('Please provide a custom field value.'));
1222 1222
 		}
1223 1223
 
1224
-		$meta = get_metadata_by_mid( 'post', $mid );
1224
+		$meta = get_metadata_by_mid('post', $mid);
1225 1225
 		$pid = (int) $meta->post_id;
1226
-		$meta = get_object_vars( $meta );
1227
-		$x = new WP_Ajax_Response( array(
1226
+		$meta = get_object_vars($meta);
1227
+		$x = new WP_Ajax_Response(array(
1228 1228
 			'what' => 'meta',
1229 1229
 			'id' => $mid,
1230
-			'data' => _list_meta_row( $meta, $c ),
1230
+			'data' => _list_meta_row($meta, $c),
1231 1231
 			'position' => 1,
1232 1232
 			'supplemental' => array('postid' => $pid)
1233
-		) );
1233
+		));
1234 1234
 	} else { // Update?
1235
-		$mid = (int) key( $_POST['meta'] );
1236
-		$key = wp_unslash( $_POST['meta'][$mid]['key'] );
1237
-		$value = wp_unslash( $_POST['meta'][$mid]['value'] );
1238
-		if ( '' == trim($key) )
1239
-			wp_die( __( 'Please provide a custom field name.' ) );
1240
-		if ( '' == trim($value) )
1241
-			wp_die( __( 'Please provide a custom field value.' ) );
1242
-		if ( ! $meta = get_metadata_by_mid( 'post', $mid ) )
1243
-			wp_die( 0 ); // if meta doesn't exist
1244
-		if ( is_protected_meta( $meta->meta_key, 'post' ) || is_protected_meta( $key, 'post' ) ||
1245
-			! current_user_can( 'edit_post_meta', $meta->post_id, $meta->meta_key ) ||
1246
-			! current_user_can( 'edit_post_meta', $meta->post_id, $key ) )
1235
+		$mid = (int) key($_POST['meta']);
1236
+		$key = wp_unslash($_POST['meta'][$mid]['key']);
1237
+		$value = wp_unslash($_POST['meta'][$mid]['value']);
1238
+		if ('' == trim($key))
1239
+			wp_die(__('Please provide a custom field name.'));
1240
+		if ('' == trim($value))
1241
+			wp_die(__('Please provide a custom field value.'));
1242
+		if ( ! $meta = get_metadata_by_mid('post', $mid))
1243
+			wp_die(0); // if meta doesn't exist
1244
+		if (is_protected_meta($meta->meta_key, 'post') || is_protected_meta($key, 'post') ||
1245
+			! current_user_can('edit_post_meta', $meta->post_id, $meta->meta_key) ||
1246
+			! current_user_can('edit_post_meta', $meta->post_id, $key))
1247 1247
 			wp_die( -1 );
1248
-		if ( $meta->meta_value != $value || $meta->meta_key != $key ) {
1249
-			if ( !$u = update_metadata_by_mid( 'post', $mid, $value, $key ) )
1250
-				wp_die( 0 ); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems).
1248
+		if ($meta->meta_value != $value || $meta->meta_key != $key) {
1249
+			if ( ! $u = update_metadata_by_mid('post', $mid, $value, $key))
1250
+				wp_die(0); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems).
1251 1251
 		}
1252 1252
 
1253
-		$x = new WP_Ajax_Response( array(
1253
+		$x = new WP_Ajax_Response(array(
1254 1254
 			'what' => 'meta',
1255 1255
 			'id' => $mid, 'old_id' => $mid,
1256
-			'data' => _list_meta_row( array(
1256
+			'data' => _list_meta_row(array(
1257 1257
 				'meta_key' => $key,
1258 1258
 				'meta_value' => $value,
1259 1259
 				'meta_id' => $mid
1260
-			), $c ),
1260
+			), $c),
1261 1261
 			'position' => 0,
1262 1262
 			'supplemental' => array('postid' => $meta->post_id)
1263
-		) );
1263
+		));
1264 1264
 	}
1265 1265
 	$x->send();
1266 1266
 }
@@ -1274,38 +1274,38 @@  discard block
 block discarded – undo
1274 1274
  *
1275 1275
  * @param string $action Action to perform.
1276 1276
  */
1277
-function wp_ajax_add_user( $action ) {
1277
+function wp_ajax_add_user($action) {
1278 1278
 	global $wp_list_table;
1279
-	if ( empty( $action ) )
1279
+	if (empty($action))
1280 1280
 		$action = 'add-user';
1281 1281
 
1282
-	check_ajax_referer( $action );
1283
-	if ( ! current_user_can('create_users') )
1282
+	check_ajax_referer($action);
1283
+	if ( ! current_user_can('create_users'))
1284 1284
 		wp_die( -1 );
1285
-	if ( ! $user_id = edit_user() ) {
1286
-		wp_die( 0 );
1287
-	} elseif ( is_wp_error( $user_id ) ) {
1288
-		$x = new WP_Ajax_Response( array(
1285
+	if ( ! $user_id = edit_user()) {
1286
+		wp_die(0);
1287
+	} elseif (is_wp_error($user_id)) {
1288
+		$x = new WP_Ajax_Response(array(
1289 1289
 			'what' => 'user',
1290 1290
 			'id' => $user_id
1291
-		) );
1291
+		));
1292 1292
 		$x->send();
1293 1293
 	}
1294
-	$user_object = get_userdata( $user_id );
1294
+	$user_object = get_userdata($user_id);
1295 1295
 
1296 1296
 	$wp_list_table = _get_list_table('WP_Users_List_Table');
1297 1297
 
1298
-	$role = current( $user_object->roles );
1298
+	$role = current($user_object->roles);
1299 1299
 
1300
-	$x = new WP_Ajax_Response( array(
1300
+	$x = new WP_Ajax_Response(array(
1301 1301
 		'what' => 'user',
1302 1302
 		'id' => $user_id,
1303
-		'data' => $wp_list_table->single_row( $user_object, '', $role ),
1303
+		'data' => $wp_list_table->single_row($user_object, '', $role),
1304 1304
 		'supplemental' => array(
1305
-			'show-link' => sprintf(__( 'User <a href="#%s">%s</a> added' ), "user-$user_id", $user_object->user_login),
1305
+			'show-link' => sprintf(__('User <a href="#%s">%s</a> added'), "user-$user_id", $user_object->user_login),
1306 1306
 			'role' => $role,
1307 1307
 		)
1308
-	) );
1308
+	));
1309 1309
 	$x->send();
1310 1310
 }
1311 1311
 
@@ -1315,30 +1315,30 @@  discard block
 block discarded – undo
1315 1315
  * @since 3.1.0
1316 1316
  */
1317 1317
 function wp_ajax_closed_postboxes() {
1318
-	check_ajax_referer( 'closedpostboxes', 'closedpostboxesnonce' );
1319
-	$closed = isset( $_POST['closed'] ) ? explode( ',', $_POST['closed']) : array();
1318
+	check_ajax_referer('closedpostboxes', 'closedpostboxesnonce');
1319
+	$closed = isset($_POST['closed']) ? explode(',', $_POST['closed']) : array();
1320 1320
 	$closed = array_filter($closed);
1321 1321
 
1322
-	$hidden = isset( $_POST['hidden'] ) ? explode( ',', $_POST['hidden']) : array();
1322
+	$hidden = isset($_POST['hidden']) ? explode(',', $_POST['hidden']) : array();
1323 1323
 	$hidden = array_filter($hidden);
1324 1324
 
1325
-	$page = isset( $_POST['page'] ) ? $_POST['page'] : '';
1325
+	$page = isset($_POST['page']) ? $_POST['page'] : '';
1326 1326
 
1327
-	if ( $page != sanitize_key( $page ) )
1328
-		wp_die( 0 );
1327
+	if ($page != sanitize_key($page))
1328
+		wp_die(0);
1329 1329
 
1330
-	if ( ! $user = wp_get_current_user() )
1330
+	if ( ! $user = wp_get_current_user())
1331 1331
 		wp_die( -1 );
1332 1332
 
1333
-	if ( is_array($closed) )
1333
+	if (is_array($closed))
1334 1334
 		update_user_option($user->ID, "closedpostboxes_$page", $closed, true);
1335 1335
 
1336
-	if ( is_array($hidden) ) {
1337
-		$hidden = array_diff( $hidden, array('submitdiv', 'linksubmitdiv', 'manage-menu', 'create-menu') ); // postboxes that are always shown
1336
+	if (is_array($hidden)) {
1337
+		$hidden = array_diff($hidden, array('submitdiv', 'linksubmitdiv', 'manage-menu', 'create-menu')); // postboxes that are always shown
1338 1338
 		update_user_option($user->ID, "metaboxhidden_$page", $hidden, true);
1339 1339
 	}
1340 1340
 
1341
-	wp_die( 1 );
1341
+	wp_die(1);
1342 1342
 }
1343 1343
 
1344 1344
 /**
@@ -1347,19 +1347,19 @@  discard block
 block discarded – undo
1347 1347
  * @since 3.1.0
1348 1348
  */
1349 1349
 function wp_ajax_hidden_columns() {
1350
-	check_ajax_referer( 'screen-options-nonce', 'screenoptionnonce' );
1351
-	$page = isset( $_POST['page'] ) ? $_POST['page'] : '';
1350
+	check_ajax_referer('screen-options-nonce', 'screenoptionnonce');
1351
+	$page = isset($_POST['page']) ? $_POST['page'] : '';
1352 1352
 
1353
-	if ( $page != sanitize_key( $page ) )
1354
-		wp_die( 0 );
1353
+	if ($page != sanitize_key($page))
1354
+		wp_die(0);
1355 1355
 
1356
-	if ( ! $user = wp_get_current_user() )
1356
+	if ( ! $user = wp_get_current_user())
1357 1357
 		wp_die( -1 );
1358 1358
 
1359
-	$hidden = ! empty( $_POST['hidden'] ) ? explode( ',', $_POST['hidden'] ) : array();
1360
-	update_user_option( $user->ID, "manage{$page}columnshidden", $hidden, true );
1359
+	$hidden = ! empty($_POST['hidden']) ? explode(',', $_POST['hidden']) : array();
1360
+	update_user_option($user->ID, "manage{$page}columnshidden", $hidden, true);
1361 1361
 
1362
-	wp_die( 1 );
1362
+	wp_die(1);
1363 1363
 }
1364 1364
 
1365 1365
 /**
@@ -1368,14 +1368,14 @@  discard block
 block discarded – undo
1368 1368
  * @since 3.1.0
1369 1369
  */
1370 1370
 function wp_ajax_update_welcome_panel() {
1371
-	check_ajax_referer( 'welcome-panel-nonce', 'welcomepanelnonce' );
1371
+	check_ajax_referer('welcome-panel-nonce', 'welcomepanelnonce');
1372 1372
 
1373
-	if ( ! current_user_can( 'edit_theme_options' ) )
1373
+	if ( ! current_user_can('edit_theme_options'))
1374 1374
 		wp_die( -1 );
1375 1375
 
1376
-	update_user_meta( get_current_user_id(), 'show_welcome_panel', empty( $_POST['visible'] ) ? 0 : 1 );
1376
+	update_user_meta(get_current_user_id(), 'show_welcome_panel', empty($_POST['visible']) ? 0 : 1);
1377 1377
 
1378
-	wp_die( 1 );
1378
+	wp_die(1);
1379 1379
 }
1380 1380
 
1381 1381
 /**
@@ -1384,31 +1384,31 @@  discard block
 block discarded – undo
1384 1384
  * @since 3.1.0
1385 1385
  */
1386 1386
 function wp_ajax_menu_get_metabox() {
1387
-	if ( ! current_user_can( 'edit_theme_options' ) )
1387
+	if ( ! current_user_can('edit_theme_options'))
1388 1388
 		wp_die( -1 );
1389 1389
 
1390
-	require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
1390
+	require_once ABSPATH.'wp-admin/includes/nav-menu.php';
1391 1391
 
1392
-	if ( isset( $_POST['item-type'] ) && 'post_type' == $_POST['item-type'] ) {
1392
+	if (isset($_POST['item-type']) && 'post_type' == $_POST['item-type']) {
1393 1393
 		$type = 'posttype';
1394 1394
 		$callback = 'wp_nav_menu_item_post_type_meta_box';
1395
-		$items = (array) get_post_types( array( 'show_in_nav_menus' => true ), 'object' );
1396
-	} elseif ( isset( $_POST['item-type'] ) && 'taxonomy' == $_POST['item-type'] ) {
1395
+		$items = (array) get_post_types(array('show_in_nav_menus' => true), 'object');
1396
+	} elseif (isset($_POST['item-type']) && 'taxonomy' == $_POST['item-type']) {
1397 1397
 		$type = 'taxonomy';
1398 1398
 		$callback = 'wp_nav_menu_item_taxonomy_meta_box';
1399
-		$items = (array) get_taxonomies( array( 'show_ui' => true ), 'object' );
1399
+		$items = (array) get_taxonomies(array('show_ui' => true), 'object');
1400 1400
 	}
1401 1401
 
1402
-	if ( ! empty( $_POST['item-object'] ) && isset( $items[$_POST['item-object']] ) ) {
1403
-		$menus_meta_box_object = $items[ $_POST['item-object'] ];
1402
+	if ( ! empty($_POST['item-object']) && isset($items[$_POST['item-object']])) {
1403
+		$menus_meta_box_object = $items[$_POST['item-object']];
1404 1404
 
1405 1405
 		/** This filter is documented in wp-admin/includes/nav-menu.php */
1406
-		$item = apply_filters( 'nav_menu_meta_box_object', $menus_meta_box_object );
1406
+		$item = apply_filters('nav_menu_meta_box_object', $menus_meta_box_object);
1407 1407
 		ob_start();
1408 1408
 		call_user_func_array($callback, array(
1409 1409
 			null,
1410 1410
 			array(
1411
-				'id' => 'add-' . $item->name,
1411
+				'id' => 'add-'.$item->name,
1412 1412
 				'title' => $item->labels->name,
1413 1413
 				'callback' => $callback,
1414 1414
 				'args' => $item,
@@ -1418,7 +1418,7 @@  discard block
 block discarded – undo
1418 1418
 		$markup = ob_get_clean();
1419 1419
 
1420 1420
 		echo wp_json_encode(array(
1421
-			'replace-id' => $type . '-' . $item->name,
1421
+			'replace-id' => $type.'-'.$item->name,
1422 1422
 			'markup' => $markup,
1423 1423
 		));
1424 1424
 	}
@@ -1432,21 +1432,21 @@  discard block
 block discarded – undo
1432 1432
  * @since 3.1.0
1433 1433
  */
1434 1434
 function wp_ajax_wp_link_ajax() {
1435
-	check_ajax_referer( 'internal-linking', '_ajax_linking_nonce' );
1435
+	check_ajax_referer('internal-linking', '_ajax_linking_nonce');
1436 1436
 
1437 1437
 	$args = array();
1438 1438
 
1439
-	if ( isset( $_POST['search'] ) )
1440
-		$args['s'] = wp_unslash( $_POST['search'] );
1441
-	$args['pagenum'] = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
1439
+	if (isset($_POST['search']))
1440
+		$args['s'] = wp_unslash($_POST['search']);
1441
+	$args['pagenum'] = ! empty($_POST['page']) ? absint($_POST['page']) : 1;
1442 1442
 
1443
-	require(ABSPATH . WPINC . '/class-wp-editor.php');
1444
-	$results = _WP_Editors::wp_link_query( $args );
1443
+	require(ABSPATH.WPINC.'/class-wp-editor.php');
1444
+	$results = _WP_Editors::wp_link_query($args);
1445 1445
 
1446
-	if ( ! isset( $results ) )
1447
-		wp_die( 0 );
1446
+	if ( ! isset($results))
1447
+		wp_die(0);
1448 1448
 
1449
-	echo wp_json_encode( $results );
1449
+	echo wp_json_encode($results);
1450 1450
 	echo "\n";
1451 1451
 
1452 1452
 	wp_die();
@@ -1458,13 +1458,13 @@  discard block
 block discarded – undo
1458 1458
  * @since 3.1.0
1459 1459
  */
1460 1460
 function wp_ajax_menu_locations_save() {
1461
-	if ( ! current_user_can( 'edit_theme_options' ) )
1461
+	if ( ! current_user_can('edit_theme_options'))
1462 1462
 		wp_die( -1 );
1463
-	check_ajax_referer( 'add-menu_item', 'menu-settings-column-nonce' );
1464
-	if ( ! isset( $_POST['menu-locations'] ) )
1465
-		wp_die( 0 );
1466
-	set_theme_mod( 'nav_menu_locations', array_map( 'absint', $_POST['menu-locations'] ) );
1467
-	wp_die( 1 );
1463
+	check_ajax_referer('add-menu_item', 'menu-settings-column-nonce');
1464
+	if ( ! isset($_POST['menu-locations']))
1465
+		wp_die(0);
1466
+	set_theme_mod('nav_menu_locations', array_map('absint', $_POST['menu-locations']));
1467
+	wp_die(1);
1468 1468
 }
1469 1469
 
1470 1470
 /**
@@ -1473,28 +1473,28 @@  discard block
 block discarded – undo
1473 1473
  * @since 3.1.0
1474 1474
  */
1475 1475
 function wp_ajax_meta_box_order() {
1476
-	check_ajax_referer( 'meta-box-order' );
1477
-	$order = isset( $_POST['order'] ) ? (array) $_POST['order'] : false;
1478
-	$page_columns = isset( $_POST['page_columns'] ) ? $_POST['page_columns'] : 'auto';
1476
+	check_ajax_referer('meta-box-order');
1477
+	$order = isset($_POST['order']) ? (array) $_POST['order'] : false;
1478
+	$page_columns = isset($_POST['page_columns']) ? $_POST['page_columns'] : 'auto';
1479 1479
 
1480
-	if ( $page_columns != 'auto' )
1480
+	if ($page_columns != 'auto')
1481 1481
 		$page_columns = (int) $page_columns;
1482 1482
 
1483
-	$page = isset( $_POST['page'] ) ? $_POST['page'] : '';
1483
+	$page = isset($_POST['page']) ? $_POST['page'] : '';
1484 1484
 
1485
-	if ( $page != sanitize_key( $page ) )
1486
-		wp_die( 0 );
1485
+	if ($page != sanitize_key($page))
1486
+		wp_die(0);
1487 1487
 
1488
-	if ( ! $user = wp_get_current_user() )
1488
+	if ( ! $user = wp_get_current_user())
1489 1489
 		wp_die( -1 );
1490 1490
 
1491
-	if ( $order )
1491
+	if ($order)
1492 1492
 		update_user_option($user->ID, "meta-box-order_$page", $order, true);
1493 1493
 
1494
-	if ( $page_columns )
1494
+	if ($page_columns)
1495 1495
 		update_user_option($user->ID, "screen_layout_$page", $page_columns, true);
1496 1496
 
1497
-	wp_die( 1 );
1497
+	wp_die(1);
1498 1498
 }
1499 1499
 
1500 1500
 /**
@@ -1503,12 +1503,12 @@  discard block
 block discarded – undo
1503 1503
  * @since 3.1.0
1504 1504
  */
1505 1505
 function wp_ajax_menu_quick_search() {
1506
-	if ( ! current_user_can( 'edit_theme_options' ) )
1506
+	if ( ! current_user_can('edit_theme_options'))
1507 1507
 		wp_die( -1 );
1508 1508
 
1509
-	require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
1509
+	require_once ABSPATH.'wp-admin/includes/nav-menu.php';
1510 1510
 
1511
-	_wp_ajax_menu_quick_search( $_POST );
1511
+	_wp_ajax_menu_quick_search($_POST);
1512 1512
 
1513 1513
 	wp_die();
1514 1514
 }
@@ -1519,9 +1519,9 @@  discard block
 block discarded – undo
1519 1519
  * @since 3.1.0
1520 1520
  */
1521 1521
 function wp_ajax_get_permalink() {
1522
-	check_ajax_referer( 'getpermalink', 'getpermalinknonce' );
1523
-	$post_id = isset($_POST['post_id'])? intval($_POST['post_id']) : 0;
1524
-	wp_die( add_query_arg( array( 'preview' => 'true' ), get_permalink( $post_id ) ) );
1522
+	check_ajax_referer('getpermalink', 'getpermalinknonce');
1523
+	$post_id = isset($_POST['post_id']) ? intval($_POST['post_id']) : 0;
1524
+	wp_die(add_query_arg(array('preview' => 'true'), get_permalink($post_id)));
1525 1525
 }
1526 1526
 
1527 1527
 /**
@@ -1530,11 +1530,11 @@  discard block
 block discarded – undo
1530 1530
  * @since 3.1.0
1531 1531
  */
1532 1532
 function wp_ajax_sample_permalink() {
1533
-	check_ajax_referer( 'samplepermalink', 'samplepermalinknonce' );
1534
-	$post_id = isset($_POST['post_id'])? intval($_POST['post_id']) : 0;
1535
-	$title = isset($_POST['new_title'])? $_POST['new_title'] : '';
1536
-	$slug = isset($_POST['new_slug'])? $_POST['new_slug'] : null;
1537
-	wp_die( get_sample_permalink_html( $post_id, $title, $slug ) );
1533
+	check_ajax_referer('samplepermalink', 'samplepermalinknonce');
1534
+	$post_id = isset($_POST['post_id']) ? intval($_POST['post_id']) : 0;
1535
+	$title = isset($_POST['new_title']) ? $_POST['new_title'] : '';
1536
+	$slug = isset($_POST['new_slug']) ? $_POST['new_slug'] : null;
1537
+	wp_die(get_sample_permalink_html($post_id, $title, $slug));
1538 1538
 }
1539 1539
 
1540 1540
 /**
@@ -1547,29 +1547,29 @@  discard block
 block discarded – undo
1547 1547
 function wp_ajax_inline_save() {
1548 1548
 	global $wp_list_table;
1549 1549
 
1550
-	check_ajax_referer( 'inlineeditnonce', '_inline_edit' );
1550
+	check_ajax_referer('inlineeditnonce', '_inline_edit');
1551 1551
 
1552
-	if ( ! isset($_POST['post_ID']) || ! ( $post_ID = (int) $_POST['post_ID'] ) )
1552
+	if ( ! isset($_POST['post_ID']) || ! ($post_ID = (int) $_POST['post_ID']))
1553 1553
 		wp_die();
1554 1554
 
1555
-	if ( 'page' == $_POST['post_type'] ) {
1556
-		if ( ! current_user_can( 'edit_page', $post_ID ) )
1557
-			wp_die( __( 'You are not allowed to edit this page.' ) );
1555
+	if ('page' == $_POST['post_type']) {
1556
+		if ( ! current_user_can('edit_page', $post_ID))
1557
+			wp_die(__('You are not allowed to edit this page.'));
1558 1558
 	} else {
1559
-		if ( ! current_user_can( 'edit_post', $post_ID ) )
1560
-			wp_die( __( 'You are not allowed to edit this post.' ) );
1559
+		if ( ! current_user_can('edit_post', $post_ID))
1560
+			wp_die(__('You are not allowed to edit this post.'));
1561 1561
 	}
1562 1562
 
1563
-	if ( $last = wp_check_post_lock( $post_ID ) ) {
1564
-		$last_user = get_userdata( $last );
1565
-		$last_user_name = $last_user ? $last_user->display_name : __( 'Someone' );
1566
-		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 ) );
1563
+	if ($last = wp_check_post_lock($post_ID)) {
1564
+		$last_user = get_userdata($last);
1565
+		$last_user_name = $last_user ? $last_user->display_name : __('Someone');
1566
+		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));
1567 1567
 		wp_die();
1568 1568
 	}
1569 1569
 
1570 1570
 	$data = &$_POST;
1571 1571
 
1572
-	$post = get_post( $post_ID, ARRAY_A );
1572
+	$post = get_post($post_ID, ARRAY_A);
1573 1573
 
1574 1574
 	// Since it's coming from the database.
1575 1575
 	$post = wp_slash($post);
@@ -1580,55 +1580,55 @@  discard block
 block discarded – undo
1580 1580
 	// Rename.
1581 1581
 	$data['user_ID'] = get_current_user_id();
1582 1582
 
1583
-	if ( isset($data['post_parent']) )
1583
+	if (isset($data['post_parent']))
1584 1584
 		$data['parent_id'] = $data['post_parent'];
1585 1585
 
1586 1586
 	// Status.
1587
-	if ( isset( $data['keep_private'] ) && 'private' == $data['keep_private'] ) {
1587
+	if (isset($data['keep_private']) && 'private' == $data['keep_private']) {
1588 1588
 		$data['visibility']  = 'private';
1589 1589
 		$data['post_status'] = 'private';
1590 1590
 	} else {
1591 1591
 		$data['post_status'] = $data['_status'];
1592 1592
 	}
1593 1593
 
1594
-	if ( empty($data['comment_status']) )
1594
+	if (empty($data['comment_status']))
1595 1595
 		$data['comment_status'] = 'closed';
1596
-	if ( empty($data['ping_status']) )
1596
+	if (empty($data['ping_status']))
1597 1597
 		$data['ping_status'] = 'closed';
1598 1598
 
1599 1599
 	// Exclude terms from taxonomies that are not supposed to appear in Quick Edit.
1600
-	if ( ! empty( $data['tax_input'] ) ) {
1601
-		foreach ( $data['tax_input'] as $taxonomy => $terms ) {
1602
-			$tax_object = get_taxonomy( $taxonomy );
1600
+	if ( ! empty($data['tax_input'])) {
1601
+		foreach ($data['tax_input'] as $taxonomy => $terms) {
1602
+			$tax_object = get_taxonomy($taxonomy);
1603 1603
 			/** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */
1604
-			if ( ! apply_filters( 'quick_edit_show_taxonomy', $tax_object->show_in_quick_edit, $taxonomy, $post['post_type'] ) ) {
1605
-				unset( $data['tax_input'][ $taxonomy ] );
1604
+			if ( ! apply_filters('quick_edit_show_taxonomy', $tax_object->show_in_quick_edit, $taxonomy, $post['post_type'])) {
1605
+				unset($data['tax_input'][$taxonomy]);
1606 1606
 			}
1607 1607
 		}
1608 1608
 	}
1609 1609
 
1610 1610
 	// Hack: wp_unique_post_slug() doesn't work for drafts, so we will fake that our post is published.
1611
-	if ( ! empty( $data['post_name'] ) && in_array( $post['post_status'], array( 'draft', 'pending' ) ) ) {
1611
+	if ( ! empty($data['post_name']) && in_array($post['post_status'], array('draft', 'pending'))) {
1612 1612
 		$post['post_status'] = 'publish';
1613
-		$data['post_name'] = wp_unique_post_slug( $data['post_name'], $post['ID'], $post['post_status'], $post['post_type'], $post['post_parent'] );
1613
+		$data['post_name'] = wp_unique_post_slug($data['post_name'], $post['ID'], $post['post_status'], $post['post_type'], $post['post_parent']);
1614 1614
 	}
1615 1615
 
1616 1616
 	// Update the post.
1617 1617
 	edit_post();
1618 1618
 
1619
-	$wp_list_table = _get_list_table( 'WP_Posts_List_Table', array( 'screen' => $_POST['screen'] ) );
1619
+	$wp_list_table = _get_list_table('WP_Posts_List_Table', array('screen' => $_POST['screen']));
1620 1620
 
1621 1621
 	$level = 0;
1622
-	$request_post = array( get_post( $_POST['post_ID'] ) );
1622
+	$request_post = array(get_post($_POST['post_ID']));
1623 1623
 	$parent = $request_post[0]->post_parent;
1624 1624
 
1625
-	while ( $parent > 0 ) {
1626
-		$parent_post = get_post( $parent );
1625
+	while ($parent > 0) {
1626
+		$parent_post = get_post($parent);
1627 1627
 		$parent = $parent_post->post_parent;
1628 1628
 		$level++;
1629 1629
 	}
1630 1630
 
1631
-	$wp_list_table->display_rows( array( get_post( $_POST['post_ID'] ) ), $level );
1631
+	$wp_list_table->display_rows(array(get_post($_POST['post_ID'])), $level);
1632 1632
 
1633 1633
 	wp_die();
1634 1634
 }
@@ -1643,45 +1643,45 @@  discard block
 block discarded – undo
1643 1643
 function wp_ajax_inline_save_tax() {
1644 1644
 	global $wp_list_table;
1645 1645
 
1646
-	check_ajax_referer( 'taxinlineeditnonce', '_inline_edit' );
1646
+	check_ajax_referer('taxinlineeditnonce', '_inline_edit');
1647 1647
 
1648
-	$taxonomy = sanitize_key( $_POST['taxonomy'] );
1649
-	$tax = get_taxonomy( $taxonomy );
1650
-	if ( ! $tax )
1651
-		wp_die( 0 );
1648
+	$taxonomy = sanitize_key($_POST['taxonomy']);
1649
+	$tax = get_taxonomy($taxonomy);
1650
+	if ( ! $tax)
1651
+		wp_die(0);
1652 1652
 
1653
-	if ( ! current_user_can( $tax->cap->edit_terms ) )
1653
+	if ( ! current_user_can($tax->cap->edit_terms))
1654 1654
 		wp_die( -1 );
1655 1655
 
1656
-	$wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => 'edit-' . $taxonomy ) );
1656
+	$wp_list_table = _get_list_table('WP_Terms_List_Table', array('screen' => 'edit-'.$taxonomy));
1657 1657
 
1658
-	if ( ! isset($_POST['tax_ID']) || ! ( $id = (int) $_POST['tax_ID'] ) )
1658
+	if ( ! isset($_POST['tax_ID']) || ! ($id = (int) $_POST['tax_ID']))
1659 1659
 		wp_die( -1 );
1660 1660
 
1661
-	$tag = get_term( $id, $taxonomy );
1661
+	$tag = get_term($id, $taxonomy);
1662 1662
 	$_POST['description'] = $tag->description;
1663 1663
 
1664 1664
 	$updated = wp_update_term($id, $taxonomy, $_POST);
1665
-	if ( $updated && !is_wp_error($updated) ) {
1666
-		$tag = get_term( $updated['term_id'], $taxonomy );
1667
-		if ( !$tag || is_wp_error( $tag ) ) {
1668
-			if ( is_wp_error($tag) && $tag->get_error_message() )
1669
-				wp_die( $tag->get_error_message() );
1670
-			wp_die( __( 'Item not updated.' ) );
1665
+	if ($updated && ! is_wp_error($updated)) {
1666
+		$tag = get_term($updated['term_id'], $taxonomy);
1667
+		if ( ! $tag || is_wp_error($tag)) {
1668
+			if (is_wp_error($tag) && $tag->get_error_message())
1669
+				wp_die($tag->get_error_message());
1670
+			wp_die(__('Item not updated.'));
1671 1671
 		}
1672 1672
 	} else {
1673
-		if ( is_wp_error($updated) && $updated->get_error_message() )
1674
-			wp_die( $updated->get_error_message() );
1675
-		wp_die( __( 'Item not updated.' ) );
1673
+		if (is_wp_error($updated) && $updated->get_error_message())
1674
+			wp_die($updated->get_error_message());
1675
+		wp_die(__('Item not updated.'));
1676 1676
 	}
1677 1677
 	$level = 0;
1678 1678
 	$parent = $tag->parent;
1679
-	while ( $parent > 0 ) {
1680
-		$parent_tag = get_term( $parent, $taxonomy );
1679
+	while ($parent > 0) {
1680
+		$parent_tag = get_term($parent, $taxonomy);
1681 1681
 		$parent = $parent_tag->parent;
1682 1682
 		$level++;
1683 1683
 	}
1684
-	$wp_list_table->single_row( $tag, $level );
1684
+	$wp_list_table->single_row($tag, $level);
1685 1685
 	wp_die();
1686 1686
 }
1687 1687
 
@@ -1693,33 +1693,33 @@  discard block
 block discarded – undo
1693 1693
  * @since 3.1.0
1694 1694
  */
1695 1695
 function wp_ajax_find_posts() {
1696
-	check_ajax_referer( 'find-posts' );
1696
+	check_ajax_referer('find-posts');
1697 1697
 
1698
-	$post_types = get_post_types( array( 'public' => true ), 'objects' );
1699
-	unset( $post_types['attachment'] );
1698
+	$post_types = get_post_types(array('public' => true), 'objects');
1699
+	unset($post_types['attachment']);
1700 1700
 
1701
-	$s = wp_unslash( $_POST['ps'] );
1701
+	$s = wp_unslash($_POST['ps']);
1702 1702
 	$args = array(
1703
-		'post_type' => array_keys( $post_types ),
1703
+		'post_type' => array_keys($post_types),
1704 1704
 		'post_status' => 'any',
1705 1705
 		'posts_per_page' => 50,
1706 1706
 	);
1707
-	if ( '' !== $s )
1707
+	if ('' !== $s)
1708 1708
 		$args['s'] = $s;
1709 1709
 
1710
-	$posts = get_posts( $args );
1710
+	$posts = get_posts($args);
1711 1711
 
1712
-	if ( ! $posts ) {
1713
-		wp_send_json_error( __( 'No items found.' ) );
1712
+	if ( ! $posts) {
1713
+		wp_send_json_error(__('No items found.'));
1714 1714
 	}
1715 1715
 
1716 1716
 	$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>';
1717 1717
 	$alt = '';
1718
-	foreach ( $posts as $post ) {
1719
-		$title = trim( $post->post_title ) ? $post->post_title : __( '(no title)' );
1720
-		$alt = ( 'alternate' == $alt ) ? '' : 'alternate';
1718
+	foreach ($posts as $post) {
1719
+		$title = trim($post->post_title) ? $post->post_title : __('(no title)');
1720
+		$alt = ('alternate' == $alt) ? '' : 'alternate';
1721 1721
 
1722
-		switch ( $post->post_status ) {
1722
+		switch ($post->post_status) {
1723 1723
 			case 'publish' :
1724 1724
 			case 'private' :
1725 1725
 				$stat = __('Published');
@@ -1735,20 +1735,20 @@  discard block
 block discarded – undo
1735 1735
 				break;
1736 1736
 		}
1737 1737
 
1738
-		if ( '0000-00-00 00:00:00' == $post->post_date ) {
1738
+		if ('0000-00-00 00:00:00' == $post->post_date) {
1739 1739
 			$time = '';
1740 1740
 		} else {
1741 1741
 			/* translators: date format in table columns, see http://php.net/date */
1742 1742
 			$time = mysql2date(__('Y/m/d'), $post->post_date);
1743 1743
 		}
1744 1744
 
1745
-		$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>';
1746
-		$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";
1745
+		$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>';
1746
+		$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";
1747 1747
 	}
1748 1748
 
1749 1749
 	$html .= '</tbody></table>';
1750 1750
 
1751
-	wp_send_json_success( $html );
1751
+	wp_send_json_success($html);
1752 1752
 }
1753 1753
 
1754 1754
 /**
@@ -1757,22 +1757,22 @@  discard block
 block discarded – undo
1757 1757
  * @since 3.1.0
1758 1758
  */
1759 1759
 function wp_ajax_widgets_order() {
1760
-	check_ajax_referer( 'save-sidebar-widgets', 'savewidgets' );
1760
+	check_ajax_referer('save-sidebar-widgets', 'savewidgets');
1761 1761
 
1762
-	if ( !current_user_can('edit_theme_options') )
1762
+	if ( ! current_user_can('edit_theme_options'))
1763 1763
 		wp_die( -1 );
1764 1764
 
1765
-	unset( $_POST['savewidgets'], $_POST['action'] );
1765
+	unset($_POST['savewidgets'], $_POST['action']);
1766 1766
 
1767 1767
 	// Save widgets order for all sidebars.
1768
-	if ( is_array($_POST['sidebars']) ) {
1768
+	if (is_array($_POST['sidebars'])) {
1769 1769
 		$sidebars = array();
1770
-		foreach ( $_POST['sidebars'] as $key => $val ) {
1770
+		foreach ($_POST['sidebars'] as $key => $val) {
1771 1771
 			$sb = array();
1772
-			if ( !empty($val) ) {
1772
+			if ( ! empty($val)) {
1773 1773
 				$val = explode(',', $val);
1774
-				foreach ( $val as $k => $v ) {
1775
-					if ( strpos($v, 'widget-') === false )
1774
+				foreach ($val as $k => $v) {
1775
+					if (strpos($v, 'widget-') === false)
1776 1776
 						continue;
1777 1777
 
1778 1778
 					$sb[$k] = substr($v, strpos($v, '_') + 1);
@@ -1781,7 +1781,7 @@  discard block
 block discarded – undo
1781 1781
 			$sidebars[$key] = $sb;
1782 1782
 		}
1783 1783
 		wp_set_sidebars_widgets($sidebars);
1784
-		wp_die( 1 );
1784
+		wp_die(1);
1785 1785
 	}
1786 1786
 
1787 1787
 	wp_die( -1 );
@@ -1799,83 +1799,83 @@  discard block
 block discarded – undo
1799 1799
 function wp_ajax_save_widget() {
1800 1800
 	global $wp_registered_widgets, $wp_registered_widget_controls, $wp_registered_widget_updates;
1801 1801
 
1802
-	check_ajax_referer( 'save-sidebar-widgets', 'savewidgets' );
1802
+	check_ajax_referer('save-sidebar-widgets', 'savewidgets');
1803 1803
 
1804
-	if ( !current_user_can('edit_theme_options') || !isset($_POST['id_base']) )
1804
+	if ( ! current_user_can('edit_theme_options') || ! isset($_POST['id_base']))
1805 1805
 		wp_die( -1 );
1806 1806
 
1807
-	unset( $_POST['savewidgets'], $_POST['action'] );
1807
+	unset($_POST['savewidgets'], $_POST['action']);
1808 1808
 
1809 1809
 	/**
1810 1810
 	 * Fires early when editing the widgets displayed in sidebars.
1811 1811
 	 *
1812 1812
 	 * @since 2.8.0
1813 1813
 	 */
1814
-	do_action( 'load-widgets.php' );
1814
+	do_action('load-widgets.php');
1815 1815
 
1816 1816
 	/**
1817 1817
 	 * Fires early when editing the widgets displayed in sidebars.
1818 1818
 	 *
1819 1819
 	 * @since 2.8.0
1820 1820
 	 */
1821
-	do_action( 'widgets.php' );
1821
+	do_action('widgets.php');
1822 1822
 
1823 1823
 	/** This action is documented in wp-admin/widgets.php */
1824
-	do_action( 'sidebar_admin_setup' );
1824
+	do_action('sidebar_admin_setup');
1825 1825
 
1826 1826
 	$id_base = $_POST['id_base'];
1827 1827
 	$widget_id = $_POST['widget-id'];
1828 1828
 	$sidebar_id = $_POST['sidebar'];
1829
-	$multi_number = !empty($_POST['multi_number']) ? (int) $_POST['multi_number'] : 0;
1830
-	$settings = isset($_POST['widget-' . $id_base]) && is_array($_POST['widget-' . $id_base]) ? $_POST['widget-' . $id_base] : false;
1831
-	$error = '<p>' . __('An error has occurred. Please reload the page and try again.') . '</p>';
1829
+	$multi_number = ! empty($_POST['multi_number']) ? (int) $_POST['multi_number'] : 0;
1830
+	$settings = isset($_POST['widget-'.$id_base]) && is_array($_POST['widget-'.$id_base]) ? $_POST['widget-'.$id_base] : false;
1831
+	$error = '<p>'.__('An error has occurred. Please reload the page and try again.').'</p>';
1832 1832
 
1833 1833
 	$sidebars = wp_get_sidebars_widgets();
1834 1834
 	$sidebar = isset($sidebars[$sidebar_id]) ? $sidebars[$sidebar_id] : array();
1835 1835
 
1836 1836
 	// Delete.
1837
-	if ( isset($_POST['delete_widget']) && $_POST['delete_widget'] ) {
1837
+	if (isset($_POST['delete_widget']) && $_POST['delete_widget']) {
1838 1838
 
1839
-		if ( !isset($wp_registered_widgets[$widget_id]) )
1840
-			wp_die( $error );
1839
+		if ( ! isset($wp_registered_widgets[$widget_id]))
1840
+			wp_die($error);
1841 1841
 
1842
-		$sidebar = array_diff( $sidebar, array($widget_id) );
1843
-		$_POST = array('sidebar' => $sidebar_id, 'widget-' . $id_base => array(), 'the-widget-id' => $widget_id, 'delete_widget' => '1');
1844
-	} elseif ( $settings && preg_match( '/__i__|%i%/', key($settings) ) ) {
1845
-		if ( !$multi_number )
1846
-			wp_die( $error );
1842
+		$sidebar = array_diff($sidebar, array($widget_id));
1843
+		$_POST = array('sidebar' => $sidebar_id, 'widget-'.$id_base => array(), 'the-widget-id' => $widget_id, 'delete_widget' => '1');
1844
+	} elseif ($settings && preg_match('/__i__|%i%/', key($settings))) {
1845
+		if ( ! $multi_number)
1846
+			wp_die($error);
1847 1847
 
1848
-		$_POST[ 'widget-' . $id_base ] = array( $multi_number => reset( $settings ) );
1849
-		$widget_id = $id_base . '-' . $multi_number;
1848
+		$_POST['widget-'.$id_base] = array($multi_number => reset($settings));
1849
+		$widget_id = $id_base.'-'.$multi_number;
1850 1850
 		$sidebar[] = $widget_id;
1851 1851
 	}
1852 1852
 	$_POST['widget-id'] = $sidebar;
1853 1853
 
1854
-	foreach ( (array) $wp_registered_widget_updates as $name => $control ) {
1854
+	foreach ((array) $wp_registered_widget_updates as $name => $control) {
1855 1855
 
1856
-		if ( $name == $id_base ) {
1857
-			if ( !is_callable( $control['callback'] ) )
1856
+		if ($name == $id_base) {
1857
+			if ( ! is_callable($control['callback']))
1858 1858
 				continue;
1859 1859
 
1860 1860
 			ob_start();
1861
-				call_user_func_array( $control['callback'], $control['params'] );
1861
+				call_user_func_array($control['callback'], $control['params']);
1862 1862
 			ob_end_clean();
1863 1863
 			break;
1864 1864
 		}
1865 1865
 	}
1866 1866
 
1867
-	if ( isset($_POST['delete_widget']) && $_POST['delete_widget'] ) {
1867
+	if (isset($_POST['delete_widget']) && $_POST['delete_widget']) {
1868 1868
 		$sidebars[$sidebar_id] = $sidebar;
1869 1869
 		wp_set_sidebars_widgets($sidebars);
1870 1870
 		echo "deleted:$widget_id";
1871 1871
 		wp_die();
1872 1872
 	}
1873 1873
 
1874
-	if ( !empty($_POST['add_new']) )
1874
+	if ( ! empty($_POST['add_new']))
1875 1875
 		wp_die();
1876 1876
 
1877
-	if ( $form = $wp_registered_widget_controls[$widget_id] )
1878
-		call_user_func_array( $form['callback'], $form['params'] );
1877
+	if ($form = $wp_registered_widget_controls[$widget_id])
1878
+		call_user_func_array($form['callback'], $form['params']);
1879 1879
 
1880 1880
 	wp_die();
1881 1881
 }
@@ -1898,35 +1898,35 @@  discard block
 block discarded – undo
1898 1898
  * @since 3.3.0
1899 1899
  */
1900 1900
 function wp_ajax_upload_attachment() {
1901
-	check_ajax_referer( 'media-form' );
1901
+	check_ajax_referer('media-form');
1902 1902
 	/*
1903 1903
 	 * This function does not use wp_send_json_success() / wp_send_json_error()
1904 1904
 	 * as the html4 Plupload handler requires a text/html content-type for older IE.
1905 1905
 	 * See https://core.trac.wordpress.org/ticket/31037
1906 1906
 	 */
1907 1907
 
1908
-	if ( ! current_user_can( 'upload_files' ) ) {
1909
-		echo wp_json_encode( array(
1908
+	if ( ! current_user_can('upload_files')) {
1909
+		echo wp_json_encode(array(
1910 1910
 			'success' => false,
1911 1911
 			'data'    => array(
1912
-				'message'  => __( "You don't have permission to upload files." ),
1912
+				'message'  => __("You don't have permission to upload files."),
1913 1913
 				'filename' => $_FILES['async-upload']['name'],
1914 1914
 			)
1915
-		) );
1915
+		));
1916 1916
 
1917 1917
 		wp_die();
1918 1918
 	}
1919 1919
 
1920
-	if ( isset( $_REQUEST['post_id'] ) ) {
1920
+	if (isset($_REQUEST['post_id'])) {
1921 1921
 		$post_id = $_REQUEST['post_id'];
1922
-		if ( ! current_user_can( 'edit_post', $post_id ) ) {
1923
-			echo wp_json_encode( array(
1922
+		if ( ! current_user_can('edit_post', $post_id)) {
1923
+			echo wp_json_encode(array(
1924 1924
 				'success' => false,
1925 1925
 				'data'    => array(
1926
-					'message'  => __( "You don't have permission to attach files to this post." ),
1926
+					'message'  => __("You don't have permission to attach files to this post."),
1927 1927
 					'filename' => $_FILES['async-upload']['name'],
1928 1928
 				)
1929
-			) );
1929
+			));
1930 1930
 
1931 1931
 			wp_die();
1932 1932
 		}
@@ -1934,53 +1934,53 @@  discard block
 block discarded – undo
1934 1934
 		$post_id = null;
1935 1935
 	}
1936 1936
 
1937
-	$post_data = isset( $_REQUEST['post_data'] ) ? $_REQUEST['post_data'] : array();
1937
+	$post_data = isset($_REQUEST['post_data']) ? $_REQUEST['post_data'] : array();
1938 1938
 
1939 1939
 	// If the context is custom header or background, make sure the uploaded file is an image.
1940
-	if ( isset( $post_data['context'] ) && in_array( $post_data['context'], array( 'custom-header', 'custom-background' ) ) ) {
1941
-		$wp_filetype = wp_check_filetype_and_ext( $_FILES['async-upload']['tmp_name'], $_FILES['async-upload']['name'] );
1942
-		if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) ) {
1943
-			echo wp_json_encode( array(
1940
+	if (isset($post_data['context']) && in_array($post_data['context'], array('custom-header', 'custom-background'))) {
1941
+		$wp_filetype = wp_check_filetype_and_ext($_FILES['async-upload']['tmp_name'], $_FILES['async-upload']['name']);
1942
+		if ( ! wp_match_mime_types('image', $wp_filetype['type'])) {
1943
+			echo wp_json_encode(array(
1944 1944
 				'success' => false,
1945 1945
 				'data'    => array(
1946
-					'message'  => __( 'The uploaded file is not a valid image. Please try again.' ),
1946
+					'message'  => __('The uploaded file is not a valid image. Please try again.'),
1947 1947
 					'filename' => $_FILES['async-upload']['name'],
1948 1948
 				)
1949
-			) );
1949
+			));
1950 1950
 
1951 1951
 			wp_die();
1952 1952
 		}
1953 1953
 	}
1954 1954
 
1955
-	$attachment_id = media_handle_upload( 'async-upload', $post_id, $post_data );
1955
+	$attachment_id = media_handle_upload('async-upload', $post_id, $post_data);
1956 1956
 
1957
-	if ( is_wp_error( $attachment_id ) ) {
1958
-		echo wp_json_encode( array(
1957
+	if (is_wp_error($attachment_id)) {
1958
+		echo wp_json_encode(array(
1959 1959
 			'success' => false,
1960 1960
 			'data'    => array(
1961 1961
 				'message'  => $attachment_id->get_error_message(),
1962 1962
 				'filename' => $_FILES['async-upload']['name'],
1963 1963
 			)
1964
-		) );
1964
+		));
1965 1965
 
1966 1966
 		wp_die();
1967 1967
 	}
1968 1968
 
1969
-	if ( isset( $post_data['context'] ) && isset( $post_data['theme'] ) ) {
1970
-		if ( 'custom-background' === $post_data['context'] )
1971
-			update_post_meta( $attachment_id, '_wp_attachment_is_custom_background', $post_data['theme'] );
1969
+	if (isset($post_data['context']) && isset($post_data['theme'])) {
1970
+		if ('custom-background' === $post_data['context'])
1971
+			update_post_meta($attachment_id, '_wp_attachment_is_custom_background', $post_data['theme']);
1972 1972
 
1973
-		if ( 'custom-header' === $post_data['context'] )
1974
-			update_post_meta( $attachment_id, '_wp_attachment_is_custom_header', $post_data['theme'] );
1973
+		if ('custom-header' === $post_data['context'])
1974
+			update_post_meta($attachment_id, '_wp_attachment_is_custom_header', $post_data['theme']);
1975 1975
 	}
1976 1976
 
1977
-	if ( ! $attachment = wp_prepare_attachment_for_js( $attachment_id ) )
1977
+	if ( ! $attachment = wp_prepare_attachment_for_js($attachment_id))
1978 1978
 		wp_die();
1979 1979
 
1980
-	echo wp_json_encode( array(
1980
+	echo wp_json_encode(array(
1981 1981
 		'success' => true,
1982 1982
 		'data'    => $attachment,
1983
-	) );
1983
+	));
1984 1984
 
1985 1985
 	wp_die();
1986 1986
 }
@@ -1992,18 +1992,18 @@  discard block
 block discarded – undo
1992 1992
  */
1993 1993
 function wp_ajax_image_editor() {
1994 1994
 	$attachment_id = intval($_POST['postid']);
1995
-	if ( empty($attachment_id) || !current_user_can('edit_post', $attachment_id) )
1995
+	if (empty($attachment_id) || ! current_user_can('edit_post', $attachment_id))
1996 1996
 		wp_die( -1 );
1997 1997
 
1998
-	check_ajax_referer( "image_editor-$attachment_id" );
1999
-	include_once( ABSPATH . 'wp-admin/includes/image-edit.php' );
1998
+	check_ajax_referer("image_editor-$attachment_id");
1999
+	include_once(ABSPATH.'wp-admin/includes/image-edit.php');
2000 2000
 
2001 2001
 	$msg = false;
2002
-	switch ( $_POST['do'] ) {
2002
+	switch ($_POST['do']) {
2003 2003
 		case 'save' :
2004 2004
 			$msg = wp_save_image($attachment_id);
2005 2005
 			$msg = wp_json_encode($msg);
2006
-			wp_die( $msg );
2006
+			wp_die($msg);
2007 2007
 			break;
2008 2008
 		case 'scale' :
2009 2009
 			$msg = wp_save_image($attachment_id);
@@ -2023,34 +2023,34 @@  discard block
 block discarded – undo
2023 2023
  * @since 3.1.0
2024 2024
  */
2025 2025
 function wp_ajax_set_post_thumbnail() {
2026
-	$json = ! empty( $_REQUEST['json'] ); // New-style request
2026
+	$json = ! empty($_REQUEST['json']); // New-style request
2027 2027
 
2028
-	$post_ID = intval( $_POST['post_id'] );
2029
-	if ( ! current_user_can( 'edit_post', $post_ID ) )
2028
+	$post_ID = intval($_POST['post_id']);
2029
+	if ( ! current_user_can('edit_post', $post_ID))
2030 2030
 		wp_die( -1 );
2031 2031
 
2032
-	$thumbnail_id = intval( $_POST['thumbnail_id'] );
2032
+	$thumbnail_id = intval($_POST['thumbnail_id']);
2033 2033
 
2034
-	if ( $json )
2035
-		check_ajax_referer( "update-post_$post_ID" );
2034
+	if ($json)
2035
+		check_ajax_referer("update-post_$post_ID");
2036 2036
 	else
2037
-		check_ajax_referer( "set_post_thumbnail-$post_ID" );
2037
+		check_ajax_referer("set_post_thumbnail-$post_ID");
2038 2038
 
2039
-	if ( $thumbnail_id == '-1' ) {
2040
-		if ( delete_post_thumbnail( $post_ID ) ) {
2041
-			$return = _wp_post_thumbnail_html( null, $post_ID );
2042
-			$json ? wp_send_json_success( $return ) : wp_die( $return );
2039
+	if ($thumbnail_id == '-1') {
2040
+		if (delete_post_thumbnail($post_ID)) {
2041
+			$return = _wp_post_thumbnail_html(null, $post_ID);
2042
+			$json ? wp_send_json_success($return) : wp_die($return);
2043 2043
 		} else {
2044
-			wp_die( 0 );
2044
+			wp_die(0);
2045 2045
 		}
2046 2046
 	}
2047 2047
 
2048
-	if ( set_post_thumbnail( $post_ID, $thumbnail_id ) ) {
2049
-		$return = _wp_post_thumbnail_html( $thumbnail_id, $post_ID );
2050
-		$json ? wp_send_json_success( $return ) : wp_die( $return );
2048
+	if (set_post_thumbnail($post_ID, $thumbnail_id)) {
2049
+		$return = _wp_post_thumbnail_html($thumbnail_id, $post_ID);
2050
+		$json ? wp_send_json_success($return) : wp_die($return);
2051 2051
 	}
2052 2052
 
2053
-	wp_die( 0 );
2053
+	wp_die(0);
2054 2054
 }
2055 2055
 
2056 2056
 /**
@@ -2061,41 +2061,41 @@  discard block
 block discarded – undo
2061 2061
  * @see set_post_thumbnail()
2062 2062
  */
2063 2063
 function wp_ajax_set_attachment_thumbnail() {
2064
-	if ( empty( $_POST['urls'] ) || ! is_array( $_POST['urls'] ) ) {
2064
+	if (empty($_POST['urls']) || ! is_array($_POST['urls'])) {
2065 2065
 		wp_send_json_error();
2066 2066
 	}
2067 2067
 
2068 2068
 	$thumbnail_id = (int) $_POST['thumbnail_id'];
2069
-	if ( empty( $thumbnail_id ) ) {
2069
+	if (empty($thumbnail_id)) {
2070 2070
 		wp_send_json_error();
2071 2071
 	}
2072 2072
 
2073 2073
 	$post_ids = array();
2074 2074
 	// For each URL, try to find its corresponding post ID.
2075
-	foreach ( $_POST['urls'] as $url ) {
2076
-		$post_id = attachment_url_to_postid( $url );
2077
-		if ( ! empty( $post_id ) ) {
2075
+	foreach ($_POST['urls'] as $url) {
2076
+		$post_id = attachment_url_to_postid($url);
2077
+		if ( ! empty($post_id)) {
2078 2078
 			$post_ids[] = $post_id;
2079 2079
 		}
2080 2080
 	}
2081 2081
 
2082
-	if ( empty( $post_ids ) ) {
2082
+	if (empty($post_ids)) {
2083 2083
 		wp_send_json_error();
2084 2084
 	}
2085 2085
 
2086 2086
 	$success = 0;
2087 2087
 	// For each found attachment, set its thumbnail.
2088
-	foreach ( $post_ids as $post_id ) {
2089
-		if ( ! current_user_can( 'edit_post', $post_id ) ) {
2088
+	foreach ($post_ids as $post_id) {
2089
+		if ( ! current_user_can('edit_post', $post_id)) {
2090 2090
 			continue;
2091 2091
 		}
2092 2092
 
2093
-		if ( set_post_thumbnail( $post_id, $thumbnail_id ) ) {
2093
+		if (set_post_thumbnail($post_id, $thumbnail_id)) {
2094 2094
 			$success++;
2095 2095
 		}
2096 2096
 	}
2097 2097
 
2098
-	if ( 0 === $success ) {
2098
+	if (0 === $success) {
2099 2099
 		wp_send_json_error();
2100 2100
 	} else {
2101 2101
 		wp_send_json_success();
@@ -2110,7 +2110,7 @@  discard block
 block discarded – undo
2110 2110
  * @since 3.1.0
2111 2111
  */
2112 2112
 function wp_ajax_date_format() {
2113
-	wp_die( date_i18n( sanitize_option( 'date_format', wp_unslash( $_POST['date'] ) ) ) );
2113
+	wp_die(date_i18n(sanitize_option('date_format', wp_unslash($_POST['date']))));
2114 2114
 }
2115 2115
 
2116 2116
 /**
@@ -2119,7 +2119,7 @@  discard block
 block discarded – undo
2119 2119
  * @since 3.1.0
2120 2120
  */
2121 2121
 function wp_ajax_time_format() {
2122
-	wp_die( date_i18n( sanitize_option( 'time_format', wp_unslash( $_POST['date'] ) ) ) );
2122
+	wp_die(date_i18n(sanitize_option('time_format', wp_unslash($_POST['date']))));
2123 2123
 }
2124 2124
 
2125 2125
 /**
@@ -2129,37 +2129,37 @@  discard block
 block discarded – undo
2129 2129
  * @deprecated 4.3.0
2130 2130
  */
2131 2131
 function wp_ajax_wp_fullscreen_save_post() {
2132
-	$post_id = isset( $_POST['post_ID'] ) ? (int) $_POST['post_ID'] : 0;
2132
+	$post_id = isset($_POST['post_ID']) ? (int) $_POST['post_ID'] : 0;
2133 2133
 
2134 2134
 	$post = null;
2135 2135
 
2136
-	if ( $post_id )
2137
-		$post = get_post( $post_id );
2136
+	if ($post_id)
2137
+		$post = get_post($post_id);
2138 2138
 
2139
-	check_ajax_referer('update-post_' . $post_id, '_wpnonce');
2139
+	check_ajax_referer('update-post_'.$post_id, '_wpnonce');
2140 2140
 
2141 2141
 	$post_id = edit_post();
2142 2142
 
2143
-	if ( is_wp_error( $post_id ) ) {
2143
+	if (is_wp_error($post_id)) {
2144 2144
 		wp_send_json_error();
2145 2145
 	}
2146 2146
 
2147
-	if ( $post ) {
2148
-		$last_date = mysql2date( get_option('date_format'), $post->post_modified );
2149
-		$last_time = mysql2date( get_option('time_format'), $post->post_modified );
2147
+	if ($post) {
2148
+		$last_date = mysql2date(get_option('date_format'), $post->post_modified);
2149
+		$last_time = mysql2date(get_option('time_format'), $post->post_modified);
2150 2150
 	} else {
2151
-		$last_date = date_i18n( get_option('date_format') );
2152
-		$last_time = date_i18n( get_option('time_format') );
2151
+		$last_date = date_i18n(get_option('date_format'));
2152
+		$last_time = date_i18n(get_option('time_format'));
2153 2153
 	}
2154 2154
 
2155
-	if ( $last_id = get_post_meta( $post_id, '_edit_last', true ) ) {
2156
-		$last_user = get_userdata( $last_id );
2157
-		$last_edited = sprintf( __('Last edited by %1$s on %2$s at %3$s'), esc_html( $last_user->display_name ), $last_date, $last_time );
2155
+	if ($last_id = get_post_meta($post_id, '_edit_last', true)) {
2156
+		$last_user = get_userdata($last_id);
2157
+		$last_edited = sprintf(__('Last edited by %1$s on %2$s at %3$s'), esc_html($last_user->display_name), $last_date, $last_time);
2158 2158
 	} else {
2159
-		$last_edited = sprintf( __('Last edited on %1$s at %2$s'), $last_date, $last_time );
2159
+		$last_edited = sprintf(__('Last edited on %1$s at %2$s'), $last_date, $last_time);
2160 2160
 	}
2161 2161
 
2162
-	wp_send_json_success( array( 'last_edited' => $last_edited ) );
2162
+	wp_send_json_success(array('last_edited' => $last_edited));
2163 2163
 }
2164 2164
 
2165 2165
 /**
@@ -2168,20 +2168,20 @@  discard block
 block discarded – undo
2168 2168
  * @since 3.1.0
2169 2169
  */
2170 2170
 function wp_ajax_wp_remove_post_lock() {
2171
-	if ( empty( $_POST['post_ID'] ) || empty( $_POST['active_post_lock'] ) )
2172
-		wp_die( 0 );
2171
+	if (empty($_POST['post_ID']) || empty($_POST['active_post_lock']))
2172
+		wp_die(0);
2173 2173
 	$post_id = (int) $_POST['post_ID'];
2174
-	if ( ! $post = get_post( $post_id ) )
2175
-		wp_die( 0 );
2174
+	if ( ! $post = get_post($post_id))
2175
+		wp_die(0);
2176 2176
 
2177
-	check_ajax_referer( 'update-post_' . $post_id );
2177
+	check_ajax_referer('update-post_'.$post_id);
2178 2178
 
2179
-	if ( ! current_user_can( 'edit_post', $post_id ) )
2179
+	if ( ! current_user_can('edit_post', $post_id))
2180 2180
 		wp_die( -1 );
2181 2181
 
2182
-	$active_lock = array_map( 'absint', explode( ':', $_POST['active_post_lock'] ) );
2183
-	if ( $active_lock[1] != get_current_user_id() )
2184
-		wp_die( 0 );
2182
+	$active_lock = array_map('absint', explode(':', $_POST['active_post_lock']));
2183
+	if ($active_lock[1] != get_current_user_id())
2184
+		wp_die(0);
2185 2185
 
2186 2186
 	/**
2187 2187
 	 * Filter the post lock window duration.
@@ -2191,9 +2191,9 @@  discard block
 block discarded – undo
2191 2191
 	 * @param int $interval The interval in seconds the post lock duration
2192 2192
 	 *                      should last, plus 5 seconds. Default 150.
2193 2193
 	 */
2194
-	$new_lock = ( time() - apply_filters( 'wp_check_post_lock_window', 150 ) + 5 ) . ':' . $active_lock[1];
2195
-	update_post_meta( $post_id, '_edit_lock', $new_lock, implode( ':', $active_lock ) );
2196
-	wp_die( 1 );
2194
+	$new_lock = (time() - apply_filters('wp_check_post_lock_window', 150) + 5).':'.$active_lock[1];
2195
+	update_post_meta($post_id, '_edit_lock', $new_lock, implode(':', $active_lock));
2196
+	wp_die(1);
2197 2197
 }
2198 2198
 
2199 2199
 /**
@@ -2203,21 +2203,21 @@  discard block
 block discarded – undo
2203 2203
  */
2204 2204
 function wp_ajax_dismiss_wp_pointer() {
2205 2205
 	$pointer = $_POST['pointer'];
2206
-	if ( $pointer != sanitize_key( $pointer ) )
2207
-		wp_die( 0 );
2206
+	if ($pointer != sanitize_key($pointer))
2207
+		wp_die(0);
2208 2208
 
2209 2209
 //	check_ajax_referer( 'dismiss-pointer_' . $pointer );
2210 2210
 
2211
-	$dismissed = array_filter( explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ) );
2211
+	$dismissed = array_filter(explode(',', (string) get_user_meta(get_current_user_id(), 'dismissed_wp_pointers', true)));
2212 2212
 
2213
-	if ( in_array( $pointer, $dismissed ) )
2214
-		wp_die( 0 );
2213
+	if (in_array($pointer, $dismissed))
2214
+		wp_die(0);
2215 2215
 
2216 2216
 	$dismissed[] = $pointer;
2217
-	$dismissed = implode( ',', $dismissed );
2217
+	$dismissed = implode(',', $dismissed);
2218 2218
 
2219
-	update_user_meta( get_current_user_id(), 'dismissed_wp_pointers', $dismissed );
2220
-	wp_die( 1 );
2219
+	update_user_meta(get_current_user_id(), 'dismissed_wp_pointers', $dismissed);
2220
+	wp_die(1);
2221 2221
 }
2222 2222
 
2223 2223
 /**
@@ -2226,25 +2226,25 @@  discard block
 block discarded – undo
2226 2226
  * @since 3.5.0
2227 2227
  */
2228 2228
 function wp_ajax_get_attachment() {
2229
-	if ( ! isset( $_REQUEST['id'] ) )
2229
+	if ( ! isset($_REQUEST['id']))
2230 2230
 		wp_send_json_error();
2231 2231
 
2232
-	if ( ! $id = absint( $_REQUEST['id'] ) )
2232
+	if ( ! $id = absint($_REQUEST['id']))
2233 2233
 		wp_send_json_error();
2234 2234
 
2235
-	if ( ! $post = get_post( $id ) )
2235
+	if ( ! $post = get_post($id))
2236 2236
 		wp_send_json_error();
2237 2237
 
2238
-	if ( 'attachment' != $post->post_type )
2238
+	if ('attachment' != $post->post_type)
2239 2239
 		wp_send_json_error();
2240 2240
 
2241
-	if ( ! current_user_can( 'upload_files' ) )
2241
+	if ( ! current_user_can('upload_files'))
2242 2242
 		wp_send_json_error();
2243 2243
 
2244
-	if ( ! $attachment = wp_prepare_attachment_for_js( $id ) )
2244
+	if ( ! $attachment = wp_prepare_attachment_for_js($id))
2245 2245
 		wp_send_json_error();
2246 2246
 
2247
-	wp_send_json_success( $attachment );
2247
+	wp_send_json_success($attachment);
2248 2248
 }
2249 2249
 
2250 2250
 /**
@@ -2253,31 +2253,31 @@  discard block
 block discarded – undo
2253 2253
  * @since 3.5.0
2254 2254
  */
2255 2255
 function wp_ajax_query_attachments() {
2256
-	if ( ! current_user_can( 'upload_files' ) )
2256
+	if ( ! current_user_can('upload_files'))
2257 2257
 		wp_send_json_error();
2258 2258
 
2259
-	$query = isset( $_REQUEST['query'] ) ? (array) $_REQUEST['query'] : array();
2259
+	$query = isset($_REQUEST['query']) ? (array) $_REQUEST['query'] : array();
2260 2260
 	$keys = array(
2261 2261
 		's', 'order', 'orderby', 'posts_per_page', 'paged', 'post_mime_type',
2262 2262
 		'post_parent', 'post__in', 'post__not_in', 'year', 'monthnum'
2263 2263
 	);
2264
-	foreach ( get_taxonomies_for_attachments( 'objects' ) as $t ) {
2265
-		if ( $t->query_var && isset( $query[ $t->query_var ] ) ) {
2264
+	foreach (get_taxonomies_for_attachments('objects') as $t) {
2265
+		if ($t->query_var && isset($query[$t->query_var])) {
2266 2266
 			$keys[] = $t->query_var;
2267 2267
 		}
2268 2268
 	}
2269 2269
 
2270
-	$query = array_intersect_key( $query, array_flip( $keys ) );
2270
+	$query = array_intersect_key($query, array_flip($keys));
2271 2271
 	$query['post_type'] = 'attachment';
2272
-	if ( MEDIA_TRASH
2273
-		&& ! empty( $_REQUEST['query']['post_status'] )
2274
-		&& 'trash' === $_REQUEST['query']['post_status'] ) {
2272
+	if (MEDIA_TRASH
2273
+		&& ! empty($_REQUEST['query']['post_status'])
2274
+		&& 'trash' === $_REQUEST['query']['post_status']) {
2275 2275
 		$query['post_status'] = 'trash';
2276 2276
 	} else {
2277 2277
 		$query['post_status'] = 'inherit';
2278 2278
 	}
2279 2279
 
2280
-	if ( current_user_can( get_post_type_object( 'attachment' )->cap->read_private_posts ) )
2280
+	if (current_user_can(get_post_type_object('attachment')->cap->read_private_posts))
2281 2281
 		$query['post_status'] .= ',private';
2282 2282
 
2283 2283
 	/**
@@ -2290,13 +2290,13 @@  discard block
 block discarded – undo
2290 2290
 	 *
2291 2291
 	 * @param array $query An array of query variables.
2292 2292
 	 */
2293
-	$query = apply_filters( 'ajax_query_attachments_args', $query );
2294
-	$query = new WP_Query( $query );
2293
+	$query = apply_filters('ajax_query_attachments_args', $query);
2294
+	$query = new WP_Query($query);
2295 2295
 
2296
-	$posts = array_map( 'wp_prepare_attachment_for_js', $query->posts );
2297
-	$posts = array_filter( $posts );
2296
+	$posts = array_map('wp_prepare_attachment_for_js', $query->posts);
2297
+	$posts = array_filter($posts);
2298 2298
 
2299
-	wp_send_json_success( $posts );
2299
+	wp_send_json_success($posts);
2300 2300
 }
2301 2301
 
2302 2302
 /**
@@ -2305,69 +2305,69 @@  discard block
 block discarded – undo
2305 2305
  * @since 3.5.0
2306 2306
  */
2307 2307
 function wp_ajax_save_attachment() {
2308
-	if ( ! isset( $_REQUEST['id'] ) || ! isset( $_REQUEST['changes'] ) )
2308
+	if ( ! isset($_REQUEST['id']) || ! isset($_REQUEST['changes']))
2309 2309
 		wp_send_json_error();
2310 2310
 
2311
-	if ( ! $id = absint( $_REQUEST['id'] ) )
2311
+	if ( ! $id = absint($_REQUEST['id']))
2312 2312
 		wp_send_json_error();
2313 2313
 
2314
-	check_ajax_referer( 'update-post_' . $id, 'nonce' );
2314
+	check_ajax_referer('update-post_'.$id, 'nonce');
2315 2315
 
2316
-	if ( ! current_user_can( 'edit_post', $id ) )
2316
+	if ( ! current_user_can('edit_post', $id))
2317 2317
 		wp_send_json_error();
2318 2318
 
2319 2319
 	$changes = $_REQUEST['changes'];
2320
-	$post    = get_post( $id, ARRAY_A );
2320
+	$post    = get_post($id, ARRAY_A);
2321 2321
 
2322
-	if ( 'attachment' != $post['post_type'] )
2322
+	if ('attachment' != $post['post_type'])
2323 2323
 		wp_send_json_error();
2324 2324
 
2325
-	if ( isset( $changes['parent'] ) )
2325
+	if (isset($changes['parent']))
2326 2326
 		$post['post_parent'] = $changes['parent'];
2327 2327
 
2328
-	if ( isset( $changes['title'] ) )
2328
+	if (isset($changes['title']))
2329 2329
 		$post['post_title'] = $changes['title'];
2330 2330
 
2331
-	if ( isset( $changes['caption'] ) )
2331
+	if (isset($changes['caption']))
2332 2332
 		$post['post_excerpt'] = $changes['caption'];
2333 2333
 
2334
-	if ( isset( $changes['description'] ) )
2334
+	if (isset($changes['description']))
2335 2335
 		$post['post_content'] = $changes['description'];
2336 2336
 
2337
-	if ( MEDIA_TRASH && isset( $changes['status'] ) )
2337
+	if (MEDIA_TRASH && isset($changes['status']))
2338 2338
 		$post['post_status'] = $changes['status'];
2339 2339
 
2340
-	if ( isset( $changes['alt'] ) ) {
2341
-		$alt = wp_unslash( $changes['alt'] );
2342
-		if ( $alt != get_post_meta( $id, '_wp_attachment_image_alt', true ) ) {
2343
-			$alt = wp_strip_all_tags( $alt, true );
2344
-			update_post_meta( $id, '_wp_attachment_image_alt', wp_slash( $alt ) );
2340
+	if (isset($changes['alt'])) {
2341
+		$alt = wp_unslash($changes['alt']);
2342
+		if ($alt != get_post_meta($id, '_wp_attachment_image_alt', true)) {
2343
+			$alt = wp_strip_all_tags($alt, true);
2344
+			update_post_meta($id, '_wp_attachment_image_alt', wp_slash($alt));
2345 2345
 		}
2346 2346
 	}
2347 2347
 
2348
-	if ( wp_attachment_is( 'audio', $post['ID'] ) ) {
2348
+	if (wp_attachment_is('audio', $post['ID'])) {
2349 2349
 		$changed = false;
2350
-		$id3data = wp_get_attachment_metadata( $post['ID'] );
2351
-		if ( ! is_array( $id3data ) ) {
2350
+		$id3data = wp_get_attachment_metadata($post['ID']);
2351
+		if ( ! is_array($id3data)) {
2352 2352
 			$changed = true;
2353 2353
 			$id3data = array();
2354 2354
 		}
2355
-		foreach ( wp_get_attachment_id3_keys( (object) $post, 'edit' ) as $key => $label ) {
2356
-			if ( isset( $changes[ $key ] ) ) {
2355
+		foreach (wp_get_attachment_id3_keys((object) $post, 'edit') as $key => $label) {
2356
+			if (isset($changes[$key])) {
2357 2357
 				$changed = true;
2358
-				$id3data[ $key ] = sanitize_text_field( wp_unslash( $changes[ $key ] ) );
2358
+				$id3data[$key] = sanitize_text_field(wp_unslash($changes[$key]));
2359 2359
 			}
2360 2360
 		}
2361 2361
 
2362
-		if ( $changed ) {
2363
-			wp_update_attachment_metadata( $id, $id3data );
2362
+		if ($changed) {
2363
+			wp_update_attachment_metadata($id, $id3data);
2364 2364
 		}
2365 2365
 	}
2366 2366
 
2367
-	if ( MEDIA_TRASH && isset( $changes['status'] ) && 'trash' === $changes['status'] ) {
2368
-		wp_delete_post( $id );
2367
+	if (MEDIA_TRASH && isset($changes['status']) && 'trash' === $changes['status']) {
2368
+		wp_delete_post($id);
2369 2369
 	} else {
2370
-		wp_update_post( $post );
2370
+		wp_update_post($post);
2371 2371
 	}
2372 2372
 
2373 2373
 	wp_send_json_success();
@@ -2379,45 +2379,45 @@  discard block
 block discarded – undo
2379 2379
  * @since 3.5.0
2380 2380
  */
2381 2381
 function wp_ajax_save_attachment_compat() {
2382
-	if ( ! isset( $_REQUEST['id'] ) )
2382
+	if ( ! isset($_REQUEST['id']))
2383 2383
 		wp_send_json_error();
2384 2384
 
2385
-	if ( ! $id = absint( $_REQUEST['id'] ) )
2385
+	if ( ! $id = absint($_REQUEST['id']))
2386 2386
 		wp_send_json_error();
2387 2387
 
2388
-	if ( empty( $_REQUEST['attachments'] ) || empty( $_REQUEST['attachments'][ $id ] ) )
2388
+	if (empty($_REQUEST['attachments']) || empty($_REQUEST['attachments'][$id]))
2389 2389
 		wp_send_json_error();
2390
-	$attachment_data = $_REQUEST['attachments'][ $id ];
2390
+	$attachment_data = $_REQUEST['attachments'][$id];
2391 2391
 
2392
-	check_ajax_referer( 'update-post_' . $id, 'nonce' );
2392
+	check_ajax_referer('update-post_'.$id, 'nonce');
2393 2393
 
2394
-	if ( ! current_user_can( 'edit_post', $id ) )
2394
+	if ( ! current_user_can('edit_post', $id))
2395 2395
 		wp_send_json_error();
2396 2396
 
2397
-	$post = get_post( $id, ARRAY_A );
2397
+	$post = get_post($id, ARRAY_A);
2398 2398
 
2399
-	if ( 'attachment' != $post['post_type'] )
2399
+	if ('attachment' != $post['post_type'])
2400 2400
 		wp_send_json_error();
2401 2401
 
2402 2402
 	/** This filter is documented in wp-admin/includes/media.php */
2403
-	$post = apply_filters( 'attachment_fields_to_save', $post, $attachment_data );
2403
+	$post = apply_filters('attachment_fields_to_save', $post, $attachment_data);
2404 2404
 
2405
-	if ( isset( $post['errors'] ) ) {
2405
+	if (isset($post['errors'])) {
2406 2406
 		$errors = $post['errors']; // @todo return me and display me!
2407
-		unset( $post['errors'] );
2407
+		unset($post['errors']);
2408 2408
 	}
2409 2409
 
2410
-	wp_update_post( $post );
2410
+	wp_update_post($post);
2411 2411
 
2412
-	foreach ( get_attachment_taxonomies( $post ) as $taxonomy ) {
2413
-		if ( isset( $attachment_data[ $taxonomy ] ) )
2414
-			wp_set_object_terms( $id, array_map( 'trim', preg_split( '/,+/', $attachment_data[ $taxonomy ] ) ), $taxonomy, false );
2412
+	foreach (get_attachment_taxonomies($post) as $taxonomy) {
2413
+		if (isset($attachment_data[$taxonomy]))
2414
+			wp_set_object_terms($id, array_map('trim', preg_split('/,+/', $attachment_data[$taxonomy])), $taxonomy, false);
2415 2415
 	}
2416 2416
 
2417
-	if ( ! $attachment = wp_prepare_attachment_for_js( $id ) )
2417
+	if ( ! $attachment = wp_prepare_attachment_for_js($id))
2418 2418
 		wp_send_json_error();
2419 2419
 
2420
-	wp_send_json_success( $attachment );
2420
+	wp_send_json_success($attachment);
2421 2421
 }
2422 2422
 
2423 2423
 /**
@@ -2426,31 +2426,31 @@  discard block
 block discarded – undo
2426 2426
  * @since 3.5.0
2427 2427
  */
2428 2428
 function wp_ajax_save_attachment_order() {
2429
-	if ( ! isset( $_REQUEST['post_id'] ) )
2429
+	if ( ! isset($_REQUEST['post_id']))
2430 2430
 		wp_send_json_error();
2431 2431
 
2432
-	if ( ! $post_id = absint( $_REQUEST['post_id'] ) )
2432
+	if ( ! $post_id = absint($_REQUEST['post_id']))
2433 2433
 		wp_send_json_error();
2434 2434
 
2435
-	if ( empty( $_REQUEST['attachments'] ) )
2435
+	if (empty($_REQUEST['attachments']))
2436 2436
 		wp_send_json_error();
2437 2437
 
2438
-	check_ajax_referer( 'update-post_' . $post_id, 'nonce' );
2438
+	check_ajax_referer('update-post_'.$post_id, 'nonce');
2439 2439
 
2440 2440
 	$attachments = $_REQUEST['attachments'];
2441 2441
 
2442
-	if ( ! current_user_can( 'edit_post', $post_id ) )
2442
+	if ( ! current_user_can('edit_post', $post_id))
2443 2443
 		wp_send_json_error();
2444 2444
 
2445
-	foreach ( $attachments as $attachment_id => $menu_order ) {
2446
-		if ( ! current_user_can( 'edit_post', $attachment_id ) )
2445
+	foreach ($attachments as $attachment_id => $menu_order) {
2446
+		if ( ! current_user_can('edit_post', $attachment_id))
2447 2447
 			continue;
2448
-		if ( ! $attachment = get_post( $attachment_id ) )
2448
+		if ( ! $attachment = get_post($attachment_id))
2449 2449
 			continue;
2450
-		if ( 'attachment' != $attachment->post_type )
2450
+		if ('attachment' != $attachment->post_type)
2451 2451
 			continue;
2452 2452
 
2453
-		wp_update_post( array( 'ID' => $attachment_id, 'menu_order' => $menu_order ) );
2453
+		wp_update_post(array('ID' => $attachment_id, 'menu_order' => $menu_order));
2454 2454
 	}
2455 2455
 
2456 2456
 	wp_send_json_success();
@@ -2466,57 +2466,57 @@  discard block
 block discarded – undo
2466 2466
  * @since 3.5.0
2467 2467
  */
2468 2468
 function wp_ajax_send_attachment_to_editor() {
2469
-	check_ajax_referer( 'media-send-to-editor', 'nonce' );
2469
+	check_ajax_referer('media-send-to-editor', 'nonce');
2470 2470
 
2471
-	$attachment = wp_unslash( $_POST['attachment'] );
2471
+	$attachment = wp_unslash($_POST['attachment']);
2472 2472
 
2473
-	$id = intval( $attachment['id'] );
2473
+	$id = intval($attachment['id']);
2474 2474
 
2475
-	if ( ! $post = get_post( $id ) )
2475
+	if ( ! $post = get_post($id))
2476 2476
 		wp_send_json_error();
2477 2477
 
2478
-	if ( 'attachment' != $post->post_type )
2478
+	if ('attachment' != $post->post_type)
2479 2479
 		wp_send_json_error();
2480 2480
 
2481
-	if ( current_user_can( 'edit_post', $id ) ) {
2481
+	if (current_user_can('edit_post', $id)) {
2482 2482
 		// If this attachment is unattached, attach it. Primarily a back compat thing.
2483
-		if ( 0 == $post->post_parent && $insert_into_post_id = intval( $_POST['post_id'] ) ) {
2484
-			wp_update_post( array( 'ID' => $id, 'post_parent' => $insert_into_post_id ) );
2483
+		if (0 == $post->post_parent && $insert_into_post_id = intval($_POST['post_id'])) {
2484
+			wp_update_post(array('ID' => $id, 'post_parent' => $insert_into_post_id));
2485 2485
 		}
2486 2486
 	}
2487 2487
 
2488 2488
 	$rel = $url = '';
2489
-	$html = isset( $attachment['post_title'] ) ? $attachment['post_title'] : '';
2490
-	if ( ! empty( $attachment['url'] ) ) {
2489
+	$html = isset($attachment['post_title']) ? $attachment['post_title'] : '';
2490
+	if ( ! empty($attachment['url'])) {
2491 2491
 		$url = $attachment['url'];
2492
-		if ( strpos( $url, 'attachment_id') || get_attachment_link( $id ) == $url )
2493
-			$rel = ' rel="attachment wp-att-' . $id . '"';
2494
-		$html = '<a href="' . esc_url( $url ) . '"' . $rel . '>' . $html . '</a>';
2492
+		if (strpos($url, 'attachment_id') || get_attachment_link($id) == $url)
2493
+			$rel = ' rel="attachment wp-att-'.$id.'"';
2494
+		$html = '<a href="'.esc_url($url).'"'.$rel.'>'.$html.'</a>';
2495 2495
 	}
2496 2496
 
2497
-	remove_filter( 'media_send_to_editor', 'image_media_send_to_editor' );
2497
+	remove_filter('media_send_to_editor', 'image_media_send_to_editor');
2498 2498
 
2499
-	if ( 'image' === substr( $post->post_mime_type, 0, 5 ) ) {
2500
-		$align = isset( $attachment['align'] ) ? $attachment['align'] : 'none';
2501
-		$size = isset( $attachment['image-size'] ) ? $attachment['image-size'] : 'medium';
2502
-		$alt = isset( $attachment['image_alt'] ) ? $attachment['image_alt'] : '';
2499
+	if ('image' === substr($post->post_mime_type, 0, 5)) {
2500
+		$align = isset($attachment['align']) ? $attachment['align'] : 'none';
2501
+		$size = isset($attachment['image-size']) ? $attachment['image-size'] : 'medium';
2502
+		$alt = isset($attachment['image_alt']) ? $attachment['image_alt'] : '';
2503 2503
 
2504 2504
 		// No whitespace-only captions.
2505
-		$caption = isset( $attachment['post_excerpt'] ) ? $attachment['post_excerpt'] : '';
2506
-		if ( '' === trim( $caption ) ) {
2505
+		$caption = isset($attachment['post_excerpt']) ? $attachment['post_excerpt'] : '';
2506
+		if ('' === trim($caption)) {
2507 2507
 			$caption = '';
2508 2508
 		}
2509 2509
 
2510 2510
 		$title = ''; // We no longer insert title tags into <img> tags, as they are redundant.
2511
-		$html = get_image_send_to_editor( $id, $caption, $title, $align, $url, (bool) $rel, $size, $alt );
2512
-	} elseif ( wp_attachment_is( 'video', $post ) || wp_attachment_is( 'audio', $post )  ) {
2513
-		$html = stripslashes_deep( $_POST['html'] );
2511
+		$html = get_image_send_to_editor($id, $caption, $title, $align, $url, (bool) $rel, $size, $alt);
2512
+	} elseif (wp_attachment_is('video', $post) || wp_attachment_is('audio', $post)) {
2513
+		$html = stripslashes_deep($_POST['html']);
2514 2514
 	}
2515 2515
 
2516 2516
 	/** This filter is documented in wp-admin/includes/media.php */
2517
-	$html = apply_filters( 'media_send_to_editor', $html, $id, $attachment );
2517
+	$html = apply_filters('media_send_to_editor', $html, $id, $attachment);
2518 2518
 
2519
-	wp_send_json_success( $html );
2519
+	wp_send_json_success($html);
2520 2520
 }
2521 2521
 
2522 2522
 /**
@@ -2537,47 +2537,47 @@  discard block
 block discarded – undo
2537 2537
 function wp_ajax_send_link_to_editor() {
2538 2538
 	global $post, $wp_embed;
2539 2539
 
2540
-	check_ajax_referer( 'media-send-to-editor', 'nonce' );
2540
+	check_ajax_referer('media-send-to-editor', 'nonce');
2541 2541
 
2542
-	if ( ! $src = wp_unslash( $_POST['src'] ) )
2542
+	if ( ! $src = wp_unslash($_POST['src']))
2543 2543
 		wp_send_json_error();
2544 2544
 
2545
-	if ( ! strpos( $src, '://' ) )
2546
-		$src = 'http://' . $src;
2545
+	if ( ! strpos($src, '://'))
2546
+		$src = 'http://'.$src;
2547 2547
 
2548
-	if ( ! $src = esc_url_raw( $src ) )
2548
+	if ( ! $src = esc_url_raw($src))
2549 2549
 		wp_send_json_error();
2550 2550
 
2551
-	if ( ! $link_text = trim( wp_unslash( $_POST['link_text'] ) ) )
2552
-		$link_text = wp_basename( $src );
2551
+	if ( ! $link_text = trim(wp_unslash($_POST['link_text'])))
2552
+		$link_text = wp_basename($src);
2553 2553
 
2554
-	$post = get_post( isset( $_POST['post_id'] ) ? $_POST['post_id'] : 0 );
2554
+	$post = get_post(isset($_POST['post_id']) ? $_POST['post_id'] : 0);
2555 2555
 
2556 2556
 	// Ping WordPress for an embed.
2557
-	$check_embed = $wp_embed->run_shortcode( '[embed]'. $src .'[/embed]' );
2557
+	$check_embed = $wp_embed->run_shortcode('[embed]'.$src.'[/embed]');
2558 2558
 
2559 2559
 	// Fallback that WordPress creates when no oEmbed was found.
2560
-	$fallback = $wp_embed->maybe_make_link( $src );
2560
+	$fallback = $wp_embed->maybe_make_link($src);
2561 2561
 
2562
-	if ( $check_embed !== $fallback ) {
2562
+	if ($check_embed !== $fallback) {
2563 2563
 		// TinyMCE view for [embed] will parse this
2564
-		$html = '[embed]' . $src . '[/embed]';
2565
-	} elseif ( $link_text ) {
2566
-		$html = '<a href="' . esc_url( $src ) . '">' . $link_text . '</a>';
2564
+		$html = '[embed]'.$src.'[/embed]';
2565
+	} elseif ($link_text) {
2566
+		$html = '<a href="'.esc_url($src).'">'.$link_text.'</a>';
2567 2567
 	} else {
2568 2568
 		$html = '';
2569 2569
 	}
2570 2570
 
2571 2571
 	// Figure out what filter to run:
2572 2572
 	$type = 'file';
2573
-	if ( ( $ext = preg_replace( '/^.+?\.([^.]+)$/', '$1', $src ) ) && ( $ext_type = wp_ext2type( $ext ) )
2574
-		&& ( 'audio' == $ext_type || 'video' == $ext_type ) )
2573
+	if (($ext = preg_replace('/^.+?\.([^.]+)$/', '$1', $src)) && ($ext_type = wp_ext2type($ext))
2574
+		&& ('audio' == $ext_type || 'video' == $ext_type))
2575 2575
 			$type = $ext_type;
2576 2576
 
2577 2577
 	/** This filter is documented in wp-admin/includes/media.php */
2578
-	$html = apply_filters( $type . '_send_to_editor_url', $html, $src, $link_text );
2578
+	$html = apply_filters($type.'_send_to_editor_url', $html, $src, $link_text);
2579 2579
 
2580
-	wp_send_json_success( $html );
2580
+	wp_send_json_success($html);
2581 2581
 }
2582 2582
 
2583 2583
 /**
@@ -2588,35 +2588,35 @@  discard block
 block discarded – undo
2588 2588
  * @since 3.6.0
2589 2589
  */
2590 2590
 function wp_ajax_heartbeat() {
2591
-	if ( empty( $_POST['_nonce'] ) ) {
2591
+	if (empty($_POST['_nonce'])) {
2592 2592
 		wp_send_json_error();
2593 2593
 	}
2594 2594
 
2595 2595
 	$response = $data = array();
2596
-	$nonce_state = wp_verify_nonce( $_POST['_nonce'], 'heartbeat-nonce' );
2596
+	$nonce_state = wp_verify_nonce($_POST['_nonce'], 'heartbeat-nonce');
2597 2597
 
2598 2598
 	// screen_id is the same as $current_screen->id and the JS global 'pagenow'.
2599
-	if ( ! empty( $_POST['screen_id'] ) ) {
2599
+	if ( ! empty($_POST['screen_id'])) {
2600 2600
 		$screen_id = sanitize_key($_POST['screen_id']);
2601 2601
 	} else {
2602 2602
 		$screen_id = 'front';
2603 2603
 	}
2604 2604
 
2605
-	if ( ! empty( $_POST['data'] ) ) {
2606
-		$data = wp_unslash( (array) $_POST['data'] );
2605
+	if ( ! empty($_POST['data'])) {
2606
+		$data = wp_unslash((array) $_POST['data']);
2607 2607
 	}
2608 2608
 
2609
-	if ( 1 !== $nonce_state ) {
2610
-		$response = apply_filters( 'wp_refresh_nonces', $response, $data, $screen_id );
2609
+	if (1 !== $nonce_state) {
2610
+		$response = apply_filters('wp_refresh_nonces', $response, $data, $screen_id);
2611 2611
 
2612
-		if ( false === $nonce_state ) {
2612
+		if (false === $nonce_state) {
2613 2613
 			// User is logged in but nonces have expired.
2614 2614
 			$response['nonces_expired'] = true;
2615
-			wp_send_json( $response );
2615
+			wp_send_json($response);
2616 2616
 		}
2617 2617
 	}
2618 2618
 
2619
-	if ( ! empty( $data ) ) {
2619
+	if ( ! empty($data)) {
2620 2620
 		/**
2621 2621
 		 * Filter the Heartbeat response received.
2622 2622
 		 *
@@ -2626,7 +2626,7 @@  discard block
 block discarded – undo
2626 2626
 		 * @param array        $data      The $_POST data sent.
2627 2627
 		 * @param string       $screen_id The screen id.
2628 2628
 		 */
2629
-		$response = apply_filters( 'heartbeat_received', $response, $data, $screen_id );
2629
+		$response = apply_filters('heartbeat_received', $response, $data, $screen_id);
2630 2630
 	}
2631 2631
 
2632 2632
 	/**
@@ -2637,7 +2637,7 @@  discard block
 block discarded – undo
2637 2637
 	 * @param array|object $response  The Heartbeat response object or array.
2638 2638
 	 * @param string       $screen_id The screen id.
2639 2639
 	 */
2640
-	$response = apply_filters( 'heartbeat_send', $response, $screen_id );
2640
+	$response = apply_filters('heartbeat_send', $response, $screen_id);
2641 2641
 
2642 2642
 	/**
2643 2643
 	 * Fires when Heartbeat ticks in logged-in environments.
@@ -2649,12 +2649,12 @@  discard block
 block discarded – undo
2649 2649
 	 * @param array|object $response  The Heartbeat response object or array.
2650 2650
 	 * @param string       $screen_id The screen id.
2651 2651
 	 */
2652
-	do_action( 'heartbeat_tick', $response, $screen_id );
2652
+	do_action('heartbeat_tick', $response, $screen_id);
2653 2653
 
2654 2654
 	// Send the current time according to the server
2655 2655
 	$response['server_time'] = time();
2656 2656
 
2657
-	wp_send_json( $response );
2657
+	wp_send_json($response);
2658 2658
 }
2659 2659
 
2660 2660
 /**
@@ -2663,30 +2663,30 @@  discard block
 block discarded – undo
2663 2663
  * @since 3.6.0
2664 2664
  */
2665 2665
 function wp_ajax_get_revision_diffs() {
2666
-	require ABSPATH . 'wp-admin/includes/revision.php';
2666
+	require ABSPATH.'wp-admin/includes/revision.php';
2667 2667
 
2668
-	if ( ! $post = get_post( (int) $_REQUEST['post_id'] ) )
2668
+	if ( ! $post = get_post((int) $_REQUEST['post_id']))
2669 2669
 		wp_send_json_error();
2670 2670
 
2671
-	if ( ! current_user_can( 'read_post', $post->ID ) )
2671
+	if ( ! current_user_can('read_post', $post->ID))
2672 2672
 		wp_send_json_error();
2673 2673
 
2674 2674
 	// Really just pre-loading the cache here.
2675
-	if ( ! $revisions = wp_get_post_revisions( $post->ID, array( 'check_enabled' => false ) ) )
2675
+	if ( ! $revisions = wp_get_post_revisions($post->ID, array('check_enabled' => false)))
2676 2676
 		wp_send_json_error();
2677 2677
 
2678 2678
 	$return = array();
2679
-	@set_time_limit( 0 );
2679
+	@set_time_limit(0);
2680 2680
 
2681
-	foreach ( $_REQUEST['compare'] as $compare_key ) {
2682
-		list( $compare_from, $compare_to ) = explode( ':', $compare_key ); // from:to
2681
+	foreach ($_REQUEST['compare'] as $compare_key) {
2682
+		list($compare_from, $compare_to) = explode(':', $compare_key); // from:to
2683 2683
 
2684 2684
 		$return[] = array(
2685 2685
 			'id' => $compare_key,
2686
-			'fields' => wp_get_revision_ui_diff( $post, $compare_from, $compare_to ),
2686
+			'fields' => wp_get_revision_ui_diff($post, $compare_from, $compare_to),
2687 2687
 		);
2688 2688
 	}
2689
-	wp_send_json_success( $return );
2689
+	wp_send_json_success($return);
2690 2690
 }
2691 2691
 
2692 2692
 /**
@@ -2700,21 +2700,21 @@  discard block
 block discarded – undo
2700 2700
 function wp_ajax_save_user_color_scheme() {
2701 2701
 	global $_wp_admin_css_colors;
2702 2702
 
2703
-	check_ajax_referer( 'save-color-scheme', 'nonce' );
2703
+	check_ajax_referer('save-color-scheme', 'nonce');
2704 2704
 
2705
-	$color_scheme = sanitize_key( $_POST['color_scheme'] );
2705
+	$color_scheme = sanitize_key($_POST['color_scheme']);
2706 2706
 
2707
-	if ( ! isset( $_wp_admin_css_colors[ $color_scheme ] ) ) {
2707
+	if ( ! isset($_wp_admin_css_colors[$color_scheme])) {
2708 2708
 		wp_send_json_error();
2709 2709
 	}
2710 2710
 
2711
-	$previous_color_scheme = get_user_meta( get_current_user_id(), 'admin_color', true );
2712
-	update_user_meta( get_current_user_id(), 'admin_color', $color_scheme );
2711
+	$previous_color_scheme = get_user_meta(get_current_user_id(), 'admin_color', true);
2712
+	update_user_meta(get_current_user_id(), 'admin_color', $color_scheme);
2713 2713
 
2714
-	wp_send_json_success( array(
2715
-		'previousScheme' => 'admin-color-' . $previous_color_scheme,
2716
-		'currentScheme'  => 'admin-color-' . $color_scheme
2717
-	) );
2714
+	wp_send_json_success(array(
2715
+		'previousScheme' => 'admin-color-'.$previous_color_scheme,
2716
+		'currentScheme'  => 'admin-color-'.$color_scheme
2717
+	));
2718 2718
 }
2719 2719
 
2720 2720
 /**
@@ -2728,42 +2728,42 @@  discard block
 block discarded – undo
2728 2728
 function wp_ajax_query_themes() {
2729 2729
 	global $themes_allowedtags, $theme_field_defaults;
2730 2730
 
2731
-	if ( ! current_user_can( 'install_themes' ) ) {
2731
+	if ( ! current_user_can('install_themes')) {
2732 2732
 		wp_send_json_error();
2733 2733
 	}
2734 2734
 
2735
-	$args = wp_parse_args( wp_unslash( $_REQUEST['request'] ), array(
2735
+	$args = wp_parse_args(wp_unslash($_REQUEST['request']), array(
2736 2736
 		'per_page' => 20,
2737 2737
 		'fields'   => $theme_field_defaults
2738
-	) );
2738
+	));
2739 2739
 
2740
-	$old_filter = isset( $args['browse'] ) ? $args['browse'] : 'search';
2740
+	$old_filter = isset($args['browse']) ? $args['browse'] : 'search';
2741 2741
 
2742 2742
 	/** This filter is documented in wp-admin/includes/class-wp-theme-install-list-table.php */
2743
-	$args = apply_filters( 'install_themes_table_api_args_' . $old_filter, $args );
2743
+	$args = apply_filters('install_themes_table_api_args_'.$old_filter, $args);
2744 2744
 
2745
-	$api = themes_api( 'query_themes', $args );
2745
+	$api = themes_api('query_themes', $args);
2746 2746
 
2747
-	if ( is_wp_error( $api ) ) {
2747
+	if (is_wp_error($api)) {
2748 2748
 		wp_send_json_error();
2749 2749
 	}
2750 2750
 
2751
-	$update_php = network_admin_url( 'update.php?action=install-theme' );
2752
-	foreach ( $api->themes as &$theme ) {
2753
-		$theme->install_url = add_query_arg( array(
2751
+	$update_php = network_admin_url('update.php?action=install-theme');
2752
+	foreach ($api->themes as &$theme) {
2753
+		$theme->install_url = add_query_arg(array(
2754 2754
 			'theme'    => $theme->slug,
2755
-			'_wpnonce' => wp_create_nonce( 'install-theme_' . $theme->slug )
2756
-		), $update_php );
2755
+			'_wpnonce' => wp_create_nonce('install-theme_'.$theme->slug)
2756
+		), $update_php);
2757 2757
 
2758
-		$theme->name        = wp_kses( $theme->name, $themes_allowedtags );
2759
-		$theme->author      = wp_kses( $theme->author, $themes_allowedtags );
2760
-		$theme->version     = wp_kses( $theme->version, $themes_allowedtags );
2761
-		$theme->description = wp_kses( $theme->description, $themes_allowedtags );
2762
-		$theme->num_ratings = sprintf( _n( '(based on %s rating)', '(based on %s ratings)', $theme->num_ratings ), number_format_i18n( $theme->num_ratings ) );
2763
-		$theme->preview_url = set_url_scheme( $theme->preview_url );
2758
+		$theme->name        = wp_kses($theme->name, $themes_allowedtags);
2759
+		$theme->author      = wp_kses($theme->author, $themes_allowedtags);
2760
+		$theme->version     = wp_kses($theme->version, $themes_allowedtags);
2761
+		$theme->description = wp_kses($theme->description, $themes_allowedtags);
2762
+		$theme->num_ratings = sprintf(_n('(based on %s rating)', '(based on %s ratings)', $theme->num_ratings), number_format_i18n($theme->num_ratings));
2763
+		$theme->preview_url = set_url_scheme($theme->preview_url);
2764 2764
 	}
2765 2765
 
2766
-	wp_send_json_success( $api );
2766
+	wp_send_json_success($api);
2767 2767
 }
2768 2768
 
2769 2769
 /**
@@ -2778,87 +2778,87 @@  discard block
 block discarded – undo
2778 2778
 function wp_ajax_parse_embed() {
2779 2779
 	global $post, $wp_embed;
2780 2780
 
2781
-	if ( ! $post = get_post( (int) $_POST['post_ID'] ) ) {
2781
+	if ( ! $post = get_post((int) $_POST['post_ID'])) {
2782 2782
 		wp_send_json_error();
2783 2783
 	}
2784 2784
 
2785
-	if ( empty( $_POST['shortcode'] ) || ! current_user_can( 'edit_post', $post->ID ) ) {
2785
+	if (empty($_POST['shortcode']) || ! current_user_can('edit_post', $post->ID)) {
2786 2786
 		wp_send_json_error();
2787 2787
 	}
2788 2788
 
2789
-	$shortcode = wp_unslash( $_POST['shortcode'] );
2789
+	$shortcode = wp_unslash($_POST['shortcode']);
2790 2790
 
2791
-	preg_match( '/' . get_shortcode_regex() . '/s', $shortcode, $matches );
2792
-	$atts = shortcode_parse_atts( $matches[3] );
2793
-	if ( ! empty( $matches[5] ) ) {
2791
+	preg_match('/'.get_shortcode_regex().'/s', $shortcode, $matches);
2792
+	$atts = shortcode_parse_atts($matches[3]);
2793
+	if ( ! empty($matches[5])) {
2794 2794
 		$url = $matches[5];
2795
-	} elseif ( ! empty( $atts['src'] ) ) {
2795
+	} elseif ( ! empty($atts['src'])) {
2796 2796
 		$url = $atts['src'];
2797 2797
 	} else {
2798 2798
 		$url = '';
2799 2799
 	}
2800 2800
 
2801 2801
 	$parsed = false;
2802
-	setup_postdata( $post );
2802
+	setup_postdata($post);
2803 2803
 
2804 2804
 	$wp_embed->return_false_on_fail = true;
2805 2805
 
2806
-	if ( is_ssl() && 0 === strpos( $url, 'http://' ) ) {
2806
+	if (is_ssl() && 0 === strpos($url, 'http://')) {
2807 2807
 		// Admin is ssl and the user pasted non-ssl URL.
2808 2808
 		// Check if the provider supports ssl embeds and use that for the preview.
2809
-		$ssl_shortcode = preg_replace( '%^(\\[embed[^\\]]*\\])http://%i', '$1https://', $shortcode );
2810
-		$parsed = $wp_embed->run_shortcode( $ssl_shortcode );
2809
+		$ssl_shortcode = preg_replace('%^(\\[embed[^\\]]*\\])http://%i', '$1https://', $shortcode);
2810
+		$parsed = $wp_embed->run_shortcode($ssl_shortcode);
2811 2811
 
2812
-		if ( ! $parsed ) {
2812
+		if ( ! $parsed) {
2813 2813
 			$no_ssl_support = true;
2814 2814
 		}
2815 2815
 	}
2816 2816
 
2817
-	if ( $url && ! $parsed ) {
2818
-		$parsed = $wp_embed->run_shortcode( $shortcode );
2817
+	if ($url && ! $parsed) {
2818
+		$parsed = $wp_embed->run_shortcode($shortcode);
2819 2819
 	}
2820 2820
 
2821
-	if ( ! $parsed ) {
2822
-		wp_send_json_error( array(
2821
+	if ( ! $parsed) {
2822
+		wp_send_json_error(array(
2823 2823
 			'type' => 'not-embeddable',
2824
-			'message' => sprintf( __( '%s failed to embed.' ), '<code>' . esc_html( $url ) . '</code>' ),
2825
-		) );
2824
+			'message' => sprintf(__('%s failed to embed.'), '<code>'.esc_html($url).'</code>'),
2825
+		));
2826 2826
 	}
2827 2827
 
2828
-	if ( has_shortcode( $parsed, 'audio' ) || has_shortcode( $parsed, 'video' ) ) {
2828
+	if (has_shortcode($parsed, 'audio') || has_shortcode($parsed, 'video')) {
2829 2829
 		$styles = '';
2830 2830
 		$mce_styles = wpview_media_sandbox_styles();
2831
-		foreach ( $mce_styles as $style ) {
2832
-			$styles .= sprintf( '<link rel="stylesheet" href="%s"/>', $style );
2831
+		foreach ($mce_styles as $style) {
2832
+			$styles .= sprintf('<link rel="stylesheet" href="%s"/>', $style);
2833 2833
 		}
2834 2834
 
2835
-		$html = do_shortcode( $parsed );
2835
+		$html = do_shortcode($parsed);
2836 2836
 
2837 2837
 		global $wp_scripts;
2838
-		if ( ! empty( $wp_scripts ) ) {
2838
+		if ( ! empty($wp_scripts)) {
2839 2839
 			$wp_scripts->done = array();
2840 2840
 		}
2841 2841
 		ob_start();
2842
-		wp_print_scripts( 'wp-mediaelement' );
2842
+		wp_print_scripts('wp-mediaelement');
2843 2843
 		$scripts = ob_get_clean();
2844 2844
 
2845
-		$parsed = $styles . $html . $scripts;
2845
+		$parsed = $styles.$html.$scripts;
2846 2846
 	}
2847 2847
 
2848 2848
 
2849
-	if ( ! empty( $no_ssl_support ) || ( is_ssl() && ( preg_match( '%<(iframe|script|embed) [^>]*src="http://%', $parsed ) ||
2850
-		preg_match( '%<link [^>]*href="http://%', $parsed ) ) ) ) {
2849
+	if ( ! empty($no_ssl_support) || (is_ssl() && (preg_match('%<(iframe|script|embed) [^>]*src="http://%', $parsed) ||
2850
+		preg_match('%<link [^>]*href="http://%', $parsed)))) {
2851 2851
 		// Admin is ssl and the embed is not. Iframes, scripts, and other "active content" will be blocked.
2852
-		wp_send_json_error( array(
2852
+		wp_send_json_error(array(
2853 2853
 			'type' => 'not-ssl',
2854
-			'message' => __( 'This preview is unavailable in the editor.' ),
2855
-		) );
2854
+			'message' => __('This preview is unavailable in the editor.'),
2855
+		));
2856 2856
 	}
2857 2857
 
2858
-	wp_send_json_success( array(
2858
+	wp_send_json_success(array(
2859 2859
 		'body' => $parsed,
2860 2860
 		'attr' => $wp_embed->last_attr
2861
-	) );
2861
+	));
2862 2862
 }
2863 2863
 
2864 2864
 /**
@@ -2870,42 +2870,42 @@  discard block
 block discarded – undo
2870 2870
 function wp_ajax_parse_media_shortcode() {
2871 2871
 	global $post, $wp_scripts;
2872 2872
 
2873
-	if ( empty( $_POST['shortcode'] ) ) {
2873
+	if (empty($_POST['shortcode'])) {
2874 2874
 		wp_send_json_error();
2875 2875
 	}
2876 2876
 
2877
-	$shortcode = wp_unslash( $_POST['shortcode'] );
2877
+	$shortcode = wp_unslash($_POST['shortcode']);
2878 2878
 
2879
-	if ( ! empty( $_POST['post_ID'] ) ) {
2880
-		$post = get_post( (int) $_POST['post_ID'] );
2879
+	if ( ! empty($_POST['post_ID'])) {
2880
+		$post = get_post((int) $_POST['post_ID']);
2881 2881
 	}
2882 2882
 
2883 2883
 	// the embed shortcode requires a post
2884
-	if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) {
2885
-		if ( 'embed' === $shortcode ) {
2884
+	if ( ! $post || ! current_user_can('edit_post', $post->ID)) {
2885
+		if ('embed' === $shortcode) {
2886 2886
 			wp_send_json_error();
2887 2887
 		}
2888 2888
 	} else {
2889
-		setup_postdata( $post );
2889
+		setup_postdata($post);
2890 2890
 	}
2891 2891
 
2892
-	$parsed = do_shortcode( $shortcode  );
2892
+	$parsed = do_shortcode($shortcode);
2893 2893
 
2894
-	if ( empty( $parsed ) ) {
2895
-		wp_send_json_error( array(
2894
+	if (empty($parsed)) {
2895
+		wp_send_json_error(array(
2896 2896
 			'type' => 'no-items',
2897
-			'message' => __( 'No items found.' ),
2898
-		) );
2897
+			'message' => __('No items found.'),
2898
+		));
2899 2899
 	}
2900 2900
 
2901 2901
 	$head = '';
2902 2902
 	$styles = wpview_media_sandbox_styles();
2903 2903
 
2904
-	foreach ( $styles as $style ) {
2905
-		$head .= '<link type="text/css" rel="stylesheet" href="' . $style . '">';
2904
+	foreach ($styles as $style) {
2905
+		$head .= '<link type="text/css" rel="stylesheet" href="'.$style.'">';
2906 2906
 	}
2907 2907
 
2908
-	if ( ! empty( $wp_scripts ) ) {
2908
+	if ( ! empty($wp_scripts)) {
2909 2909
 		$wp_scripts->done = array();
2910 2910
 	}
2911 2911
 
@@ -2913,18 +2913,18 @@  discard block
 block discarded – undo
2913 2913
 
2914 2914
 	echo $parsed;
2915 2915
 
2916
-	if ( 'playlist' === $_REQUEST['type'] ) {
2916
+	if ('playlist' === $_REQUEST['type']) {
2917 2917
 		wp_underscore_playlist_templates();
2918 2918
 
2919
-		wp_print_scripts( 'wp-playlist' );
2919
+		wp_print_scripts('wp-playlist');
2920 2920
 	} else {
2921
-		wp_print_scripts( array( 'froogaloop', 'wp-mediaelement' ) );
2921
+		wp_print_scripts(array('froogaloop', 'wp-mediaelement'));
2922 2922
 	}
2923 2923
 
2924
-	wp_send_json_success( array(
2924
+	wp_send_json_success(array(
2925 2925
 		'head' => $head,
2926 2926
 		'body' => ob_get_clean()
2927
-	) );
2927
+	));
2928 2928
 }
2929 2929
 
2930 2930
 /**
@@ -2933,33 +2933,33 @@  discard block
 block discarded – undo
2933 2933
  * @since 4.1.0
2934 2934
  */
2935 2935
 function wp_ajax_destroy_sessions() {
2936
-	$user = get_userdata( (int) $_POST['user_id'] );
2937
-	if ( $user ) {
2938
-		if ( ! current_user_can( 'edit_user', $user->ID ) ) {
2936
+	$user = get_userdata((int) $_POST['user_id']);
2937
+	if ($user) {
2938
+		if ( ! current_user_can('edit_user', $user->ID)) {
2939 2939
 			$user = false;
2940
-		} elseif ( ! wp_verify_nonce( $_POST['nonce'], 'update-user_' . $user->ID ) ) {
2940
+		} elseif ( ! wp_verify_nonce($_POST['nonce'], 'update-user_'.$user->ID)) {
2941 2941
 			$user = false;
2942 2942
 		}
2943 2943
 	}
2944 2944
 
2945
-	if ( ! $user ) {
2946
-		wp_send_json_error( array(
2947
-			'message' => __( 'Could not log out user sessions. Please try again.' ),
2948
-		) );
2945
+	if ( ! $user) {
2946
+		wp_send_json_error(array(
2947
+			'message' => __('Could not log out user sessions. Please try again.'),
2948
+		));
2949 2949
 	}
2950 2950
 
2951
-	$sessions = WP_Session_Tokens::get_instance( $user->ID );
2951
+	$sessions = WP_Session_Tokens::get_instance($user->ID);
2952 2952
 
2953
-	if ( $user->ID === get_current_user_id() ) {
2954
-		$sessions->destroy_others( wp_get_session_token() );
2955
-		$message = __( 'You are now logged out everywhere else.' );
2953
+	if ($user->ID === get_current_user_id()) {
2954
+		$sessions->destroy_others(wp_get_session_token());
2955
+		$message = __('You are now logged out everywhere else.');
2956 2956
 	} else {
2957 2957
 		$sessions->destroy_all();
2958 2958
 		/* translators: 1: User's display name. */
2959
-		$message = sprintf( __( '%s has been logged out.' ), $user->display_name );
2959
+		$message = sprintf(__('%s has been logged out.'), $user->display_name);
2960 2960
 	}
2961 2961
 
2962
-	wp_send_json_success( array( 'message' => $message ) );
2962
+	wp_send_json_success(array('message' => $message));
2963 2963
 }
2964 2964
 
2965 2965
 
@@ -2973,42 +2973,42 @@  discard block
 block discarded – undo
2973 2973
 function wp_ajax_update_plugin() {
2974 2974
 	global $wp_filesystem;
2975 2975
 
2976
-	$plugin = urldecode( $_POST['plugin'] );
2976
+	$plugin = urldecode($_POST['plugin']);
2977 2977
 
2978 2978
 	$status = array(
2979 2979
 		'update'     => 'plugin',
2980 2980
 		'plugin'     => $plugin,
2981
-		'slug'       => sanitize_key( $_POST['slug'] ),
2981
+		'slug'       => sanitize_key($_POST['slug']),
2982 2982
 		'oldVersion' => '',
2983 2983
 		'newVersion' => '',
2984 2984
 	);
2985 2985
 
2986
-	$plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
2987
-	if ( $plugin_data['Version'] ) {
2988
-		$status['oldVersion'] = sprintf( __( 'Version %s' ), $plugin_data['Version'] );
2986
+	$plugin_data = get_plugin_data(WP_PLUGIN_DIR.'/'.$plugin);
2987
+	if ($plugin_data['Version']) {
2988
+		$status['oldVersion'] = sprintf(__('Version %s'), $plugin_data['Version']);
2989 2989
 	}
2990 2990
 
2991
-	if ( ! current_user_can( 'update_plugins' ) ) {
2992
-		$status['error'] = __( 'You do not have sufficient permissions to update plugins for this site.' );
2993
- 		wp_send_json_error( $status );
2991
+	if ( ! current_user_can('update_plugins')) {
2992
+		$status['error'] = __('You do not have sufficient permissions to update plugins for this site.');
2993
+ 		wp_send_json_error($status);
2994 2994
 	}
2995 2995
 
2996
-	check_ajax_referer( 'updates' );
2996
+	check_ajax_referer('updates');
2997 2997
 
2998
-	include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
2998
+	include_once(ABSPATH.'wp-admin/includes/class-wp-upgrader.php');
2999 2999
 
3000 3000
 	wp_update_plugins();
3001 3001
 
3002 3002
 	$skin = new Automatic_Upgrader_Skin();
3003
-	$upgrader = new Plugin_Upgrader( $skin );
3004
-	$result = $upgrader->bulk_upgrade( array( $plugin ) );
3003
+	$upgrader = new Plugin_Upgrader($skin);
3004
+	$result = $upgrader->bulk_upgrade(array($plugin));
3005 3005
 
3006
-	if ( is_array( $result ) && empty( $result[$plugin] ) && is_wp_error( $skin->result ) ) {
3006
+	if (is_array($result) && empty($result[$plugin]) && is_wp_error($skin->result)) {
3007 3007
 		$result = $skin->result;
3008 3008
 	}
3009 3009
 
3010
-	if ( is_array( $result ) && !empty( $result[ $plugin ] ) ) {
3011
-		$plugin_update_data = current( $result );
3010
+	if (is_array($result) && ! empty($result[$plugin])) {
3011
+		$plugin_update_data = current($result);
3012 3012
 
3013 3013
 		/*
3014 3014
 		 * If the `update_plugins` site transient is empty (e.g. when you update
@@ -3018,32 +3018,32 @@  discard block
 block discarded – undo
3018 3018
 		 * Preferably something can be done to ensure `update_plugins` isn't empty.
3019 3019
 		 * For now, surface some sort of error here.
3020 3020
 		 */
3021
-		if ( $plugin_update_data === true ) {
3022
- 			wp_send_json_error( $status );
3021
+		if ($plugin_update_data === true) {
3022
+ 			wp_send_json_error($status);
3023 3023
 		}
3024 3024
 
3025
-		$plugin_data = get_plugins( '/' . $result[ $plugin ]['destination_name'] );
3026
-		$plugin_data = reset( $plugin_data );
3025
+		$plugin_data = get_plugins('/'.$result[$plugin]['destination_name']);
3026
+		$plugin_data = reset($plugin_data);
3027 3027
 
3028
-		if ( $plugin_data['Version'] ) {
3029
-			$status['newVersion'] = sprintf( __( 'Version %s' ), $plugin_data['Version'] );
3028
+		if ($plugin_data['Version']) {
3029
+			$status['newVersion'] = sprintf(__('Version %s'), $plugin_data['Version']);
3030 3030
 		}
3031 3031
 
3032
-		wp_send_json_success( $status );
3033
-	} else if ( is_wp_error( $result ) ) {
3032
+		wp_send_json_success($status);
3033
+	} else if (is_wp_error($result)) {
3034 3034
 		$status['error'] = $result->get_error_message();
3035
- 		wp_send_json_error( $status );
3035
+ 		wp_send_json_error($status);
3036 3036
 
3037
- 	} else if ( is_bool( $result ) && ! $result ) {
3037
+ 	} else if (is_bool($result) && ! $result) {
3038 3038
 		$status['errorCode'] = 'unable_to_connect_to_filesystem';
3039
-		$status['error'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );
3039
+		$status['error'] = __('Unable to connect to the filesystem. Please confirm your credentials.');
3040 3040
 
3041 3041
 		// Pass through the error from WP_Filesystem if one was raised
3042
-		if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
3042
+		if (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
3043 3043
 			$status['error'] = $wp_filesystem->errors->get_error_message();
3044 3044
 		}
3045 3045
 
3046
-		wp_send_json_error( $status );
3046
+		wp_send_json_error($status);
3047 3047
 
3048 3048
 	}
3049 3049
 }
@@ -3056,8 +3056,8 @@  discard block
 block discarded – undo
3056 3056
  * @global WP_Press_This $wp_press_this
3057 3057
  */
3058 3058
 function wp_ajax_press_this_save_post() {
3059
-	if ( empty( $GLOBALS['wp_press_this'] ) ) {
3060
-		include( ABSPATH . 'wp-admin/includes/class-wp-press-this.php' );
3059
+	if (empty($GLOBALS['wp_press_this'])) {
3060
+		include(ABSPATH.'wp-admin/includes/class-wp-press-this.php');
3061 3061
 	}
3062 3062
 
3063 3063
 	$GLOBALS['wp_press_this']->save_post();
@@ -3071,8 +3071,8 @@  discard block
 block discarded – undo
3071 3071
  * @global WP_Press_This $wp_press_this
3072 3072
  */
3073 3073
 function wp_ajax_press_this_add_category() {
3074
-	if ( empty( $GLOBALS['wp_press_this'] ) ) {
3075
-		include( ABSPATH . 'wp-admin/includes/class-wp-press-this.php' );
3074
+	if (empty($GLOBALS['wp_press_this'])) {
3075
+		include(ABSPATH.'wp-admin/includes/class-wp-press-this.php');
3076 3076
 	}
3077 3077
 
3078 3078
 	$GLOBALS['wp_press_this']->add_category();
@@ -3086,49 +3086,49 @@  discard block
 block discarded – undo
3086 3086
  * @global WP_Site_Icon $wp_site_icon
3087 3087
  */
3088 3088
 function wp_ajax_crop_image() {
3089
-	$attachment_id = absint( $_POST['id'] );
3089
+	$attachment_id = absint($_POST['id']);
3090 3090
 
3091
-	check_ajax_referer( 'image_editor-' . $attachment_id, 'nonce' );
3092
-	if ( ! current_user_can( 'customize' ) ) {
3091
+	check_ajax_referer('image_editor-'.$attachment_id, 'nonce');
3092
+	if ( ! current_user_can('customize')) {
3093 3093
 		wp_send_json_error();
3094 3094
 	}
3095 3095
 
3096
-	$context = str_replace( '_', '-', $_POST['context'] );
3097
-	$data    = array_map( 'absint', $_POST['cropDetails'] );
3098
-	$cropped = wp_crop_image( $attachment_id, $data['x1'], $data['y1'], $data['width'], $data['height'], $data['dst_width'], $data['dst_height'] );
3096
+	$context = str_replace('_', '-', $_POST['context']);
3097
+	$data    = array_map('absint', $_POST['cropDetails']);
3098
+	$cropped = wp_crop_image($attachment_id, $data['x1'], $data['y1'], $data['width'], $data['height'], $data['dst_width'], $data['dst_height']);
3099 3099
 
3100
-	if ( ! $cropped || is_wp_error( $cropped ) ) {
3101
-		wp_send_json_error( array( 'message' => __( 'Image could not be processed.' ) ) );
3100
+	if ( ! $cropped || is_wp_error($cropped)) {
3101
+		wp_send_json_error(array('message' => __('Image could not be processed.')));
3102 3102
 	}
3103 3103
 
3104
-	switch ( $context ) {
3104
+	switch ($context) {
3105 3105
 		case 'site-icon':
3106
-			require_once ABSPATH . '/wp-admin/includes/class-wp-site-icon.php';
3106
+			require_once ABSPATH.'/wp-admin/includes/class-wp-site-icon.php';
3107 3107
 			global $wp_site_icon;
3108 3108
 
3109 3109
 			// Skip creating a new attachment if the attachment is a Site Icon.
3110
-			if ( get_post_meta( $attachment_id, '_wp_attachment_context', true ) == $context ) {
3110
+			if (get_post_meta($attachment_id, '_wp_attachment_context', true) == $context) {
3111 3111
 
3112 3112
 				// Delete the temporary cropped file, we don't need it.
3113
-				wp_delete_file( $cropped );
3113
+				wp_delete_file($cropped);
3114 3114
 
3115 3115
 				// Additional sizes in wp_prepare_attachment_for_js().
3116
-				add_filter( 'image_size_names_choose', array( $wp_site_icon, 'additional_sizes' ) );
3116
+				add_filter('image_size_names_choose', array($wp_site_icon, 'additional_sizes'));
3117 3117
 				break;
3118 3118
 			}
3119 3119
 
3120 3120
 			/** This filter is documented in wp-admin/custom-header.php */
3121
-			$cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication.
3122
-			$object  = $wp_site_icon->create_attachment_object( $cropped, $attachment_id );
3123
-			unset( $object['ID'] );
3121
+			$cropped = apply_filters('wp_create_file_in_uploads', $cropped, $attachment_id); // For replication.
3122
+			$object  = $wp_site_icon->create_attachment_object($cropped, $attachment_id);
3123
+			unset($object['ID']);
3124 3124
 
3125 3125
 			// Update the attachment.
3126
-			add_filter( 'intermediate_image_sizes_advanced', array( $wp_site_icon, 'additional_sizes' ) );
3127
-			$attachment_id = $wp_site_icon->insert_attachment( $object, $cropped );
3128
-			remove_filter( 'intermediate_image_sizes_advanced', array( $wp_site_icon, 'additional_sizes' ) );
3126
+			add_filter('intermediate_image_sizes_advanced', array($wp_site_icon, 'additional_sizes'));
3127
+			$attachment_id = $wp_site_icon->insert_attachment($object, $cropped);
3128
+			remove_filter('intermediate_image_sizes_advanced', array($wp_site_icon, 'additional_sizes'));
3129 3129
 
3130 3130
 			// Additional sizes in wp_prepare_attachment_for_js().
3131
-			add_filter( 'image_size_names_choose', array( $wp_site_icon, 'additional_sizes' ) );
3131
+			add_filter('image_size_names_choose', array($wp_site_icon, 'additional_sizes'));
3132 3132
 			break;
3133 3133
 
3134 3134
 		default:
@@ -3144,27 +3144,27 @@  discard block
 block discarded – undo
3144 3144
 			 * @param int    $attachment_id The attachment ID of the original image.
3145 3145
 			 * @param string $cropped       Path to the cropped image file.
3146 3146
 			 */
3147
-			do_action( 'wp_ajax_crop_image_pre_save', $context, $attachment_id, $cropped );
3147
+			do_action('wp_ajax_crop_image_pre_save', $context, $attachment_id, $cropped);
3148 3148
 
3149 3149
 			/** This filter is documented in wp-admin/custom-header.php */
3150
-			$cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication.
3150
+			$cropped = apply_filters('wp_create_file_in_uploads', $cropped, $attachment_id); // For replication.
3151 3151
 
3152
-			$parent_url = get_post( $attachment_id )->guid;
3153
-			$url        = str_replace( basename( $parent_url ), basename( $cropped ), $parent_url );
3152
+			$parent_url = get_post($attachment_id)->guid;
3153
+			$url        = str_replace(basename($parent_url), basename($cropped), $parent_url);
3154 3154
 
3155
-			$size       = @getimagesize( $cropped );
3156
-			$image_type = ( $size ) ? $size['mime'] : 'image/jpeg';
3155
+			$size       = @getimagesize($cropped);
3156
+			$image_type = ($size) ? $size['mime'] : 'image/jpeg';
3157 3157
 
3158 3158
 			$object = array(
3159
-				'post_title'     => basename( $cropped ),
3159
+				'post_title'     => basename($cropped),
3160 3160
 				'post_content'   => $url,
3161 3161
 				'post_mime_type' => $image_type,
3162 3162
 				'guid'           => $url,
3163 3163
 				'context'        => $context,
3164 3164
 			);
3165 3165
 
3166
-			$attachment_id = wp_insert_attachment( $object, $cropped );
3167
-			$metadata = wp_generate_attachment_metadata( $attachment_id, $cropped );
3166
+			$attachment_id = wp_insert_attachment($object, $cropped);
3167
+			$metadata = wp_generate_attachment_metadata($attachment_id, $cropped);
3168 3168
 
3169 3169
 			/**
3170 3170
 			 * Filter the cropped image attachment metadata.
@@ -3175,8 +3175,8 @@  discard block
 block discarded – undo
3175 3175
 			 *
3176 3176
 			 * @param array $metadata Attachment metadata.
3177 3177
 			 */
3178
-			$metadata = apply_filters( 'wp_ajax_cropped_attachment_metadata', $metadata );
3179
-			wp_update_attachment_metadata( $attachment_id, $metadata );
3178
+			$metadata = apply_filters('wp_ajax_cropped_attachment_metadata', $metadata);
3179
+			wp_update_attachment_metadata($attachment_id, $metadata);
3180 3180
 
3181 3181
 			/**
3182 3182
 			 * Filter the attachment ID for a cropped image.
@@ -3186,8 +3186,8 @@  discard block
 block discarded – undo
3186 3186
 			 * @param int    $attachment_id The attachment ID of the cropped image.
3187 3187
 			 * @param string $context       The Customizer control requesting the cropped image.
3188 3188
 			 */
3189
-			$attachment_id = apply_filters( 'wp_ajax_cropped_attachment_id', $attachment_id, $context );
3189
+			$attachment_id = apply_filters('wp_ajax_cropped_attachment_id', $attachment_id, $context);
3190 3190
 	}
3191 3191
 
3192
-	wp_send_json_success( wp_prepare_attachment_for_js( $attachment_id ) );
3192
+	wp_send_json_success(wp_prepare_attachment_for_js($attachment_id));
3193 3193
 }
Please login to merge, or discard this patch.
Braces   +596 added lines, -399 removed lines patch added patch discarded remove patch
@@ -22,10 +22,11 @@  discard block
 block discarded – undo
22 22
 	$response = array();
23 23
 
24 24
 	// screen_id is the same as $current_screen->id and the JS global 'pagenow'.
25
-	if ( ! empty($_POST['screen_id']) )
26
-		$screen_id = sanitize_key($_POST['screen_id']);
27
-	else
28
-		$screen_id = 'front';
25
+	if ( ! empty($_POST['screen_id']) ) {
26
+			$screen_id = sanitize_key($_POST['screen_id']);
27
+	} else {
28
+			$screen_id = 'front';
29
+	}
29 30
 
30 31
 	if ( ! empty($_POST['data']) ) {
31 32
 		$data = wp_unslash( (array) $_POST['data'] );
@@ -88,11 +89,13 @@  discard block
 block discarded – undo
88 89
 	check_ajax_referer( "fetch-list-$list_class", '_ajax_fetch_list_nonce' );
89 90
 
90 91
 	$wp_list_table = _get_list_table( $list_class, array( 'screen' => $_GET['list_args']['screen']['id'] ) );
91
-	if ( ! $wp_list_table )
92
-		wp_die( 0 );
92
+	if ( ! $wp_list_table ) {
93
+			wp_die( 0 );
94
+	}
93 95
 
94
-	if ( ! $wp_list_table->ajax_user_can() )
95
-		wp_die( -1 );
96
+	if ( ! $wp_list_table->ajax_user_can() ) {
97
+			wp_die( -1 );
98
+	}
96 99
 
97 100
 	$wp_list_table->ajax_response();
98 101
 
@@ -122,8 +125,9 @@  discard block
 block discarded – undo
122 125
 	$s = wp_unslash( $_GET['q'] );
123 126
 
124 127
 	$comma = _x( ',', 'tag delimiter' );
125
-	if ( ',' !== $comma )
126
-		$s = str_replace( $comma, ',', $s );
128
+	if ( ',' !== $comma ) {
129
+			$s = str_replace( $comma, ',', $s );
130
+	}
127 131
 	if ( false !== strpos( $s, ',' ) ) {
128 132
 		$s = explode( ',', $s );
129 133
 		$s = $s[count( $s ) - 1];
@@ -161,8 +165,9 @@  discard block
 block discarded – undo
161 165
  * @since 3.1.0
162 166
  */
163 167
 function wp_ajax_wp_compression_test() {
164
-	if ( !current_user_can( 'manage_options' ) )
165
-		wp_die( -1 );
168
+	if ( !current_user_can( 'manage_options' ) ) {
169
+			wp_die( -1 );
170
+	}
166 171
 
167 172
 	if ( ini_get('zlib.output_compression') || 'ob_gzhandler' == ini_get('output_handler') ) {
168 173
 		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 );
@@ -212,14 +218,16 @@  discard block
 block discarded – undo
212 218
  */
213 219
 function wp_ajax_imgedit_preview() {
214 220
 	$post_id = intval($_GET['postid']);
215
-	if ( empty($post_id) || !current_user_can('edit_post', $post_id) )
216
-		wp_die( -1 );
221
+	if ( empty($post_id) || !current_user_can('edit_post', $post_id) ) {
222
+			wp_die( -1 );
223
+	}
217 224
 
218 225
 	check_ajax_referer( "image_editor-$post_id" );
219 226
 
220 227
 	include_once( ABSPATH . 'wp-admin/includes/image-edit.php' );
221
-	if ( ! stream_preview_image($post_id) )
222
-		wp_die( -1 );
228
+	if ( ! stream_preview_image($post_id) ) {
229
+			wp_die( -1 );
230
+	}
223 231
 
224 232
 	wp_die();
225 233
 }
@@ -242,12 +250,14 @@  discard block
 block discarded – undo
242 250
  * @since 3.4.0
243 251
  */
244 252
 function wp_ajax_autocomplete_user() {
245
-	if ( ! is_multisite() || ! current_user_can( 'promote_users' ) || wp_is_large_network( 'users' ) )
246
-		wp_die( -1 );
253
+	if ( ! is_multisite() || ! current_user_can( 'promote_users' ) || wp_is_large_network( 'users' ) ) {
254
+			wp_die( -1 );
255
+	}
247 256
 
248 257
 	/** This filter is documented in wp-admin/user-new.php */
249
-	if ( ! is_super_admin() && ! apply_filters( 'autocomplete_users_for_site_admins', false ) )
250
-		wp_die( -1 );
258
+	if ( ! is_super_admin() && ! apply_filters( 'autocomplete_users_for_site_admins', false ) ) {
259
+			wp_die( -1 );
260
+	}
251 261
 
252 262
 	$return = array();
253 263
 
@@ -365,8 +375,9 @@  discard block
 block discarded – undo
365 375
 	}
366 376
 
367 377
 	$total += $delta;
368
-	if ( $total < 0 )
369
-		$total = 0;
378
+	if ( $total < 0 ) {
379
+			$total = 0;
380
+	}
370 381
 
371 382
 	// Only do the expensive stuff on a page-break, and about 1 other time per page
372 383
 	if ( 0 == $total % $per_page || 1 == mt_rand( 1, $per_page ) ) {
@@ -375,17 +386,20 @@  discard block
 block discarded – undo
375 386
 		$parsed = parse_url( $url );
376 387
 		if ( isset( $parsed['query'] ) ) {
377 388
 			parse_str( $parsed['query'], $query_vars );
378
-			if ( !empty( $query_vars['comment_status'] ) )
379
-				$status = $query_vars['comment_status'];
380
-			if ( !empty( $query_vars['p'] ) )
381
-				$post_id = (int) $query_vars['p'];
389
+			if ( !empty( $query_vars['comment_status'] ) ) {
390
+							$status = $query_vars['comment_status'];
391
+			}
392
+			if ( !empty( $query_vars['p'] ) ) {
393
+							$post_id = (int) $query_vars['p'];
394
+			}
382 395
 		}
383 396
 
384 397
 		$comment_count = wp_count_comments($post_id);
385 398
 
386 399
 		// We're looking for a known type of comment count.
387
-		if ( isset( $comment_count->$status ) )
388
-			$total = $comment_count->$status;
400
+		if ( isset( $comment_count->$status ) ) {
401
+					$total = $comment_count->$status;
402
+		}
389 403
 			// Else use the decremented value from above.
390 404
 	}
391 405
 
@@ -423,34 +437,41 @@  discard block
 block discarded – undo
423 437
 	$action = $_POST['action'];
424 438
 	$taxonomy = get_taxonomy(substr($action, 4));
425 439
 	check_ajax_referer( $action, '_ajax_nonce-add-' . $taxonomy->name );
426
-	if ( !current_user_can( $taxonomy->cap->edit_terms ) )
427
-		wp_die( -1 );
440
+	if ( !current_user_can( $taxonomy->cap->edit_terms ) ) {
441
+			wp_die( -1 );
442
+	}
428 443
 	$names = explode(',', $_POST['new'.$taxonomy->name]);
429 444
 	$parent = isset($_POST['new'.$taxonomy->name.'_parent']) ? (int) $_POST['new'.$taxonomy->name.'_parent'] : 0;
430
-	if ( 0 > $parent )
431
-		$parent = 0;
432
-	if ( $taxonomy->name == 'category' )
433
-		$post_category = isset($_POST['post_category']) ? (array) $_POST['post_category'] : array();
434
-	else
435
-		$post_category = ( isset($_POST['tax_input']) && isset($_POST['tax_input'][$taxonomy->name]) ) ? (array) $_POST['tax_input'][$taxonomy->name] : array();
445
+	if ( 0 > $parent ) {
446
+			$parent = 0;
447
+	}
448
+	if ( $taxonomy->name == 'category' ) {
449
+			$post_category = isset($_POST['post_category']) ? (array) $_POST['post_category'] : array();
450
+	} else {
451
+			$post_category = ( isset($_POST['tax_input']) && isset($_POST['tax_input'][$taxonomy->name]) ) ? (array) $_POST['tax_input'][$taxonomy->name] : array();
452
+	}
436 453
 	$checked_categories = array_map( 'absint', (array) $post_category );
437 454
 	$popular_ids = wp_popular_terms_checklist($taxonomy->name, 0, 10, false);
438 455
 
439 456
 	foreach ( $names as $cat_name ) {
440 457
 		$cat_name = trim($cat_name);
441 458
 		$category_nicename = sanitize_title($cat_name);
442
-		if ( '' === $category_nicename )
443
-			continue;
444
-		if ( !$cat_id = term_exists( $cat_name, $taxonomy->name, $parent ) )
445
-			$cat_id = wp_insert_term( $cat_name, $taxonomy->name, array( 'parent' => $parent ) );
459
+		if ( '' === $category_nicename ) {
460
+					continue;
461
+		}
462
+		if ( !$cat_id = term_exists( $cat_name, $taxonomy->name, $parent ) ) {
463
+					$cat_id = wp_insert_term( $cat_name, $taxonomy->name, array( 'parent' => $parent ) );
464
+		}
446 465
 		if ( is_wp_error( $cat_id ) ) {
447 466
 			continue;
448 467
 		} elseif ( is_array( $cat_id ) ) {
449 468
 			$cat_id = $cat_id['term_id'];
450 469
 		}
451 470
 		$checked_categories[] = $cat_id;
452
-		if ( $parent ) // Do these all at once in a second
471
+		if ( $parent ) {
472
+			// Do these all at once in a second
453 473
 			continue;
474
+		}
454 475
 
455 476
 		ob_start();
456 477
 
@@ -472,8 +493,9 @@  discard block
 block discarded – undo
472 493
 
473 494
 		while ( $parent->parent ) { // get the top parent
474 495
 			$parent = get_term( $parent->parent, $taxonomy->name );
475
-			if ( is_wp_error( $parent ) )
476
-				break;
496
+			if ( is_wp_error( $parent ) ) {
497
+							break;
498
+			}
477 499
 			$term_id = $parent->term_id;
478 500
 		}
479 501
 
@@ -514,43 +536,55 @@  discard block
 block discarded – undo
514 536
 function wp_ajax_delete_comment() {
515 537
 	$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
516 538
 
517
-	if ( !$comment = get_comment( $id ) )
518
-		wp_die( time() );
519
-	if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) )
520
-		wp_die( -1 );
539
+	if ( !$comment = get_comment( $id ) ) {
540
+			wp_die( time() );
541
+	}
542
+	if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) {
543
+			wp_die( -1 );
544
+	}
521 545
 
522 546
 	check_ajax_referer( "delete-comment_$id" );
523 547
 	$status = wp_get_comment_status( $comment->comment_ID );
524 548
 
525 549
 	$delta = -1;
526 550
 	if ( isset($_POST['trash']) && 1 == $_POST['trash'] ) {
527
-		if ( 'trash' == $status )
528
-			wp_die( time() );
551
+		if ( 'trash' == $status ) {
552
+					wp_die( time() );
553
+		}
529 554
 		$r = wp_trash_comment( $comment->comment_ID );
530 555
 	} elseif ( isset($_POST['untrash']) && 1 == $_POST['untrash'] ) {
531
-		if ( 'trash' != $status )
532
-			wp_die( time() );
556
+		if ( 'trash' != $status ) {
557
+					wp_die( time() );
558
+		}
533 559
 		$r = wp_untrash_comment( $comment->comment_ID );
534
-		if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) // undo trash, not in trash
560
+		if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) {
561
+			// undo trash, not in trash
535 562
 			$delta = 1;
563
+		}
536 564
 	} elseif ( isset($_POST['spam']) && 1 == $_POST['spam'] ) {
537
-		if ( 'spam' == $status )
538
-			wp_die( time() );
565
+		if ( 'spam' == $status ) {
566
+					wp_die( time() );
567
+		}
539 568
 		$r = wp_spam_comment( $comment->comment_ID );
540 569
 	} elseif ( isset($_POST['unspam']) && 1 == $_POST['unspam'] ) {
541
-		if ( 'spam' != $status )
542
-			wp_die( time() );
570
+		if ( 'spam' != $status ) {
571
+					wp_die( time() );
572
+		}
543 573
 		$r = wp_unspam_comment( $comment->comment_ID );
544
-		if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) // undo spam, not in spam
574
+		if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) {
575
+			// undo spam, not in spam
545 576
 			$delta = 1;
577
+		}
546 578
 	} elseif ( isset($_POST['delete']) && 1 == $_POST['delete'] ) {
547 579
 		$r = wp_delete_comment( $comment->comment_ID );
548 580
 	} else {
549 581
 		wp_die( -1 );
550 582
 	}
551 583
 
552
-	if ( $r ) // Decide if we need to send back '1' or a more complicated response including page links and comment counts
584
+	if ( $r ) {
585
+		// Decide if we need to send back '1' or a more complicated response including page links and comment counts
553 586
 		_wp_ajax_delete_comment_response( $comment->comment_ID, $delta );
587
+	}
554 588
 	wp_die( 0 );
555 589
 }
556 590
 
@@ -566,18 +600,21 @@  discard block
 block discarded – undo
566 600
 	$taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
567 601
 	$tax = get_taxonomy($taxonomy);
568 602
 
569
-	if ( !current_user_can( $tax->cap->delete_terms ) )
570
-		wp_die( -1 );
603
+	if ( !current_user_can( $tax->cap->delete_terms ) ) {
604
+			wp_die( -1 );
605
+	}
571 606
 
572 607
 	$tag = get_term( $tag_id, $taxonomy );
573
-	if ( !$tag || is_wp_error( $tag ) )
574
-		wp_die( 1 );
608
+	if ( !$tag || is_wp_error( $tag ) ) {
609
+			wp_die( 1 );
610
+	}
575 611
 
576
-	if ( wp_delete_term($tag_id, $taxonomy))
577
-		wp_die( 1 );
578
-	else
579
-		wp_die( 0 );
580
-}
612
+	if ( wp_delete_term($tag_id, $taxonomy)) {
613
+			wp_die( 1 );
614
+	} else {
615
+			wp_die( 0 );
616
+	}
617
+	}
581 618
 
582 619
 /**
583 620
  * Ajax handler for deleting a link.
@@ -588,18 +625,21 @@  discard block
 block discarded – undo
588 625
 	$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
589 626
 
590 627
 	check_ajax_referer( "delete-bookmark_$id" );
591
-	if ( !current_user_can( 'manage_links' ) )
592
-		wp_die( -1 );
628
+	if ( !current_user_can( 'manage_links' ) ) {
629
+			wp_die( -1 );
630
+	}
593 631
 
594 632
 	$link = get_bookmark( $id );
595
-	if ( !$link || is_wp_error( $link ) )
596
-		wp_die( 1 );
633
+	if ( !$link || is_wp_error( $link ) ) {
634
+			wp_die( 1 );
635
+	}
597 636
 
598
-	if ( wp_delete_link( $id ) )
599
-		wp_die( 1 );
600
-	else
601
-		wp_die( 0 );
602
-}
637
+	if ( wp_delete_link( $id ) ) {
638
+			wp_die( 1 );
639
+	} else {
640
+			wp_die( 0 );
641
+	}
642
+	}
603 643
 
604 644
 /**
605 645
  * Ajax handler for deleting meta.
@@ -610,13 +650,16 @@  discard block
 block discarded – undo
610 650
 	$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
611 651
 
612 652
 	check_ajax_referer( "delete-meta_$id" );
613
-	if ( !$meta = get_metadata_by_mid( 'post', $id ) )
614
-		wp_die( 1 );
653
+	if ( !$meta = get_metadata_by_mid( 'post', $id ) ) {
654
+			wp_die( 1 );
655
+	}
615 656
 
616
-	if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta',  $meta->post_id, $meta->meta_key ) )
617
-		wp_die( -1 );
618
-	if ( delete_meta( $meta->meta_id ) )
619
-		wp_die( 1 );
657
+	if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta',  $meta->post_id, $meta->meta_key ) ) {
658
+			wp_die( -1 );
659
+	}
660
+	if ( delete_meta( $meta->meta_id ) ) {
661
+			wp_die( 1 );
662
+	}
620 663
 	wp_die( 0 );
621 664
 }
622 665
 
@@ -628,22 +671,26 @@  discard block
 block discarded – undo
628 671
  * @param string $action Action to perform.
629 672
  */
630 673
 function wp_ajax_delete_post( $action ) {
631
-	if ( empty( $action ) )
632
-		$action = 'delete-post';
674
+	if ( empty( $action ) ) {
675
+			$action = 'delete-post';
676
+	}
633 677
 	$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
634 678
 
635 679
 	check_ajax_referer( "{$action}_$id" );
636
-	if ( !current_user_can( 'delete_post', $id ) )
637
-		wp_die( -1 );
680
+	if ( !current_user_can( 'delete_post', $id ) ) {
681
+			wp_die( -1 );
682
+	}
638 683
 
639
-	if ( !get_post( $id ) )
640
-		wp_die( 1 );
684
+	if ( !get_post( $id ) ) {
685
+			wp_die( 1 );
686
+	}
641 687
 
642
-	if ( wp_delete_post( $id ) )
643
-		wp_die( 1 );
644
-	else
645
-		wp_die( 0 );
646
-}
688
+	if ( wp_delete_post( $id ) ) {
689
+			wp_die( 1 );
690
+	} else {
691
+			wp_die( 0 );
692
+	}
693
+	}
647 694
 
648 695
 /**
649 696
  * Ajax handler for sending a post to the trash.
@@ -653,24 +700,29 @@  discard block
 block discarded – undo
653 700
  * @param string $action Action to perform.
654 701
  */
655 702
 function wp_ajax_trash_post( $action ) {
656
-	if ( empty( $action ) )
657
-		$action = 'trash-post';
703
+	if ( empty( $action ) ) {
704
+			$action = 'trash-post';
705
+	}
658 706
 	$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
659 707
 
660 708
 	check_ajax_referer( "{$action}_$id" );
661
-	if ( !current_user_can( 'delete_post', $id ) )
662
-		wp_die( -1 );
709
+	if ( !current_user_can( 'delete_post', $id ) ) {
710
+			wp_die( -1 );
711
+	}
663 712
 
664
-	if ( !get_post( $id ) )
665
-		wp_die( 1 );
713
+	if ( !get_post( $id ) ) {
714
+			wp_die( 1 );
715
+	}
666 716
 
667
-	if ( 'trash-post' == $action )
668
-		$done = wp_trash_post( $id );
669
-	else
670
-		$done = wp_untrash_post( $id );
717
+	if ( 'trash-post' == $action ) {
718
+			$done = wp_trash_post( $id );
719
+	} else {
720
+			$done = wp_untrash_post( $id );
721
+	}
671 722
 
672
-	if ( $done )
673
-		wp_die( 1 );
723
+	if ( $done ) {
724
+			wp_die( 1 );
725
+	}
674 726
 
675 727
 	wp_die( 0 );
676 728
 }
@@ -683,8 +735,9 @@  discard block
 block discarded – undo
683 735
  * @param string $action Action to perform.
684 736
  */
685 737
 function wp_ajax_untrash_post( $action ) {
686
-	if ( empty( $action ) )
687
-		$action = 'untrash-post';
738
+	if ( empty( $action ) ) {
739
+			$action = 'untrash-post';
740
+	}
688 741
 	wp_ajax_trash_post( $action );
689 742
 }
690 743
 
@@ -694,22 +747,26 @@  discard block
 block discarded – undo
694 747
  * @param string $action
695 748
  */
696 749
 function wp_ajax_delete_page( $action ) {
697
-	if ( empty( $action ) )
698
-		$action = 'delete-page';
750
+	if ( empty( $action ) ) {
751
+			$action = 'delete-page';
752
+	}
699 753
 	$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
700 754
 
701 755
 	check_ajax_referer( "{$action}_$id" );
702
-	if ( !current_user_can( 'delete_page', $id ) )
703
-		wp_die( -1 );
756
+	if ( !current_user_can( 'delete_page', $id ) ) {
757
+			wp_die( -1 );
758
+	}
704 759
 
705
-	if ( ! get_post( $id ) )
706
-		wp_die( 1 );
760
+	if ( ! get_post( $id ) ) {
761
+			wp_die( 1 );
762
+	}
707 763
 
708
-	if ( wp_delete_post( $id ) )
709
-		wp_die( 1 );
710
-	else
711
-		wp_die( 0 );
712
-}
764
+	if ( wp_delete_post( $id ) ) {
765
+			wp_die( 1 );
766
+	} else {
767
+			wp_die( 0 );
768
+	}
769
+	}
713 770
 
714 771
 /**
715 772
  * Ajax handler to dim a comment.
@@ -727,18 +784,21 @@  discard block
 block discarded – undo
727 784
 		$x->send();
728 785
 	}
729 786
 
730
-	if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) && ! current_user_can( 'moderate_comments' ) )
731
-		wp_die( -1 );
787
+	if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) && ! current_user_can( 'moderate_comments' ) ) {
788
+			wp_die( -1 );
789
+	}
732 790
 
733 791
 	$current = wp_get_comment_status( $comment->comment_ID );
734
-	if ( isset( $_POST['new'] ) && $_POST['new'] == $current )
735
-		wp_die( time() );
792
+	if ( isset( $_POST['new'] ) && $_POST['new'] == $current ) {
793
+			wp_die( time() );
794
+	}
736 795
 
737 796
 	check_ajax_referer( "approve-comment_$id" );
738
-	if ( in_array( $current, array( 'unapproved', 'spam' ) ) )
739
-		$result = wp_set_comment_status( $comment->comment_ID, 'approve', true );
740
-	else
741
-		$result = wp_set_comment_status( $comment->comment_ID, 'hold', true );
797
+	if ( in_array( $current, array( 'unapproved', 'spam' ) ) ) {
798
+			$result = wp_set_comment_status( $comment->comment_ID, 'approve', true );
799
+	} else {
800
+			$result = wp_set_comment_status( $comment->comment_ID, 'hold', true );
801
+	}
742 802
 
743 803
 	if ( is_wp_error($result) ) {
744 804
 		$x = new WP_Ajax_Response( array(
@@ -761,20 +821,24 @@  discard block
 block discarded – undo
761 821
  * @param string $action Action to perform.
762 822
  */
763 823
 function wp_ajax_add_link_category( $action ) {
764
-	if ( empty( $action ) )
765
-		$action = 'add-link-category';
824
+	if ( empty( $action ) ) {
825
+			$action = 'add-link-category';
826
+	}
766 827
 	check_ajax_referer( $action );
767
-	if ( !current_user_can( 'manage_categories' ) )
768
-		wp_die( -1 );
828
+	if ( !current_user_can( 'manage_categories' ) ) {
829
+			wp_die( -1 );
830
+	}
769 831
 	$names = explode(',', wp_unslash( $_POST['newcat'] ) );
770 832
 	$x = new WP_Ajax_Response();
771 833
 	foreach ( $names as $cat_name ) {
772 834
 		$cat_name = trim($cat_name);
773 835
 		$slug = sanitize_title($cat_name);
774
-		if ( '' === $slug )
775
-			continue;
776
-		if ( !$cat_id = term_exists( $cat_name, 'link_category' ) )
777
-			$cat_id = wp_insert_term( $cat_name, 'link_category' );
836
+		if ( '' === $slug ) {
837
+					continue;
838
+		}
839
+		if ( !$cat_id = term_exists( $cat_name, 'link_category' ) ) {
840
+					$cat_id = wp_insert_term( $cat_name, 'link_category' );
841
+		}
778 842
 		if ( is_wp_error( $cat_id ) ) {
779 843
 			continue;
780 844
 		} elseif ( is_array( $cat_id ) ) {
@@ -805,8 +869,9 @@  discard block
 block discarded – undo
805 869
 	$taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
806 870
 	$tax = get_taxonomy($taxonomy);
807 871
 
808
-	if ( !current_user_can( $tax->cap->edit_terms ) )
809
-		wp_die( -1 );
872
+	if ( !current_user_can( $tax->cap->edit_terms ) ) {
873
+			wp_die( -1 );
874
+	}
810 875
 
811 876
 	$x = new WP_Ajax_Response();
812 877
 
@@ -814,8 +879,9 @@  discard block
 block discarded – undo
814 879
 
815 880
 	if ( !$tag || is_wp_error($tag) || (!$tag = get_term( $tag['term_id'], $taxonomy )) ) {
816 881
 		$message = __('An error has occurred. Please reload the page and try again.');
817
-		if ( is_wp_error($tag) && $tag->get_error_message() )
818
-			$message = $tag->get_error_message();
882
+		if ( is_wp_error($tag) && $tag->get_error_message() ) {
883
+					$message = $tag->get_error_message();
884
+		}
819 885
 
820 886
 		$x->add( array(
821 887
 			'what' => 'taxonomy',
@@ -872,11 +938,13 @@  discard block
 block discarded – undo
872 938
 
873 939
 	$tags = get_terms( $taxonomy, array( 'number' => 45, 'orderby' => 'count', 'order' => 'DESC' ) );
874 940
 
875
-	if ( empty( $tags ) )
876
-		wp_die( $tax->labels->not_found );
941
+	if ( empty( $tags ) ) {
942
+			wp_die( $tax->labels->not_found );
943
+	}
877 944
 
878
-	if ( is_wp_error( $tags ) )
879
-		wp_die( $tags->get_error_message() );
945
+	if ( is_wp_error( $tags ) ) {
946
+			wp_die( $tags->get_error_message() );
947
+	}
880 948
 
881 949
 	foreach ( $tags as $key => $tag ) {
882 950
 		$tags[ $key ]->link = '#';
@@ -886,8 +954,9 @@  discard block
 block discarded – undo
886 954
 	// We need raw tag names here, so don't filter the output
887 955
 	$return = wp_generate_tag_cloud( $tags, array('filter' => 0) );
888 956
 
889
-	if ( empty($return) )
890
-		wp_die( 0 );
957
+	if ( empty($return) ) {
958
+			wp_die( 0 );
959
+	}
891 960
 
892 961
 	echo $return;
893 962
 
@@ -906,35 +975,41 @@  discard block
 block discarded – undo
906 975
  */
907 976
 function wp_ajax_get_comments( $action ) {
908 977
 	global $wp_list_table, $post_id;
909
-	if ( empty( $action ) )
910
-		$action = 'get-comments';
978
+	if ( empty( $action ) ) {
979
+			$action = 'get-comments';
980
+	}
911 981
 
912 982
 	check_ajax_referer( $action );
913 983
 
914 984
 	if ( empty( $post_id ) && ! empty( $_REQUEST['p'] ) ) {
915 985
 		$id = absint( $_REQUEST['p'] );
916
-		if ( ! empty( $id ) )
917
-			$post_id = $id;
986
+		if ( ! empty( $id ) ) {
987
+					$post_id = $id;
988
+		}
918 989
 	}
919 990
 
920
-	if ( empty( $post_id ) )
921
-		wp_die( -1 );
991
+	if ( empty( $post_id ) ) {
992
+			wp_die( -1 );
993
+	}
922 994
 
923 995
 	$wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
924 996
 
925
-	if ( ! current_user_can( 'edit_post', $post_id ) )
926
-		wp_die( -1 );
997
+	if ( ! current_user_can( 'edit_post', $post_id ) ) {
998
+			wp_die( -1 );
999
+	}
927 1000
 
928 1001
 	$wp_list_table->prepare_items();
929 1002
 
930
-	if ( !$wp_list_table->has_items() )
931
-		wp_die( 1 );
1003
+	if ( !$wp_list_table->has_items() ) {
1004
+			wp_die( 1 );
1005
+	}
932 1006
 
933 1007
 	$x = new WP_Ajax_Response();
934 1008
 	ob_start();
935 1009
 	foreach ( $wp_list_table->items as $comment ) {
936
-		if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) )
937
-			continue;
1010
+		if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) {
1011
+					continue;
1012
+		}
938 1013
 		get_comment( $comment );
939 1014
 		$wp_list_table->single_row( $comment );
940 1015
 	}
@@ -958,23 +1033,27 @@  discard block
 block discarded – undo
958 1033
  */
959 1034
 function wp_ajax_replyto_comment( $action ) {
960 1035
 	global $wp_list_table;
961
-	if ( empty( $action ) )
962
-		$action = 'replyto-comment';
1036
+	if ( empty( $action ) ) {
1037
+			$action = 'replyto-comment';
1038
+	}
963 1039
 
964 1040
 	check_ajax_referer( $action, '_ajax_nonce-replyto-comment' );
965 1041
 
966 1042
 	$comment_post_ID = (int) $_POST['comment_post_ID'];
967 1043
 	$post = get_post( $comment_post_ID );
968
-	if ( ! $post )
969
-		wp_die( -1 );
1044
+	if ( ! $post ) {
1045
+			wp_die( -1 );
1046
+	}
970 1047
 
971
-	if ( !current_user_can( 'edit_post', $comment_post_ID ) )
972
-		wp_die( -1 );
1048
+	if ( !current_user_can( 'edit_post', $comment_post_ID ) ) {
1049
+			wp_die( -1 );
1050
+	}
973 1051
 
974
-	if ( empty( $post->post_status ) )
975
-		wp_die( 1 );
976
-	elseif ( in_array($post->post_status, array('draft', 'pending', 'trash') ) )
977
-		wp_die( __('ERROR: you are replying to a comment on a draft post.') );
1052
+	if ( empty( $post->post_status ) ) {
1053
+			wp_die( 1 );
1054
+	} elseif ( in_array($post->post_status, array('draft', 'pending', 'trash') ) ) {
1055
+			wp_die( __('ERROR: you are replying to a comment on a draft post.') );
1056
+	}
978 1057
 
979 1058
 	$user = wp_get_current_user();
980 1059
 	if ( $user->exists() ) {
@@ -985,8 +1064,9 @@  discard block
 block discarded – undo
985 1064
 		$comment_content      = trim( $_POST['content'] );
986 1065
 		$comment_type         = isset( $_POST['comment_type'] ) ? trim( $_POST['comment_type'] ) : '';
987 1066
 		if ( current_user_can( 'unfiltered_html' ) ) {
988
-			if ( ! isset( $_POST['_wp_unfiltered_html_comment'] ) )
989
-				$_POST['_wp_unfiltered_html_comment'] = '';
1067
+			if ( ! isset( $_POST['_wp_unfiltered_html_comment'] ) ) {
1068
+							$_POST['_wp_unfiltered_html_comment'] = '';
1069
+			}
990 1070
 
991 1071
 			if ( wp_create_nonce( 'unfiltered-html-comment' ) != $_POST['_wp_unfiltered_html_comment'] ) {
992 1072
 				kses_remove_filters(); // start with a clean slate
@@ -997,12 +1077,14 @@  discard block
 block discarded – undo
997 1077
 		wp_die( __( 'Sorry, you must be logged in to reply to a comment.' ) );
998 1078
 	}
999 1079
 
1000
-	if ( '' == $comment_content )
1001
-		wp_die( __( 'ERROR: please type a comment.' ) );
1080
+	if ( '' == $comment_content ) {
1081
+			wp_die( __( 'ERROR: please type a comment.' ) );
1082
+	}
1002 1083
 
1003 1084
 	$comment_parent = 0;
1004
-	if ( isset( $_POST['comment_ID'] ) )
1005
-		$comment_parent = absint( $_POST['comment_ID'] );
1085
+	if ( isset( $_POST['comment_ID'] ) ) {
1086
+			$comment_parent = absint( $_POST['comment_ID'] );
1087
+	}
1006 1088
 	$comment_auto_approved = false;
1007 1089
 	$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID');
1008 1090
 
@@ -1011,14 +1093,17 @@  discard block
 block discarded – undo
1011 1093
 		$parent = get_comment( $comment_parent );
1012 1094
 
1013 1095
 		if ( $parent && $parent->comment_approved === '0' && $parent->comment_post_ID == $comment_post_ID ) {
1014
-			if ( wp_set_comment_status( $parent->comment_ID, 'approve' ) )
1015
-				$comment_auto_approved = true;
1096
+			if ( wp_set_comment_status( $parent->comment_ID, 'approve' ) ) {
1097
+							$comment_auto_approved = true;
1098
+			}
1016 1099
 		}
1017 1100
 	}
1018 1101
 
1019 1102
 	$comment_id = wp_new_comment( $commentdata );
1020 1103
 	$comment = get_comment($comment_id);
1021
-	if ( ! $comment ) wp_die( 1 );
1104
+	if ( ! $comment ) {
1105
+		wp_die( 1 );
1106
+	}
1022 1107
 
1023 1108
 	$position = ( isset($_POST['position']) && (int) $_POST['position'] ) ? (int) $_POST['position'] : '-1';
1024 1109
 
@@ -1043,8 +1128,9 @@  discard block
 block discarded – undo
1043 1128
 		'position' => $position
1044 1129
 	);
1045 1130
 
1046
-	if ( $comment_auto_approved )
1047
-		$response['supplemental'] = array( 'parent_approved' => $parent->comment_ID, 'parent_post_id' => $parent->comment_post_ID );
1131
+	if ( $comment_auto_approved ) {
1132
+			$response['supplemental'] = array( 'parent_approved' => $parent->comment_ID, 'parent_post_id' => $parent->comment_post_ID );
1133
+	}
1048 1134
 
1049 1135
 	$x = new WP_Ajax_Response();
1050 1136
 	$x->add( $response );
@@ -1064,14 +1150,17 @@  discard block
 block discarded – undo
1064 1150
 	check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' );
1065 1151
 
1066 1152
 	$comment_id = (int) $_POST['comment_ID'];
1067
-	if ( ! current_user_can( 'edit_comment', $comment_id ) )
1068
-		wp_die( -1 );
1153
+	if ( ! current_user_can( 'edit_comment', $comment_id ) ) {
1154
+			wp_die( -1 );
1155
+	}
1069 1156
 
1070
-	if ( '' == $_POST['content'] )
1071
-		wp_die( __( 'ERROR: please type a comment.' ) );
1157
+	if ( '' == $_POST['content'] ) {
1158
+			wp_die( __( 'ERROR: please type a comment.' ) );
1159
+	}
1072 1160
 
1073
-	if ( isset( $_POST['status'] ) )
1074
-		$_POST['comment_status'] = $_POST['status'];
1161
+	if ( isset( $_POST['status'] ) ) {
1162
+			$_POST['comment_status'] = $_POST['status'];
1163
+	}
1075 1164
 	edit_comment();
1076 1165
 
1077 1166
 	$position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1';
@@ -1079,8 +1168,9 @@  discard block
 block discarded – undo
1079 1168
 	$wp_list_table = _get_list_table( $checkbox ? 'WP_Comments_List_Table' : 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
1080 1169
 
1081 1170
 	$comment = get_comment( $comment_id );
1082
-	if ( empty( $comment->comment_ID ) )
1083
-		wp_die( -1 );
1171
+	if ( empty( $comment->comment_ID ) ) {
1172
+			wp_die( -1 );
1173
+	}
1084 1174
 
1085 1175
 	ob_start();
1086 1176
 	$wp_list_table->single_row( $comment );
@@ -1106,8 +1196,9 @@  discard block
 block discarded – undo
1106 1196
 function wp_ajax_add_menu_item() {
1107 1197
 	check_ajax_referer( 'add-menu_item', 'menu-settings-column-nonce' );
1108 1198
 
1109
-	if ( ! current_user_can( 'edit_theme_options' ) )
1110
-		wp_die( -1 );
1199
+	if ( ! current_user_can( 'edit_theme_options' ) ) {
1200
+			wp_die( -1 );
1201
+	}
1111 1202
 
1112 1203
 	require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
1113 1204
 
@@ -1142,8 +1233,9 @@  discard block
 block discarded – undo
1142 1233
 	}
1143 1234
 
1144 1235
 	$item_ids = wp_save_nav_menu_items( 0, $menu_items_data );
1145
-	if ( is_wp_error( $item_ids ) )
1146
-		wp_die( 0 );
1236
+	if ( is_wp_error( $item_ids ) ) {
1237
+			wp_die( 0 );
1238
+	}
1147 1239
 
1148 1240
 	$menu_items = array();
1149 1241
 
@@ -1159,8 +1251,9 @@  discard block
 block discarded – undo
1159 1251
 	/** This filter is documented in wp-admin/includes/nav-menu.php */
1160 1252
 	$walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $_POST['menu'] );
1161 1253
 
1162
-	if ( ! class_exists( $walker_class_name ) )
1163
-		wp_die( 0 );
1254
+	if ( ! class_exists( $walker_class_name ) ) {
1255
+			wp_die( 0 );
1256
+	}
1164 1257
 
1165 1258
 	if ( ! empty( $menu_items ) ) {
1166 1259
 		$args = array(
@@ -1187,10 +1280,12 @@  discard block
 block discarded – undo
1187 1280
 	$post = get_post( $pid );
1188 1281
 
1189 1282
 	if ( isset($_POST['metakeyselect']) || isset($_POST['metakeyinput']) ) {
1190
-		if ( !current_user_can( 'edit_post', $pid ) )
1191
-			wp_die( -1 );
1192
-		if ( isset($_POST['metakeyselect']) && '#NONE#' == $_POST['metakeyselect'] && empty($_POST['metakeyinput']) )
1193
-			wp_die( 1 );
1283
+		if ( !current_user_can( 'edit_post', $pid ) ) {
1284
+					wp_die( -1 );
1285
+		}
1286
+		if ( isset($_POST['metakeyselect']) && '#NONE#' == $_POST['metakeyselect'] && empty($_POST['metakeyinput']) ) {
1287
+					wp_die( 1 );
1288
+		}
1194 1289
 
1195 1290
 		// If the post is an autodraft, save the post as a draft and then attempt to save the meta.
1196 1291
 		if ( $post->post_status == 'auto-draft' ) {
@@ -1212,8 +1307,9 @@  discard block
 block discarded – undo
1212 1307
 					$x->send();
1213 1308
 				}
1214 1309
 				$_POST = $save_POST; // Now we can restore original $_POST again
1215
-				if ( !$mid = add_meta( $pid ) )
1216
-					wp_die( __( 'Please provide a custom field value.' ) );
1310
+				if ( !$mid = add_meta( $pid ) ) {
1311
+									wp_die( __( 'Please provide a custom field value.' ) );
1312
+				}
1217 1313
 			} else {
1218 1314
 				wp_die( 0 );
1219 1315
 			}
@@ -1235,19 +1331,26 @@  discard block
 block discarded – undo
1235 1331
 		$mid = (int) key( $_POST['meta'] );
1236 1332
 		$key = wp_unslash( $_POST['meta'][$mid]['key'] );
1237 1333
 		$value = wp_unslash( $_POST['meta'][$mid]['value'] );
1238
-		if ( '' == trim($key) )
1239
-			wp_die( __( 'Please provide a custom field name.' ) );
1240
-		if ( '' == trim($value) )
1241
-			wp_die( __( 'Please provide a custom field value.' ) );
1242
-		if ( ! $meta = get_metadata_by_mid( 'post', $mid ) )
1243
-			wp_die( 0 ); // if meta doesn't exist
1334
+		if ( '' == trim($key) ) {
1335
+					wp_die( __( 'Please provide a custom field name.' ) );
1336
+		}
1337
+		if ( '' == trim($value) ) {
1338
+					wp_die( __( 'Please provide a custom field value.' ) );
1339
+		}
1340
+		if ( ! $meta = get_metadata_by_mid( 'post', $mid ) ) {
1341
+					wp_die( 0 );
1342
+		}
1343
+		// if meta doesn't exist
1244 1344
 		if ( is_protected_meta( $meta->meta_key, 'post' ) || is_protected_meta( $key, 'post' ) ||
1245 1345
 			! current_user_can( 'edit_post_meta', $meta->post_id, $meta->meta_key ) ||
1246
-			! current_user_can( 'edit_post_meta', $meta->post_id, $key ) )
1247
-			wp_die( -1 );
1346
+			! current_user_can( 'edit_post_meta', $meta->post_id, $key ) ) {
1347
+					wp_die( -1 );
1348
+		}
1248 1349
 		if ( $meta->meta_value != $value || $meta->meta_key != $key ) {
1249
-			if ( !$u = update_metadata_by_mid( 'post', $mid, $value, $key ) )
1250
-				wp_die( 0 ); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems).
1350
+			if ( !$u = update_metadata_by_mid( 'post', $mid, $value, $key ) ) {
1351
+							wp_die( 0 );
1352
+			}
1353
+			// We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems).
1251 1354
 		}
1252 1355
 
1253 1356
 		$x = new WP_Ajax_Response( array(
@@ -1276,12 +1379,14 @@  discard block
 block discarded – undo
1276 1379
  */
1277 1380
 function wp_ajax_add_user( $action ) {
1278 1381
 	global $wp_list_table;
1279
-	if ( empty( $action ) )
1280
-		$action = 'add-user';
1382
+	if ( empty( $action ) ) {
1383
+			$action = 'add-user';
1384
+	}
1281 1385
 
1282 1386
 	check_ajax_referer( $action );
1283
-	if ( ! current_user_can('create_users') )
1284
-		wp_die( -1 );
1387
+	if ( ! current_user_can('create_users') ) {
1388
+			wp_die( -1 );
1389
+	}
1285 1390
 	if ( ! $user_id = edit_user() ) {
1286 1391
 		wp_die( 0 );
1287 1392
 	} elseif ( is_wp_error( $user_id ) ) {
@@ -1324,14 +1429,17 @@  discard block
 block discarded – undo
1324 1429
 
1325 1430
 	$page = isset( $_POST['page'] ) ? $_POST['page'] : '';
1326 1431
 
1327
-	if ( $page != sanitize_key( $page ) )
1328
-		wp_die( 0 );
1432
+	if ( $page != sanitize_key( $page ) ) {
1433
+			wp_die( 0 );
1434
+	}
1329 1435
 
1330
-	if ( ! $user = wp_get_current_user() )
1331
-		wp_die( -1 );
1436
+	if ( ! $user = wp_get_current_user() ) {
1437
+			wp_die( -1 );
1438
+	}
1332 1439
 
1333
-	if ( is_array($closed) )
1334
-		update_user_option($user->ID, "closedpostboxes_$page", $closed, true);
1440
+	if ( is_array($closed) ) {
1441
+			update_user_option($user->ID, "closedpostboxes_$page", $closed, true);
1442
+	}
1335 1443
 
1336 1444
 	if ( is_array($hidden) ) {
1337 1445
 		$hidden = array_diff( $hidden, array('submitdiv', 'linksubmitdiv', 'manage-menu', 'create-menu') ); // postboxes that are always shown
@@ -1350,11 +1458,13 @@  discard block
 block discarded – undo
1350 1458
 	check_ajax_referer( 'screen-options-nonce', 'screenoptionnonce' );
1351 1459
 	$page = isset( $_POST['page'] ) ? $_POST['page'] : '';
1352 1460
 
1353
-	if ( $page != sanitize_key( $page ) )
1354
-		wp_die( 0 );
1461
+	if ( $page != sanitize_key( $page ) ) {
1462
+			wp_die( 0 );
1463
+	}
1355 1464
 
1356
-	if ( ! $user = wp_get_current_user() )
1357
-		wp_die( -1 );
1465
+	if ( ! $user = wp_get_current_user() ) {
1466
+			wp_die( -1 );
1467
+	}
1358 1468
 
1359 1469
 	$hidden = ! empty( $_POST['hidden'] ) ? explode( ',', $_POST['hidden'] ) : array();
1360 1470
 	update_user_option( $user->ID, "manage{$page}columnshidden", $hidden, true );
@@ -1370,8 +1480,9 @@  discard block
 block discarded – undo
1370 1480
 function wp_ajax_update_welcome_panel() {
1371 1481
 	check_ajax_referer( 'welcome-panel-nonce', 'welcomepanelnonce' );
1372 1482
 
1373
-	if ( ! current_user_can( 'edit_theme_options' ) )
1374
-		wp_die( -1 );
1483
+	if ( ! current_user_can( 'edit_theme_options' ) ) {
1484
+			wp_die( -1 );
1485
+	}
1375 1486
 
1376 1487
 	update_user_meta( get_current_user_id(), 'show_welcome_panel', empty( $_POST['visible'] ) ? 0 : 1 );
1377 1488
 
@@ -1384,8 +1495,9 @@  discard block
 block discarded – undo
1384 1495
  * @since 3.1.0
1385 1496
  */
1386 1497
 function wp_ajax_menu_get_metabox() {
1387
-	if ( ! current_user_can( 'edit_theme_options' ) )
1388
-		wp_die( -1 );
1498
+	if ( ! current_user_can( 'edit_theme_options' ) ) {
1499
+			wp_die( -1 );
1500
+	}
1389 1501
 
1390 1502
 	require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
1391 1503
 
@@ -1436,15 +1548,17 @@  discard block
 block discarded – undo
1436 1548
 
1437 1549
 	$args = array();
1438 1550
 
1439
-	if ( isset( $_POST['search'] ) )
1440
-		$args['s'] = wp_unslash( $_POST['search'] );
1551
+	if ( isset( $_POST['search'] ) ) {
1552
+			$args['s'] = wp_unslash( $_POST['search'] );
1553
+	}
1441 1554
 	$args['pagenum'] = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
1442 1555
 
1443 1556
 	require(ABSPATH . WPINC . '/class-wp-editor.php');
1444 1557
 	$results = _WP_Editors::wp_link_query( $args );
1445 1558
 
1446
-	if ( ! isset( $results ) )
1447
-		wp_die( 0 );
1559
+	if ( ! isset( $results ) ) {
1560
+			wp_die( 0 );
1561
+	}
1448 1562
 
1449 1563
 	echo wp_json_encode( $results );
1450 1564
 	echo "\n";
@@ -1458,11 +1572,13 @@  discard block
 block discarded – undo
1458 1572
  * @since 3.1.0
1459 1573
  */
1460 1574
 function wp_ajax_menu_locations_save() {
1461
-	if ( ! current_user_can( 'edit_theme_options' ) )
1462
-		wp_die( -1 );
1575
+	if ( ! current_user_can( 'edit_theme_options' ) ) {
1576
+			wp_die( -1 );
1577
+	}
1463 1578
 	check_ajax_referer( 'add-menu_item', 'menu-settings-column-nonce' );
1464
-	if ( ! isset( $_POST['menu-locations'] ) )
1465
-		wp_die( 0 );
1579
+	if ( ! isset( $_POST['menu-locations'] ) ) {
1580
+			wp_die( 0 );
1581
+	}
1466 1582
 	set_theme_mod( 'nav_menu_locations', array_map( 'absint', $_POST['menu-locations'] ) );
1467 1583
 	wp_die( 1 );
1468 1584
 }
@@ -1477,22 +1593,27 @@  discard block
 block discarded – undo
1477 1593
 	$order = isset( $_POST['order'] ) ? (array) $_POST['order'] : false;
1478 1594
 	$page_columns = isset( $_POST['page_columns'] ) ? $_POST['page_columns'] : 'auto';
1479 1595
 
1480
-	if ( $page_columns != 'auto' )
1481
-		$page_columns = (int) $page_columns;
1596
+	if ( $page_columns != 'auto' ) {
1597
+			$page_columns = (int) $page_columns;
1598
+	}
1482 1599
 
1483 1600
 	$page = isset( $_POST['page'] ) ? $_POST['page'] : '';
1484 1601
 
1485
-	if ( $page != sanitize_key( $page ) )
1486
-		wp_die( 0 );
1602
+	if ( $page != sanitize_key( $page ) ) {
1603
+			wp_die( 0 );
1604
+	}
1487 1605
 
1488
-	if ( ! $user = wp_get_current_user() )
1489
-		wp_die( -1 );
1606
+	if ( ! $user = wp_get_current_user() ) {
1607
+			wp_die( -1 );
1608
+	}
1490 1609
 
1491
-	if ( $order )
1492
-		update_user_option($user->ID, "meta-box-order_$page", $order, true);
1610
+	if ( $order ) {
1611
+			update_user_option($user->ID, "meta-box-order_$page", $order, true);
1612
+	}
1493 1613
 
1494
-	if ( $page_columns )
1495
-		update_user_option($user->ID, "screen_layout_$page", $page_columns, true);
1614
+	if ( $page_columns ) {
1615
+			update_user_option($user->ID, "screen_layout_$page", $page_columns, true);
1616
+	}
1496 1617
 
1497 1618
 	wp_die( 1 );
1498 1619
 }
@@ -1503,8 +1624,9 @@  discard block
 block discarded – undo
1503 1624
  * @since 3.1.0
1504 1625
  */
1505 1626
 function wp_ajax_menu_quick_search() {
1506
-	if ( ! current_user_can( 'edit_theme_options' ) )
1507
-		wp_die( -1 );
1627
+	if ( ! current_user_can( 'edit_theme_options' ) ) {
1628
+			wp_die( -1 );
1629
+	}
1508 1630
 
1509 1631
 	require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
1510 1632
 
@@ -1549,15 +1671,18 @@  discard block
 block discarded – undo
1549 1671
 
1550 1672
 	check_ajax_referer( 'inlineeditnonce', '_inline_edit' );
1551 1673
 
1552
-	if ( ! isset($_POST['post_ID']) || ! ( $post_ID = (int) $_POST['post_ID'] ) )
1553
-		wp_die();
1674
+	if ( ! isset($_POST['post_ID']) || ! ( $post_ID = (int) $_POST['post_ID'] ) ) {
1675
+			wp_die();
1676
+	}
1554 1677
 
1555 1678
 	if ( 'page' == $_POST['post_type'] ) {
1556
-		if ( ! current_user_can( 'edit_page', $post_ID ) )
1557
-			wp_die( __( 'You are not allowed to edit this page.' ) );
1679
+		if ( ! current_user_can( 'edit_page', $post_ID ) ) {
1680
+					wp_die( __( 'You are not allowed to edit this page.' ) );
1681
+		}
1558 1682
 	} else {
1559
-		if ( ! current_user_can( 'edit_post', $post_ID ) )
1560
-			wp_die( __( 'You are not allowed to edit this post.' ) );
1683
+		if ( ! current_user_can( 'edit_post', $post_ID ) ) {
1684
+					wp_die( __( 'You are not allowed to edit this post.' ) );
1685
+		}
1561 1686
 	}
1562 1687
 
1563 1688
 	if ( $last = wp_check_post_lock( $post_ID ) ) {
@@ -1580,8 +1705,9 @@  discard block
 block discarded – undo
1580 1705
 	// Rename.
1581 1706
 	$data['user_ID'] = get_current_user_id();
1582 1707
 
1583
-	if ( isset($data['post_parent']) )
1584
-		$data['parent_id'] = $data['post_parent'];
1708
+	if ( isset($data['post_parent']) ) {
1709
+			$data['parent_id'] = $data['post_parent'];
1710
+	}
1585 1711
 
1586 1712
 	// Status.
1587 1713
 	if ( isset( $data['keep_private'] ) && 'private' == $data['keep_private'] ) {
@@ -1591,10 +1717,12 @@  discard block
 block discarded – undo
1591 1717
 		$data['post_status'] = $data['_status'];
1592 1718
 	}
1593 1719
 
1594
-	if ( empty($data['comment_status']) )
1595
-		$data['comment_status'] = 'closed';
1596
-	if ( empty($data['ping_status']) )
1597
-		$data['ping_status'] = 'closed';
1720
+	if ( empty($data['comment_status']) ) {
1721
+			$data['comment_status'] = 'closed';
1722
+	}
1723
+	if ( empty($data['ping_status']) ) {
1724
+			$data['ping_status'] = 'closed';
1725
+	}
1598 1726
 
1599 1727
 	// Exclude terms from taxonomies that are not supposed to appear in Quick Edit.
1600 1728
 	if ( ! empty( $data['tax_input'] ) ) {
@@ -1647,16 +1775,19 @@  discard block
 block discarded – undo
1647 1775
 
1648 1776
 	$taxonomy = sanitize_key( $_POST['taxonomy'] );
1649 1777
 	$tax = get_taxonomy( $taxonomy );
1650
-	if ( ! $tax )
1651
-		wp_die( 0 );
1778
+	if ( ! $tax ) {
1779
+			wp_die( 0 );
1780
+	}
1652 1781
 
1653
-	if ( ! current_user_can( $tax->cap->edit_terms ) )
1654
-		wp_die( -1 );
1782
+	if ( ! current_user_can( $tax->cap->edit_terms ) ) {
1783
+			wp_die( -1 );
1784
+	}
1655 1785
 
1656 1786
 	$wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => 'edit-' . $taxonomy ) );
1657 1787
 
1658
-	if ( ! isset($_POST['tax_ID']) || ! ( $id = (int) $_POST['tax_ID'] ) )
1659
-		wp_die( -1 );
1788
+	if ( ! isset($_POST['tax_ID']) || ! ( $id = (int) $_POST['tax_ID'] ) ) {
1789
+			wp_die( -1 );
1790
+	}
1660 1791
 
1661 1792
 	$tag = get_term( $id, $taxonomy );
1662 1793
 	$_POST['description'] = $tag->description;
@@ -1665,13 +1796,15 @@  discard block
 block discarded – undo
1665 1796
 	if ( $updated && !is_wp_error($updated) ) {
1666 1797
 		$tag = get_term( $updated['term_id'], $taxonomy );
1667 1798
 		if ( !$tag || is_wp_error( $tag ) ) {
1668
-			if ( is_wp_error($tag) && $tag->get_error_message() )
1669
-				wp_die( $tag->get_error_message() );
1799
+			if ( is_wp_error($tag) && $tag->get_error_message() ) {
1800
+							wp_die( $tag->get_error_message() );
1801
+			}
1670 1802
 			wp_die( __( 'Item not updated.' ) );
1671 1803
 		}
1672 1804
 	} else {
1673
-		if ( is_wp_error($updated) && $updated->get_error_message() )
1674
-			wp_die( $updated->get_error_message() );
1805
+		if ( is_wp_error($updated) && $updated->get_error_message() ) {
1806
+					wp_die( $updated->get_error_message() );
1807
+		}
1675 1808
 		wp_die( __( 'Item not updated.' ) );
1676 1809
 	}
1677 1810
 	$level = 0;
@@ -1704,8 +1837,9 @@  discard block
 block discarded – undo
1704 1837
 		'post_status' => 'any',
1705 1838
 		'posts_per_page' => 50,
1706 1839
 	);
1707
-	if ( '' !== $s )
1708
-		$args['s'] = $s;
1840
+	if ( '' !== $s ) {
1841
+			$args['s'] = $s;
1842
+	}
1709 1843
 
1710 1844
 	$posts = get_posts( $args );
1711 1845
 
@@ -1759,8 +1893,9 @@  discard block
 block discarded – undo
1759 1893
 function wp_ajax_widgets_order() {
1760 1894
 	check_ajax_referer( 'save-sidebar-widgets', 'savewidgets' );
1761 1895
 
1762
-	if ( !current_user_can('edit_theme_options') )
1763
-		wp_die( -1 );
1896
+	if ( !current_user_can('edit_theme_options') ) {
1897
+			wp_die( -1 );
1898
+	}
1764 1899
 
1765 1900
 	unset( $_POST['savewidgets'], $_POST['action'] );
1766 1901
 
@@ -1772,8 +1907,9 @@  discard block
 block discarded – undo
1772 1907
 			if ( !empty($val) ) {
1773 1908
 				$val = explode(',', $val);
1774 1909
 				foreach ( $val as $k => $v ) {
1775
-					if ( strpos($v, 'widget-') === false )
1776
-						continue;
1910
+					if ( strpos($v, 'widget-') === false ) {
1911
+											continue;
1912
+					}
1777 1913
 
1778 1914
 					$sb[$k] = substr($v, strpos($v, '_') + 1);
1779 1915
 				}
@@ -1801,8 +1937,9 @@  discard block
 block discarded – undo
1801 1937
 
1802 1938
 	check_ajax_referer( 'save-sidebar-widgets', 'savewidgets' );
1803 1939
 
1804
-	if ( !current_user_can('edit_theme_options') || !isset($_POST['id_base']) )
1805
-		wp_die( -1 );
1940
+	if ( !current_user_can('edit_theme_options') || !isset($_POST['id_base']) ) {
1941
+			wp_die( -1 );
1942
+	}
1806 1943
 
1807 1944
 	unset( $_POST['savewidgets'], $_POST['action'] );
1808 1945
 
@@ -1836,14 +1973,16 @@  discard block
 block discarded – undo
1836 1973
 	// Delete.
1837 1974
 	if ( isset($_POST['delete_widget']) && $_POST['delete_widget'] ) {
1838 1975
 
1839
-		if ( !isset($wp_registered_widgets[$widget_id]) )
1840
-			wp_die( $error );
1976
+		if ( !isset($wp_registered_widgets[$widget_id]) ) {
1977
+					wp_die( $error );
1978
+		}
1841 1979
 
1842 1980
 		$sidebar = array_diff( $sidebar, array($widget_id) );
1843 1981
 		$_POST = array('sidebar' => $sidebar_id, 'widget-' . $id_base => array(), 'the-widget-id' => $widget_id, 'delete_widget' => '1');
1844 1982
 	} elseif ( $settings && preg_match( '/__i__|%i%/', key($settings) ) ) {
1845
-		if ( !$multi_number )
1846
-			wp_die( $error );
1983
+		if ( !$multi_number ) {
1984
+					wp_die( $error );
1985
+		}
1847 1986
 
1848 1987
 		$_POST[ 'widget-' . $id_base ] = array( $multi_number => reset( $settings ) );
1849 1988
 		$widget_id = $id_base . '-' . $multi_number;
@@ -1854,8 +1993,9 @@  discard block
 block discarded – undo
1854 1993
 	foreach ( (array) $wp_registered_widget_updates as $name => $control ) {
1855 1994
 
1856 1995
 		if ( $name == $id_base ) {
1857
-			if ( !is_callable( $control['callback'] ) )
1858
-				continue;
1996
+			if ( !is_callable( $control['callback'] ) ) {
1997
+							continue;
1998
+			}
1859 1999
 
1860 2000
 			ob_start();
1861 2001
 				call_user_func_array( $control['callback'], $control['params'] );
@@ -1871,11 +2011,13 @@  discard block
 block discarded – undo
1871 2011
 		wp_die();
1872 2012
 	}
1873 2013
 
1874
-	if ( !empty($_POST['add_new']) )
1875
-		wp_die();
2014
+	if ( !empty($_POST['add_new']) ) {
2015
+			wp_die();
2016
+	}
1876 2017
 
1877
-	if ( $form = $wp_registered_widget_controls[$widget_id] )
1878
-		call_user_func_array( $form['callback'], $form['params'] );
2018
+	if ( $form = $wp_registered_widget_controls[$widget_id] ) {
2019
+			call_user_func_array( $form['callback'], $form['params'] );
2020
+	}
1879 2021
 
1880 2022
 	wp_die();
1881 2023
 }
@@ -1967,15 +2109,18 @@  discard block
 block discarded – undo
1967 2109
 	}
1968 2110
 
1969 2111
 	if ( isset( $post_data['context'] ) && isset( $post_data['theme'] ) ) {
1970
-		if ( 'custom-background' === $post_data['context'] )
1971
-			update_post_meta( $attachment_id, '_wp_attachment_is_custom_background', $post_data['theme'] );
2112
+		if ( 'custom-background' === $post_data['context'] ) {
2113
+					update_post_meta( $attachment_id, '_wp_attachment_is_custom_background', $post_data['theme'] );
2114
+		}
1972 2115
 
1973
-		if ( 'custom-header' === $post_data['context'] )
1974
-			update_post_meta( $attachment_id, '_wp_attachment_is_custom_header', $post_data['theme'] );
2116
+		if ( 'custom-header' === $post_data['context'] ) {
2117
+					update_post_meta( $attachment_id, '_wp_attachment_is_custom_header', $post_data['theme'] );
2118
+		}
1975 2119
 	}
1976 2120
 
1977
-	if ( ! $attachment = wp_prepare_attachment_for_js( $attachment_id ) )
1978
-		wp_die();
2121
+	if ( ! $attachment = wp_prepare_attachment_for_js( $attachment_id ) ) {
2122
+			wp_die();
2123
+	}
1979 2124
 
1980 2125
 	echo wp_json_encode( array(
1981 2126
 		'success' => true,
@@ -1992,8 +2137,9 @@  discard block
 block discarded – undo
1992 2137
  */
1993 2138
 function wp_ajax_image_editor() {
1994 2139
 	$attachment_id = intval($_POST['postid']);
1995
-	if ( empty($attachment_id) || !current_user_can('edit_post', $attachment_id) )
1996
-		wp_die( -1 );
2140
+	if ( empty($attachment_id) || !current_user_can('edit_post', $attachment_id) ) {
2141
+			wp_die( -1 );
2142
+	}
1997 2143
 
1998 2144
 	check_ajax_referer( "image_editor-$attachment_id" );
1999 2145
 	include_once( ABSPATH . 'wp-admin/includes/image-edit.php' );
@@ -2026,15 +2172,17 @@  discard block
 block discarded – undo
2026 2172
 	$json = ! empty( $_REQUEST['json'] ); // New-style request
2027 2173
 
2028 2174
 	$post_ID = intval( $_POST['post_id'] );
2029
-	if ( ! current_user_can( 'edit_post', $post_ID ) )
2030
-		wp_die( -1 );
2175
+	if ( ! current_user_can( 'edit_post', $post_ID ) ) {
2176
+			wp_die( -1 );
2177
+	}
2031 2178
 
2032 2179
 	$thumbnail_id = intval( $_POST['thumbnail_id'] );
2033 2180
 
2034
-	if ( $json )
2035
-		check_ajax_referer( "update-post_$post_ID" );
2036
-	else
2037
-		check_ajax_referer( "set_post_thumbnail-$post_ID" );
2181
+	if ( $json ) {
2182
+			check_ajax_referer( "update-post_$post_ID" );
2183
+	} else {
2184
+			check_ajax_referer( "set_post_thumbnail-$post_ID" );
2185
+	}
2038 2186
 
2039 2187
 	if ( $thumbnail_id == '-1' ) {
2040 2188
 		if ( delete_post_thumbnail( $post_ID ) ) {
@@ -2133,8 +2281,9 @@  discard block
 block discarded – undo
2133 2281
 
2134 2282
 	$post = null;
2135 2283
 
2136
-	if ( $post_id )
2137
-		$post = get_post( $post_id );
2284
+	if ( $post_id ) {
2285
+			$post = get_post( $post_id );
2286
+	}
2138 2287
 
2139 2288
 	check_ajax_referer('update-post_' . $post_id, '_wpnonce');
2140 2289
 
@@ -2168,20 +2317,24 @@  discard block
 block discarded – undo
2168 2317
  * @since 3.1.0
2169 2318
  */
2170 2319
 function wp_ajax_wp_remove_post_lock() {
2171
-	if ( empty( $_POST['post_ID'] ) || empty( $_POST['active_post_lock'] ) )
2172
-		wp_die( 0 );
2320
+	if ( empty( $_POST['post_ID'] ) || empty( $_POST['active_post_lock'] ) ) {
2321
+			wp_die( 0 );
2322
+	}
2173 2323
 	$post_id = (int) $_POST['post_ID'];
2174
-	if ( ! $post = get_post( $post_id ) )
2175
-		wp_die( 0 );
2324
+	if ( ! $post = get_post( $post_id ) ) {
2325
+			wp_die( 0 );
2326
+	}
2176 2327
 
2177 2328
 	check_ajax_referer( 'update-post_' . $post_id );
2178 2329
 
2179
-	if ( ! current_user_can( 'edit_post', $post_id ) )
2180
-		wp_die( -1 );
2330
+	if ( ! current_user_can( 'edit_post', $post_id ) ) {
2331
+			wp_die( -1 );
2332
+	}
2181 2333
 
2182 2334
 	$active_lock = array_map( 'absint', explode( ':', $_POST['active_post_lock'] ) );
2183
-	if ( $active_lock[1] != get_current_user_id() )
2184
-		wp_die( 0 );
2335
+	if ( $active_lock[1] != get_current_user_id() ) {
2336
+			wp_die( 0 );
2337
+	}
2185 2338
 
2186 2339
 	/**
2187 2340
 	 * Filter the post lock window duration.
@@ -2203,15 +2356,17 @@  discard block
 block discarded – undo
2203 2356
  */
2204 2357
 function wp_ajax_dismiss_wp_pointer() {
2205 2358
 	$pointer = $_POST['pointer'];
2206
-	if ( $pointer != sanitize_key( $pointer ) )
2207
-		wp_die( 0 );
2359
+	if ( $pointer != sanitize_key( $pointer ) ) {
2360
+			wp_die( 0 );
2361
+	}
2208 2362
 
2209 2363
 //	check_ajax_referer( 'dismiss-pointer_' . $pointer );
2210 2364
 
2211 2365
 	$dismissed = array_filter( explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ) );
2212 2366
 
2213
-	if ( in_array( $pointer, $dismissed ) )
2214
-		wp_die( 0 );
2367
+	if ( in_array( $pointer, $dismissed ) ) {
2368
+			wp_die( 0 );
2369
+	}
2215 2370
 
2216 2371
 	$dismissed[] = $pointer;
2217 2372
 	$dismissed = implode( ',', $dismissed );
@@ -2226,23 +2381,29 @@  discard block
 block discarded – undo
2226 2381
  * @since 3.5.0
2227 2382
  */
2228 2383
 function wp_ajax_get_attachment() {
2229
-	if ( ! isset( $_REQUEST['id'] ) )
2230
-		wp_send_json_error();
2384
+	if ( ! isset( $_REQUEST['id'] ) ) {
2385
+			wp_send_json_error();
2386
+	}
2231 2387
 
2232
-	if ( ! $id = absint( $_REQUEST['id'] ) )
2233
-		wp_send_json_error();
2388
+	if ( ! $id = absint( $_REQUEST['id'] ) ) {
2389
+			wp_send_json_error();
2390
+	}
2234 2391
 
2235
-	if ( ! $post = get_post( $id ) )
2236
-		wp_send_json_error();
2392
+	if ( ! $post = get_post( $id ) ) {
2393
+			wp_send_json_error();
2394
+	}
2237 2395
 
2238
-	if ( 'attachment' != $post->post_type )
2239
-		wp_send_json_error();
2396
+	if ( 'attachment' != $post->post_type ) {
2397
+			wp_send_json_error();
2398
+	}
2240 2399
 
2241
-	if ( ! current_user_can( 'upload_files' ) )
2242
-		wp_send_json_error();
2400
+	if ( ! current_user_can( 'upload_files' ) ) {
2401
+			wp_send_json_error();
2402
+	}
2243 2403
 
2244
-	if ( ! $attachment = wp_prepare_attachment_for_js( $id ) )
2245
-		wp_send_json_error();
2404
+	if ( ! $attachment = wp_prepare_attachment_for_js( $id ) ) {
2405
+			wp_send_json_error();
2406
+	}
2246 2407
 
2247 2408
 	wp_send_json_success( $attachment );
2248 2409
 }
@@ -2253,8 +2414,9 @@  discard block
 block discarded – undo
2253 2414
  * @since 3.5.0
2254 2415
  */
2255 2416
 function wp_ajax_query_attachments() {
2256
-	if ( ! current_user_can( 'upload_files' ) )
2257
-		wp_send_json_error();
2417
+	if ( ! current_user_can( 'upload_files' ) ) {
2418
+			wp_send_json_error();
2419
+	}
2258 2420
 
2259 2421
 	$query = isset( $_REQUEST['query'] ) ? (array) $_REQUEST['query'] : array();
2260 2422
 	$keys = array(
@@ -2277,8 +2439,9 @@  discard block
 block discarded – undo
2277 2439
 		$query['post_status'] = 'inherit';
2278 2440
 	}
2279 2441
 
2280
-	if ( current_user_can( get_post_type_object( 'attachment' )->cap->read_private_posts ) )
2281
-		$query['post_status'] .= ',private';
2442
+	if ( current_user_can( get_post_type_object( 'attachment' )->cap->read_private_posts ) ) {
2443
+			$query['post_status'] .= ',private';
2444
+	}
2282 2445
 
2283 2446
 	/**
2284 2447
 	 * Filter the arguments passed to WP_Query during an AJAX
@@ -2305,37 +2468,46 @@  discard block
 block discarded – undo
2305 2468
  * @since 3.5.0
2306 2469
  */
2307 2470
 function wp_ajax_save_attachment() {
2308
-	if ( ! isset( $_REQUEST['id'] ) || ! isset( $_REQUEST['changes'] ) )
2309
-		wp_send_json_error();
2471
+	if ( ! isset( $_REQUEST['id'] ) || ! isset( $_REQUEST['changes'] ) ) {
2472
+			wp_send_json_error();
2473
+	}
2310 2474
 
2311
-	if ( ! $id = absint( $_REQUEST['id'] ) )
2312
-		wp_send_json_error();
2475
+	if ( ! $id = absint( $_REQUEST['id'] ) ) {
2476
+			wp_send_json_error();
2477
+	}
2313 2478
 
2314 2479
 	check_ajax_referer( 'update-post_' . $id, 'nonce' );
2315 2480
 
2316
-	if ( ! current_user_can( 'edit_post', $id ) )
2317
-		wp_send_json_error();
2481
+	if ( ! current_user_can( 'edit_post', $id ) ) {
2482
+			wp_send_json_error();
2483
+	}
2318 2484
 
2319 2485
 	$changes = $_REQUEST['changes'];
2320 2486
 	$post    = get_post( $id, ARRAY_A );
2321 2487
 
2322
-	if ( 'attachment' != $post['post_type'] )
2323
-		wp_send_json_error();
2488
+	if ( 'attachment' != $post['post_type'] ) {
2489
+			wp_send_json_error();
2490
+	}
2324 2491
 
2325
-	if ( isset( $changes['parent'] ) )
2326
-		$post['post_parent'] = $changes['parent'];
2492
+	if ( isset( $changes['parent'] ) ) {
2493
+			$post['post_parent'] = $changes['parent'];
2494
+	}
2327 2495
 
2328
-	if ( isset( $changes['title'] ) )
2329
-		$post['post_title'] = $changes['title'];
2496
+	if ( isset( $changes['title'] ) ) {
2497
+			$post['post_title'] = $changes['title'];
2498
+	}
2330 2499
 
2331
-	if ( isset( $changes['caption'] ) )
2332
-		$post['post_excerpt'] = $changes['caption'];
2500
+	if ( isset( $changes['caption'] ) ) {
2501
+			$post['post_excerpt'] = $changes['caption'];
2502
+	}
2333 2503
 
2334
-	if ( isset( $changes['description'] ) )
2335
-		$post['post_content'] = $changes['description'];
2504
+	if ( isset( $changes['description'] ) ) {
2505
+			$post['post_content'] = $changes['description'];
2506
+	}
2336 2507
 
2337
-	if ( MEDIA_TRASH && isset( $changes['status'] ) )
2338
-		$post['post_status'] = $changes['status'];
2508
+	if ( MEDIA_TRASH && isset( $changes['status'] ) ) {
2509
+			$post['post_status'] = $changes['status'];
2510
+	}
2339 2511
 
2340 2512
 	if ( isset( $changes['alt'] ) ) {
2341 2513
 		$alt = wp_unslash( $changes['alt'] );
@@ -2379,25 +2551,30 @@  discard block
 block discarded – undo
2379 2551
  * @since 3.5.0
2380 2552
  */
2381 2553
 function wp_ajax_save_attachment_compat() {
2382
-	if ( ! isset( $_REQUEST['id'] ) )
2383
-		wp_send_json_error();
2554
+	if ( ! isset( $_REQUEST['id'] ) ) {
2555
+			wp_send_json_error();
2556
+	}
2384 2557
 
2385
-	if ( ! $id = absint( $_REQUEST['id'] ) )
2386
-		wp_send_json_error();
2558
+	if ( ! $id = absint( $_REQUEST['id'] ) ) {
2559
+			wp_send_json_error();
2560
+	}
2387 2561
 
2388
-	if ( empty( $_REQUEST['attachments'] ) || empty( $_REQUEST['attachments'][ $id ] ) )
2389
-		wp_send_json_error();
2562
+	if ( empty( $_REQUEST['attachments'] ) || empty( $_REQUEST['attachments'][ $id ] ) ) {
2563
+			wp_send_json_error();
2564
+	}
2390 2565
 	$attachment_data = $_REQUEST['attachments'][ $id ];
2391 2566
 
2392 2567
 	check_ajax_referer( 'update-post_' . $id, 'nonce' );
2393 2568
 
2394
-	if ( ! current_user_can( 'edit_post', $id ) )
2395
-		wp_send_json_error();
2569
+	if ( ! current_user_can( 'edit_post', $id ) ) {
2570
+			wp_send_json_error();
2571
+	}
2396 2572
 
2397 2573
 	$post = get_post( $id, ARRAY_A );
2398 2574
 
2399
-	if ( 'attachment' != $post['post_type'] )
2400
-		wp_send_json_error();
2575
+	if ( 'attachment' != $post['post_type'] ) {
2576
+			wp_send_json_error();
2577
+	}
2401 2578
 
2402 2579
 	/** This filter is documented in wp-admin/includes/media.php */
2403 2580
 	$post = apply_filters( 'attachment_fields_to_save', $post, $attachment_data );
@@ -2410,12 +2587,14 @@  discard block
 block discarded – undo
2410 2587
 	wp_update_post( $post );
2411 2588
 
2412 2589
 	foreach ( get_attachment_taxonomies( $post ) as $taxonomy ) {
2413
-		if ( isset( $attachment_data[ $taxonomy ] ) )
2414
-			wp_set_object_terms( $id, array_map( 'trim', preg_split( '/,+/', $attachment_data[ $taxonomy ] ) ), $taxonomy, false );
2590
+		if ( isset( $attachment_data[ $taxonomy ] ) ) {
2591
+					wp_set_object_terms( $id, array_map( 'trim', preg_split( '/,+/', $attachment_data[ $taxonomy ] ) ), $taxonomy, false );
2592
+		}
2415 2593
 	}
2416 2594
 
2417
-	if ( ! $attachment = wp_prepare_attachment_for_js( $id ) )
2418
-		wp_send_json_error();
2595
+	if ( ! $attachment = wp_prepare_attachment_for_js( $id ) ) {
2596
+			wp_send_json_error();
2597
+	}
2419 2598
 
2420 2599
 	wp_send_json_success( $attachment );
2421 2600
 }
@@ -2426,29 +2605,36 @@  discard block
 block discarded – undo
2426 2605
  * @since 3.5.0
2427 2606
  */
2428 2607
 function wp_ajax_save_attachment_order() {
2429
-	if ( ! isset( $_REQUEST['post_id'] ) )
2430
-		wp_send_json_error();
2608
+	if ( ! isset( $_REQUEST['post_id'] ) ) {
2609
+			wp_send_json_error();
2610
+	}
2431 2611
 
2432
-	if ( ! $post_id = absint( $_REQUEST['post_id'] ) )
2433
-		wp_send_json_error();
2612
+	if ( ! $post_id = absint( $_REQUEST['post_id'] ) ) {
2613
+			wp_send_json_error();
2614
+	}
2434 2615
 
2435
-	if ( empty( $_REQUEST['attachments'] ) )
2436
-		wp_send_json_error();
2616
+	if ( empty( $_REQUEST['attachments'] ) ) {
2617
+			wp_send_json_error();
2618
+	}
2437 2619
 
2438 2620
 	check_ajax_referer( 'update-post_' . $post_id, 'nonce' );
2439 2621
 
2440 2622
 	$attachments = $_REQUEST['attachments'];
2441 2623
 
2442
-	if ( ! current_user_can( 'edit_post', $post_id ) )
2443
-		wp_send_json_error();
2624
+	if ( ! current_user_can( 'edit_post', $post_id ) ) {
2625
+			wp_send_json_error();
2626
+	}
2444 2627
 
2445 2628
 	foreach ( $attachments as $attachment_id => $menu_order ) {
2446
-		if ( ! current_user_can( 'edit_post', $attachment_id ) )
2447
-			continue;
2448
-		if ( ! $attachment = get_post( $attachment_id ) )
2449
-			continue;
2450
-		if ( 'attachment' != $attachment->post_type )
2451
-			continue;
2629
+		if ( ! current_user_can( 'edit_post', $attachment_id ) ) {
2630
+					continue;
2631
+		}
2632
+		if ( ! $attachment = get_post( $attachment_id ) ) {
2633
+					continue;
2634
+		}
2635
+		if ( 'attachment' != $attachment->post_type ) {
2636
+					continue;
2637
+		}
2452 2638
 
2453 2639
 		wp_update_post( array( 'ID' => $attachment_id, 'menu_order' => $menu_order ) );
2454 2640
 	}
@@ -2472,11 +2658,13 @@  discard block
 block discarded – undo
2472 2658
 
2473 2659
 	$id = intval( $attachment['id'] );
2474 2660
 
2475
-	if ( ! $post = get_post( $id ) )
2476
-		wp_send_json_error();
2661
+	if ( ! $post = get_post( $id ) ) {
2662
+			wp_send_json_error();
2663
+	}
2477 2664
 
2478
-	if ( 'attachment' != $post->post_type )
2479
-		wp_send_json_error();
2665
+	if ( 'attachment' != $post->post_type ) {
2666
+			wp_send_json_error();
2667
+	}
2480 2668
 
2481 2669
 	if ( current_user_can( 'edit_post', $id ) ) {
2482 2670
 		// If this attachment is unattached, attach it. Primarily a back compat thing.
@@ -2489,8 +2677,9 @@  discard block
 block discarded – undo
2489 2677
 	$html = isset( $attachment['post_title'] ) ? $attachment['post_title'] : '';
2490 2678
 	if ( ! empty( $attachment['url'] ) ) {
2491 2679
 		$url = $attachment['url'];
2492
-		if ( strpos( $url, 'attachment_id') || get_attachment_link( $id ) == $url )
2493
-			$rel = ' rel="attachment wp-att-' . $id . '"';
2680
+		if ( strpos( $url, 'attachment_id') || get_attachment_link( $id ) == $url ) {
2681
+					$rel = ' rel="attachment wp-att-' . $id . '"';
2682
+		}
2494 2683
 		$html = '<a href="' . esc_url( $url ) . '"' . $rel . '>' . $html . '</a>';
2495 2684
 	}
2496 2685
 
@@ -2539,17 +2728,21 @@  discard block
 block discarded – undo
2539 2728
 
2540 2729
 	check_ajax_referer( 'media-send-to-editor', 'nonce' );
2541 2730
 
2542
-	if ( ! $src = wp_unslash( $_POST['src'] ) )
2543
-		wp_send_json_error();
2731
+	if ( ! $src = wp_unslash( $_POST['src'] ) ) {
2732
+			wp_send_json_error();
2733
+	}
2544 2734
 
2545
-	if ( ! strpos( $src, '://' ) )
2546
-		$src = 'http://' . $src;
2735
+	if ( ! strpos( $src, '://' ) ) {
2736
+			$src = 'http://' . $src;
2737
+	}
2547 2738
 
2548
-	if ( ! $src = esc_url_raw( $src ) )
2549
-		wp_send_json_error();
2739
+	if ( ! $src = esc_url_raw( $src ) ) {
2740
+			wp_send_json_error();
2741
+	}
2550 2742
 
2551
-	if ( ! $link_text = trim( wp_unslash( $_POST['link_text'] ) ) )
2552
-		$link_text = wp_basename( $src );
2743
+	if ( ! $link_text = trim( wp_unslash( $_POST['link_text'] ) ) ) {
2744
+			$link_text = wp_basename( $src );
2745
+	}
2553 2746
 
2554 2747
 	$post = get_post( isset( $_POST['post_id'] ) ? $_POST['post_id'] : 0 );
2555 2748
 
@@ -2571,8 +2764,9 @@  discard block
 block discarded – undo
2571 2764
 	// Figure out what filter to run:
2572 2765
 	$type = 'file';
2573 2766
 	if ( ( $ext = preg_replace( '/^.+?\.([^.]+)$/', '$1', $src ) ) && ( $ext_type = wp_ext2type( $ext ) )
2574
-		&& ( 'audio' == $ext_type || 'video' == $ext_type ) )
2575
-			$type = $ext_type;
2767
+		&& ( 'audio' == $ext_type || 'video' == $ext_type ) ) {
2768
+				$type = $ext_type;
2769
+	}
2576 2770
 
2577 2771
 	/** This filter is documented in wp-admin/includes/media.php */
2578 2772
 	$html = apply_filters( $type . '_send_to_editor_url', $html, $src, $link_text );
@@ -2665,15 +2859,18 @@  discard block
 block discarded – undo
2665 2859
 function wp_ajax_get_revision_diffs() {
2666 2860
 	require ABSPATH . 'wp-admin/includes/revision.php';
2667 2861
 
2668
-	if ( ! $post = get_post( (int) $_REQUEST['post_id'] ) )
2669
-		wp_send_json_error();
2862
+	if ( ! $post = get_post( (int) $_REQUEST['post_id'] ) ) {
2863
+			wp_send_json_error();
2864
+	}
2670 2865
 
2671
-	if ( ! current_user_can( 'read_post', $post->ID ) )
2672
-		wp_send_json_error();
2866
+	if ( ! current_user_can( 'read_post', $post->ID ) ) {
2867
+			wp_send_json_error();
2868
+	}
2673 2869
 
2674 2870
 	// Really just pre-loading the cache here.
2675
-	if ( ! $revisions = wp_get_post_revisions( $post->ID, array( 'check_enabled' => false ) ) )
2676
-		wp_send_json_error();
2871
+	if ( ! $revisions = wp_get_post_revisions( $post->ID, array( 'check_enabled' => false ) ) ) {
2872
+			wp_send_json_error();
2873
+	}
2677 2874
 
2678 2875
 	$return = array();
2679 2876
 	@set_time_limit( 0 );
Please login to merge, or discard this patch.
src/wp-admin/includes/class-wp-filesystem-direct.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * WordPress Direct Filesystem.
4
- *
5
- * @package WordPress
6
- * @subpackage Filesystem
7
- */
3
+	 * WordPress Direct Filesystem.
4
+	 *
5
+	 * @package WordPress
6
+	 * @subpackage Filesystem
7
+	 */
8 8
 
9 9
 /**
10 10
  * WordPress Filesystem Class for direct PHP file and folder manipulation.
Please login to merge, or discard this patch.
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -55,25 +55,25 @@  discard block
 block discarded – undo
55 55
 	 *                         Default false.
56 56
 	 * @return bool False upon failure, true otherwise.
57 57
 	 */
58
-	public function put_contents( $file, $contents, $mode = false ) {
59
-		$fp = @fopen( $file, 'wb' );
60
-		if ( ! $fp )
58
+	public function put_contents($file, $contents, $mode = false) {
59
+		$fp = @fopen($file, 'wb');
60
+		if ( ! $fp)
61 61
 			return false;
62 62
 
63 63
 		mbstring_binary_safe_encoding();
64 64
 
65
-		$data_length = strlen( $contents );
65
+		$data_length = strlen($contents);
66 66
 
67
-		$bytes_written = fwrite( $fp, $contents );
67
+		$bytes_written = fwrite($fp, $contents);
68 68
 
69 69
 		reset_mbstring_encoding();
70 70
 
71
-		fclose( $fp );
71
+		fclose($fp);
72 72
 
73
-		if ( $data_length !== $bytes_written )
73
+		if ($data_length !== $bytes_written)
74 74
 			return false;
75 75
 
76
-		$this->chmod( $file, $mode );
76
+		$this->chmod($file, $mode);
77 77
 
78 78
 		return true;
79 79
 	}
@@ -106,17 +106,17 @@  discard block
 block discarded – undo
106 106
 	 * @return bool Returns true on success or false on failure.
107 107
 	 */
108 108
 	public function chgrp($file, $group, $recursive = false) {
109
-		if ( ! $this->exists($file) )
109
+		if ( ! $this->exists($file))
110 110
 			return false;
111
-		if ( ! $recursive )
111
+		if ( ! $recursive)
112 112
 			return @chgrp($file, $group);
113
-		if ( ! $this->is_dir($file) )
113
+		if ( ! $this->is_dir($file))
114 114
 			return @chgrp($file, $group);
115 115
 		// Is a directory, and we want recursive
116 116
 		$file = trailingslashit($file);
117 117
 		$filelist = $this->dirlist($file);
118 118
 		foreach ($filelist as $filename)
119
-			$this->chgrp($file . $filename, $group, $recursive);
119
+			$this->chgrp($file.$filename, $group, $recursive);
120 120
 
121 121
 		return true;
122 122
 	}
@@ -131,22 +131,22 @@  discard block
 block discarded – undo
131 131
 	 * @return bool Returns true on success or false on failure.
132 132
 	 */
133 133
 	public function chmod($file, $mode = false, $recursive = false) {
134
-		if ( ! $mode ) {
135
-			if ( $this->is_file($file) )
134
+		if ( ! $mode) {
135
+			if ($this->is_file($file))
136 136
 				$mode = FS_CHMOD_FILE;
137
-			elseif ( $this->is_dir($file) )
137
+			elseif ($this->is_dir($file))
138 138
 				$mode = FS_CHMOD_DIR;
139 139
 			else
140 140
 				return false;
141 141
 		}
142 142
 
143
-		if ( ! $recursive || ! $this->is_dir($file) )
143
+		if ( ! $recursive || ! $this->is_dir($file))
144 144
 			return @chmod($file, $mode);
145 145
 		// Is a directory, and we want recursive
146 146
 		$file = trailingslashit($file);
147 147
 		$filelist = $this->dirlist($file);
148
-		foreach ( (array)$filelist as $filename => $filemeta)
149
-			$this->chmod($file . $filename, $mode, $recursive);
148
+		foreach ((array) $filelist as $filename => $filemeta)
149
+			$this->chmod($file.$filename, $mode, $recursive);
150 150
 
151 151
 		return true;
152 152
 	}
@@ -161,16 +161,16 @@  discard block
 block discarded – undo
161 161
 	 * @return bool Returns true on success or false on failure.
162 162
 	 */
163 163
 	public function chown($file, $owner, $recursive = false) {
164
-		if ( ! $this->exists($file) )
164
+		if ( ! $this->exists($file))
165 165
 			return false;
166
-		if ( ! $recursive )
166
+		if ( ! $recursive)
167 167
 			return @chown($file, $owner);
168
-		if ( ! $this->is_dir($file) )
168
+		if ( ! $this->is_dir($file))
169 169
 			return @chown($file, $owner);
170 170
 		// Is a directory, and we want recursive
171 171
 		$filelist = $this->dirlist($file);
172 172
 		foreach ($filelist as $filename) {
173
-			$this->chown($file . '/' . $filename, $owner, $recursive);
173
+			$this->chown($file.'/'.$filename, $owner, $recursive);
174 174
 		}
175 175
 		return true;
176 176
 	}
@@ -183,9 +183,9 @@  discard block
 block discarded – undo
183 183
 	 */
184 184
 	public function owner($file) {
185 185
 		$owneruid = @fileowner($file);
186
-		if ( ! $owneruid )
186
+		if ( ! $owneruid)
187 187
 			return false;
188
-		if ( ! function_exists('posix_getpwuid') )
188
+		if ( ! function_exists('posix_getpwuid'))
189 189
 			return $owneruid;
190 190
 		$ownerarray = posix_getpwuid($owneruid);
191 191
 		return $ownerarray['name'];
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 	 * @return string Mode of the file (last 3 digits).
201 201
 	 */
202 202
 	public function getchmod($file) {
203
-		return substr( decoct( @fileperms( $file ) ), -3 );
203
+		return substr(decoct(@fileperms($file)), -3);
204 204
 	}
205 205
 
206 206
 	/**
@@ -209,9 +209,9 @@  discard block
 block discarded – undo
209 209
 	 */
210 210
 	public function group($file) {
211 211
 		$gid = @filegroup($file);
212
-		if ( ! $gid )
212
+		if ( ! $gid)
213 213
 			return false;
214
-		if ( ! function_exists('posix_getgrgid') )
214
+		if ( ! function_exists('posix_getgrgid'))
215 215
 			return $gid;
216 216
 		$grouparray = posix_getgrgid($gid);
217 217
 		return $grouparray['name'];
@@ -225,11 +225,11 @@  discard block
 block discarded – undo
225 225
 	 * @return bool
226 226
 	 */
227 227
 	public function copy($source, $destination, $overwrite = false, $mode = false) {
228
-		if ( ! $overwrite && $this->exists($destination) )
228
+		if ( ! $overwrite && $this->exists($destination))
229 229
 			return false;
230 230
 
231 231
 		$rtval = copy($source, $destination);
232
-		if ( $mode )
232
+		if ($mode)
233 233
 			$this->chmod($destination, $mode);
234 234
 		return $rtval;
235 235
 	}
@@ -241,14 +241,14 @@  discard block
 block discarded – undo
241 241
 	 * @return bool
242 242
 	 */
243 243
 	public function move($source, $destination, $overwrite = false) {
244
-		if ( ! $overwrite && $this->exists($destination) )
244
+		if ( ! $overwrite && $this->exists($destination))
245 245
 			return false;
246 246
 
247 247
 		// Try using rename first. if that fails (for example, source is read only) try copy.
248
-		if ( @rename($source, $destination) )
248
+		if (@rename($source, $destination))
249 249
 			return true;
250 250
 
251
-		if ( $this->copy($source, $destination, $overwrite) && $this->exists($destination) ) {
251
+		if ($this->copy($source, $destination, $overwrite) && $this->exists($destination)) {
252 252
 			$this->delete($source);
253 253
 			return true;
254 254
 		} else {
@@ -263,13 +263,13 @@  discard block
 block discarded – undo
263 263
 	 * @return bool
264 264
 	 */
265 265
 	public function delete($file, $recursive = false, $type = false) {
266
-		if ( empty( $file ) ) // Some filesystems report this as /, which can cause non-expected recursive deletion of all files in the filesystem.
266
+		if (empty($file)) // Some filesystems report this as /, which can cause non-expected recursive deletion of all files in the filesystem.
267 267
 			return false;
268
-		$file = str_replace( '\\', '/', $file ); // for win32, occasional problems deleting files otherwise
268
+		$file = str_replace('\\', '/', $file); // for win32, occasional problems deleting files otherwise
269 269
 
270
-		if ( 'f' == $type || $this->is_file($file) )
270
+		if ('f' == $type || $this->is_file($file))
271 271
 			return @unlink($file);
272
-		if ( ! $recursive && $this->is_dir($file) )
272
+		if ( ! $recursive && $this->is_dir($file))
273 273
 			return @rmdir($file);
274 274
 
275 275
 		// At this point it's a folder, and we're in recursive mode
@@ -277,14 +277,14 @@  discard block
 block discarded – undo
277 277
 		$filelist = $this->dirlist($file, true);
278 278
 
279 279
 		$retval = true;
280
-		if ( is_array( $filelist ) ) {
281
-			foreach ( $filelist as $filename => $fileinfo ) {
282
-				if ( ! $this->delete($file . $filename, $recursive, $fileinfo['type']) )
280
+		if (is_array($filelist)) {
281
+			foreach ($filelist as $filename => $fileinfo) {
282
+				if ( ! $this->delete($file.$filename, $recursive, $fileinfo['type']))
283 283
 					$retval = false;
284 284
 			}
285 285
 		}
286 286
 
287
-		if ( file_exists($file) && ! @rmdir($file) )
287
+		if (file_exists($file) && ! @rmdir($file))
288 288
 			$retval = false;
289 289
 
290 290
 		return $retval;
@@ -375,18 +375,18 @@  discard block
 block discarded – undo
375 375
 	public function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
376 376
 		// Safe mode fails with a trailing slash under certain PHP versions.
377 377
 		$path = untrailingslashit($path);
378
-		if ( empty($path) )
378
+		if (empty($path))
379 379
 			return false;
380 380
 
381
-		if ( ! $chmod )
381
+		if ( ! $chmod)
382 382
 			$chmod = FS_CHMOD_DIR;
383 383
 
384
-		if ( ! @mkdir($path) )
384
+		if ( ! @mkdir($path))
385 385
 			return false;
386 386
 		$this->chmod($path, $chmod);
387
-		if ( $chown )
387
+		if ($chown)
388 388
 			$this->chown($path, $chown);
389
-		if ( $chgrp )
389
+		if ($chgrp)
390 390
 			$this->chgrp($path, $chgrp);
391 391
 		return true;
392 392
 	}
@@ -407,54 +407,54 @@  discard block
 block discarded – undo
407 407
 	 * @return bool|array
408 408
 	 */
409 409
 	public function dirlist($path, $include_hidden = true, $recursive = false) {
410
-		if ( $this->is_file($path) ) {
410
+		if ($this->is_file($path)) {
411 411
 			$limit_file = basename($path);
412 412
 			$path = dirname($path);
413 413
 		} else {
414 414
 			$limit_file = false;
415 415
 		}
416 416
 
417
-		if ( ! $this->is_dir($path) )
417
+		if ( ! $this->is_dir($path))
418 418
 			return false;
419 419
 
420 420
 		$dir = @dir($path);
421
-		if ( ! $dir )
421
+		if ( ! $dir)
422 422
 			return false;
423 423
 
424 424
 		$ret = array();
425 425
 
426
-		while (false !== ($entry = $dir->read()) ) {
426
+		while (false !== ($entry = $dir->read())) {
427 427
 			$struc = array();
428 428
 			$struc['name'] = $entry;
429 429
 
430
-			if ( '.' == $struc['name'] || '..' == $struc['name'] )
430
+			if ('.' == $struc['name'] || '..' == $struc['name'])
431 431
 				continue;
432 432
 
433
-			if ( ! $include_hidden && '.' == $struc['name'][0] )
433
+			if ( ! $include_hidden && '.' == $struc['name'][0])
434 434
 				continue;
435 435
 
436
-			if ( $limit_file && $struc['name'] != $limit_file)
436
+			if ($limit_file && $struc['name'] != $limit_file)
437 437
 				continue;
438 438
 
439 439
 			$struc['perms'] 	= $this->gethchmod($path.'/'.$entry);
440 440
 			$struc['permsn']	= $this->getnumchmodfromh($struc['perms']);
441
-			$struc['number'] 	= false;
441
+			$struc['number'] = false;
442 442
 			$struc['owner']    	= $this->owner($path.'/'.$entry);
443 443
 			$struc['group']    	= $this->group($path.'/'.$entry);
444 444
 			$struc['size']    	= $this->size($path.'/'.$entry);
445
-			$struc['lastmodunix']= $this->mtime($path.'/'.$entry);
446
-			$struc['lastmod']   = date('M j',$struc['lastmodunix']);
447
-			$struc['time']    	= date('h:i:s',$struc['lastmodunix']);
448
-			$struc['type']		= $this->is_dir($path.'/'.$entry) ? 'd' : 'f';
449
-
450
-			if ( 'd' == $struc['type'] ) {
451
-				if ( $recursive )
452
-					$struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
445
+			$struc['lastmodunix'] = $this->mtime($path.'/'.$entry);
446
+			$struc['lastmod']   = date('M j', $struc['lastmodunix']);
447
+			$struc['time']    	= date('h:i:s', $struc['lastmodunix']);
448
+			$struc['type'] = $this->is_dir($path.'/'.$entry) ? 'd' : 'f';
449
+
450
+			if ('d' == $struc['type']) {
451
+				if ($recursive)
452
+					$struc['files'] = $this->dirlist($path.'/'.$struc['name'], $include_hidden, $recursive);
453 453
 				else
454 454
 					$struc['files'] = array();
455 455
 			}
456 456
 
457
-			$ret[ $struc['name'] ] = $struc;
457
+			$ret[$struc['name']] = $struc;
458 458
 		}
459 459
 		$dir->close();
460 460
 		unset($dir);
Please login to merge, or discard this patch.
Braces   +120 added lines, -81 removed lines patch added patch discarded remove patch
@@ -57,8 +57,9 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	public function put_contents( $file, $contents, $mode = false ) {
59 59
 		$fp = @fopen( $file, 'wb' );
60
-		if ( ! $fp )
61
-			return false;
60
+		if ( ! $fp ) {
61
+					return false;
62
+		}
62 63
 
63 64
 		mbstring_binary_safe_encoding();
64 65
 
@@ -70,8 +71,9 @@  discard block
 block discarded – undo
70 71
 
71 72
 		fclose( $fp );
72 73
 
73
-		if ( $data_length !== $bytes_written )
74
-			return false;
74
+		if ( $data_length !== $bytes_written ) {
75
+					return false;
76
+		}
75 77
 
76 78
 		$this->chmod( $file, $mode );
77 79
 
@@ -106,17 +108,21 @@  discard block
 block discarded – undo
106 108
 	 * @return bool Returns true on success or false on failure.
107 109
 	 */
108 110
 	public function chgrp($file, $group, $recursive = false) {
109
-		if ( ! $this->exists($file) )
110
-			return false;
111
-		if ( ! $recursive )
112
-			return @chgrp($file, $group);
113
-		if ( ! $this->is_dir($file) )
114
-			return @chgrp($file, $group);
111
+		if ( ! $this->exists($file) ) {
112
+					return false;
113
+		}
114
+		if ( ! $recursive ) {
115
+					return @chgrp($file, $group);
116
+		}
117
+		if ( ! $this->is_dir($file) ) {
118
+					return @chgrp($file, $group);
119
+		}
115 120
 		// Is a directory, and we want recursive
116 121
 		$file = trailingslashit($file);
117 122
 		$filelist = $this->dirlist($file);
118
-		foreach ($filelist as $filename)
119
-			$this->chgrp($file . $filename, $group, $recursive);
123
+		foreach ($filelist as $filename) {
124
+					$this->chgrp($file . $filename, $group, $recursive);
125
+		}
120 126
 
121 127
 		return true;
122 128
 	}
@@ -132,21 +138,24 @@  discard block
 block discarded – undo
132 138
 	 */
133 139
 	public function chmod($file, $mode = false, $recursive = false) {
134 140
 		if ( ! $mode ) {
135
-			if ( $this->is_file($file) )
136
-				$mode = FS_CHMOD_FILE;
137
-			elseif ( $this->is_dir($file) )
138
-				$mode = FS_CHMOD_DIR;
139
-			else
140
-				return false;
141
+			if ( $this->is_file($file) ) {
142
+							$mode = FS_CHMOD_FILE;
143
+			} elseif ( $this->is_dir($file) ) {
144
+							$mode = FS_CHMOD_DIR;
145
+			} else {
146
+							return false;
147
+			}
141 148
 		}
142 149
 
143
-		if ( ! $recursive || ! $this->is_dir($file) )
144
-			return @chmod($file, $mode);
150
+		if ( ! $recursive || ! $this->is_dir($file) ) {
151
+					return @chmod($file, $mode);
152
+		}
145 153
 		// Is a directory, and we want recursive
146 154
 		$file = trailingslashit($file);
147 155
 		$filelist = $this->dirlist($file);
148
-		foreach ( (array)$filelist as $filename => $filemeta)
149
-			$this->chmod($file . $filename, $mode, $recursive);
156
+		foreach ( (array)$filelist as $filename => $filemeta) {
157
+					$this->chmod($file . $filename, $mode, $recursive);
158
+		}
150 159
 
151 160
 		return true;
152 161
 	}
@@ -161,12 +170,15 @@  discard block
 block discarded – undo
161 170
 	 * @return bool Returns true on success or false on failure.
162 171
 	 */
163 172
 	public function chown($file, $owner, $recursive = false) {
164
-		if ( ! $this->exists($file) )
165
-			return false;
166
-		if ( ! $recursive )
167
-			return @chown($file, $owner);
168
-		if ( ! $this->is_dir($file) )
169
-			return @chown($file, $owner);
173
+		if ( ! $this->exists($file) ) {
174
+					return false;
175
+		}
176
+		if ( ! $recursive ) {
177
+					return @chown($file, $owner);
178
+		}
179
+		if ( ! $this->is_dir($file) ) {
180
+					return @chown($file, $owner);
181
+		}
170 182
 		// Is a directory, and we want recursive
171 183
 		$filelist = $this->dirlist($file);
172 184
 		foreach ($filelist as $filename) {
@@ -183,10 +195,12 @@  discard block
 block discarded – undo
183 195
 	 */
184 196
 	public function owner($file) {
185 197
 		$owneruid = @fileowner($file);
186
-		if ( ! $owneruid )
187
-			return false;
188
-		if ( ! function_exists('posix_getpwuid') )
189
-			return $owneruid;
198
+		if ( ! $owneruid ) {
199
+					return false;
200
+		}
201
+		if ( ! function_exists('posix_getpwuid') ) {
202
+					return $owneruid;
203
+		}
190 204
 		$ownerarray = posix_getpwuid($owneruid);
191 205
 		return $ownerarray['name'];
192 206
 	}
@@ -209,10 +223,12 @@  discard block
 block discarded – undo
209 223
 	 */
210 224
 	public function group($file) {
211 225
 		$gid = @filegroup($file);
212
-		if ( ! $gid )
213
-			return false;
214
-		if ( ! function_exists('posix_getgrgid') )
215
-			return $gid;
226
+		if ( ! $gid ) {
227
+					return false;
228
+		}
229
+		if ( ! function_exists('posix_getgrgid') ) {
230
+					return $gid;
231
+		}
216 232
 		$grouparray = posix_getgrgid($gid);
217 233
 		return $grouparray['name'];
218 234
 	}
@@ -225,12 +241,14 @@  discard block
 block discarded – undo
225 241
 	 * @return bool
226 242
 	 */
227 243
 	public function copy($source, $destination, $overwrite = false, $mode = false) {
228
-		if ( ! $overwrite && $this->exists($destination) )
229
-			return false;
244
+		if ( ! $overwrite && $this->exists($destination) ) {
245
+					return false;
246
+		}
230 247
 
231 248
 		$rtval = copy($source, $destination);
232
-		if ( $mode )
233
-			$this->chmod($destination, $mode);
249
+		if ( $mode ) {
250
+					$this->chmod($destination, $mode);
251
+		}
234 252
 		return $rtval;
235 253
 	}
236 254
 
@@ -241,12 +259,14 @@  discard block
 block discarded – undo
241 259
 	 * @return bool
242 260
 	 */
243 261
 	public function move($source, $destination, $overwrite = false) {
244
-		if ( ! $overwrite && $this->exists($destination) )
245
-			return false;
262
+		if ( ! $overwrite && $this->exists($destination) ) {
263
+					return false;
264
+		}
246 265
 
247 266
 		// Try using rename first. if that fails (for example, source is read only) try copy.
248
-		if ( @rename($source, $destination) )
249
-			return true;
267
+		if ( @rename($source, $destination) ) {
268
+					return true;
269
+		}
250 270
 
251 271
 		if ( $this->copy($source, $destination, $overwrite) && $this->exists($destination) ) {
252 272
 			$this->delete($source);
@@ -263,14 +283,18 @@  discard block
 block discarded – undo
263 283
 	 * @return bool
264 284
 	 */
265 285
 	public function delete($file, $recursive = false, $type = false) {
266
-		if ( empty( $file ) ) // Some filesystems report this as /, which can cause non-expected recursive deletion of all files in the filesystem.
286
+		if ( empty( $file ) ) {
287
+			// Some filesystems report this as /, which can cause non-expected recursive deletion of all files in the filesystem.
267 288
 			return false;
289
+		}
268 290
 		$file = str_replace( '\\', '/', $file ); // for win32, occasional problems deleting files otherwise
269 291
 
270
-		if ( 'f' == $type || $this->is_file($file) )
271
-			return @unlink($file);
272
-		if ( ! $recursive && $this->is_dir($file) )
273
-			return @rmdir($file);
292
+		if ( 'f' == $type || $this->is_file($file) ) {
293
+					return @unlink($file);
294
+		}
295
+		if ( ! $recursive && $this->is_dir($file) ) {
296
+					return @rmdir($file);
297
+		}
274 298
 
275 299
 		// At this point it's a folder, and we're in recursive mode
276 300
 		$file = trailingslashit($file);
@@ -279,13 +303,15 @@  discard block
 block discarded – undo
279 303
 		$retval = true;
280 304
 		if ( is_array( $filelist ) ) {
281 305
 			foreach ( $filelist as $filename => $fileinfo ) {
282
-				if ( ! $this->delete($file . $filename, $recursive, $fileinfo['type']) )
283
-					$retval = false;
306
+				if ( ! $this->delete($file . $filename, $recursive, $fileinfo['type']) ) {
307
+									$retval = false;
308
+				}
284 309
 			}
285 310
 		}
286 311
 
287
-		if ( file_exists($file) && ! @rmdir($file) )
288
-			$retval = false;
312
+		if ( file_exists($file) && ! @rmdir($file) ) {
313
+					$retval = false;
314
+		}
289 315
 
290 316
 		return $retval;
291 317
 	}
@@ -358,10 +384,12 @@  discard block
 block discarded – undo
358 384
 	 * @return bool
359 385
 	 */
360 386
 	public function touch($file, $time = 0, $atime = 0) {
361
-		if ($time == 0)
362
-			$time = time();
363
-		if ($atime == 0)
364
-			$atime = time();
387
+		if ($time == 0) {
388
+					$time = time();
389
+		}
390
+		if ($atime == 0) {
391
+					$atime = time();
392
+		}
365 393
 		return @touch($file, $time, $atime);
366 394
 	}
367 395
 
@@ -375,19 +403,24 @@  discard block
 block discarded – undo
375 403
 	public function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
376 404
 		// Safe mode fails with a trailing slash under certain PHP versions.
377 405
 		$path = untrailingslashit($path);
378
-		if ( empty($path) )
379
-			return false;
406
+		if ( empty($path) ) {
407
+					return false;
408
+		}
380 409
 
381
-		if ( ! $chmod )
382
-			$chmod = FS_CHMOD_DIR;
410
+		if ( ! $chmod ) {
411
+					$chmod = FS_CHMOD_DIR;
412
+		}
383 413
 
384
-		if ( ! @mkdir($path) )
385
-			return false;
414
+		if ( ! @mkdir($path) ) {
415
+					return false;
416
+		}
386 417
 		$this->chmod($path, $chmod);
387
-		if ( $chown )
388
-			$this->chown($path, $chown);
389
-		if ( $chgrp )
390
-			$this->chgrp($path, $chgrp);
418
+		if ( $chown ) {
419
+					$this->chown($path, $chown);
420
+		}
421
+		if ( $chgrp ) {
422
+					$this->chgrp($path, $chgrp);
423
+		}
391 424
 		return true;
392 425
 	}
393 426
 
@@ -414,12 +447,14 @@  discard block
 block discarded – undo
414 447
 			$limit_file = false;
415 448
 		}
416 449
 
417
-		if ( ! $this->is_dir($path) )
418
-			return false;
450
+		if ( ! $this->is_dir($path) ) {
451
+					return false;
452
+		}
419 453
 
420 454
 		$dir = @dir($path);
421
-		if ( ! $dir )
422
-			return false;
455
+		if ( ! $dir ) {
456
+					return false;
457
+		}
423 458
 
424 459
 		$ret = array();
425 460
 
@@ -427,14 +462,17 @@  discard block
 block discarded – undo
427 462
 			$struc = array();
428 463
 			$struc['name'] = $entry;
429 464
 
430
-			if ( '.' == $struc['name'] || '..' == $struc['name'] )
431
-				continue;
465
+			if ( '.' == $struc['name'] || '..' == $struc['name'] ) {
466
+							continue;
467
+			}
432 468
 
433
-			if ( ! $include_hidden && '.' == $struc['name'][0] )
434
-				continue;
469
+			if ( ! $include_hidden && '.' == $struc['name'][0] ) {
470
+							continue;
471
+			}
435 472
 
436
-			if ( $limit_file && $struc['name'] != $limit_file)
437
-				continue;
473
+			if ( $limit_file && $struc['name'] != $limit_file) {
474
+							continue;
475
+			}
438 476
 
439 477
 			$struc['perms'] 	= $this->gethchmod($path.'/'.$entry);
440 478
 			$struc['permsn']	= $this->getnumchmodfromh($struc['perms']);
@@ -448,10 +486,11 @@  discard block
 block discarded – undo
448 486
 			$struc['type']		= $this->is_dir($path.'/'.$entry) ? 'd' : 'f';
449 487
 
450 488
 			if ( 'd' == $struc['type'] ) {
451
-				if ( $recursive )
452
-					$struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
453
-				else
454
-					$struc['files'] = array();
489
+				if ( $recursive ) {
490
+									$struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
491
+				} else {
492
+									$struc['files'] = array();
493
+				}
455 494
 			}
456 495
 
457 496
 			$ret[ $struc['name'] ] = $struc;
Please login to merge, or discard this patch.
src/wp-admin/includes/menu.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Build Administration Menu.
4
- *
5
- * @package WordPress
6
- * @subpackage Administration
7
- */
3
+	 * Build Administration Menu.
4
+	 *
5
+	 * @package WordPress
6
+	 * @subpackage Administration
7
+	 */
8 8
 
9 9
 if ( is_network_admin() ) {
10 10
 
Please login to merge, or discard this patch.
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @subpackage Administration
7 7
  */
8 8
 
9
-if ( is_network_admin() ) {
9
+if (is_network_admin()) {
10 10
 
11 11
 	/**
12 12
 	 * Fires before the administration menu loads in the Network Admin.
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 	 * @private
17 17
 	 * @since 3.1.0
18 18
 	 */
19
-	do_action( '_network_admin_menu' );
20
-} elseif ( is_user_admin() ) {
19
+	do_action('_network_admin_menu');
20
+} elseif (is_user_admin()) {
21 21
 
22 22
 	/**
23 23
 	 * Fires before the administration menu loads in the User Admin.
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 * @private
28 28
 	 * @since 3.1.0
29 29
 	 */
30
-	do_action( '_user_admin_menu' );
30
+	do_action('_user_admin_menu');
31 31
 } else {
32 32
 
33 33
 	/**
@@ -38,18 +38,18 @@  discard block
 block discarded – undo
38 38
 	 * @private
39 39
 	 * @since 2.2.0
40 40
 	 */
41
-	do_action( '_admin_menu' );
41
+	do_action('_admin_menu');
42 42
 }
43 43
 
44 44
 // Create list of page plugin hook names.
45 45
 foreach ($menu as $menu_page) {
46
-	if ( false !== $pos = strpos($menu_page[2], '?') ) {
46
+	if (false !== $pos = strpos($menu_page[2], '?')) {
47 47
 		// Handle post_type=post|page|foo pages.
48 48
 		$hook_name = substr($menu_page[2], 0, $pos);
49 49
 		$hook_args = substr($menu_page[2], $pos + 1);
50 50
 		wp_parse_str($hook_args, $hook_args);
51 51
 		// Set the hook name to be the post type.
52
-		if ( isset($hook_args['post_type']) )
52
+		if (isset($hook_args['post_type']))
53 53
 			$hook_name = $hook_args['post_type'];
54 54
 		else
55 55
 			$hook_name = basename($hook_name, '.php');
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
 	}
60 60
 	$hook_name = sanitize_title($hook_name);
61 61
 
62
-	if ( isset($compat[$hook_name]) )
62
+	if (isset($compat[$hook_name]))
63 63
 		$hook_name = $compat[$hook_name];
64
-	elseif ( !$hook_name )
64
+	elseif ( ! $hook_name)
65 65
 		continue;
66 66
 
67 67
 	$admin_page_hooks[$menu_page[2]] = $hook_name;
@@ -73,14 +73,14 @@  discard block
 block discarded – undo
73 73
 // Loop over submenus and remove pages for which the user does not have privs.
74 74
 foreach ($submenu as $parent => $sub) {
75 75
 	foreach ($sub as $index => $data) {
76
-		if ( ! current_user_can($data[1]) ) {
76
+		if ( ! current_user_can($data[1])) {
77 77
 			unset($submenu[$parent][$index]);
78 78
 			$_wp_submenu_nopriv[$parent][$data[2]] = true;
79 79
 		}
80 80
 	}
81 81
 	unset($index, $data);
82 82
 
83
-	if ( empty($submenu[$parent]) )
83
+	if (empty($submenu[$parent]))
84 84
 		unset($submenu[$parent]);
85 85
 }
86 86
 unset($sub, $parent);
@@ -90,18 +90,18 @@  discard block
 block discarded – undo
90 90
  * Menus for which the original parent is not accessible due to lack of privileges
91 91
  * will have the next submenu in line be assigned as the new menu parent.
92 92
  */
93
-foreach ( $menu as $id => $data ) {
94
-	if ( empty($submenu[$data[2]]) )
93
+foreach ($menu as $id => $data) {
94
+	if (empty($submenu[$data[2]]))
95 95
 		continue;
96 96
 	$subs = $submenu[$data[2]];
97
-	$first_sub = reset( $subs );
97
+	$first_sub = reset($subs);
98 98
 	$old_parent = $data[2];
99 99
 	$new_parent = $first_sub[2];
100 100
 	/*
101 101
 	 * If the first submenu is not the same as the assigned parent,
102 102
 	 * make the first submenu the new parent.
103 103
 	 */
104
-	if ( $new_parent != $old_parent ) {
104
+	if ($new_parent != $old_parent) {
105 105
 		$_wp_real_parent_file[$old_parent] = $new_parent;
106 106
 		$menu[$id][2] = $new_parent;
107 107
 
@@ -111,13 +111,13 @@  discard block
 block discarded – undo
111 111
 		}
112 112
 		unset($submenu[$old_parent], $index);
113 113
 
114
-		if ( isset($_wp_submenu_nopriv[$old_parent]) )
114
+		if (isset($_wp_submenu_nopriv[$old_parent]))
115 115
 			$_wp_submenu_nopriv[$new_parent] = $_wp_submenu_nopriv[$old_parent];
116 116
 	}
117 117
 }
118 118
 unset($id, $data, $subs, $first_sub, $old_parent, $new_parent);
119 119
 
120
-if ( is_network_admin() ) {
120
+if (is_network_admin()) {
121 121
 
122 122
 	/**
123 123
 	 * Fires before the administration menu loads in the Network Admin.
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 	 *
127 127
 	 * @param string $context Empty context.
128 128
 	 */
129
-	do_action( 'network_admin_menu', '' );
130
-} elseif ( is_user_admin() ) {
129
+	do_action('network_admin_menu', '');
130
+} elseif (is_user_admin()) {
131 131
 
132 132
 	/**
133 133
 	 * Fires before the administration menu loads in the User Admin.
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	 *
137 137
 	 * @param string $context Empty context.
138 138
 	 */
139
-	do_action( 'user_admin_menu', '' );
139
+	do_action('user_admin_menu', '');
140 140
 } else {
141 141
 
142 142
 	/**
@@ -146,32 +146,32 @@  discard block
 block discarded – undo
146 146
 	 *
147 147
 	 * @param string $context Empty context.
148 148
 	 */
149
-	do_action( 'admin_menu', '' );
149
+	do_action('admin_menu', '');
150 150
 }
151 151
 
152 152
 /*
153 153
  * Remove menus that have no accessible submenus and require privileges
154 154
  * that the user does not have. Run re-parent loop again.
155 155
  */
156
-foreach ( $menu as $id => $data ) {
157
-	if ( ! current_user_can($data[1]) )
156
+foreach ($menu as $id => $data) {
157
+	if ( ! current_user_can($data[1]))
158 158
 		$_wp_menu_nopriv[$data[2]] = true;
159 159
 
160 160
 	/*
161 161
 	 * If there is only one submenu and it is has same destination as the parent,
162 162
 	 * remove the submenu.
163 163
 	 */
164
-	if ( ! empty( $submenu[$data[2]] ) && 1 == count ( $submenu[$data[2]] ) ) {
164
+	if ( ! empty($submenu[$data[2]]) && 1 == count($submenu[$data[2]])) {
165 165
 		$subs = $submenu[$data[2]];
166
-		$first_sub = reset( $subs );
167
-		if ( $data[2] == $first_sub[2] )
168
-			unset( $submenu[$data[2]] );
166
+		$first_sub = reset($subs);
167
+		if ($data[2] == $first_sub[2])
168
+			unset($submenu[$data[2]]);
169 169
 	}
170 170
 
171 171
 	// If submenu is empty...
172
-	if ( empty($submenu[$data[2]]) ) {
172
+	if (empty($submenu[$data[2]])) {
173 173
 		// And user doesn't have privs, remove menu.
174
-		if ( isset( $_wp_menu_nopriv[$data[2]] ) ) {
174
+		if (isset($_wp_menu_nopriv[$data[2]])) {
175 175
 			unset($menu[$id]);
176 176
 		}
177 177
 	}
@@ -180,9 +180,9 @@  discard block
 block discarded – undo
180 180
 
181 181
 // Remove any duplicated separators
182 182
 $separator_found = false;
183
-foreach ( $menu as $id => $data ) {
184
-	if ( 0 == strcmp('wp-menu-separator', $data[4] ) ) {
185
-		if ( ! $separator_found ) {
183
+foreach ($menu as $id => $data) {
184
+	if (0 == strcmp('wp-menu-separator', $data[4])) {
185
+		if ( ! $separator_found) {
186 186
 			$separator_found = true;
187 187
 		} else {
188 188
 			unset($menu[$id]);
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
  * @return string
202 202
  */
203 203
 function add_cssclass($add, $class) {
204
-	$class = empty($class) ? $add : $class .= ' ' . $add;
204
+	$class = empty($class) ? $add : $class .= ' '.$add;
205 205
 	return $class;
206 206
 }
207 207
 
@@ -214,29 +214,29 @@  discard block
 block discarded – undo
214 214
 	$first = $lastorder = false;
215 215
 	$i = 0;
216 216
 	$mc = count($menu);
217
-	foreach ( $menu as $order => $top ) {
217
+	foreach ($menu as $order => $top) {
218 218
 		$i++;
219 219
 
220
-		if ( 0 == $order ) { // dashboard is always shown/single
220
+		if (0 == $order) { // dashboard is always shown/single
221 221
 			$menu[0][4] = add_cssclass('menu-top-first', $top[4]);
222 222
 			$lastorder = 0;
223 223
 			continue;
224 224
 		}
225 225
 
226
-		if ( 0 === strpos($top[2], 'separator') && false !== $lastorder ) { // if separator
226
+		if (0 === strpos($top[2], 'separator') && false !== $lastorder) { // if separator
227 227
 			$first = true;
228 228
 			$c = $menu[$lastorder][4];
229 229
 			$menu[$lastorder][4] = add_cssclass('menu-top-last', $c);
230 230
 			continue;
231 231
 		}
232 232
 
233
-		if ( $first ) {
233
+		if ($first) {
234 234
 			$c = $menu[$order][4];
235 235
 			$menu[$order][4] = add_cssclass('menu-top-first', $c);
236 236
 			$first = false;
237 237
 		}
238 238
 
239
-		if ( $mc == $i ) { // last item
239
+		if ($mc == $i) { // last item
240 240
 			$c = $menu[$order][4];
241 241
 			$menu[$order][4] = add_cssclass('menu-top-last', $c);
242 242
 		}
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 	 *
252 252
 	 * @param array $menu Associative array of administration menu items.
253 253
 	 */
254
-	return apply_filters( 'add_menu_classes', $menu );
254
+	return apply_filters('add_menu_classes', $menu);
255 255
 }
256 256
 
257 257
 uksort($menu, "strnatcasecmp"); // make it all pretty
@@ -265,9 +265,9 @@  discard block
 block discarded – undo
265 265
  *
266 266
  * @param bool $custom Whether custom ordering is enabled. Default false.
267 267
  */
268
-if ( apply_filters( 'custom_menu_order', false ) ) {
268
+if (apply_filters('custom_menu_order', false)) {
269 269
 	$menu_order = array();
270
-	foreach ( $menu as $menu_item ) {
270
+	foreach ($menu as $menu_item) {
271 271
 		$menu_order[] = $menu_item[2];
272 272
 	}
273 273
 	unset($menu_item);
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 	 *
286 286
 	 * @param array $menu_order An ordered array of menu items.
287 287
 	 */
288
-	$menu_order = apply_filters( 'menu_order', $menu_order );
288
+	$menu_order = apply_filters('menu_order', $menu_order);
289 289
 	$menu_order = array_flip($menu_order);
290 290
 	$default_menu_order = array_flip($default_menu_order);
291 291
 
@@ -302,12 +302,12 @@  discard block
 block discarded – undo
302 302
 		global $menu_order, $default_menu_order;
303 303
 		$a = $a[2];
304 304
 		$b = $b[2];
305
-		if ( isset($menu_order[$a]) && !isset($menu_order[$b]) ) {
305
+		if (isset($menu_order[$a]) && ! isset($menu_order[$b])) {
306 306
 			return -1;
307
-		} elseif ( !isset($menu_order[$a]) && isset($menu_order[$b]) ) {
307
+		} elseif ( ! isset($menu_order[$a]) && isset($menu_order[$b])) {
308 308
 			return 1;
309
-		} elseif ( isset($menu_order[$a]) && isset($menu_order[$b]) ) {
310
-			if ( $menu_order[$a] == $menu_order[$b] )
309
+		} elseif (isset($menu_order[$a]) && isset($menu_order[$b])) {
310
+			if ($menu_order[$a] == $menu_order[$b])
311 311
 				return 0;
312 312
 			return ($menu_order[$a] < $menu_order[$b]) ? -1 : 1;
313 313
 		} else {
@@ -320,22 +320,22 @@  discard block
 block discarded – undo
320 320
 }
321 321
 
322 322
 // Remove the last menu item if it is a separator.
323
-$last_menu_key = array_keys( $menu );
324
-$last_menu_key = array_pop( $last_menu_key );
325
-if ( !empty( $menu ) && 'wp-menu-separator' == $menu[ $last_menu_key ][ 4 ] )
326
-	unset( $menu[ $last_menu_key ] );
327
-unset( $last_menu_key );
323
+$last_menu_key = array_keys($menu);
324
+$last_menu_key = array_pop($last_menu_key);
325
+if ( ! empty($menu) && 'wp-menu-separator' == $menu[$last_menu_key][4])
326
+	unset($menu[$last_menu_key]);
327
+unset($last_menu_key);
328 328
 
329
-if ( !user_can_access_admin_page() ) {
329
+if ( ! user_can_access_admin_page()) {
330 330
 
331 331
 	/**
332 332
 	 * Fires when access to an admin page is denied.
333 333
 	 *
334 334
 	 * @since 2.5.0
335 335
 	 */
336
-	do_action( 'admin_page_access_denied' );
336
+	do_action('admin_page_access_denied');
337 337
 
338
-	wp_die( __( 'You do not have sufficient permissions to access this page.' ), 403 );
338
+	wp_die(__('You do not have sufficient permissions to access this page.'), 403);
339 339
 }
340 340
 
341 341
 $menu = add_menu_classes($menu);
Please login to merge, or discard this patch.
Braces   +31 added lines, -22 removed lines patch added patch discarded remove patch
@@ -49,20 +49,22 @@  discard block
 block discarded – undo
49 49
 		$hook_args = substr($menu_page[2], $pos + 1);
50 50
 		wp_parse_str($hook_args, $hook_args);
51 51
 		// Set the hook name to be the post type.
52
-		if ( isset($hook_args['post_type']) )
53
-			$hook_name = $hook_args['post_type'];
54
-		else
55
-			$hook_name = basename($hook_name, '.php');
52
+		if ( isset($hook_args['post_type']) ) {
53
+					$hook_name = $hook_args['post_type'];
54
+		} else {
55
+					$hook_name = basename($hook_name, '.php');
56
+		}
56 57
 		unset($hook_args);
57 58
 	} else {
58 59
 		$hook_name = basename($menu_page[2], '.php');
59 60
 	}
60 61
 	$hook_name = sanitize_title($hook_name);
61 62
 
62
-	if ( isset($compat[$hook_name]) )
63
-		$hook_name = $compat[$hook_name];
64
-	elseif ( !$hook_name )
65
-		continue;
63
+	if ( isset($compat[$hook_name]) ) {
64
+			$hook_name = $compat[$hook_name];
65
+	} elseif ( !$hook_name ) {
66
+			continue;
67
+	}
66 68
 
67 69
 	$admin_page_hooks[$menu_page[2]] = $hook_name;
68 70
 }
@@ -80,9 +82,10 @@  discard block
 block discarded – undo
80 82
 	}
81 83
 	unset($index, $data);
82 84
 
83
-	if ( empty($submenu[$parent]) )
84
-		unset($submenu[$parent]);
85
-}
85
+	if ( empty($submenu[$parent]) ) {
86
+			unset($submenu[$parent]);
87
+	}
88
+	}
86 89
 unset($sub, $parent);
87 90
 
88 91
 /*
@@ -91,8 +94,9 @@  discard block
 block discarded – undo
91 94
  * will have the next submenu in line be assigned as the new menu parent.
92 95
  */
93 96
 foreach ( $menu as $id => $data ) {
94
-	if ( empty($submenu[$data[2]]) )
95
-		continue;
97
+	if ( empty($submenu[$data[2]]) ) {
98
+			continue;
99
+	}
96 100
 	$subs = $submenu[$data[2]];
97 101
 	$first_sub = reset( $subs );
98 102
 	$old_parent = $data[2];
@@ -111,8 +115,9 @@  discard block
 block discarded – undo
111 115
 		}
112 116
 		unset($submenu[$old_parent], $index);
113 117
 
114
-		if ( isset($_wp_submenu_nopriv[$old_parent]) )
115
-			$_wp_submenu_nopriv[$new_parent] = $_wp_submenu_nopriv[$old_parent];
118
+		if ( isset($_wp_submenu_nopriv[$old_parent]) ) {
119
+					$_wp_submenu_nopriv[$new_parent] = $_wp_submenu_nopriv[$old_parent];
120
+		}
116 121
 	}
117 122
 }
118 123
 unset($id, $data, $subs, $first_sub, $old_parent, $new_parent);
@@ -154,8 +159,9 @@  discard block
 block discarded – undo
154 159
  * that the user does not have. Run re-parent loop again.
155 160
  */
156 161
 foreach ( $menu as $id => $data ) {
157
-	if ( ! current_user_can($data[1]) )
158
-		$_wp_menu_nopriv[$data[2]] = true;
162
+	if ( ! current_user_can($data[1]) ) {
163
+			$_wp_menu_nopriv[$data[2]] = true;
164
+	}
159 165
 
160 166
 	/*
161 167
 	 * If there is only one submenu and it is has same destination as the parent,
@@ -164,8 +170,9 @@  discard block
 block discarded – undo
164 170
 	if ( ! empty( $submenu[$data[2]] ) && 1 == count ( $submenu[$data[2]] ) ) {
165 171
 		$subs = $submenu[$data[2]];
166 172
 		$first_sub = reset( $subs );
167
-		if ( $data[2] == $first_sub[2] )
168
-			unset( $submenu[$data[2]] );
173
+		if ( $data[2] == $first_sub[2] ) {
174
+					unset( $submenu[$data[2]] );
175
+		}
169 176
 	}
170 177
 
171 178
 	// If submenu is empty...
@@ -307,8 +314,9 @@  discard block
 block discarded – undo
307 314
 		} elseif ( !isset($menu_order[$a]) && isset($menu_order[$b]) ) {
308 315
 			return 1;
309 316
 		} elseif ( isset($menu_order[$a]) && isset($menu_order[$b]) ) {
310
-			if ( $menu_order[$a] == $menu_order[$b] )
311
-				return 0;
317
+			if ( $menu_order[$a] == $menu_order[$b] ) {
318
+							return 0;
319
+			}
312 320
 			return ($menu_order[$a] < $menu_order[$b]) ? -1 : 1;
313 321
 		} else {
314 322
 			return ($default_menu_order[$a] <= $default_menu_order[$b]) ? -1 : 1;
@@ -322,8 +330,9 @@  discard block
 block discarded – undo
322 330
 // Remove the last menu item if it is a separator.
323 331
 $last_menu_key = array_keys( $menu );
324 332
 $last_menu_key = array_pop( $last_menu_key );
325
-if ( !empty( $menu ) && 'wp-menu-separator' == $menu[ $last_menu_key ][ 4 ] )
333
+if ( !empty( $menu ) && 'wp-menu-separator' == $menu[ $last_menu_key ][ 4 ] ) {
326 334
 	unset( $menu[ $last_menu_key ] );
335
+}
327 336
 unset( $last_menu_key );
328 337
 
329 338
 if ( !user_can_access_admin_page() ) {
Please login to merge, or discard this patch.
src/wp-admin/includes/update.php 4 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * WordPress Administration Update API
4
- *
5
- * @package WordPress
6
- * @subpackage Administration
7
- */
3
+	 * WordPress Administration Update API
4
+	 *
5
+	 * @package WordPress
6
+	 * @subpackage Administration
7
+	 */
8 8
 
9 9
 /**
10 10
  * Selects the first update version from the update_core option.
@@ -354,16 +354,16 @@  discard block
 block discarded – undo
354 354
 		 *     @type string $title        The human-readable title of the plugin.
355 355
 		 *     @type string $author_name  Plugin author's name.
356 356
 		 *     @type bool   $update       Whether there's an available update. Default null.
357
-	 	 * }
358
-	 	 * @param array $r {
359
-	 	 *     An array of metadata about the available plugin update.
360
-	 	 *
361
-	 	 *     @type int    $id           Plugin ID.
362
-	 	 *     @type string $slug         Plugin slug.
363
-	 	 *     @type string $new_version  New plugin version.
364
-	 	 *     @type string $url          Plugin URL.
365
-	 	 *     @type string $package      Plugin update package URL.
366
-	 	 * }
357
+		 * }
358
+		 * @param array $r {
359
+		 *     An array of metadata about the available plugin update.
360
+		 *
361
+		 *     @type int    $id           Plugin ID.
362
+		 *     @type string $slug         Plugin slug.
363
+		 *     @type string $new_version  New plugin version.
364
+		 *     @type string $url          Plugin URL.
365
+		 *     @type string $package      Plugin update package URL.
366
+		 * }
367 367
 		 */
368 368
 		do_action( "in_plugin_update_message-{$file}", $plugin_data, $r );
369 369
 
Please login to merge, or discard this patch.
Switch Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -199,15 +199,15 @@
 block discarded – undo
199 199
 		$cur->response = '';
200 200
 
201 201
 	switch ( $cur->response ) {
202
-	case 'development' :
203
-		return sprintf( __( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ), get_bloginfo( 'version', 'display' ), network_admin_url( 'update-core.php' ) );
202
+		case 'development' :
203
+			return sprintf( __( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ), get_bloginfo( 'version', 'display' ), network_admin_url( 'update-core.php' ) );
204 204
 
205
-	case 'upgrade' :
206
-		return sprintf( '<strong>'.__( '<a href="%1$s">Get Version %2$s</a>' ).'</strong>', network_admin_url( 'update-core.php' ), $cur->current);
205
+		case 'upgrade' :
206
+			return sprintf( '<strong>'.__( '<a href="%1$s">Get Version %2$s</a>' ).'</strong>', network_admin_url( 'update-core.php' ), $cur->current);
207 207
 
208
-	case 'latest' :
209
-	default :
210
-		return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) );
208
+		case 'latest' :
209
+		default :
210
+			return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) );
211 211
 	}
212 212
 }
213 213
 
Please login to merge, or discard this patch.
Spacing   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@  discard block
 block discarded – undo
13 13
  */
14 14
 function get_preferred_from_update_core() {
15 15
 	$updates = get_core_updates();
16
-	if ( ! is_array( $updates ) )
16
+	if ( ! is_array($updates))
17 17
 		return false;
18
-	if ( empty( $updates ) )
19
-		return (object) array( 'response' => 'latest' );
18
+	if (empty($updates))
19
+		return (object) array('response' => 'latest');
20 20
 	return $updates[0];
21 21
 }
22 22
 
@@ -27,31 +27,31 @@  discard block
 block discarded – undo
27 27
  * 	                     set $options['available'] to false to skip not-dismissed updates.
28 28
  * @return array|false Array of the update objects on success, false on failure.
29 29
  */
30
-function get_core_updates( $options = array() ) {
31
-	$options = array_merge( array( 'available' => true, 'dismissed' => false ), $options );
32
-	$dismissed = get_site_option( 'dismissed_update_core' );
30
+function get_core_updates($options = array()) {
31
+	$options = array_merge(array('available' => true, 'dismissed' => false), $options);
32
+	$dismissed = get_site_option('dismissed_update_core');
33 33
 
34
-	if ( ! is_array( $dismissed ) )
34
+	if ( ! is_array($dismissed))
35 35
 		$dismissed = array();
36 36
 
37
-	$from_api = get_site_transient( 'update_core' );
37
+	$from_api = get_site_transient('update_core');
38 38
 
39
-	if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) )
39
+	if ( ! isset($from_api->updates) || ! is_array($from_api->updates))
40 40
 		return false;
41 41
 
42 42
 	$updates = $from_api->updates;
43 43
 	$result = array();
44
-	foreach ( $updates as $update ) {
45
-		if ( $update->response == 'autoupdate' )
44
+	foreach ($updates as $update) {
45
+		if ($update->response == 'autoupdate')
46 46
 			continue;
47 47
 
48
-		if ( array_key_exists( $update->current . '|' . $update->locale, $dismissed ) ) {
49
-			if ( $options['dismissed'] ) {
48
+		if (array_key_exists($update->current.'|'.$update->locale, $dismissed)) {
49
+			if ($options['dismissed']) {
50 50
 				$update->dismissed = true;
51 51
 				$result[] = $update;
52 52
 			}
53 53
 		} else {
54
-			if ( $options['available'] ) {
54
+			if ($options['available']) {
55 55
 				$update->dismissed = false;
56 56
 				$result[] = $update;
57 57
 			}
@@ -70,22 +70,22 @@  discard block
 block discarded – undo
70 70
  * @return array|false False on failure, otherwise the core update offering.
71 71
  */
72 72
 function find_core_auto_update() {
73
-	$updates = get_site_transient( 'update_core' );
74
-	if ( ! $updates || empty( $updates->updates ) )
73
+	$updates = get_site_transient('update_core');
74
+	if ( ! $updates || empty($updates->updates))
75 75
 		return false;
76 76
 
77
-	include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
77
+	include_once(ABSPATH.'wp-admin/includes/class-wp-upgrader.php');
78 78
 
79 79
 	$auto_update = false;
80 80
 	$upgrader = new WP_Automatic_Updater;
81
-	foreach ( $updates->updates as $update ) {
82
-		if ( 'autoupdate' != $update->response )
81
+	foreach ($updates->updates as $update) {
82
+		if ('autoupdate' != $update->response)
83 83
 			continue;
84 84
 
85
-		if ( ! $upgrader->should_update( 'core', $update, ABSPATH ) )
85
+		if ( ! $upgrader->should_update('core', $update, ABSPATH))
86 86
 			continue;
87 87
 
88
-		if ( ! $auto_update || version_compare( $update->current, $auto_update->current, '>' ) )
88
+		if ( ! $auto_update || version_compare($update->current, $auto_update->current, '>'))
89 89
 			$auto_update = $update;
90 90
 	}
91 91
 	return $auto_update;
@@ -100,29 +100,29 @@  discard block
 block discarded – undo
100 100
  * @param string $locale  Locale to query.
101 101
  * @return bool|array False on failure. An array of checksums on success.
102 102
  */
103
-function get_core_checksums( $version, $locale ) {
104
-	$url = $http_url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( compact( 'version', 'locale' ), null, '&' );
103
+function get_core_checksums($version, $locale) {
104
+	$url = $http_url = 'http://api.wordpress.org/core/checksums/1.0/?'.http_build_query(compact('version', 'locale'), null, '&');
105 105
 
106
-	if ( $ssl = wp_http_supports( array( 'ssl' ) ) )
107
-		$url = set_url_scheme( $url, 'https' );
106
+	if ($ssl = wp_http_supports(array('ssl')))
107
+		$url = set_url_scheme($url, 'https');
108 108
 
109 109
 	$options = array(
110
-		'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3 ),
110
+		'timeout' => ((defined('DOING_CRON') && DOING_CRON) ? 30 : 3),
111 111
 	);
112 112
 
113
-	$response = wp_remote_get( $url, $options );
114
-	if ( $ssl && is_wp_error( $response ) ) {
115
-		trigger_error( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE );
116
-		$response = wp_remote_get( $http_url, $options );
113
+	$response = wp_remote_get($url, $options);
114
+	if ($ssl && is_wp_error($response)) {
115
+		trigger_error(__('An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.').' '.__('(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)'), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE);
116
+		$response = wp_remote_get($http_url, $options);
117 117
 	}
118 118
 
119
-	if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )
119
+	if (is_wp_error($response) || 200 != wp_remote_retrieve_response_code($response))
120 120
 		return false;
121 121
 
122
-	$body = trim( wp_remote_retrieve_body( $response ) );
123
-	$body = json_decode( $body, true );
122
+	$body = trim(wp_remote_retrieve_body($response));
123
+	$body = json_decode($body, true);
124 124
 
125
-	if ( ! is_array( $body ) || ! isset( $body['checksums'] ) || ! is_array( $body['checksums'] ) )
125
+	if ( ! is_array($body) || ! isset($body['checksums']) || ! is_array($body['checksums']))
126 126
 		return false;
127 127
 
128 128
 	return $body['checksums'];
@@ -133,10 +133,10 @@  discard block
 block discarded – undo
133 133
  * @param object $update
134 134
  * @return bool
135 135
  */
136
-function dismiss_core_update( $update ) {
137
-	$dismissed = get_site_option( 'dismissed_update_core' );
138
-	$dismissed[ $update->current . '|' . $update->locale ] = true;
139
-	return update_site_option( 'dismissed_update_core', $dismissed );
136
+function dismiss_core_update($update) {
137
+	$dismissed = get_site_option('dismissed_update_core');
138
+	$dismissed[$update->current.'|'.$update->locale] = true;
139
+	return update_site_option('dismissed_update_core', $dismissed);
140 140
 }
141 141
 
142 142
 /**
@@ -145,15 +145,15 @@  discard block
 block discarded – undo
145 145
  * @param string $locale
146 146
  * @return bool
147 147
  */
148
-function undismiss_core_update( $version, $locale ) {
149
-	$dismissed = get_site_option( 'dismissed_update_core' );
150
-	$key = $version . '|' . $locale;
148
+function undismiss_core_update($version, $locale) {
149
+	$dismissed = get_site_option('dismissed_update_core');
150
+	$key = $version.'|'.$locale;
151 151
 
152
-	if ( ! isset( $dismissed[$key] ) )
152
+	if ( ! isset($dismissed[$key]))
153 153
 		return false;
154 154
 
155
-	unset( $dismissed[$key] );
156
-	return update_site_option( 'dismissed_update_core', $dismissed );
155
+	unset($dismissed[$key]);
156
+	return update_site_option('dismissed_update_core', $dismissed);
157 157
 }
158 158
 
159 159
 /**
@@ -162,15 +162,15 @@  discard block
 block discarded – undo
162 162
  * @param string $locale
163 163
  * @return object|false
164 164
  */
165
-function find_core_update( $version, $locale ) {
166
-	$from_api = get_site_transient( 'update_core' );
165
+function find_core_update($version, $locale) {
166
+	$from_api = get_site_transient('update_core');
167 167
 
168
-	if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) )
168
+	if ( ! isset($from_api->updates) || ! is_array($from_api->updates))
169 169
 		return false;
170 170
 
171 171
 	$updates = $from_api->updates;
172
-	foreach ( $updates as $update ) {
173
-		if ( $update->current == $version && $update->locale == $locale )
172
+	foreach ($updates as $update) {
173
+		if ($update->current == $version && $update->locale == $locale)
174 174
 			return $update;
175 175
 	}
176 176
 	return false;
@@ -181,33 +181,33 @@  discard block
 block discarded – undo
181 181
  * @param string $msg
182 182
  * @return string
183 183
  */
184
-function core_update_footer( $msg = '' ) {
185
-	if ( !current_user_can('update_core') )
186
-		return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) );
184
+function core_update_footer($msg = '') {
185
+	if ( ! current_user_can('update_core'))
186
+		return sprintf(__('Version %s'), get_bloginfo('version', 'display'));
187 187
 
188 188
 	$cur = get_preferred_from_update_core();
189
-	if ( ! is_object( $cur ) )
189
+	if ( ! is_object($cur))
190 190
 		$cur = new stdClass;
191 191
 
192
-	if ( ! isset( $cur->current ) )
192
+	if ( ! isset($cur->current))
193 193
 		$cur->current = '';
194 194
 
195
-	if ( ! isset( $cur->url ) )
195
+	if ( ! isset($cur->url))
196 196
 		$cur->url = '';
197 197
 
198
-	if ( ! isset( $cur->response ) )
198
+	if ( ! isset($cur->response))
199 199
 		$cur->response = '';
200 200
 
201
-	switch ( $cur->response ) {
201
+	switch ($cur->response) {
202 202
 	case 'development' :
203
-		return sprintf( __( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ), get_bloginfo( 'version', 'display' ), network_admin_url( 'update-core.php' ) );
203
+		return sprintf(__('You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.'), get_bloginfo('version', 'display'), network_admin_url('update-core.php'));
204 204
 
205 205
 	case 'upgrade' :
206
-		return sprintf( '<strong>'.__( '<a href="%1$s">Get Version %2$s</a>' ).'</strong>', network_admin_url( 'update-core.php' ), $cur->current);
206
+		return sprintf('<strong>'.__('<a href="%1$s">Get Version %2$s</a>').'</strong>', network_admin_url('update-core.php'), $cur->current);
207 207
 
208 208
 	case 'latest' :
209 209
 	default :
210
-		return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) );
210
+		return sprintf(__('Version %s'), get_bloginfo('version', 'display'));
211 211
 	}
212 212
 }
213 213
 
@@ -217,23 +217,23 @@  discard block
 block discarded – undo
217 217
  * @return false|void
218 218
  */
219 219
 function update_nag() {
220
-	if ( is_multisite() && !current_user_can('update_core') )
220
+	if (is_multisite() && ! current_user_can('update_core'))
221 221
 		return false;
222 222
 
223 223
 	global $pagenow;
224 224
 
225
-	if ( 'update-core.php' == $pagenow )
225
+	if ('update-core.php' == $pagenow)
226 226
 		return;
227 227
 
228 228
 	$cur = get_preferred_from_update_core();
229 229
 
230
-	if ( ! isset( $cur->response ) || $cur->response != 'upgrade' )
230
+	if ( ! isset($cur->response) || $cur->response != 'upgrade')
231 231
 		return false;
232 232
 
233
-	if ( current_user_can('update_core') ) {
234
-		$msg = sprintf( __('<a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> is available! <a href="%2$s">Please update now</a>.'), $cur->current, network_admin_url( 'update-core.php' ) );
233
+	if (current_user_can('update_core')) {
234
+		$msg = sprintf(__('<a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> is available! <a href="%2$s">Please update now</a>.'), $cur->current, network_admin_url('update-core.php'));
235 235
 	} else {
236
-		$msg = sprintf( __('<a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> is available! Please notify the site administrator.'), $cur->current );
236
+		$msg = sprintf(__('<a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> is available! Please notify the site administrator.'), $cur->current);
237 237
 	}
238 238
 	echo "<div class='update-nag'>$msg</div>";
239 239
 }
@@ -241,20 +241,20 @@  discard block
 block discarded – undo
241 241
 // Called directly from dashboard
242 242
 function update_right_now_message() {
243 243
 	$theme_name = wp_get_theme();
244
-	if ( current_user_can( 'switch_themes' ) ) {
245
-		$theme_name = sprintf( '<a href="themes.php">%1$s</a>', $theme_name );
244
+	if (current_user_can('switch_themes')) {
245
+		$theme_name = sprintf('<a href="themes.php">%1$s</a>', $theme_name);
246 246
 	}
247 247
 
248 248
 	$msg = '';
249 249
 
250
-	if ( current_user_can('update_core') ) {
250
+	if (current_user_can('update_core')) {
251 251
 		$cur = get_preferred_from_update_core();
252 252
 
253
-		if ( isset( $cur->response ) && $cur->response == 'upgrade' )
254
-			$msg .= '<a href="' . network_admin_url( 'update-core.php' ) . '" class="button" aria-describedby="wp-version">' . sprintf( __( 'Update to %s' ), $cur->current ? $cur->current : __( 'Latest' ) ) . '</a> ';
253
+		if (isset($cur->response) && $cur->response == 'upgrade')
254
+			$msg .= '<a href="'.network_admin_url('update-core.php').'" class="button" aria-describedby="wp-version">'.sprintf(__('Update to %s'), $cur->current ? $cur->current : __('Latest')).'</a> ';
255 255
 	}
256 256
 
257
-	$msg .= sprintf( '<span id="wp-version">' . __( 'WordPress %1$s running %2$s theme.' ) . '</span>', get_bloginfo( 'version', 'display' ), $theme_name );
257
+	$msg .= sprintf('<span id="wp-version">'.__('WordPress %1$s running %2$s theme.').'</span>', get_bloginfo('version', 'display'), $theme_name);
258 258
 
259 259
 	echo "<p id='wp-version-message'>$msg</p>";
260 260
 }
@@ -267,11 +267,11 @@  discard block
 block discarded – undo
267 267
 function get_plugin_updates() {
268 268
 	$all_plugins = get_plugins();
269 269
 	$upgrade_plugins = array();
270
-	$current = get_site_transient( 'update_plugins' );
271
-	foreach ( (array)$all_plugins as $plugin_file => $plugin_data) {
272
-		if ( isset( $current->response[ $plugin_file ] ) ) {
273
-			$upgrade_plugins[ $plugin_file ] = (object) $plugin_data;
274
-			$upgrade_plugins[ $plugin_file ]->update = $current->response[ $plugin_file ];
270
+	$current = get_site_transient('update_plugins');
271
+	foreach ((array) $all_plugins as $plugin_file => $plugin_data) {
272
+		if (isset($current->response[$plugin_file])) {
273
+			$upgrade_plugins[$plugin_file] = (object) $plugin_data;
274
+			$upgrade_plugins[$plugin_file]->update = $current->response[$plugin_file];
275 275
 		}
276 276
 	}
277 277
 
@@ -282,14 +282,14 @@  discard block
 block discarded – undo
282 282
  * @since 2.9.0
283 283
  */
284 284
 function wp_plugin_update_rows() {
285
-	if ( !current_user_can('update_plugins' ) )
285
+	if ( ! current_user_can('update_plugins'))
286 286
 		return;
287 287
 
288
-	$plugins = get_site_transient( 'update_plugins' );
289
-	if ( isset($plugins->response) && is_array($plugins->response) ) {
290
-		$plugins = array_keys( $plugins->response );
291
-		foreach( $plugins as $plugin_file ) {
292
-			add_action( "after_plugin_row_$plugin_file", 'wp_plugin_update_row', 10, 2 );
288
+	$plugins = get_site_transient('update_plugins');
289
+	if (isset($plugins->response) && is_array($plugins->response)) {
290
+		$plugins = array_keys($plugins->response);
291
+		foreach ($plugins as $plugin_file) {
292
+			add_action("after_plugin_row_$plugin_file", 'wp_plugin_update_row', 10, 2);
293 293
 		}
294 294
 	}
295 295
 }
@@ -300,35 +300,35 @@  discard block
 block discarded – undo
300 300
  * @param array  $plugin_data
301 301
  * @return false|void
302 302
  */
303
-function wp_plugin_update_row( $file, $plugin_data ) {
304
-	$current = get_site_transient( 'update_plugins' );
305
-	if ( !isset( $current->response[ $file ] ) )
303
+function wp_plugin_update_row($file, $plugin_data) {
304
+	$current = get_site_transient('update_plugins');
305
+	if ( ! isset($current->response[$file]))
306 306
 		return false;
307 307
 
308
-	$r = $current->response[ $file ];
308
+	$r = $current->response[$file];
309 309
 
310
-	$plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array());
311
-	$plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags );
310
+	$plugins_allowedtags = array('a' => array('href' => array(), 'title' => array()), 'abbr' => array('title' => array()), 'acronym' => array('title' => array()), 'code' => array(), 'em' => array(), 'strong' => array());
311
+	$plugin_name = wp_kses($plugin_data['Name'], $plugins_allowedtags);
312 312
 
313
-	$details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin=' . $r->slug . '&section=changelog&TB_iframe=true&width=600&height=800');
313
+	$details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin='.$r->slug.'&section=changelog&TB_iframe=true&width=600&height=800');
314 314
 
315 315
 	$wp_list_table = _get_list_table('WP_Plugins_List_Table');
316 316
 
317
-	if ( is_network_admin() || !is_multisite() ) {
318
-		if ( is_network_admin() ) {
319
-			$active_class = is_plugin_active_for_network( $file ) ? ' active': '';
317
+	if (is_network_admin() || ! is_multisite()) {
318
+		if (is_network_admin()) {
319
+			$active_class = is_plugin_active_for_network($file) ? ' active' : '';
320 320
 		} else {
321
-			$active_class = is_plugin_active( $file ) ? ' active' : '';
321
+			$active_class = is_plugin_active($file) ? ' active' : '';
322 322
 		}
323 323
 
324
-		echo '<tr class="plugin-update-tr' . $active_class . '" id="' . esc_attr( $r->slug . '-update' ) . '" data-slug="' . esc_attr( $r->slug ) . '" data-plugin="' . esc_attr( $file ) . '"><td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"><div class="update-message">';
324
+		echo '<tr class="plugin-update-tr'.$active_class.'" id="'.esc_attr($r->slug.'-update').'" data-slug="'.esc_attr($r->slug).'" data-plugin="'.esc_attr($file).'"><td colspan="'.esc_attr($wp_list_table->get_column_count()).'" class="plugin-update colspanchange"><div class="update-message">';
325 325
 
326
-		if ( ! current_user_can( 'update_plugins' ) ) {
327
-			printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version );
328
-		} elseif ( empty($r->package) ) {
329
-			printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this plugin.</em>'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version );
326
+		if ( ! current_user_can('update_plugins')) {
327
+			printf(__('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version);
328
+		} elseif (empty($r->package)) {
329
+			printf(__('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this plugin.</em>'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version);
330 330
 		} else {
331
-			printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a> or <a href="%5$s" class="update-link">update now</a>.' ), $plugin_name, esc_url( $details_url ), esc_attr( $plugin_name ), $r->new_version, wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $file, 'upgrade-plugin_' . $file ) );
331
+			printf(__('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a> or <a href="%5$s" class="update-link">update now</a>.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version, wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=').$file, 'upgrade-plugin_'.$file));
332 332
 		}
333 333
 		/**
334 334
 		 * Fires at the end of the update message container in each
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 	 	 *     @type string $package      Plugin update package URL.
366 366
 	 	 * }
367 367
 		 */
368
-		do_action( "in_plugin_update_message-{$file}", $plugin_data, $r );
368
+		do_action("in_plugin_update_message-{$file}", $plugin_data, $r);
369 369
 
370 370
 		echo '</div></td></tr>';
371 371
 	}
@@ -378,13 +378,13 @@  discard block
 block discarded – undo
378 378
 function get_theme_updates() {
379 379
 	$current = get_site_transient('update_themes');
380 380
 
381
-	if ( ! isset( $current->response ) )
381
+	if ( ! isset($current->response))
382 382
 		return array();
383 383
 
384 384
 	$update_themes = array();
385
-	foreach ( $current->response as $stylesheet => $data ) {
386
-		$update_themes[ $stylesheet ] = wp_get_theme( $stylesheet );
387
-		$update_themes[ $stylesheet ]->update = $data;
385
+	foreach ($current->response as $stylesheet => $data) {
386
+		$update_themes[$stylesheet] = wp_get_theme($stylesheet);
387
+		$update_themes[$stylesheet]->update = $data;
388 388
 	}
389 389
 
390 390
 	return $update_themes;
@@ -394,15 +394,15 @@  discard block
 block discarded – undo
394 394
  * @since 3.1.0
395 395
  */
396 396
 function wp_theme_update_rows() {
397
-	if ( !current_user_can('update_themes' ) )
397
+	if ( ! current_user_can('update_themes'))
398 398
 		return;
399 399
 
400
-	$themes = get_site_transient( 'update_themes' );
401
-	if ( isset($themes->response) && is_array($themes->response) ) {
402
-		$themes = array_keys( $themes->response );
400
+	$themes = get_site_transient('update_themes');
401
+	if (isset($themes->response) && is_array($themes->response)) {
402
+		$themes = array_keys($themes->response);
403 403
 
404
-		foreach( $themes as $theme ) {
405
-			add_action( "after_theme_row_$theme", 'wp_theme_update_row', 10, 2 );
404
+		foreach ($themes as $theme) {
405
+			add_action("after_theme_row_$theme", 'wp_theme_update_row', 10, 2);
406 406
 		}
407 407
 	}
408 408
 }
@@ -413,23 +413,23 @@  discard block
 block discarded – undo
413 413
  * @param WP_Theme $theme
414 414
  * @return false|void
415 415
  */
416
-function wp_theme_update_row( $theme_key, $theme ) {
417
-	$current = get_site_transient( 'update_themes' );
418
-	if ( !isset( $current->response[ $theme_key ] ) )
416
+function wp_theme_update_row($theme_key, $theme) {
417
+	$current = get_site_transient('update_themes');
418
+	if ( ! isset($current->response[$theme_key]))
419 419
 		return false;
420
-	$r = $current->response[ $theme_key ];
420
+	$r = $current->response[$theme_key];
421 421
 
422
-	$details_url = add_query_arg( array( 'TB_iframe' => 'true', 'width' => 1024, 'height' => 800 ), $current->response[ $theme_key ]['url'] );
422
+	$details_url = add_query_arg(array('TB_iframe' => 'true', 'width' => 1024, 'height' => 800), $current->response[$theme_key]['url']);
423 423
 
424 424
 	$wp_list_table = _get_list_table('WP_MS_Themes_List_Table');
425 425
 
426
-	echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
427
-	if ( ! current_user_can('update_themes') ) {
428
-		printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>.'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r->new_version );
429
-	} elseif ( empty( $r['package'] ) ) {
430
-		printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r['new_version'] );
426
+	echo '<tr class="plugin-update-tr"><td colspan="'.$wp_list_table->get_column_count().'" class="plugin-update colspanchange"><div class="update-message">';
427
+	if ( ! current_user_can('update_themes')) {
428
+		printf(__('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>.'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r->new_version);
429
+	} elseif (empty($r['package'])) {
430
+		printf(__('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r['new_version']);
431 431
 	} else {
432
-		printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a> or <a href="%5$s">update now</a>.'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r['new_version'], wp_nonce_url( self_admin_url('update.php?action=upgrade-theme&theme=') . $theme_key, 'upgrade-theme_' . $theme_key) );
432
+		printf(__('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a> or <a href="%5$s">update now</a>.'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r['new_version'], wp_nonce_url(self_admin_url('update.php?action=upgrade-theme&theme=').$theme_key, 'upgrade-theme_'.$theme_key));
433 433
 	}
434 434
 	/**
435 435
 	 * Fires at the end of the update message container in each
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
 	 *     @type string $package     Theme update package URL.
450 450
 	 * }
451 451
 	 */
452
-	do_action( "in_theme_update_message-{$theme_key}", $theme, $r );
452
+	do_action("in_theme_update_message-{$theme_key}", $theme, $r);
453 453
 
454 454
 	echo '</div></td></tr>';
455 455
 }
@@ -460,11 +460,11 @@  discard block
 block discarded – undo
460 460
  * @return false|void
461 461
  */
462 462
 function maintenance_nag() {
463
-	include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version
463
+	include(ABSPATH.WPINC.'/version.php'); // include an unmodified $wp_version
464 464
 	global $upgrading;
465
-	$nag = isset( $upgrading );
466
-	if ( ! $nag ) {
467
-		$failed = get_site_option( 'auto_core_update_failed' );
465
+	$nag = isset($upgrading);
466
+	if ( ! $nag) {
467
+		$failed = get_site_option('auto_core_update_failed');
468 468
 		/*
469 469
 		 * If an update failed critically, we may have copied over version.php but not other files.
470 470
 		 * In that case, if the install claims we're running the version we attempted, nag.
@@ -475,16 +475,16 @@  discard block
 block discarded – undo
475 475
 		 *
476 476
 		 * This flag is cleared whenever a successful update occurs using Core_Upgrader.
477 477
 		 */
478
-		$comparison = ! empty( $failed['critical'] ) ? '>=' : '>';
479
-		if ( version_compare( $failed['attempted'], $wp_version, $comparison ) )
478
+		$comparison = ! empty($failed['critical']) ? '>=' : '>';
479
+		if (version_compare($failed['attempted'], $wp_version, $comparison))
480 480
 			$nag = true;
481 481
 	}
482 482
 
483
-	if ( ! $nag )
483
+	if ( ! $nag)
484 484
 		return false;
485 485
 
486
-	if ( current_user_can('update_core') )
487
-		$msg = sprintf( __('An automated WordPress update has failed to complete - <a href="%s">please attempt the update again now</a>.'), 'update-core.php' );
486
+	if (current_user_can('update_core'))
487
+		$msg = sprintf(__('An automated WordPress update has failed to complete - <a href="%s">please attempt the update again now</a>.'), 'update-core.php');
488 488
 	else
489 489
 		$msg = __('An automated WordPress update has failed to complete! Please notify the site administrator.');
490 490
 
Please login to merge, or discard this patch.
Braces   +98 added lines, -66 removed lines patch added patch discarded remove patch
@@ -13,10 +13,12 @@  discard block
 block discarded – undo
13 13
  */
14 14
 function get_preferred_from_update_core() {
15 15
 	$updates = get_core_updates();
16
-	if ( ! is_array( $updates ) )
17
-		return false;
18
-	if ( empty( $updates ) )
19
-		return (object) array( 'response' => 'latest' );
16
+	if ( ! is_array( $updates ) ) {
17
+			return false;
18
+	}
19
+	if ( empty( $updates ) ) {
20
+			return (object) array( 'response' => 'latest' );
21
+	}
20 22
 	return $updates[0];
21 23
 }
22 24
 
@@ -31,19 +33,22 @@  discard block
 block discarded – undo
31 33
 	$options = array_merge( array( 'available' => true, 'dismissed' => false ), $options );
32 34
 	$dismissed = get_site_option( 'dismissed_update_core' );
33 35
 
34
-	if ( ! is_array( $dismissed ) )
35
-		$dismissed = array();
36
+	if ( ! is_array( $dismissed ) ) {
37
+			$dismissed = array();
38
+	}
36 39
 
37 40
 	$from_api = get_site_transient( 'update_core' );
38 41
 
39
-	if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) )
40
-		return false;
42
+	if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) ) {
43
+			return false;
44
+	}
41 45
 
42 46
 	$updates = $from_api->updates;
43 47
 	$result = array();
44 48
 	foreach ( $updates as $update ) {
45
-		if ( $update->response == 'autoupdate' )
46
-			continue;
49
+		if ( $update->response == 'autoupdate' ) {
50
+					continue;
51
+		}
47 52
 
48 53
 		if ( array_key_exists( $update->current . '|' . $update->locale, $dismissed ) ) {
49 54
 			if ( $options['dismissed'] ) {
@@ -71,22 +76,26 @@  discard block
 block discarded – undo
71 76
  */
72 77
 function find_core_auto_update() {
73 78
 	$updates = get_site_transient( 'update_core' );
74
-	if ( ! $updates || empty( $updates->updates ) )
75
-		return false;
79
+	if ( ! $updates || empty( $updates->updates ) ) {
80
+			return false;
81
+	}
76 82
 
77 83
 	include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
78 84
 
79 85
 	$auto_update = false;
80 86
 	$upgrader = new WP_Automatic_Updater;
81 87
 	foreach ( $updates->updates as $update ) {
82
-		if ( 'autoupdate' != $update->response )
83
-			continue;
88
+		if ( 'autoupdate' != $update->response ) {
89
+					continue;
90
+		}
84 91
 
85
-		if ( ! $upgrader->should_update( 'core', $update, ABSPATH ) )
86
-			continue;
92
+		if ( ! $upgrader->should_update( 'core', $update, ABSPATH ) ) {
93
+					continue;
94
+		}
87 95
 
88
-		if ( ! $auto_update || version_compare( $update->current, $auto_update->current, '>' ) )
89
-			$auto_update = $update;
96
+		if ( ! $auto_update || version_compare( $update->current, $auto_update->current, '>' ) ) {
97
+					$auto_update = $update;
98
+		}
90 99
 	}
91 100
 	return $auto_update;
92 101
 }
@@ -103,8 +112,9 @@  discard block
 block discarded – undo
103 112
 function get_core_checksums( $version, $locale ) {
104 113
 	$url = $http_url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( compact( 'version', 'locale' ), null, '&' );
105 114
 
106
-	if ( $ssl = wp_http_supports( array( 'ssl' ) ) )
107
-		$url = set_url_scheme( $url, 'https' );
115
+	if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) {
116
+			$url = set_url_scheme( $url, 'https' );
117
+	}
108 118
 
109 119
 	$options = array(
110 120
 		'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3 ),
@@ -116,14 +126,16 @@  discard block
 block discarded – undo
116 126
 		$response = wp_remote_get( $http_url, $options );
117 127
 	}
118 128
 
119
-	if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )
120
-		return false;
129
+	if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
130
+			return false;
131
+	}
121 132
 
122 133
 	$body = trim( wp_remote_retrieve_body( $response ) );
123 134
 	$body = json_decode( $body, true );
124 135
 
125
-	if ( ! is_array( $body ) || ! isset( $body['checksums'] ) || ! is_array( $body['checksums'] ) )
126
-		return false;
136
+	if ( ! is_array( $body ) || ! isset( $body['checksums'] ) || ! is_array( $body['checksums'] ) ) {
137
+			return false;
138
+	}
127 139
 
128 140
 	return $body['checksums'];
129 141
 }
@@ -149,8 +161,9 @@  discard block
 block discarded – undo
149 161
 	$dismissed = get_site_option( 'dismissed_update_core' );
150 162
 	$key = $version . '|' . $locale;
151 163
 
152
-	if ( ! isset( $dismissed[$key] ) )
153
-		return false;
164
+	if ( ! isset( $dismissed[$key] ) ) {
165
+			return false;
166
+	}
154 167
 
155 168
 	unset( $dismissed[$key] );
156 169
 	return update_site_option( 'dismissed_update_core', $dismissed );
@@ -165,13 +178,15 @@  discard block
 block discarded – undo
165 178
 function find_core_update( $version, $locale ) {
166 179
 	$from_api = get_site_transient( 'update_core' );
167 180
 
168
-	if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) )
169
-		return false;
181
+	if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) ) {
182
+			return false;
183
+	}
170 184
 
171 185
 	$updates = $from_api->updates;
172 186
 	foreach ( $updates as $update ) {
173
-		if ( $update->current == $version && $update->locale == $locale )
174
-			return $update;
187
+		if ( $update->current == $version && $update->locale == $locale ) {
188
+					return $update;
189
+		}
175 190
 	}
176 191
 	return false;
177 192
 }
@@ -182,21 +197,26 @@  discard block
 block discarded – undo
182 197
  * @return string
183 198
  */
184 199
 function core_update_footer( $msg = '' ) {
185
-	if ( !current_user_can('update_core') )
186
-		return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) );
200
+	if ( !current_user_can('update_core') ) {
201
+			return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) );
202
+	}
187 203
 
188 204
 	$cur = get_preferred_from_update_core();
189
-	if ( ! is_object( $cur ) )
190
-		$cur = new stdClass;
205
+	if ( ! is_object( $cur ) ) {
206
+			$cur = new stdClass;
207
+	}
191 208
 
192
-	if ( ! isset( $cur->current ) )
193
-		$cur->current = '';
209
+	if ( ! isset( $cur->current ) ) {
210
+			$cur->current = '';
211
+	}
194 212
 
195
-	if ( ! isset( $cur->url ) )
196
-		$cur->url = '';
213
+	if ( ! isset( $cur->url ) ) {
214
+			$cur->url = '';
215
+	}
197 216
 
198
-	if ( ! isset( $cur->response ) )
199
-		$cur->response = '';
217
+	if ( ! isset( $cur->response ) ) {
218
+			$cur->response = '';
219
+	}
200 220
 
201 221
 	switch ( $cur->response ) {
202 222
 	case 'development' :
@@ -217,18 +237,21 @@  discard block
 block discarded – undo
217 237
  * @return false|void
218 238
  */
219 239
 function update_nag() {
220
-	if ( is_multisite() && !current_user_can('update_core') )
221
-		return false;
240
+	if ( is_multisite() && !current_user_can('update_core') ) {
241
+			return false;
242
+	}
222 243
 
223 244
 	global $pagenow;
224 245
 
225
-	if ( 'update-core.php' == $pagenow )
226
-		return;
246
+	if ( 'update-core.php' == $pagenow ) {
247
+			return;
248
+	}
227 249
 
228 250
 	$cur = get_preferred_from_update_core();
229 251
 
230
-	if ( ! isset( $cur->response ) || $cur->response != 'upgrade' )
231
-		return false;
252
+	if ( ! isset( $cur->response ) || $cur->response != 'upgrade' ) {
253
+			return false;
254
+	}
232 255
 
233 256
 	if ( current_user_can('update_core') ) {
234 257
 		$msg = sprintf( __('<a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> is available! <a href="%2$s">Please update now</a>.'), $cur->current, network_admin_url( 'update-core.php' ) );
@@ -250,8 +273,9 @@  discard block
 block discarded – undo
250 273
 	if ( current_user_can('update_core') ) {
251 274
 		$cur = get_preferred_from_update_core();
252 275
 
253
-		if ( isset( $cur->response ) && $cur->response == 'upgrade' )
254
-			$msg .= '<a href="' . network_admin_url( 'update-core.php' ) . '" class="button" aria-describedby="wp-version">' . sprintf( __( 'Update to %s' ), $cur->current ? $cur->current : __( 'Latest' ) ) . '</a> ';
276
+		if ( isset( $cur->response ) && $cur->response == 'upgrade' ) {
277
+					$msg .= '<a href="' . network_admin_url( 'update-core.php' ) . '" class="button" aria-describedby="wp-version">' . sprintf( __( 'Update to %s' ), $cur->current ? $cur->current : __( 'Latest' ) ) . '</a> ';
278
+		}
255 279
 	}
256 280
 
257 281
 	$msg .= sprintf( '<span id="wp-version">' . __( 'WordPress %1$s running %2$s theme.' ) . '</span>', get_bloginfo( 'version', 'display' ), $theme_name );
@@ -282,8 +306,9 @@  discard block
 block discarded – undo
282 306
  * @since 2.9.0
283 307
  */
284 308
 function wp_plugin_update_rows() {
285
-	if ( !current_user_can('update_plugins' ) )
286
-		return;
309
+	if ( !current_user_can('update_plugins' ) ) {
310
+			return;
311
+	}
287 312
 
288 313
 	$plugins = get_site_transient( 'update_plugins' );
289 314
 	if ( isset($plugins->response) && is_array($plugins->response) ) {
@@ -302,8 +327,9 @@  discard block
 block discarded – undo
302 327
  */
303 328
 function wp_plugin_update_row( $file, $plugin_data ) {
304 329
 	$current = get_site_transient( 'update_plugins' );
305
-	if ( !isset( $current->response[ $file ] ) )
306
-		return false;
330
+	if ( !isset( $current->response[ $file ] ) ) {
331
+			return false;
332
+	}
307 333
 
308 334
 	$r = $current->response[ $file ];
309 335
 
@@ -378,8 +404,9 @@  discard block
 block discarded – undo
378 404
 function get_theme_updates() {
379 405
 	$current = get_site_transient('update_themes');
380 406
 
381
-	if ( ! isset( $current->response ) )
382
-		return array();
407
+	if ( ! isset( $current->response ) ) {
408
+			return array();
409
+	}
383 410
 
384 411
 	$update_themes = array();
385 412
 	foreach ( $current->response as $stylesheet => $data ) {
@@ -394,8 +421,9 @@  discard block
 block discarded – undo
394 421
  * @since 3.1.0
395 422
  */
396 423
 function wp_theme_update_rows() {
397
-	if ( !current_user_can('update_themes' ) )
398
-		return;
424
+	if ( !current_user_can('update_themes' ) ) {
425
+			return;
426
+	}
399 427
 
400 428
 	$themes = get_site_transient( 'update_themes' );
401 429
 	if ( isset($themes->response) && is_array($themes->response) ) {
@@ -415,8 +443,9 @@  discard block
 block discarded – undo
415 443
  */
416 444
 function wp_theme_update_row( $theme_key, $theme ) {
417 445
 	$current = get_site_transient( 'update_themes' );
418
-	if ( !isset( $current->response[ $theme_key ] ) )
419
-		return false;
446
+	if ( !isset( $current->response[ $theme_key ] ) ) {
447
+			return false;
448
+	}
420 449
 	$r = $current->response[ $theme_key ];
421 450
 
422 451
 	$details_url = add_query_arg( array( 'TB_iframe' => 'true', 'width' => 1024, 'height' => 800 ), $current->response[ $theme_key ]['url'] );
@@ -476,17 +505,20 @@  discard block
 block discarded – undo
476 505
 		 * This flag is cleared whenever a successful update occurs using Core_Upgrader.
477 506
 		 */
478 507
 		$comparison = ! empty( $failed['critical'] ) ? '>=' : '>';
479
-		if ( version_compare( $failed['attempted'], $wp_version, $comparison ) )
480
-			$nag = true;
508
+		if ( version_compare( $failed['attempted'], $wp_version, $comparison ) ) {
509
+					$nag = true;
510
+		}
481 511
 	}
482 512
 
483
-	if ( ! $nag )
484
-		return false;
513
+	if ( ! $nag ) {
514
+			return false;
515
+	}
485 516
 
486
-	if ( current_user_can('update_core') )
487
-		$msg = sprintf( __('An automated WordPress update has failed to complete - <a href="%s">please attempt the update again now</a>.'), 'update-core.php' );
488
-	else
489
-		$msg = __('An automated WordPress update has failed to complete! Please notify the site administrator.');
517
+	if ( current_user_can('update_core') ) {
518
+			$msg = sprintf( __('An automated WordPress update has failed to complete - <a href="%s">please attempt the update again now</a>.'), 'update-core.php' );
519
+	} else {
520
+			$msg = __('An automated WordPress update has failed to complete! Please notify the site administrator.');
521
+	}
490 522
 
491 523
 	echo "<div class='update-nag'>$msg</div>";
492 524
 }
Please login to merge, or discard this patch.
src/wp-admin/includes/class-wp-themes-list-table.php 3 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Themes List Table class.
4
- *
5
- * @package WordPress
6
- * @subpackage List_Table
7
- * @since 3.1.0
8
- * @access private
9
- */
3
+	 * Themes List Table class.
4
+	 *
5
+	 * @package WordPress
6
+	 * @subpackage List_Table
7
+	 * @since 3.1.0
8
+	 * @access private
9
+	 */
10 10
 class WP_Themes_List_Table extends WP_List_Table {
11 11
 
12 12
 	protected $search_terms = array();
Please login to merge, or discard this patch.
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -22,11 +22,11 @@  discard block
 block discarded – undo
22 22
 	 *
23 23
 	 * @param array $args An associative array of arguments.
24 24
 	 */
25
-	public function __construct( $args = array() ) {
26
-		parent::__construct( array(
25
+	public function __construct($args = array()) {
26
+		parent::__construct(array(
27 27
 			'ajax' => true,
28
-			'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
29
-		) );
28
+			'screen' => isset($args['screen']) ? $args['screen'] : null,
29
+		));
30 30
 	}
31 31
 
32 32
 	/**
@@ -35,85 +35,85 @@  discard block
 block discarded – undo
35 35
 	 */
36 36
 	public function ajax_user_can() {
37 37
 		// Do not check edit_theme_options here. AJAX calls for available themes require switch_themes.
38
-		return current_user_can( 'switch_themes' );
38
+		return current_user_can('switch_themes');
39 39
 	}
40 40
 
41 41
 	/**
42 42
 	 * @access public
43 43
 	 */
44 44
 	public function prepare_items() {
45
-		$themes = wp_get_themes( array( 'allowed' => true ) );
45
+		$themes = wp_get_themes(array('allowed' => true));
46 46
 
47
-		if ( ! empty( $_REQUEST['s'] ) )
48
-			$this->search_terms = array_unique( array_filter( array_map( 'trim', explode( ',', strtolower( wp_unslash( $_REQUEST['s'] ) ) ) ) ) );
47
+		if ( ! empty($_REQUEST['s']))
48
+			$this->search_terms = array_unique(array_filter(array_map('trim', explode(',', strtolower(wp_unslash($_REQUEST['s']))))));
49 49
 
50
-		if ( ! empty( $_REQUEST['features'] ) )
50
+		if ( ! empty($_REQUEST['features']))
51 51
 			$this->features = $_REQUEST['features'];
52 52
 
53
-		if ( $this->search_terms || $this->features ) {
54
-			foreach ( $themes as $key => $theme ) {
55
-				if ( ! $this->search_theme( $theme ) )
56
-					unset( $themes[ $key ] );
53
+		if ($this->search_terms || $this->features) {
54
+			foreach ($themes as $key => $theme) {
55
+				if ( ! $this->search_theme($theme))
56
+					unset($themes[$key]);
57 57
 			}
58 58
 		}
59 59
 
60
-		unset( $themes[ get_option( 'stylesheet' ) ] );
61
-		WP_Theme::sort_by_name( $themes );
60
+		unset($themes[get_option('stylesheet')]);
61
+		WP_Theme::sort_by_name($themes);
62 62
 
63 63
 		$per_page = 36;
64 64
 		$page = $this->get_pagenum();
65 65
 
66
-		$start = ( $page - 1 ) * $per_page;
66
+		$start = ($page - 1) * $per_page;
67 67
 
68
-		$this->items = array_slice( $themes, $start, $per_page, true );
68
+		$this->items = array_slice($themes, $start, $per_page, true);
69 69
 
70
-		$this->set_pagination_args( array(
71
-			'total_items' => count( $themes ),
70
+		$this->set_pagination_args(array(
71
+			'total_items' => count($themes),
72 72
 			'per_page' => $per_page,
73 73
 			'infinite_scroll' => true,
74
-		) );
74
+		));
75 75
 	}
76 76
 
77 77
 	/**
78 78
 	 * @access public
79 79
 	 */
80 80
 	public function no_items() {
81
-		if ( $this->search_terms || $this->features ) {
82
-			_e( 'No items found.' );
81
+		if ($this->search_terms || $this->features) {
82
+			_e('No items found.');
83 83
 			return;
84 84
 		}
85 85
 
86
-		if ( is_multisite() ) {
87
-			if ( current_user_can( 'install_themes' ) && current_user_can( 'manage_network_themes' ) ) {
88
-				printf( __( 'You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> or <a href="%2$s">install</a> more themes.' ), network_admin_url( 'site-themes.php?id=' . $GLOBALS['blog_id'] ), network_admin_url( 'theme-install.php' ) );
86
+		if (is_multisite()) {
87
+			if (current_user_can('install_themes') && current_user_can('manage_network_themes')) {
88
+				printf(__('You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> or <a href="%2$s">install</a> more themes.'), network_admin_url('site-themes.php?id='.$GLOBALS['blog_id']), network_admin_url('theme-install.php'));
89 89
 
90 90
 				return;
91
-			} elseif ( current_user_can( 'manage_network_themes' ) ) {
92
-				printf( __( 'You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> more themes.' ), network_admin_url( 'site-themes.php?id=' . $GLOBALS['blog_id'] ) );
91
+			} elseif (current_user_can('manage_network_themes')) {
92
+				printf(__('You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> more themes.'), network_admin_url('site-themes.php?id='.$GLOBALS['blog_id']));
93 93
 
94 94
 				return;
95 95
 			}
96 96
 			// Else, fallthrough. install_themes doesn't help if you can't enable it.
97 97
 		} else {
98
-			if ( current_user_can( 'install_themes' ) ) {
99
-				printf( __( 'You only have one theme installed right now. Live a little! You can choose from over 1,000 free themes in the WordPress.org Theme Directory at any time: just click on the <a href="%s">Install Themes</a> tab above.' ), admin_url( 'theme-install.php' ) );
98
+			if (current_user_can('install_themes')) {
99
+				printf(__('You only have one theme installed right now. Live a little! You can choose from over 1,000 free themes in the WordPress.org Theme Directory at any time: just click on the <a href="%s">Install Themes</a> tab above.'), admin_url('theme-install.php'));
100 100
 
101 101
 				return;
102 102
 			}
103 103
 		}
104 104
 		// Fallthrough.
105
-		printf( __( 'Only the current theme is available to you. Contact the %s administrator for information about accessing additional themes.' ), get_site_option( 'site_name' ) );
105
+		printf(__('Only the current theme is available to you. Contact the %s administrator for information about accessing additional themes.'), get_site_option('site_name'));
106 106
 	}
107 107
 
108 108
 	/**
109 109
 	 * @param string $which
110 110
 	 */
111
-	public function tablenav( $which = 'top' ) {
112
-		if ( $this->get_pagination_arg( 'total_pages' ) <= 1 )
111
+	public function tablenav($which = 'top') {
112
+		if ($this->get_pagination_arg('total_pages') <= 1)
113 113
 			return;
114 114
 		?>
115 115
 		<div class="tablenav themes <?php echo $which; ?>">
116
-			<?php $this->pagination( $which ); ?>
116
+			<?php $this->pagination($which); ?>
117 117
 			<span class="spinner"></span>
118 118
 			<br class="clear" />
119 119
 		</div>
@@ -124,15 +124,15 @@  discard block
 block discarded – undo
124 124
 	 * @access public
125 125
 	 */
126 126
 	public function display() {
127
-		wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
127
+		wp_nonce_field("fetch-list-".get_class($this), '_ajax_fetch_list_nonce');
128 128
 ?>
129
-		<?php $this->tablenav( 'top' ); ?>
129
+		<?php $this->tablenav('top'); ?>
130 130
 
131 131
 		<div id="availablethemes">
132 132
 			<?php $this->display_rows_or_placeholder(); ?>
133 133
 		</div>
134 134
 
135
-		<?php $this->tablenav( 'bottom' ); ?>
135
+		<?php $this->tablenav('bottom'); ?>
136 136
 <?php
137 137
 	}
138 138
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	 * @access public
149 149
 	 */
150 150
 	public function display_rows_or_placeholder() {
151
-		if ( $this->has_items() ) {
151
+		if ($this->has_items()) {
152 152
 			$this->display_rows();
153 153
 		} else {
154 154
 			echo '<div class="no-items">';
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 	public function display_rows() {
164 164
 		$themes = $this->items;
165 165
 
166
-		foreach ( $themes as $theme ):
166
+		foreach ($themes as $theme):
167 167
 			?><div class="available-theme"><?php
168 168
 
169 169
 			$template   = $theme->get_template();
@@ -172,64 +172,64 @@  discard block
 block discarded – undo
172 172
 			$version    = $theme->display('Version');
173 173
 			$author     = $theme->display('Author');
174 174
 
175
-			$activate_link = wp_nonce_url( "themes.php?action=activate&amp;template=" . urlencode( $template ) . "&amp;stylesheet=" . urlencode( $stylesheet ), 'switch-theme_' . $stylesheet );
175
+			$activate_link = wp_nonce_url("themes.php?action=activate&amp;template=".urlencode($template)."&amp;stylesheet=".urlencode($stylesheet), 'switch-theme_'.$stylesheet);
176 176
 
177 177
 			$actions = array();
178
-			$actions['activate'] = '<a href="' . $activate_link . '" class="activatelink" title="'
179
-				. esc_attr( sprintf( __( 'Activate &#8220;%s&#8221;' ), $title ) ) . '">' . __( 'Activate' ) . '</a>';
178
+			$actions['activate'] = '<a href="'.$activate_link.'" class="activatelink" title="'
179
+				. esc_attr(sprintf(__('Activate &#8220;%s&#8221;'), $title)).'">'.__('Activate').'</a>';
180 180
 
181
-			if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
182
-				$actions['preview'] .= '<a href="' . wp_customize_url( $stylesheet ) . '" class="load-customize hide-if-no-customize">'
183
-					. __( 'Live Preview' ) . '</a>';
181
+			if (current_user_can('edit_theme_options') && current_user_can('customize')) {
182
+				$actions['preview'] .= '<a href="'.wp_customize_url($stylesheet).'" class="load-customize hide-if-no-customize">'
183
+					. __('Live Preview').'</a>';
184 184
 			}
185 185
 
186
-			if ( ! is_multisite() && current_user_can( 'delete_themes' ) )
187
-				$actions['delete'] = '<a class="submitdelete deletion" href="' . wp_nonce_url( 'themes.php?action=delete&amp;stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet )
188
-					. '" onclick="' . "return confirm( '" . esc_js( sprintf( __( "You are about to delete this theme '%s'\n  'Cancel' to stop, 'OK' to delete." ), $title ) )
189
-					. "' );" . '">' . __( 'Delete' ) . '</a>';
186
+			if ( ! is_multisite() && current_user_can('delete_themes'))
187
+				$actions['delete'] = '<a class="submitdelete deletion" href="'.wp_nonce_url('themes.php?action=delete&amp;stylesheet='.urlencode($stylesheet), 'delete-theme_'.$stylesheet)
188
+					. '" onclick="'."return confirm( '".esc_js(sprintf(__("You are about to delete this theme '%s'\n  'Cancel' to stop, 'OK' to delete."), $title))
189
+					. "' );".'">'.__('Delete').'</a>';
190 190
 
191 191
 			/** This filter is documented in wp-admin/includes/class-wp-ms-themes-list-table.php */
192
-			$actions       = apply_filters( 'theme_action_links', $actions, $theme );
192
+			$actions       = apply_filters('theme_action_links', $actions, $theme);
193 193
 
194 194
 			/** This filter is documented in wp-admin/includes/class-wp-ms-themes-list-table.php */
195
-			$actions       = apply_filters( "theme_action_links_$stylesheet", $actions, $theme );
196
-			$delete_action = isset( $actions['delete'] ) ? '<div class="delete-theme">' . $actions['delete'] . '</div>' : '';
197
-			unset( $actions['delete'] );
195
+			$actions       = apply_filters("theme_action_links_$stylesheet", $actions, $theme);
196
+			$delete_action = isset($actions['delete']) ? '<div class="delete-theme">'.$actions['delete'].'</div>' : '';
197
+			unset($actions['delete']);
198 198
 
199 199
 			?>
200 200
 
201 201
 			<span class="screenshot hide-if-customize">
202
-				<?php if ( $screenshot = $theme->get_screenshot() ) : ?>
203
-					<img src="<?php echo esc_url( $screenshot ); ?>" alt="" />
202
+				<?php if ($screenshot = $theme->get_screenshot()) : ?>
203
+					<img src="<?php echo esc_url($screenshot); ?>" alt="" />
204 204
 				<?php endif; ?>
205 205
 			</span>
206
-			<a href="<?php echo wp_customize_url( $stylesheet ); ?>" class="screenshot load-customize hide-if-no-customize">
207
-				<?php if ( $screenshot = $theme->get_screenshot() ) : ?>
208
-					<img src="<?php echo esc_url( $screenshot ); ?>" alt="" />
206
+			<a href="<?php echo wp_customize_url($stylesheet); ?>" class="screenshot load-customize hide-if-no-customize">
207
+				<?php if ($screenshot = $theme->get_screenshot()) : ?>
208
+					<img src="<?php echo esc_url($screenshot); ?>" alt="" />
209 209
 				<?php endif; ?>
210 210
 			</a>
211 211
 
212 212
 			<h3><?php echo $title; ?></h3>
213
-			<div class="theme-author"><?php printf( __( 'By %s' ), $author ); ?></div>
213
+			<div class="theme-author"><?php printf(__('By %s'), $author); ?></div>
214 214
 			<div class="action-links">
215 215
 				<ul>
216
-					<?php foreach ( $actions as $action ): ?>
216
+					<?php foreach ($actions as $action): ?>
217 217
 						<li><?php echo $action; ?></li>
218 218
 					<?php endforeach; ?>
219 219
 					<li class="hide-if-no-js"><a href="#" class="theme-detail"><?php _e('Details') ?></a></li>
220 220
 				</ul>
221 221
 				<?php echo $delete_action; ?>
222 222
 
223
-				<?php theme_update_available( $theme ); ?>
223
+				<?php theme_update_available($theme); ?>
224 224
 			</div>
225 225
 
226 226
 			<div class="themedetaildiv hide-if-js">
227 227
 				<p><strong><?php _e('Version:'); ?></strong> <?php echo $version; ?></p>
228 228
 				<p><?php echo $theme->display('Description'); ?></p>
229
-				<?php if ( $theme->parent() ) {
230
-					printf( ' <p class="howto">' . __( 'This <a href="%1$s">child theme</a> requires its parent theme, %2$s.' ) . '</p>',
231
-						__( 'https://codex.wordpress.org/Child_Themes' ),
232
-						$theme->parent()->display( 'Name' ) );
229
+				<?php if ($theme->parent()) {
230
+					printf(' <p class="howto">'.__('This <a href="%1$s">child theme</a> requires its parent theme, %2$s.').'</p>',
231
+						__('https://codex.wordpress.org/Child_Themes'),
232
+						$theme->parent()->display('Name'));
233 233
 				} ?>
234 234
 			</div>
235 235
 
@@ -242,29 +242,29 @@  discard block
 block discarded – undo
242 242
 	 * @param WP_Theme $theme
243 243
 	 * @return bool
244 244
 	 */
245
-	public function search_theme( $theme ) {
245
+	public function search_theme($theme) {
246 246
 		// Search the features
247
-		foreach ( $this->features as $word ) {
248
-			if ( ! in_array( $word, $theme->get('Tags') ) )
247
+		foreach ($this->features as $word) {
248
+			if ( ! in_array($word, $theme->get('Tags')))
249 249
 				return false;
250 250
 		}
251 251
 
252 252
 		// Match all phrases
253
-		foreach ( $this->search_terms as $word ) {
254
-			if ( in_array( $word, $theme->get('Tags') ) )
253
+		foreach ($this->search_terms as $word) {
254
+			if (in_array($word, $theme->get('Tags')))
255 255
 				continue;
256 256
 
257
-			foreach ( array( 'Name', 'Description', 'Author', 'AuthorURI' ) as $header ) {
257
+			foreach (array('Name', 'Description', 'Author', 'AuthorURI') as $header) {
258 258
 				// Don't mark up; Do translate.
259
-				if ( false !== stripos( strip_tags( $theme->display( $header, false, true ) ), $word ) ) {
259
+				if (false !== stripos(strip_tags($theme->display($header, false, true)), $word)) {
260 260
 					continue 2;
261 261
 				}
262 262
 			}
263 263
 
264
-			if ( false !== stripos( $theme->get_stylesheet(), $word ) )
264
+			if (false !== stripos($theme->get_stylesheet(), $word))
265 265
 				continue;
266 266
 
267
-			if ( false !== stripos( $theme->get_template(), $word ) )
267
+			if (false !== stripos($theme->get_template(), $word))
268 268
 				continue;
269 269
 
270 270
 			return false;
@@ -281,20 +281,20 @@  discard block
 block discarded – undo
281 281
 	 *
282 282
 	 * @param array $extra_args
283 283
 	 */
284
-	public function _js_vars( $extra_args = array() ) {
285
-		$search_string = isset( $_REQUEST['s'] ) ? esc_attr( wp_unslash( $_REQUEST['s'] ) ) : '';
284
+	public function _js_vars($extra_args = array()) {
285
+		$search_string = isset($_REQUEST['s']) ? esc_attr(wp_unslash($_REQUEST['s'])) : '';
286 286
 
287 287
 		$args = array(
288 288
 			'search' => $search_string,
289 289
 			'features' => $this->features,
290 290
 			'paged' => $this->get_pagenum(),
291
-			'total_pages' => ! empty( $this->_pagination_args['total_pages'] ) ? $this->_pagination_args['total_pages'] : 1,
291
+			'total_pages' => ! empty($this->_pagination_args['total_pages']) ? $this->_pagination_args['total_pages'] : 1,
292 292
 		);
293 293
 
294
-		if ( is_array( $extra_args ) )
295
-			$args = array_merge( $args, $extra_args );
294
+		if (is_array($extra_args))
295
+			$args = array_merge($args, $extra_args);
296 296
 
297
-		printf( "<script type='text/javascript'>var theme_list_args = %s;</script>\n", wp_json_encode( $args ) );
297
+		printf("<script type='text/javascript'>var theme_list_args = %s;</script>\n", wp_json_encode($args));
298 298
 		parent::_js_vars();
299 299
 	}
300 300
 }
Please login to merge, or discard this patch.
Braces   +30 added lines, -20 removed lines patch added patch discarded remove patch
@@ -44,16 +44,19 @@  discard block
 block discarded – undo
44 44
 	public function prepare_items() {
45 45
 		$themes = wp_get_themes( array( 'allowed' => true ) );
46 46
 
47
-		if ( ! empty( $_REQUEST['s'] ) )
48
-			$this->search_terms = array_unique( array_filter( array_map( 'trim', explode( ',', strtolower( wp_unslash( $_REQUEST['s'] ) ) ) ) ) );
47
+		if ( ! empty( $_REQUEST['s'] ) ) {
48
+					$this->search_terms = array_unique( array_filter( array_map( 'trim', explode( ',', strtolower( wp_unslash( $_REQUEST['s'] ) ) ) ) ) );
49
+		}
49 50
 
50
-		if ( ! empty( $_REQUEST['features'] ) )
51
-			$this->features = $_REQUEST['features'];
51
+		if ( ! empty( $_REQUEST['features'] ) ) {
52
+					$this->features = $_REQUEST['features'];
53
+		}
52 54
 
53 55
 		if ( $this->search_terms || $this->features ) {
54 56
 			foreach ( $themes as $key => $theme ) {
55
-				if ( ! $this->search_theme( $theme ) )
56
-					unset( $themes[ $key ] );
57
+				if ( ! $this->search_theme( $theme ) ) {
58
+									unset( $themes[ $key ] );
59
+				}
57 60
 			}
58 61
 		}
59 62
 
@@ -109,8 +112,9 @@  discard block
 block discarded – undo
109 112
 	 * @param string $which
110 113
 	 */
111 114
 	public function tablenav( $which = 'top' ) {
112
-		if ( $this->get_pagination_arg( 'total_pages' ) <= 1 )
113
-			return;
115
+		if ( $this->get_pagination_arg( 'total_pages' ) <= 1 ) {
116
+					return;
117
+		}
114 118
 		?>
115 119
 		<div class="tablenav themes <?php echo $which; ?>">
116 120
 			<?php $this->pagination( $which ); ?>
@@ -183,10 +187,11 @@  discard block
 block discarded – undo
183 187
 					. __( 'Live Preview' ) . '</a>';
184 188
 			}
185 189
 
186
-			if ( ! is_multisite() && current_user_can( 'delete_themes' ) )
187
-				$actions['delete'] = '<a class="submitdelete deletion" href="' . wp_nonce_url( 'themes.php?action=delete&amp;stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet )
190
+			if ( ! is_multisite() && current_user_can( 'delete_themes' ) ) {
191
+							$actions['delete'] = '<a class="submitdelete deletion" href="' . wp_nonce_url( 'themes.php?action=delete&amp;stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet )
188 192
 					. '" onclick="' . "return confirm( '" . esc_js( sprintf( __( "You are about to delete this theme '%s'\n  'Cancel' to stop, 'OK' to delete." ), $title ) )
189 193
 					. "' );" . '">' . __( 'Delete' ) . '</a>';
194
+			}
190 195
 
191 196
 			/** This filter is documented in wp-admin/includes/class-wp-ms-themes-list-table.php */
192 197
 			$actions       = apply_filters( 'theme_action_links', $actions, $theme );
@@ -245,14 +250,16 @@  discard block
 block discarded – undo
245 250
 	public function search_theme( $theme ) {
246 251
 		// Search the features
247 252
 		foreach ( $this->features as $word ) {
248
-			if ( ! in_array( $word, $theme->get('Tags') ) )
249
-				return false;
253
+			if ( ! in_array( $word, $theme->get('Tags') ) ) {
254
+							return false;
255
+			}
250 256
 		}
251 257
 
252 258
 		// Match all phrases
253 259
 		foreach ( $this->search_terms as $word ) {
254
-			if ( in_array( $word, $theme->get('Tags') ) )
255
-				continue;
260
+			if ( in_array( $word, $theme->get('Tags') ) ) {
261
+							continue;
262
+			}
256 263
 
257 264
 			foreach ( array( 'Name', 'Description', 'Author', 'AuthorURI' ) as $header ) {
258 265
 				// Don't mark up; Do translate.
@@ -261,11 +268,13 @@  discard block
 block discarded – undo
261 268
 				}
262 269
 			}
263 270
 
264
-			if ( false !== stripos( $theme->get_stylesheet(), $word ) )
265
-				continue;
271
+			if ( false !== stripos( $theme->get_stylesheet(), $word ) ) {
272
+							continue;
273
+			}
266 274
 
267
-			if ( false !== stripos( $theme->get_template(), $word ) )
268
-				continue;
275
+			if ( false !== stripos( $theme->get_template(), $word ) ) {
276
+							continue;
277
+			}
269 278
 
270 279
 			return false;
271 280
 		}
@@ -291,8 +300,9 @@  discard block
 block discarded – undo
291 300
 			'total_pages' => ! empty( $this->_pagination_args['total_pages'] ) ? $this->_pagination_args['total_pages'] : 1,
292 301
 		);
293 302
 
294
-		if ( is_array( $extra_args ) )
295
-			$args = array_merge( $args, $extra_args );
303
+		if ( is_array( $extra_args ) ) {
304
+					$args = array_merge( $args, $extra_args );
305
+		}
296 306
 
297 307
 		printf( "<script type='text/javascript'>var theme_list_args = %s;</script>\n", wp_json_encode( $args ) );
298 308
 		parent::_js_vars();
Please login to merge, or discard this patch.
src/wp-admin/includes/import.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * WordPress Administration Importer API.
4
- *
5
- * @package WordPress
6
- * @subpackage Administration
7
- */
3
+	 * WordPress Administration Importer API.
4
+	 *
5
+	 * @package WordPress
6
+	 * @subpackage Administration
7
+	 */
8 8
 
9 9
 /**
10 10
  * Retrieve list of importers.
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
  */
17 17
 function get_importers() {
18 18
 	global $wp_importers;
19
-	if ( is_array( $wp_importers ) ) {
20
-		uasort( $wp_importers, '_usort_by_first_member' );
19
+	if (is_array($wp_importers)) {
20
+		uasort($wp_importers, '_usort_by_first_member');
21 21
 	}
22 22
 	return $wp_importers;
23 23
 }
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
  * @param array $b
35 35
  * @return int
36 36
  */
37
-function _usort_by_first_member( $a, $b ) {
38
-	return strnatcasecmp( $a[0], $b[0] );
37
+function _usort_by_first_member($a, $b) {
38
+	return strnatcasecmp($a[0], $b[0]);
39 39
 }
40 40
 
41 41
 /**
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
  * @param callback $callback    Callback to run.
52 52
  * @return WP_Error Returns WP_Error when $callback is WP_Error.
53 53
  */
54
-function register_importer( $id, $name, $description, $callback ) {
54
+function register_importer($id, $name, $description, $callback) {
55 55
 	global $wp_importers;
56
-	if ( is_wp_error( $callback ) )
56
+	if (is_wp_error($callback))
57 57
 		return $callback;
58
-	$wp_importers[$id] = array ( $name, $description, $callback );
58
+	$wp_importers[$id] = array($name, $description, $callback);
59 59
 }
60 60
 
61 61
 /**
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
  *
68 68
  * @param string $id Importer ID.
69 69
  */
70
-function wp_import_cleanup( $id ) {
71
-	wp_delete_attachment( $id );
70
+function wp_import_cleanup($id) {
71
+	wp_delete_attachment($id);
72 72
 }
73 73
 
74 74
 /**
@@ -79,23 +79,23 @@  discard block
 block discarded – undo
79 79
  * @return array Uploaded file's details on success, error message on failure
80 80
  */
81 81
 function wp_import_handle_upload() {
82
-	if ( ! isset( $_FILES['import'] ) ) {
82
+	if ( ! isset($_FILES['import'])) {
83 83
 		return array(
84
-			'error' => __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.' )
84
+			'error' => __('File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.')
85 85
 		);
86 86
 	}
87 87
 
88
-	$overrides = array( 'test_form' => false, 'test_type' => false );
88
+	$overrides = array('test_form' => false, 'test_type' => false);
89 89
 	$_FILES['import']['name'] .= '.txt';
90
-	$upload = wp_handle_upload( $_FILES['import'], $overrides );
90
+	$upload = wp_handle_upload($_FILES['import'], $overrides);
91 91
 
92
-	if ( isset( $upload['error'] ) ) {
92
+	if (isset($upload['error'])) {
93 93
 		return $upload;
94 94
 	}
95 95
 
96 96
 	// Construct the object array
97 97
 	$object = array(
98
-		'post_title' => basename( $upload['file'] ),
98
+		'post_title' => basename($upload['file']),
99 99
 		'post_content' => $upload['url'],
100 100
 		'post_mime_type' => $upload['type'],
101 101
 		'guid' => $upload['url'],
@@ -104,15 +104,15 @@  discard block
 block discarded – undo
104 104
 	);
105 105
 
106 106
 	// Save the data
107
-	$id = wp_insert_attachment( $object, $upload['file'] );
107
+	$id = wp_insert_attachment($object, $upload['file']);
108 108
 
109 109
 	/*
110 110
 	 * Schedule a cleanup for one day from now in case of failed
111 111
 	 * import or missing wp_import_cleanup() call.
112 112
 	 */
113
-	wp_schedule_single_event( time() + DAY_IN_SECONDS, 'importer_scheduled_cleanup', array( $id ) );
113
+	wp_schedule_single_event(time() + DAY_IN_SECONDS, 'importer_scheduled_cleanup', array($id));
114 114
 
115
-	return array( 'file' => $upload['file'], 'id' => $id );
115
+	return array('file' => $upload['file'], 'id' => $id);
116 116
 }
117 117
 
118 118
 /**
@@ -123,32 +123,32 @@  discard block
 block discarded – undo
123 123
  * @return array Importers with metadata for each.
124 124
  */
125 125
 function wp_get_popular_importers() {
126
-	include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version
126
+	include(ABSPATH.WPINC.'/version.php'); // include an unmodified $wp_version
127 127
 
128 128
 	$locale = get_locale();
129
-	$popular_importers = get_site_transient( 'popular_importers_' . $locale );
129
+	$popular_importers = get_site_transient('popular_importers_'.$locale);
130 130
 
131
-	if ( ! $popular_importers ) {
132
-		$url = add_query_arg( 'locale', get_locale(), 'http://api.wordpress.org/core/importers/1.1/' );
133
-		$options = array( 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url() );
134
-		$response = wp_remote_get( $url, $options );
135
-		$popular_importers = json_decode( wp_remote_retrieve_body( $response ), true );
131
+	if ( ! $popular_importers) {
132
+		$url = add_query_arg('locale', get_locale(), 'http://api.wordpress.org/core/importers/1.1/');
133
+		$options = array('user-agent' => 'WordPress/'.$wp_version.'; '.home_url());
134
+		$response = wp_remote_get($url, $options);
135
+		$popular_importers = json_decode(wp_remote_retrieve_body($response), true);
136 136
 
137
-		if ( is_array( $popular_importers ) )
138
-			set_site_transient( 'popular_importers_' . $locale, $popular_importers, 2 * DAY_IN_SECONDS );
137
+		if (is_array($popular_importers))
138
+			set_site_transient('popular_importers_'.$locale, $popular_importers, 2 * DAY_IN_SECONDS);
139 139
 		else
140 140
 			$popular_importers = false;
141 141
 	}
142 142
 
143
-	if ( is_array( $popular_importers ) ) {
143
+	if (is_array($popular_importers)) {
144 144
 		// If the data was received as translated, return it as-is.
145
-		if ( $popular_importers['translated'] )
145
+		if ($popular_importers['translated'])
146 146
 			return $popular_importers['importers'];
147 147
 
148
-		foreach ( $popular_importers['importers'] as &$importer ) {
149
-			$importer['description'] = translate( $importer['description'] );
150
-			if ( $importer['name'] != 'WordPress' )
151
-				$importer['name'] = translate( $importer['name'] );
148
+		foreach ($popular_importers['importers'] as &$importer) {
149
+			$importer['description'] = translate($importer['description']);
150
+			if ($importer['name'] != 'WordPress')
151
+				$importer['name'] = translate($importer['name']);
152 152
 		}
153 153
 		return $popular_importers['importers'];
154 154
 	}
@@ -156,50 +156,50 @@  discard block
 block discarded – undo
156 156
 	return array(
157 157
 		// slug => name, description, plugin slug, and register_importer() slug
158 158
 		'blogger' => array(
159
-			'name' => __( 'Blogger' ),
160
-			'description' => __( 'Install the Blogger importer to import posts, comments, and users from a Blogger blog.' ),
159
+			'name' => __('Blogger'),
160
+			'description' => __('Install the Blogger importer to import posts, comments, and users from a Blogger blog.'),
161 161
 			'plugin-slug' => 'blogger-importer',
162 162
 			'importer-id' => 'blogger',
163 163
 		),
164 164
 		'wpcat2tag' => array(
165
-			'name' => __( 'Categories and Tags Converter' ),
166
-			'description' => __( 'Install the category/tag converter to convert existing categories to tags or tags to categories, selectively.' ),
165
+			'name' => __('Categories and Tags Converter'),
166
+			'description' => __('Install the category/tag converter to convert existing categories to tags or tags to categories, selectively.'),
167 167
 			'plugin-slug' => 'wpcat2tag-importer',
168 168
 			'importer-id' => 'wp-cat2tag',
169 169
 		),
170 170
 		'livejournal' => array(
171
-			'name' => __( 'LiveJournal' ),
172
-			'description' => __( 'Install the LiveJournal importer to import posts from LiveJournal using their API.' ),
171
+			'name' => __('LiveJournal'),
172
+			'description' => __('Install the LiveJournal importer to import posts from LiveJournal using their API.'),
173 173
 			'plugin-slug' => 'livejournal-importer',
174 174
 			'importer-id' => 'livejournal',
175 175
 		),
176 176
 		'movabletype' => array(
177
-			'name' => __( 'Movable Type and TypePad' ),
178
-			'description' => __( 'Install the Movable Type importer to import posts and comments from a Movable Type or TypePad blog.' ),
177
+			'name' => __('Movable Type and TypePad'),
178
+			'description' => __('Install the Movable Type importer to import posts and comments from a Movable Type or TypePad blog.'),
179 179
 			'plugin-slug' => 'movabletype-importer',
180 180
 			'importer-id' => 'mt',
181 181
 		),
182 182
 		'opml' => array(
183
-			'name' => __( 'Blogroll' ),
184
-			'description' => __( 'Install the blogroll importer to import links in OPML format.' ),
183
+			'name' => __('Blogroll'),
184
+			'description' => __('Install the blogroll importer to import links in OPML format.'),
185 185
 			'plugin-slug' => 'opml-importer',
186 186
 			'importer-id' => 'opml',
187 187
 		),
188 188
 		'rss' => array(
189
-			'name' => __( 'RSS' ),
190
-			'description' => __( 'Install the RSS importer to import posts from an RSS feed.' ),
189
+			'name' => __('RSS'),
190
+			'description' => __('Install the RSS importer to import posts from an RSS feed.'),
191 191
 			'plugin-slug' => 'rss-importer',
192 192
 			'importer-id' => 'rss',
193 193
 		),
194 194
 		'tumblr' => array(
195
-			'name' => __( 'Tumblr' ),
196
-			'description' => __( 'Install the Tumblr importer to import posts &amp; media from Tumblr using their API.' ),
195
+			'name' => __('Tumblr'),
196
+			'description' => __('Install the Tumblr importer to import posts &amp; media from Tumblr using their API.'),
197 197
 			'plugin-slug' => 'tumblr-importer',
198 198
 			'importer-id' => 'tumblr',
199 199
 		),
200 200
 		'wordpress' => array(
201 201
 			'name' => 'WordPress',
202
-			'description' => __( 'Install the WordPress importer to import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.' ),
202
+			'description' => __('Install the WordPress importer to import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.'),
203 203
 			'plugin-slug' => 'wordpress-importer',
204 204
 			'importer-id' => 'wordpress',
205 205
 		),
Please login to merge, or discard this patch.
Braces   +14 added lines, -10 removed lines patch added patch discarded remove patch
@@ -53,8 +53,9 @@  discard block
 block discarded – undo
53 53
  */
54 54
 function register_importer( $id, $name, $description, $callback ) {
55 55
 	global $wp_importers;
56
-	if ( is_wp_error( $callback ) )
57
-		return $callback;
56
+	if ( is_wp_error( $callback ) ) {
57
+			return $callback;
58
+	}
58 59
 	$wp_importers[$id] = array ( $name, $description, $callback );
59 60
 }
60 61
 
@@ -134,21 +135,24 @@  discard block
 block discarded – undo
134 135
 		$response = wp_remote_get( $url, $options );
135 136
 		$popular_importers = json_decode( wp_remote_retrieve_body( $response ), true );
136 137
 
137
-		if ( is_array( $popular_importers ) )
138
-			set_site_transient( 'popular_importers_' . $locale, $popular_importers, 2 * DAY_IN_SECONDS );
139
-		else
140
-			$popular_importers = false;
138
+		if ( is_array( $popular_importers ) ) {
139
+					set_site_transient( 'popular_importers_' . $locale, $popular_importers, 2 * DAY_IN_SECONDS );
140
+		} else {
141
+					$popular_importers = false;
142
+		}
141 143
 	}
142 144
 
143 145
 	if ( is_array( $popular_importers ) ) {
144 146
 		// If the data was received as translated, return it as-is.
145
-		if ( $popular_importers['translated'] )
146
-			return $popular_importers['importers'];
147
+		if ( $popular_importers['translated'] ) {
148
+					return $popular_importers['importers'];
149
+		}
147 150
 
148 151
 		foreach ( $popular_importers['importers'] as &$importer ) {
149 152
 			$importer['description'] = translate( $importer['description'] );
150
-			if ( $importer['name'] != 'WordPress' )
151
-				$importer['name'] = translate( $importer['name'] );
153
+			if ( $importer['name'] != 'WordPress' ) {
154
+							$importer['name'] = translate( $importer['name'] );
155
+			}
152 156
 		}
153 157
 		return $popular_importers['importers'];
154 158
 	}
Please login to merge, or discard this patch.