Completed
Push — master ( cde0c6...d99bf9 )
by Stephen
15:46
created
src/wp-admin/includes/bookmark.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@
 block discarded – undo
82 82
  * @global wpdb $wpdb WordPress database abstraction object.
83 83
  *
84 84
  * @param int $link_id ID of the link to delete
85
- * @return true Always true.
85
+ * @return boolean Always true.
86 86
  */
87 87
 function wp_delete_link( $link_id ) {
88 88
 	global $wpdb;
Please login to merge, or discard this patch.
Braces   +24 added lines, -18 removed lines patch added patch discarded remove patch
@@ -39,8 +39,9 @@  discard block
 block discarded – undo
39 39
 	$_POST['link_name'] = esc_html( $_POST['link_name'] );
40 40
 	$_POST['link_image'] = esc_html( $_POST['link_image'] );
41 41
 	$_POST['link_rss'] = esc_url($_POST['link_rss']);
42
-	if ( !isset($_POST['link_visible']) || 'N' != $_POST['link_visible'] )
43
-		$_POST['link_visible'] = 'Y';
42
+	if ( !isset($_POST['link_visible']) || 'N' != $_POST['link_visible'] ) {
43
+			$_POST['link_visible'] = 'Y';
44
+	}
44 45
 
45 46
 	if ( !empty( $link_id ) ) {
46 47
 		$_POST['link_id'] = $link_id;
@@ -59,15 +60,17 @@  discard block
 block discarded – undo
59 60
  */
60 61
 function get_default_link_to_edit() {
61 62
 	$link = new stdClass;
62
-	if ( isset( $_GET['linkurl'] ) )
63
-		$link->link_url = esc_url( wp_unslash( $_GET['linkurl'] ) );
64
-	else
65
-		$link->link_url = '';
63
+	if ( isset( $_GET['linkurl'] ) ) {
64
+			$link->link_url = esc_url( wp_unslash( $_GET['linkurl'] ) );
65
+	} else {
66
+			$link->link_url = '';
67
+	}
66 68
 
67
-	if ( isset( $_GET['name'] ) )
68
-		$link->link_name = esc_attr( wp_unslash( $_GET['name'] ) );
69
-	else
70
-		$link->link_name = '';
69
+	if ( isset( $_GET['name'] ) ) {
70
+			$link->link_name = esc_attr( wp_unslash( $_GET['name'] ) );
71
+	} else {
72
+			$link->link_name = '';
73
+	}
71 74
 
72 75
 	$link->link_visible = 'Y';
73 76
 
@@ -249,8 +252,9 @@  discard block
 block discarded – undo
249 252
  */
250 253
 function wp_set_link_cats( $link_id = 0, $link_categories = array() ) {
251 254
 	// If $link_categories isn't already an array, make it one:
252
-	if ( !is_array( $link_categories ) || 0 == count( $link_categories ) )
253
-		$link_categories = array( get_option( 'default_link_category' ) );
255
+	if ( !is_array( $link_categories ) || 0 == count( $link_categories ) ) {
256
+			$link_categories = array( get_option( 'default_link_category' ) );
257
+	}
254 258
 
255 259
 	$link_categories = array_map( 'intval', $link_categories );
256 260
 	$link_categories = array_unique( $link_categories );
@@ -278,10 +282,11 @@  discard block
 block discarded – undo
278 282
 
279 283
 	// Passed link category list overwrites existing category list if not empty.
280 284
 	if ( isset( $linkdata['link_category'] ) && is_array( $linkdata['link_category'] )
281
-			 && 0 != count( $linkdata['link_category'] ) )
282
-		$link_cats = $linkdata['link_category'];
283
-	else
284
-		$link_cats = $link['link_category'];
285
+			 && 0 != count( $linkdata['link_category'] ) ) {
286
+			$link_cats = $linkdata['link_category'];
287
+	} else {
288
+			$link_cats = $link['link_category'];
289
+	}
285 290
 
286 291
 	// Merge old and new fields with new fields overwriting old ones.
287 292
 	$linkdata = array_merge( $link, $linkdata );
@@ -300,8 +305,9 @@  discard block
 block discarded – undo
300 305
  */
301 306
 function wp_link_manager_disabled_message() {
302 307
 	global $pagenow;
303
-	if ( 'link-manager.php' != $pagenow && 'link-add.php' != $pagenow && 'link.php' != $pagenow )
304
-		return;
308
+	if ( 'link-manager.php' != $pagenow && 'link-add.php' != $pagenow && 'link.php' != $pagenow ) {
309
+			return;
310
+	}
305 311
 
306 312
 	add_filter( 'pre_option_link_manager_enabled', '__return_true', 100 );
307 313
 	$really_can_manage_links = current_user_can( 'manage_links' );
Please login to merge, or discard this patch.
Spacing   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -25,28 +25,28 @@  discard block
 block discarded – undo
25 25
  * @param int $link_id Optional. ID of the link to edit. Default 0.
26 26
  * @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success.
27 27
  */
28
-function edit_link( $link_id = 0 ) {
29
-	if ( ! current_user_can( 'manage_links' ) ) {
28
+function edit_link($link_id = 0) {
29
+	if ( ! current_user_can('manage_links')) {
30 30
 		wp_die(
31
-			'<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
32
-			'<p>' . __( 'Sorry, you are not allowed to edit the links for this site.' ) . '</p>',
31
+			'<h1>'.__('Cheatin&#8217; uh?').'</h1>'.
32
+			'<p>'.__('Sorry, you are not allowed to edit the links for this site.').'</p>',
33 33
 			403
34 34
 		);
35 35
 	}
36 36
 
37
-	$_POST['link_url'] = esc_html( $_POST['link_url'] );
37
+	$_POST['link_url'] = esc_html($_POST['link_url']);
38 38
 	$_POST['link_url'] = esc_url($_POST['link_url']);
39
-	$_POST['link_name'] = esc_html( $_POST['link_name'] );
40
-	$_POST['link_image'] = esc_html( $_POST['link_image'] );
39
+	$_POST['link_name'] = esc_html($_POST['link_name']);
40
+	$_POST['link_image'] = esc_html($_POST['link_image']);
41 41
 	$_POST['link_rss'] = esc_url($_POST['link_rss']);
42
-	if ( !isset($_POST['link_visible']) || 'N' != $_POST['link_visible'] )
42
+	if ( ! isset($_POST['link_visible']) || 'N' != $_POST['link_visible'])
43 43
 		$_POST['link_visible'] = 'Y';
44 44
 
45
-	if ( !empty( $link_id ) ) {
45
+	if ( ! empty($link_id)) {
46 46
 		$_POST['link_id'] = $link_id;
47
-		return wp_update_link( $_POST );
47
+		return wp_update_link($_POST);
48 48
 	} else {
49
-		return wp_insert_link( $_POST );
49
+		return wp_insert_link($_POST);
50 50
 	}
51 51
 }
52 52
 
@@ -59,13 +59,13 @@  discard block
 block discarded – undo
59 59
  */
60 60
 function get_default_link_to_edit() {
61 61
 	$link = new stdClass;
62
-	if ( isset( $_GET['linkurl'] ) )
63
-		$link->link_url = esc_url( wp_unslash( $_GET['linkurl'] ) );
62
+	if (isset($_GET['linkurl']))
63
+		$link->link_url = esc_url(wp_unslash($_GET['linkurl']));
64 64
 	else
65 65
 		$link->link_url = '';
66 66
 
67
-	if ( isset( $_GET['name'] ) )
68
-		$link->link_name = esc_attr( wp_unslash( $_GET['name'] ) );
67
+	if (isset($_GET['name']))
68
+		$link->link_name = esc_attr(wp_unslash($_GET['name']));
69 69
 	else
70 70
 		$link->link_name = '';
71 71
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
  * @param int $link_id ID of the link to delete
85 85
  * @return true Always true.
86 86
  */
87
-function wp_delete_link( $link_id ) {
87
+function wp_delete_link($link_id) {
88 88
 	global $wpdb;
89 89
 	/**
90 90
 	 * Fires before a link is deleted.
@@ -93,11 +93,11 @@  discard block
 block discarded – undo
93 93
 	 *
94 94
 	 * @param int $link_id ID of the link to delete.
95 95
 	 */
96
-	do_action( 'delete_link', $link_id );
96
+	do_action('delete_link', $link_id);
97 97
 
98
-	wp_delete_object_term_relationships( $link_id, 'link_category' );
98
+	wp_delete_object_term_relationships($link_id, 'link_category');
99 99
 
100
-	$wpdb->delete( $wpdb->links, array( 'link_id' => $link_id ) );
100
+	$wpdb->delete($wpdb->links, array('link_id' => $link_id));
101 101
 
102 102
 	/**
103 103
 	 * Fires after a link has been deleted.
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
 	 *
107 107
 	 * @param int $link_id ID of the deleted link.
108 108
 	 */
109
-	do_action( 'deleted_link', $link_id );
109
+	do_action('deleted_link', $link_id);
110 110
 
111
-	clean_bookmark_cache( $link_id );
111
+	clean_bookmark_cache($link_id);
112 112
 
113 113
 	return true;
114 114
 }
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
  * @param int $link_id Link ID to look up
122 122
  * @return array The requested link's categories
123 123
  */
124
-function wp_get_link_cats( $link_id = 0 ) {
125
-	$cats = wp_get_object_terms( $link_id, 'link_category', array('fields' => 'ids') );
126
-	return array_unique( $cats );
124
+function wp_get_link_cats($link_id = 0) {
125
+	$cats = wp_get_object_terms($link_id, 'link_category', array('fields' => 'ids'));
126
+	return array_unique($cats);
127 127
 }
128 128
 
129 129
 /**
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
  * @param int|stdClass $link Link ID or object to retrieve.
135 135
  * @return object Link object for editing.
136 136
  */
137
-function get_link_to_edit( $link ) {
138
-	return get_bookmark( $link, OBJECT, 'edit' );
137
+function get_link_to_edit($link) {
138
+	return get_bookmark($link, OBJECT, 'edit');
139 139
 }
140 140
 
141 141
 /**
@@ -149,63 +149,63 @@  discard block
 block discarded – undo
149 149
  * @param bool  $wp_error Optional. Whether to return a WP_Error object on failure. Default false.
150 150
  * @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success.
151 151
  */
152
-function wp_insert_link( $linkdata, $wp_error = false ) {
152
+function wp_insert_link($linkdata, $wp_error = false) {
153 153
 	global $wpdb;
154 154
 
155
-	$defaults = array( 'link_id' => 0, 'link_name' => '', 'link_url' => '', 'link_rating' => 0 );
155
+	$defaults = array('link_id' => 0, 'link_name' => '', 'link_url' => '', 'link_rating' => 0);
156 156
 
157
-	$args = wp_parse_args( $linkdata, $defaults );
158
-	$r = wp_unslash( sanitize_bookmark( $args, 'db' ) );
157
+	$args = wp_parse_args($linkdata, $defaults);
158
+	$r = wp_unslash(sanitize_bookmark($args, 'db'));
159 159
 
160 160
 	$link_id   = $r['link_id'];
161 161
 	$link_name = $r['link_name'];
162 162
 	$link_url  = $r['link_url'];
163 163
 
164 164
 	$update = false;
165
-	if ( ! empty( $link_id ) ) {
165
+	if ( ! empty($link_id)) {
166 166
 		$update = true;
167 167
 	}
168 168
 
169
-	if ( trim( $link_name ) == '' ) {
170
-		if ( trim( $link_url ) != '' ) {
169
+	if (trim($link_name) == '') {
170
+		if (trim($link_url) != '') {
171 171
 			$link_name = $link_url;
172 172
 		} else {
173 173
 			return 0;
174 174
 		}
175 175
 	}
176 176
 
177
-	if ( trim( $link_url ) == '' ) {
177
+	if (trim($link_url) == '') {
178 178
 		return 0;
179 179
 	}
180 180
 
181
-	$link_rating      = ( ! empty( $r['link_rating'] ) ) ? $r['link_rating'] : 0;
182
-	$link_image       = ( ! empty( $r['link_image'] ) ) ? $r['link_image'] : '';
183
-	$link_target      = ( ! empty( $r['link_target'] ) ) ? $r['link_target'] : '';
184
-	$link_visible     = ( ! empty( $r['link_visible'] ) ) ? $r['link_visible'] : 'Y';
185
-	$link_owner       = ( ! empty( $r['link_owner'] ) ) ? $r['link_owner'] : get_current_user_id();
186
-	$link_notes       = ( ! empty( $r['link_notes'] ) ) ? $r['link_notes'] : '';
187
-	$link_description = ( ! empty( $r['link_description'] ) ) ? $r['link_description'] : '';
188
-	$link_rss         = ( ! empty( $r['link_rss'] ) ) ? $r['link_rss'] : '';
189
-	$link_rel         = ( ! empty( $r['link_rel'] ) ) ? $r['link_rel'] : '';
190
-	$link_category    = ( ! empty( $r['link_category'] ) ) ? $r['link_category'] : array();
181
+	$link_rating      = ( ! empty($r['link_rating'])) ? $r['link_rating'] : 0;
182
+	$link_image       = ( ! empty($r['link_image'])) ? $r['link_image'] : '';
183
+	$link_target      = ( ! empty($r['link_target'])) ? $r['link_target'] : '';
184
+	$link_visible     = ( ! empty($r['link_visible'])) ? $r['link_visible'] : 'Y';
185
+	$link_owner       = ( ! empty($r['link_owner'])) ? $r['link_owner'] : get_current_user_id();
186
+	$link_notes       = ( ! empty($r['link_notes'])) ? $r['link_notes'] : '';
187
+	$link_description = ( ! empty($r['link_description'])) ? $r['link_description'] : '';
188
+	$link_rss         = ( ! empty($r['link_rss'])) ? $r['link_rss'] : '';
189
+	$link_rel         = ( ! empty($r['link_rel'])) ? $r['link_rel'] : '';
190
+	$link_category    = ( ! empty($r['link_category'])) ? $r['link_category'] : array();
191 191
 
192 192
 	// Make sure we set a valid category.
193
-	if ( ! is_array( $link_category ) || 0 == count( $link_category ) ) {
194
-		$link_category = array( get_option( 'default_link_category' ) );
193
+	if ( ! is_array($link_category) || 0 == count($link_category)) {
194
+		$link_category = array(get_option('default_link_category'));
195 195
 	}
196 196
 
197
-	if ( $update ) {
198
-		if ( false === $wpdb->update( $wpdb->links, compact( 'link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_rating', 'link_rel', 'link_notes', 'link_rss' ), compact( 'link_id' ) ) ) {
199
-			if ( $wp_error ) {
200
-				return new WP_Error( 'db_update_error', __( 'Could not update link in the database' ), $wpdb->last_error );
197
+	if ($update) {
198
+		if (false === $wpdb->update($wpdb->links, compact('link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_rating', 'link_rel', 'link_notes', 'link_rss'), compact('link_id'))) {
199
+			if ($wp_error) {
200
+				return new WP_Error('db_update_error', __('Could not update link in the database'), $wpdb->last_error);
201 201
 			} else {
202 202
 				return 0;
203 203
 			}
204 204
 		}
205 205
 	} else {
206
-		if ( false === $wpdb->insert( $wpdb->links, compact( 'link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_rel', 'link_notes', 'link_rss' ) ) ) {
207
-			if ( $wp_error ) {
208
-				return new WP_Error( 'db_insert_error', __( 'Could not insert link into the database' ), $wpdb->last_error );
206
+		if (false === $wpdb->insert($wpdb->links, compact('link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_rel', 'link_notes', 'link_rss'))) {
207
+			if ($wp_error) {
208
+				return new WP_Error('db_insert_error', __('Could not insert link into the database'), $wpdb->last_error);
209 209
 			} else {
210 210
 				return 0;
211 211
 			}
@@ -213,9 +213,9 @@  discard block
 block discarded – undo
213 213
 		$link_id = (int) $wpdb->insert_id;
214 214
 	}
215 215
 
216
-	wp_set_link_cats( $link_id, $link_category );
216
+	wp_set_link_cats($link_id, $link_category);
217 217
 
218
-	if ( $update ) {
218
+	if ($update) {
219 219
 		/**
220 220
 		 * Fires after a link was updated in the database.
221 221
 		 *
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 		 *
224 224
 		 * @param int $link_id ID of the link that was updated.
225 225
 		 */
226
-		do_action( 'edit_link', $link_id );
226
+		do_action('edit_link', $link_id);
227 227
 	} else {
228 228
 		/**
229 229
 		 * Fires after a link was added to the database.
@@ -232,9 +232,9 @@  discard block
 block discarded – undo
232 232
 		 *
233 233
 		 * @param int $link_id ID of the link that was added.
234 234
 		 */
235
-		do_action( 'add_link', $link_id );
235
+		do_action('add_link', $link_id);
236 236
 	}
237
-	clean_bookmark_cache( $link_id );
237
+	clean_bookmark_cache($link_id);
238 238
 
239 239
 	return $link_id;
240 240
 }
@@ -247,17 +247,17 @@  discard block
 block discarded – undo
247 247
  * @param int   $link_id         ID of the link to update.
248 248
  * @param array $link_categories Array of link categories to add the link to.
249 249
  */
250
-function wp_set_link_cats( $link_id = 0, $link_categories = array() ) {
250
+function wp_set_link_cats($link_id = 0, $link_categories = array()) {
251 251
 	// If $link_categories isn't already an array, make it one:
252
-	if ( !is_array( $link_categories ) || 0 == count( $link_categories ) )
253
-		$link_categories = array( get_option( 'default_link_category' ) );
252
+	if ( ! is_array($link_categories) || 0 == count($link_categories))
253
+		$link_categories = array(get_option('default_link_category'));
254 254
 
255
-	$link_categories = array_map( 'intval', $link_categories );
256
-	$link_categories = array_unique( $link_categories );
255
+	$link_categories = array_map('intval', $link_categories);
256
+	$link_categories = array_unique($link_categories);
257 257
 
258
-	wp_set_object_terms( $link_id, $link_categories, 'link_category' );
258
+	wp_set_object_terms($link_id, $link_categories, 'link_category');
259 259
 
260
-	clean_bookmark_cache( $link_id );
260
+	clean_bookmark_cache($link_id);
261 261
 }
262 262
 
263 263
 /**
@@ -268,26 +268,26 @@  discard block
 block discarded – undo
268 268
  * @param array $linkdata Link data to update.
269 269
  * @return int|WP_Error Value 0 or WP_Error on failure. The updated link ID on success.
270 270
  */
271
-function wp_update_link( $linkdata ) {
271
+function wp_update_link($linkdata) {
272 272
 	$link_id = (int) $linkdata['link_id'];
273 273
 
274
-	$link = get_bookmark( $link_id, ARRAY_A );
274
+	$link = get_bookmark($link_id, ARRAY_A);
275 275
 
276 276
 	// Escape data pulled from DB.
277
-	$link = wp_slash( $link );
277
+	$link = wp_slash($link);
278 278
 
279 279
 	// Passed link category list overwrites existing category list if not empty.
280
-	if ( isset( $linkdata['link_category'] ) && is_array( $linkdata['link_category'] )
281
-			 && 0 != count( $linkdata['link_category'] ) )
280
+	if (isset($linkdata['link_category']) && is_array($linkdata['link_category'])
281
+			 && 0 != count($linkdata['link_category']))
282 282
 		$link_cats = $linkdata['link_category'];
283 283
 	else
284 284
 		$link_cats = $link['link_category'];
285 285
 
286 286
 	// Merge old and new fields with new fields overwriting old ones.
287
-	$linkdata = array_merge( $link, $linkdata );
287
+	$linkdata = array_merge($link, $linkdata);
288 288
 	$linkdata['link_category'] = $link_cats;
289 289
 
290
-	return wp_insert_link( $linkdata );
290
+	return wp_insert_link($linkdata);
291 291
 }
292 292
 
293 293
 /**
@@ -300,17 +300,17 @@  discard block
 block discarded – undo
300 300
  */
301 301
 function wp_link_manager_disabled_message() {
302 302
 	global $pagenow;
303
-	if ( 'link-manager.php' != $pagenow && 'link-add.php' != $pagenow && 'link.php' != $pagenow )
303
+	if ('link-manager.php' != $pagenow && 'link-add.php' != $pagenow && 'link.php' != $pagenow)
304 304
 		return;
305 305
 
306
-	add_filter( 'pre_option_link_manager_enabled', '__return_true', 100 );
307
-	$really_can_manage_links = current_user_can( 'manage_links' );
308
-	remove_filter( 'pre_option_link_manager_enabled', '__return_true', 100 );
306
+	add_filter('pre_option_link_manager_enabled', '__return_true', 100);
307
+	$really_can_manage_links = current_user_can('manage_links');
308
+	remove_filter('pre_option_link_manager_enabled', '__return_true', 100);
309 309
 
310
-	if ( $really_can_manage_links && current_user_can( 'install_plugins' ) ) {
311
-		$link = network_admin_url( 'plugin-install.php?tab=search&amp;s=Link+Manager' );
312
-		wp_die( sprintf( __( 'If you are looking to use the link manager, please install the <a href="%s">Link Manager</a> plugin.' ), $link ) );
310
+	if ($really_can_manage_links && current_user_can('install_plugins')) {
311
+		$link = network_admin_url('plugin-install.php?tab=search&amp;s=Link+Manager');
312
+		wp_die(sprintf(__('If you are looking to use the link manager, please install the <a href="%s">Link Manager</a> plugin.'), $link));
313 313
 	}
314 314
 
315
-	wp_die( __( 'Sorry, you are not allowed to edit the links for this site.' ) );
315
+	wp_die(__('Sorry, you are not allowed to edit the links for this site.'));
316 316
 }
Please login to merge, or discard this patch.
src/wp-admin/includes/class-wp-posts-list-table.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 
485 485
 	/**
486 486
 	 *
487
-	 * @return array
487
+	 * @return string[]
488 488
 	 */
489 489
 	protected function get_table_classes() {
490 490
 		return array( 'widefat', 'fixed', 'striped', is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts' );
@@ -1162,7 +1162,7 @@  discard block
 block discarded – undo
1162 1162
 	 * @since 4.3.0
1163 1163
 	 * @access protected
1164 1164
 	 *
1165
-	 * @param object $post        Post being acted upon.
1165
+	 * @param WP_Post $post        Post being acted upon.
1166 1166
 	 * @param string $column_name Current column name.
1167 1167
 	 * @param string $primary     Primary column name.
1168 1168
 	 * @return string Row actions output for posts.
Please login to merge, or discard this patch.
Braces   +91 added lines, -59 removed lines patch added patch discarded remove patch
@@ -199,10 +199,11 @@  discard block
 block discarded – undo
199 199
 	 * @access public
200 200
 	 */
201 201
 	public function no_items() {
202
-		if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] )
203
-			echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash;
204
-		else
205
-			echo get_post_type_object( $this->screen->post_type )->labels->not_found;
202
+		if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) {
203
+					echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash;
204
+		} else {
205
+					echo get_post_type_object( $this->screen->post_type )->labels->not_found;
206
+		}
206 207
 	}
207 208
 
208 209
 	/**
@@ -266,8 +267,9 @@  discard block
 block discarded – undo
266 267
 
267 268
 		$post_type = $this->screen->post_type;
268 269
 
269
-		if ( !empty($locked_post_status) )
270
-			return array();
270
+		if ( !empty($locked_post_status) ) {
271
+					return array();
272
+		}
271 273
 
272 274
 		$status_links = array();
273 275
 		$num_posts = wp_count_posts( $post_type, 'readable' );
@@ -476,8 +478,9 @@  discard block
 block discarded – undo
476 478
 	 * @return string
477 479
 	 */
478 480
 	public function current_action() {
479
-		if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
480
-			return 'delete_all';
481
+		if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) {
482
+					return 'delete_all';
483
+		}
481 484
 
482 485
 		return parent::current_action();
483 486
 	}
@@ -526,19 +529,21 @@  discard block
 block discarded – undo
526 529
 		$taxonomies = array_filter( $taxonomies, 'taxonomy_exists' );
527 530
 
528 531
 		foreach ( $taxonomies as $taxonomy ) {
529
-			if ( 'category' === $taxonomy )
530
-				$column_key = 'categories';
531
-			elseif ( 'post_tag' === $taxonomy )
532
-				$column_key = 'tags';
533
-			else
534
-				$column_key = 'taxonomy-' . $taxonomy;
532
+			if ( 'category' === $taxonomy ) {
533
+							$column_key = 'categories';
534
+			} elseif ( 'post_tag' === $taxonomy ) {
535
+							$column_key = 'tags';
536
+			} else {
537
+							$column_key = 'taxonomy-' . $taxonomy;
538
+			}
535 539
 
536 540
 			$posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name;
537 541
 		}
538 542
 
539 543
 		$post_status = !empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all';
540
-		if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) )
541
-			$posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>';
544
+		if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) ) {
545
+					$posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>';
546
+		}
542 547
 
543 548
 		$posts_columns['date'] = __( 'Date' );
544 549
 
@@ -599,8 +604,9 @@  discard block
 block discarded – undo
599 604
 	public function display_rows( $posts = array(), $level = 0 ) {
600 605
 		global $wp_query, $per_page;
601 606
 
602
-		if ( empty( $posts ) )
603
-			$posts = $wp_query->posts;
607
+		if ( empty( $posts ) ) {
608
+					$posts = $wp_query->posts;
609
+		}
604 610
 
605 611
 		add_filter( 'the_title', 'esc_html' );
606 612
 
@@ -619,13 +625,15 @@  discard block
 block discarded – undo
619 625
 		// Create array of post IDs.
620 626
 		$post_ids = array();
621 627
 
622
-		foreach ( $posts as $a_post )
623
-			$post_ids[] = $a_post->ID;
628
+		foreach ( $posts as $a_post ) {
629
+					$post_ids[] = $a_post->ID;
630
+		}
624 631
 
625 632
 		$this->comment_pending_count = get_pending_comments_num( $post_ids );
626 633
 
627
-		foreach ( $posts as $post )
628
-			$this->single_row( $post, $level );
634
+		foreach ( $posts as $post ) {
635
+					$this->single_row( $post, $level );
636
+		}
629 637
 	}
630 638
 
631 639
 	/**
@@ -643,8 +651,9 @@  discard block
 block discarded – undo
643 651
 		if ( ! $pages ) {
644 652
 			$pages = get_pages( array( 'sort_column' => 'menu_order' ) );
645 653
 
646
-			if ( ! $pages )
647
-				return;
654
+			if ( ! $pages ) {
655
+							return;
656
+			}
648 657
 		}
649 658
 
650 659
 		/*
@@ -668,10 +677,11 @@  discard block
 block discarded – undo
668 677
 					clean_post_cache( $page );
669 678
 				}
670 679
 
671
-				if ( 0 == $page->post_parent )
672
-					$top_level_pages[] = $page;
673
-				else
674
-					$children_pages[ $page->post_parent ][] = $page;
680
+				if ( 0 == $page->post_parent ) {
681
+									$top_level_pages[] = $page;
682
+				} else {
683
+									$children_pages[ $page->post_parent ][] = $page;
684
+				}
675 685
 			}
676 686
 
677 687
 			$pages = &$top_level_pages;
@@ -683,8 +693,9 @@  discard block
 block discarded – undo
683 693
 		$to_display = array();
684 694
 
685 695
 		foreach ( $pages as $page ) {
686
-			if ( $count >= $end )
687
-				break;
696
+			if ( $count >= $end ) {
697
+							break;
698
+			}
688 699
 
689 700
 			if ( $count >= $start ) {
690 701
 				$to_display[$page->ID] = $level;
@@ -692,16 +703,18 @@  discard block
 block discarded – undo
692 703
 
693 704
 			$count++;
694 705
 
695
-			if ( isset( $children_pages ) )
696
-				$this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display );
706
+			if ( isset( $children_pages ) ) {
707
+							$this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display );
708
+			}
697 709
 		}
698 710
 
699 711
 		// If it is the last pagenum and there are orphaned pages, display them with paging as well.
700 712
 		if ( isset( $children_pages ) && $count < $end ){
701 713
 			foreach ( $children_pages as $orphans ){
702 714
 				foreach ( $orphans as $op ) {
703
-					if ( $count >= $end )
704
-						break;
715
+					if ( $count >= $end ) {
716
+											break;
717
+					}
705 718
 
706 719
 					if ( $count >= $start ) {
707 720
 						$to_display[$op->ID] = 0;
@@ -741,15 +754,17 @@  discard block
 block discarded – undo
741 754
 	 * @param array $to_display List of pages to be displayed. Passed by reference.
742 755
 	 */
743 756
 	private function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page, &$to_display ) {
744
-		if ( ! isset( $children_pages[$parent] ) )
745
-			return;
757
+		if ( ! isset( $children_pages[$parent] ) ) {
758
+					return;
759
+		}
746 760
 
747 761
 		$start = ( $pagenum - 1 ) * $per_page;
748 762
 		$end = $start + $per_page;
749 763
 
750 764
 		foreach ( $children_pages[$parent] as $page ) {
751
-			if ( $count >= $end )
752
-				break;
765
+			if ( $count >= $end ) {
766
+							break;
767
+			}
753 768
 
754 769
 			// If the page starts in a subtree, print the parents.
755 770
 			if ( $count == $start && $page->post_parent > 0 ) {
@@ -764,8 +779,9 @@  discard block
 block discarded – undo
764 779
 
765 780
 					$my_parent = get_post( $parent_id );
766 781
 					$my_parents[] = $my_parent;
767
-					if ( !$my_parent->post_parent )
768
-						break;
782
+					if ( !$my_parent->post_parent ) {
783
+											break;
784
+					}
769 785
 					$my_parent = $my_parent->post_parent;
770 786
 				}
771 787
 				$num_parents = count( $my_parents );
@@ -1317,10 +1333,11 @@  discard block
 block discarded – undo
1317 1333
 				continue;
1318 1334
 			}
1319 1335
 
1320
-			if ( $taxonomy->hierarchical )
1321
-				$hierarchical_taxonomies[] = $taxonomy;
1322
-			else
1323
-				$flat_taxonomies[] = $taxonomy;
1336
+			if ( $taxonomy->hierarchical ) {
1337
+							$hierarchical_taxonomies[] = $taxonomy;
1338
+			} else {
1339
+							$flat_taxonomies[] = $taxonomy;
1340
+			}
1324 1341
 		}
1325 1342
 
1326 1343
 		$m = ( isset( $mode ) && 'excerpt' === $mode ) ? 'excerpt' : 'list';
@@ -1350,10 +1367,13 @@  discard block
 block discarded – undo
1350 1367
 				<div id="bulk-titles"></div>
1351 1368
 			</div>
1352 1369
 
1353
-	<?php else : // $bulk ?>
1370
+	<?php else {
1371
+	: // $bulk ?>
1354 1372
 
1355 1373
 			<label>
1356
-				<span class="title"><?php _e( 'Title' ); ?></span>
1374
+				<span class="title"><?php _e( 'Title' );
1375
+}
1376
+?></span>
1357 1377
 				<span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span>
1358 1378
 			</label>
1359 1379
 
@@ -1386,8 +1406,9 @@  discard block
 block discarded – undo
1386 1406
 					'echo' => 0,
1387 1407
 					'show' => 'display_name_with_login',
1388 1408
 				);
1389
-				if ( $bulk )
1390
-					$users_opt['show_option_none'] = __( '&mdash; No Change &mdash;' );
1409
+				if ( $bulk ) {
1410
+									$users_opt['show_option_none'] = __( '&mdash; No Change &mdash;' );
1411
+				}
1391 1412
 
1392 1413
 				if ( $authors = wp_dropdown_users( $users_opt ) ) :
1393 1414
 					$authors_dropdown  = '<label class="inline-edit-author">';
@@ -1398,7 +1419,9 @@  discard block
 block discarded – undo
1398 1419
 			endif; // authors
1399 1420
 	?>
1400 1421
 
1401
-	<?php if ( !$bulk ) echo $authors_dropdown;
1422
+	<?php if ( !$bulk ) {
1423
+	echo $authors_dropdown;
1424
+}
1402 1425
 	endif; // post_type_supports author
1403 1426
 
1404 1427
 	if ( !$bulk && $can_publish ) :
@@ -1447,8 +1470,9 @@  discard block
 block discarded – undo
1447 1470
 		<fieldset class="inline-edit-col-right"><div class="inline-edit-col">
1448 1471
 
1449 1472
 	<?php
1450
-		if ( post_type_supports( $screen->post_type, 'author' ) && $bulk )
1451
-			echo $authors_dropdown;
1473
+		if ( post_type_supports( $screen->post_type, 'author' ) && $bulk ) {
1474
+					echo $authors_dropdown;
1475
+		}
1452 1476
 
1453 1477
 		if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) :
1454 1478
 
@@ -1466,8 +1490,9 @@  discard block
 block discarded – undo
1466 1490
 			'sort_column'       => 'menu_order, post_title',
1467 1491
 		);
1468 1492
 
1469
-		if ( $bulk )
1470
-			$dropdown_args['show_option_no_change'] =  __( '&mdash; No Change &mdash;' );
1493
+		if ( $bulk ) {
1494
+					$dropdown_args['show_option_no_change'] =  __( '&mdash; No Change &mdash;' );
1495
+		}
1471 1496
 
1472 1497
 		/**
1473 1498
 		 * Filter the arguments used to generate the Quick Edit page-parent drop-down.
@@ -1558,13 +1583,16 @@  discard block
 block discarded – undo
1558 1583
 		<?php endif; ?>
1559 1584
 			</div>
1560 1585
 
1561
-	<?php else : // $bulk ?>
1586
+	<?php else {
1587
+	: // $bulk ?>
1562 1588
 
1563 1589
 			<div class="inline-edit-group wp-clearfix">
1564 1590
 			<?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
1565 1591
 				<label class="alignleft">
1566 1592
 					<input type="checkbox" name="comment_status" value="open" />
1567
-					<span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span>
1593
+					<span class="checkbox-title"><?php _e( 'Allow Comments' );
1594
+}
1595
+?></span>
1568 1596
 				</label>
1569 1597
 			<?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
1570 1598
 				<label class="alignleft">
@@ -1609,11 +1637,14 @@  discard block
 block discarded – undo
1609 1637
 					</select>
1610 1638
 				</label>
1611 1639
 
1612
-	<?php	else : // $bulk ?>
1640
+	<?php	else {
1641
+	: // $bulk ?>
1613 1642
 
1614 1643
 				<label class="alignleft">
1615 1644
 					<input type="checkbox" name="sticky" value="sticky" />
1616
-					<span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span>
1645
+					<span class="checkbox-title"><?php _e( 'Make this post sticky' );
1646
+}
1647
+?></span>
1617 1648
 				</label>
1618 1649
 
1619 1650
 	<?php	endif; // $bulk ?>
@@ -1655,8 +1686,9 @@  discard block
 block discarded – undo
1655 1686
 		list( $columns ) = $this->get_column_info();
1656 1687
 
1657 1688
 		foreach ( $columns as $column_name => $column_display_name ) {
1658
-			if ( isset( $core_columns[$column_name] ) )
1659
-				continue;
1689
+			if ( isset( $core_columns[$column_name] ) ) {
1690
+							continue;
1691
+			}
1660 1692
 
1661 1693
 			if ( $bulk ) {
1662 1694
 
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1175,10 +1175,10 @@  discard block
 block discarded – undo
1175 1175
 		}
1176 1176
 
1177 1177
 		if ( $post->post_parent ) {
1178
-		    $count = count( get_post_ancestors( $post->ID ) );
1179
-		    $classes .= ' level-'. $count;
1178
+			$count = count( get_post_ancestors( $post->ID ) );
1179
+			$classes .= ' level-'. $count;
1180 1180
 		} else {
1181
-		    $classes .= ' level-0';
1181
+			$classes .= ' level-0';
1182 1182
 		}
1183 1183
 	?>
1184 1184
 		<tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>">
@@ -1553,7 +1553,7 @@  discard block
 block discarded – undo
1553 1553
                 <?php
1554 1554
 				/** This filter is documented in wp-admin/includes/meta-boxes.php */
1555 1555
 				$default_title = apply_filters( 'default_page_template_title',  __( 'Default Template' ), 'quick-edit' );
1556
-                ?>
1556
+				?>
1557 1557
 				<option value="default"><?php echo esc_html( $default_title ); ?></option>
1558 1558
 				<?php page_template_dropdown( '', $screen->post_type ) ?>
1559 1559
 			</select>
Please login to merge, or discard this patch.
Spacing   +425 added lines, -425 removed lines patch added patch discarded remove patch
@@ -77,35 +77,35 @@  discard block
 block discarded – undo
77 77
 	 *
78 78
 	 * @param array $args An associative array of arguments.
79 79
 	 */
80
-	public function __construct( $args = array() ) {
80
+	public function __construct($args = array()) {
81 81
 		global $post_type_object, $wpdb;
82 82
 
83
-		parent::__construct( array(
83
+		parent::__construct(array(
84 84
 			'plural' => 'posts',
85
-			'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
86
-		) );
85
+			'screen' => isset($args['screen']) ? $args['screen'] : null,
86
+		));
87 87
 
88 88
 		$post_type        = $this->screen->post_type;
89
-		$post_type_object = get_post_type_object( $post_type );
89
+		$post_type_object = get_post_type_object($post_type);
90 90
 
91
-		$exclude_states   = get_post_stati( array(
91
+		$exclude_states   = get_post_stati(array(
92 92
 			'show_in_admin_all_list' => false,
93
-		) );
94
-		$this->user_posts_count = intval( $wpdb->get_var( $wpdb->prepare( "
93
+		));
94
+		$this->user_posts_count = intval($wpdb->get_var($wpdb->prepare("
95 95
 			SELECT COUNT( 1 )
96 96
 			FROM $wpdb->posts
97 97
 			WHERE post_type = %s
98
-			AND post_status NOT IN ( '" . implode( "','", $exclude_states ) . "' )
98
+			AND post_status NOT IN ( '".implode("','", $exclude_states)."' )
99 99
 			AND post_author = %d
100
-		", $post_type, get_current_user_id() ) ) );
100
+		", $post_type, get_current_user_id())));
101 101
 
102
-		if ( $this->user_posts_count && ! current_user_can( $post_type_object->cap->edit_others_posts ) && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) && empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] ) ) {
102
+		if ($this->user_posts_count && ! current_user_can($post_type_object->cap->edit_others_posts) && empty($_REQUEST['post_status']) && empty($_REQUEST['all_posts']) && empty($_REQUEST['author']) && empty($_REQUEST['show_sticky'])) {
103 103
 			$_GET['author'] = get_current_user_id();
104 104
 		}
105 105
 
106
-		if ( 'post' === $post_type && $sticky_posts = get_option( 'sticky_posts' ) ) {
107
-			$sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) );
108
-			$this->sticky_posts_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( 1 ) FROM $wpdb->posts WHERE post_type = %s AND post_status NOT IN ('trash', 'auto-draft') AND ID IN ($sticky_posts)", $post_type ) );
106
+		if ('post' === $post_type && $sticky_posts = get_option('sticky_posts')) {
107
+			$sticky_posts = implode(', ', array_map('absint', (array) $sticky_posts));
108
+			$this->sticky_posts_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT( 1 ) FROM $wpdb->posts WHERE post_type = %s AND post_status NOT IN ('trash', 'auto-draft') AND ID IN ($sticky_posts)", $post_type));
109 109
 		}
110 110
 	}
111 111
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 *
117 117
 	 * @param bool $display Whether the table layout should be hierarchical.
118 118
 	 */
119
-	public function set_hierarchical_display( $display ) {
119
+	public function set_hierarchical_display($display) {
120 120
 		$this->hierarchical_display = $display;
121 121
 	}
122 122
 
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	 * @return bool
126 126
 	 */
127 127
 	public function ajax_user_can() {
128
-		return current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_posts );
128
+		return current_user_can(get_post_type_object($this->screen->post_type)->cap->edit_posts);
129 129
 	}
130 130
 
131 131
 	/**
@@ -141,50 +141,50 @@  discard block
 block discarded – undo
141 141
 		// is going to call wp()
142 142
 		$avail_post_stati = wp_edit_posts_query();
143 143
 
144
-		$this->set_hierarchical_display( is_post_type_hierarchical( $this->screen->post_type ) && 'menu_order title' === $wp_query->query['orderby'] );
144
+		$this->set_hierarchical_display(is_post_type_hierarchical($this->screen->post_type) && 'menu_order title' === $wp_query->query['orderby']);
145 145
 
146 146
 		$post_type = $this->screen->post_type;
147
-		$per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' );
147
+		$per_page = $this->get_items_per_page('edit_'.$post_type.'_per_page');
148 148
 
149 149
 		/** This filter is documented in wp-admin/includes/post.php */
150
- 		$per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type );
150
+ 		$per_page = apply_filters('edit_posts_per_page', $per_page, $post_type);
151 151
 
152
-		if ( $this->hierarchical_display ) {
152
+		if ($this->hierarchical_display) {
153 153
 			$total_items = $wp_query->post_count;
154
-		} elseif ( $wp_query->found_posts || $this->get_pagenum() === 1 ) {
154
+		} elseif ($wp_query->found_posts || $this->get_pagenum() === 1) {
155 155
 			$total_items = $wp_query->found_posts;
156 156
 		} else {
157
-			$post_counts = (array) wp_count_posts( $post_type, 'readable' );
157
+			$post_counts = (array) wp_count_posts($post_type, 'readable');
158 158
 
159
-			if ( isset( $_REQUEST['post_status'] ) && in_array( $_REQUEST['post_status'] , $avail_post_stati ) ) {
160
-				$total_items = $post_counts[ $_REQUEST['post_status'] ];
161
-			} elseif ( isset( $_REQUEST['show_sticky'] ) && $_REQUEST['show_sticky'] ) {
159
+			if (isset($_REQUEST['post_status']) && in_array($_REQUEST['post_status'], $avail_post_stati)) {
160
+				$total_items = $post_counts[$_REQUEST['post_status']];
161
+			} elseif (isset($_REQUEST['show_sticky']) && $_REQUEST['show_sticky']) {
162 162
 				$total_items = $this->sticky_posts_count;
163
-			} elseif ( isset( $_GET['author'] ) && $_GET['author'] == get_current_user_id() ) {
163
+			} elseif (isset($_GET['author']) && $_GET['author'] == get_current_user_id()) {
164 164
 				$total_items = $this->user_posts_count;
165 165
 			} else {
166
-				$total_items = array_sum( $post_counts );
166
+				$total_items = array_sum($post_counts);
167 167
 
168 168
 				// Subtract post types that are not included in the admin all list.
169
-				foreach ( get_post_stati( array( 'show_in_admin_all_list' => false ) ) as $state ) {
170
-					$total_items -= $post_counts[ $state ];
169
+				foreach (get_post_stati(array('show_in_admin_all_list' => false)) as $state) {
170
+					$total_items -= $post_counts[$state];
171 171
 				}
172 172
 			}
173 173
 		}
174 174
 
175
-		if ( ! empty( $_REQUEST['mode'] ) ) {
175
+		if ( ! empty($_REQUEST['mode'])) {
176 176
 			$mode = $_REQUEST['mode'] === 'excerpt' ? 'excerpt' : 'list';
177
-			set_user_setting( 'posts_list_mode', $mode );
177
+			set_user_setting('posts_list_mode', $mode);
178 178
 		} else {
179
-			$mode = get_user_setting( 'posts_list_mode', 'list' );
179
+			$mode = get_user_setting('posts_list_mode', 'list');
180 180
 		}
181 181
 
182
-		$this->is_trash = isset( $_REQUEST['post_status'] ) && $_REQUEST['post_status'] === 'trash';
182
+		$this->is_trash = isset($_REQUEST['post_status']) && $_REQUEST['post_status'] === 'trash';
183 183
 
184
-		$this->set_pagination_args( array(
184
+		$this->set_pagination_args(array(
185 185
 			'total_items' => $total_items,
186 186
 			'per_page' => $per_page
187
-		) );
187
+		));
188 188
 	}
189 189
 
190 190
 	/**
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
 	 * @access public
200 200
 	 */
201 201
 	public function no_items() {
202
-		if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] )
203
-			echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash;
202
+		if (isset($_REQUEST['post_status']) && 'trash' === $_REQUEST['post_status'])
203
+			echo get_post_type_object($this->screen->post_type)->labels->not_found_in_trash;
204 204
 		else
205
-			echo get_post_type_object( $this->screen->post_type )->labels->not_found;
205
+			echo get_post_type_object($this->screen->post_type)->labels->not_found;
206 206
 	}
207 207
 
208 208
 	/**
@@ -214,15 +214,15 @@  discard block
 block discarded – undo
214 214
 	 */
215 215
 	protected function is_base_request() {
216 216
 		$vars = $_GET;
217
-		unset( $vars['paged'] );
217
+		unset($vars['paged']);
218 218
 
219
-		if ( empty( $vars ) ) {
219
+		if (empty($vars)) {
220 220
 			return true;
221
-		} elseif ( 1 === count( $vars ) && ! empty( $vars['post_type'] ) ) {
221
+		} elseif (1 === count($vars) && ! empty($vars['post_type'])) {
222 222
 			return $this->screen->post_type === $vars['post_type'];
223 223
 		}
224 224
 
225
-		return 1 === count( $vars ) && ! empty( $vars['mode'] );
225
+		return 1 === count($vars) && ! empty($vars['mode']);
226 226
 	}
227 227
 
228 228
 	/**
@@ -236,20 +236,20 @@  discard block
 block discarded – undo
236 236
 	 * @param string $class Optional. Class attribute. Default empty string.
237 237
 	 * @return string The formatted link string.
238 238
 	 */
239
-	protected function get_edit_link( $args, $label, $class = '' ) {
240
-		$url = add_query_arg( $args, 'edit.php' );
239
+	protected function get_edit_link($args, $label, $class = '') {
240
+		$url = add_query_arg($args, 'edit.php');
241 241
 
242 242
 		$class_html = '';
243
-		if ( ! empty( $class ) ) {
243
+		if ( ! empty($class)) {
244 244
 			 $class_html = sprintf(
245 245
 				' class="%s"',
246
-				esc_attr( $class )
246
+				esc_attr($class)
247 247
 			);
248 248
 		}
249 249
 
250 250
 		return sprintf(
251 251
 			'<a href="%s"%s>%s</a>',
252
-			esc_url( $url ),
252
+			esc_url($url),
253 253
 			$class_html,
254 254
 			$label
255 255
 		);
@@ -266,25 +266,25 @@  discard block
 block discarded – undo
266 266
 
267 267
 		$post_type = $this->screen->post_type;
268 268
 
269
-		if ( !empty($locked_post_status) )
269
+		if ( ! empty($locked_post_status))
270 270
 			return array();
271 271
 
272 272
 		$status_links = array();
273
-		$num_posts = wp_count_posts( $post_type, 'readable' );
274
-		$total_posts = array_sum( (array) $num_posts );
273
+		$num_posts = wp_count_posts($post_type, 'readable');
274
+		$total_posts = array_sum((array) $num_posts);
275 275
 		$class = '';
276 276
 
277 277
 		$current_user_id = get_current_user_id();
278
-		$all_args = array( 'post_type' => $post_type );
278
+		$all_args = array('post_type' => $post_type);
279 279
 		$mine = '';
280 280
 
281 281
 		// Subtract post types that are not included in the admin all list.
282
-		foreach ( get_post_stati( array( 'show_in_admin_all_list' => false ) ) as $state ) {
282
+		foreach (get_post_stati(array('show_in_admin_all_list' => false)) as $state) {
283 283
 			$total_posts -= $num_posts->$state;
284 284
 		}
285 285
 
286
-		if ( $this->user_posts_count && $this->user_posts_count !== $total_posts ) {
287
-			if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user_id ) ) {
286
+		if ($this->user_posts_count && $this->user_posts_count !== $total_posts) {
287
+			if (isset($_GET['author']) && ($_GET['author'] == $current_user_id)) {
288 288
 				$class = 'current';
289 289
 			}
290 290
 
@@ -300,16 +300,16 @@  discard block
 block discarded – undo
300 300
 					$this->user_posts_count,
301 301
 					'posts'
302 302
 				),
303
-				number_format_i18n( $this->user_posts_count )
303
+				number_format_i18n($this->user_posts_count)
304 304
 			);
305 305
 
306
-			$mine = $this->get_edit_link( $mine_args, $mine_inner_html, $class );
306
+			$mine = $this->get_edit_link($mine_args, $mine_inner_html, $class);
307 307
 
308 308
 			$all_args['all_posts'] = 1;
309 309
 			$class = '';
310 310
 		}
311 311
 
312
-		if ( empty( $class ) && ( $this->is_base_request() || isset( $_REQUEST['all_posts'] ) ) ) {
312
+		if (empty($class) && ($this->is_base_request() || isset($_REQUEST['all_posts']))) {
313 313
 			$class = 'current';
314 314
 		}
315 315
 
@@ -320,24 +320,24 @@  discard block
 block discarded – undo
320 320
 				$total_posts,
321 321
 				'posts'
322 322
 			),
323
-			number_format_i18n( $total_posts )
323
+			number_format_i18n($total_posts)
324 324
 		);
325 325
 
326
-		$status_links['all'] = $this->get_edit_link( $all_args, $all_inner_html, $class );
327
-		if ( $mine ) {
326
+		$status_links['all'] = $this->get_edit_link($all_args, $all_inner_html, $class);
327
+		if ($mine) {
328 328
 			$status_links['mine'] = $mine;
329 329
 		}
330 330
 
331
-		foreach ( get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status ) {
331
+		foreach (get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status) {
332 332
 			$class = '';
333 333
 
334 334
 			$status_name = $status->name;
335 335
 
336
-			if ( ! in_array( $status_name, $avail_post_stati ) || empty( $num_posts->$status_name ) ) {
336
+			if ( ! in_array($status_name, $avail_post_stati) || empty($num_posts->$status_name)) {
337 337
 				continue;
338 338
 			}
339 339
 
340
-			if ( isset($_REQUEST['post_status']) && $status_name === $_REQUEST['post_status'] ) {
340
+			if (isset($_REQUEST['post_status']) && $status_name === $_REQUEST['post_status']) {
341 341
 				$class = 'current';
342 342
 			}
343 343
 
@@ -347,15 +347,15 @@  discard block
 block discarded – undo
347 347
 			);
348 348
 
349 349
 			$status_label = sprintf(
350
-				translate_nooped_plural( $status->label_count, $num_posts->$status_name ),
351
-				number_format_i18n( $num_posts->$status_name )
350
+				translate_nooped_plural($status->label_count, $num_posts->$status_name),
351
+				number_format_i18n($num_posts->$status_name)
352 352
 			);
353 353
 
354
-			$status_links[ $status_name ] = $this->get_edit_link( $status_args, $status_label, $class );
354
+			$status_links[$status_name] = $this->get_edit_link($status_args, $status_label, $class);
355 355
 		}
356 356
 
357
-		if ( ! empty( $this->sticky_posts_count ) ) {
358
-			$class = ! empty( $_REQUEST['show_sticky'] ) ? 'current' : '';
357
+		if ( ! empty($this->sticky_posts_count)) {
358
+			$class = ! empty($_REQUEST['show_sticky']) ? 'current' : '';
359 359
 
360 360
 			$sticky_args = array(
361 361
 				'post_type'	=> $post_type,
@@ -369,16 +369,16 @@  discard block
 block discarded – undo
369 369
 					$this->sticky_posts_count,
370 370
 					'posts'
371 371
 				),
372
-				number_format_i18n( $this->sticky_posts_count )
372
+				number_format_i18n($this->sticky_posts_count)
373 373
 			);
374 374
 
375 375
 			$sticky_link = array(
376
-				'sticky' => $this->get_edit_link( $sticky_args, $sticky_inner_html, $class )
376
+				'sticky' => $this->get_edit_link($sticky_args, $sticky_inner_html, $class)
377 377
 			);
378 378
 
379 379
 			// Sticky comes after Publish, or if not listed, after All.
380
-			$split = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ) );
381
-			$status_links = array_merge( array_slice( $status_links, 0, $split ), $sticky_link, array_slice( $status_links, $split ) );
380
+			$split = 1 + array_search((isset($status_links['publish']) ? 'publish' : 'all'), array_keys($status_links));
381
+			$status_links = array_merge(array_slice($status_links, 0, $split), $sticky_link, array_slice($status_links, $split));
382 382
 		}
383 383
 
384 384
 		return $status_links;
@@ -390,21 +390,21 @@  discard block
 block discarded – undo
390 390
 	 */
391 391
 	protected function get_bulk_actions() {
392 392
 		$actions = array();
393
-		$post_type_obj = get_post_type_object( $this->screen->post_type );
393
+		$post_type_obj = get_post_type_object($this->screen->post_type);
394 394
 
395
-		if ( current_user_can( $post_type_obj->cap->edit_posts ) ) {
396
-			if ( $this->is_trash ) {
397
-				$actions['untrash'] = __( 'Restore' );
395
+		if (current_user_can($post_type_obj->cap->edit_posts)) {
396
+			if ($this->is_trash) {
397
+				$actions['untrash'] = __('Restore');
398 398
 			} else {
399
-				$actions['edit'] = __( 'Edit' );
399
+				$actions['edit'] = __('Edit');
400 400
 			}
401 401
 		}
402 402
 
403
-		if ( current_user_can( $post_type_obj->cap->delete_posts ) ) {
404
-			if ( $this->is_trash || ! EMPTY_TRASH_DAYS ) {
405
-				$actions['delete'] = __( 'Delete Permanently' );
403
+		if (current_user_can($post_type_obj->cap->delete_posts)) {
404
+			if ($this->is_trash || ! EMPTY_TRASH_DAYS) {
405
+				$actions['delete'] = __('Delete Permanently');
406 406
 			} else {
407
-				$actions['trash'] = __( 'Move to Trash' );
407
+				$actions['trash'] = __('Move to Trash');
408 408
 			}
409 409
 		}
410 410
 
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 	 *
422 422
 	 * @param string $post_type Post type slug.
423 423
 	 */
424
-	protected function categories_dropdown( $post_type ) {
424
+	protected function categories_dropdown($post_type) {
425 425
 		global $cat;
426 426
 
427 427
 		/**
@@ -432,13 +432,13 @@  discard block
 block discarded – undo
432 432
 		 * @param bool   $disable   Whether to disable the categories drop-down. Default false.
433 433
 		 * @param string $post_type Post type slug.
434 434
 		 */
435
-		if ( false !== apply_filters( 'disable_categories_dropdown', false, $post_type ) ) {
435
+		if (false !== apply_filters('disable_categories_dropdown', false, $post_type)) {
436 436
 			return;
437 437
 		}
438 438
 
439
-		if ( is_object_in_taxonomy( $post_type, 'category' ) ) {
439
+		if (is_object_in_taxonomy($post_type, 'category')) {
440 440
 			$dropdown_options = array(
441
-				'show_option_all' => get_taxonomy( 'category' )->labels->all_items,
441
+				'show_option_all' => get_taxonomy('category')->labels->all_items,
442 442
 				'hide_empty' => 0,
443 443
 				'hierarchical' => 1,
444 444
 				'show_count' => 0,
@@ -446,23 +446,23 @@  discard block
 block discarded – undo
446 446
 				'selected' => $cat
447 447
 			);
448 448
 
449
-			echo '<label class="screen-reader-text" for="cat">' . __( 'Filter by category' ) . '</label>';
450
-			wp_dropdown_categories( $dropdown_options );
449
+			echo '<label class="screen-reader-text" for="cat">'.__('Filter by category').'</label>';
450
+			wp_dropdown_categories($dropdown_options);
451 451
 		}
452 452
 	}
453 453
 
454 454
 	/**
455 455
 	 * @param string $which
456 456
 	 */
457
-	protected function extra_tablenav( $which ) {
457
+	protected function extra_tablenav($which) {
458 458
 ?>
459 459
 		<div class="alignleft actions">
460 460
 <?php
461
-		if ( 'top' === $which && !is_singular() ) {
461
+		if ('top' === $which && ! is_singular()) {
462 462
 			ob_start();
463 463
 
464
-			$this->months_dropdown( $this->screen->post_type );
465
-			$this->categories_dropdown( $this->screen->post_type );
464
+			$this->months_dropdown($this->screen->post_type);
465
+			$this->categories_dropdown($this->screen->post_type);
466 466
 
467 467
 			/**
468 468
 			 * Fires before the Filter button on the Posts and Pages list tables.
@@ -478,18 +478,18 @@  discard block
 block discarded – undo
478 478
 			 * @param string $which     The location of the extra table nav markup:
479 479
 			 *                          'top' or 'bottom'.
480 480
 			 */
481
-			do_action( 'restrict_manage_posts', $this->screen->post_type, $which );
481
+			do_action('restrict_manage_posts', $this->screen->post_type, $which);
482 482
 
483 483
 			$output = ob_get_clean();
484 484
 
485
-			if ( ! empty( $output ) ) {
485
+			if ( ! empty($output)) {
486 486
 				echo $output;
487
-				submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
487
+				submit_button(__('Filter'), '', 'filter_action', false, array('id' => 'post-query-submit'));
488 488
 			}
489 489
 		}
490 490
 
491
-		if ( $this->is_trash && current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_others_posts ) ) {
492
-			submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false );
491
+		if ($this->is_trash && current_user_can(get_post_type_object($this->screen->post_type)->cap->edit_others_posts)) {
492
+			submit_button(__('Empty Trash'), 'apply', 'delete_all', false);
493 493
 		}
494 494
 ?>
495 495
 		</div>
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 		 *
503 503
 		 * @param string $which The location of the extra table nav markup: 'top' or 'bottom'.
504 504
 		 */
505
-		do_action( 'manage_posts_extra_tablenav', $which );
505
+		do_action('manage_posts_extra_tablenav', $which);
506 506
 	}
507 507
 
508 508
 	/**
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
 	 * @return string
511 511
 	 */
512 512
 	public function current_action() {
513
-		if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
513
+		if (isset($_REQUEST['delete_all']) || isset($_REQUEST['delete_all2']))
514 514
 			return 'delete_all';
515 515
 
516 516
 		return parent::current_action();
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
 	 * @return array
522 522
 	 */
523 523
 	protected function get_table_classes() {
524
-		return array( 'widefat', 'fixed', 'striped', is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts' );
524
+		return array('widefat', 'fixed', 'striped', is_post_type_hierarchical($this->screen->post_type) ? 'pages' : 'posts');
525 525
 	}
526 526
 
527 527
 	/**
@@ -536,14 +536,14 @@  discard block
 block discarded – undo
536 536
 		$posts_columns['cb'] = '<input type="checkbox" />';
537 537
 
538 538
 		/* translators: manage posts column name */
539
-		$posts_columns['title'] = _x( 'Title', 'column name' );
539
+		$posts_columns['title'] = _x('Title', 'column name');
540 540
 
541
-		if ( post_type_supports( $post_type, 'author' ) ) {
542
-			$posts_columns['author'] = __( 'Author' );
541
+		if (post_type_supports($post_type, 'author')) {
542
+			$posts_columns['author'] = __('Author');
543 543
 		}
544 544
 
545
-		$taxonomies = get_object_taxonomies( $post_type, 'objects' );
546
-		$taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' );
545
+		$taxonomies = get_object_taxonomies($post_type, 'objects');
546
+		$taxonomies = wp_filter_object_list($taxonomies, array('show_admin_column' => true), 'and', 'name');
547 547
 
548 548
 		/**
549 549
 		 * Filters the taxonomy columns in the Posts list table.
@@ -556,27 +556,27 @@  discard block
 block discarded – undo
556 556
 		 * @param array  $taxonomies Array of taxonomies to show columns for.
557 557
 		 * @param string $post_type  The post type.
558 558
 		 */
559
-		$taxonomies = apply_filters( "manage_taxonomies_for_{$post_type}_columns", $taxonomies, $post_type );
560
-		$taxonomies = array_filter( $taxonomies, 'taxonomy_exists' );
559
+		$taxonomies = apply_filters("manage_taxonomies_for_{$post_type}_columns", $taxonomies, $post_type);
560
+		$taxonomies = array_filter($taxonomies, 'taxonomy_exists');
561 561
 
562
-		foreach ( $taxonomies as $taxonomy ) {
563
-			if ( 'category' === $taxonomy )
562
+		foreach ($taxonomies as $taxonomy) {
563
+			if ('category' === $taxonomy)
564 564
 				$column_key = 'categories';
565
-			elseif ( 'post_tag' === $taxonomy )
565
+			elseif ('post_tag' === $taxonomy)
566 566
 				$column_key = 'tags';
567 567
 			else
568
-				$column_key = 'taxonomy-' . $taxonomy;
568
+				$column_key = 'taxonomy-'.$taxonomy;
569 569
 
570
-			$posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name;
570
+			$posts_columns[$column_key] = get_taxonomy($taxonomy)->labels->name;
571 571
 		}
572 572
 
573
-		$post_status = !empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all';
574
-		if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) )
575
-			$posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>';
573
+		$post_status = ! empty($_REQUEST['post_status']) ? $_REQUEST['post_status'] : 'all';
574
+		if (post_type_supports($post_type, 'comments') && ! in_array($post_status, array('pending', 'draft', 'future')))
575
+			$posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="'.esc_attr__('Comments').'"><span class="screen-reader-text">'.__('Comments').'</span></span>';
576 576
 
577
-		$posts_columns['date'] = __( 'Date' );
577
+		$posts_columns['date'] = __('Date');
578 578
 
579
-		if ( 'page' === $post_type ) {
579
+		if ('page' === $post_type) {
580 580
 
581 581
 			/**
582 582
 			 * Filters the columns displayed in the Pages list table.
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
 			 *
586 586
 			 * @param array $post_columns An array of column names.
587 587
 			 */
588
-			$posts_columns = apply_filters( 'manage_pages_columns', $posts_columns );
588
+			$posts_columns = apply_filters('manage_pages_columns', $posts_columns);
589 589
 		} else {
590 590
 
591 591
 			/**
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
 			 * @param array  $posts_columns An array of column names.
597 597
 			 * @param string $post_type     The post type slug.
598 598
 			 */
599
-			$posts_columns = apply_filters( 'manage_posts_columns', $posts_columns, $post_type );
599
+			$posts_columns = apply_filters('manage_posts_columns', $posts_columns, $post_type);
600 600
 		}
601 601
 
602 602
 		/**
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 		 *
609 609
 		 * @param array $post_columns An array of column names.
610 610
 		 */
611
-		return apply_filters( "manage_{$post_type}_posts_columns", $posts_columns );
611
+		return apply_filters("manage_{$post_type}_posts_columns", $posts_columns);
612 612
 	}
613 613
 
614 614
 	/**
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
 			'title'    => 'title',
621 621
 			'parent'   => 'parent',
622 622
 			'comments' => 'comment_count',
623
-			'date'     => array( 'date', true )
623
+			'date'     => array('date', true)
624 624
 		);
625 625
 	}
626 626
 
@@ -630,18 +630,18 @@  discard block
 block discarded – undo
630 630
 	 * @param array $posts
631 631
 	 * @param int $level
632 632
 	 */
633
-	public function display_rows( $posts = array(), $level = 0 ) {
633
+	public function display_rows($posts = array(), $level = 0) {
634 634
 		global $wp_query, $per_page;
635 635
 
636
-		if ( empty( $posts ) )
636
+		if (empty($posts))
637 637
 			$posts = $wp_query->posts;
638 638
 
639
-		add_filter( 'the_title', 'esc_html' );
639
+		add_filter('the_title', 'esc_html');
640 640
 
641
-		if ( $this->hierarchical_display ) {
642
-			$this->_display_rows_hierarchical( $posts, $this->get_pagenum(), $per_page );
641
+		if ($this->hierarchical_display) {
642
+			$this->_display_rows_hierarchical($posts, $this->get_pagenum(), $per_page);
643 643
 		} else {
644
-			$this->_display_rows( $posts, $level );
644
+			$this->_display_rows($posts, $level);
645 645
 		}
646 646
 	}
647 647
 
@@ -649,17 +649,17 @@  discard block
 block discarded – undo
649 649
 	 * @param array $posts
650 650
 	 * @param int $level
651 651
 	 */
652
-	private function _display_rows( $posts, $level = 0 ) {
652
+	private function _display_rows($posts, $level = 0) {
653 653
 		// Create array of post IDs.
654 654
 		$post_ids = array();
655 655
 
656
-		foreach ( $posts as $a_post )
656
+		foreach ($posts as $a_post)
657 657
 			$post_ids[] = $a_post->ID;
658 658
 
659
-		$this->comment_pending_count = get_pending_comments_num( $post_ids );
659
+		$this->comment_pending_count = get_pending_comments_num($post_ids);
660 660
 
661
-		foreach ( $posts as $post )
662
-			$this->single_row( $post, $level );
661
+		foreach ($posts as $post)
662
+			$this->single_row($post, $level);
663 663
 	}
664 664
 
665 665
 	/**
@@ -669,15 +669,15 @@  discard block
 block discarded – undo
669 669
 	 * @param int $pagenum
670 670
 	 * @param int $per_page
671 671
 	 */
672
-	private function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 20 ) {
672
+	private function _display_rows_hierarchical($pages, $pagenum = 1, $per_page = 20) {
673 673
 		global $wpdb;
674 674
 
675 675
 		$level = 0;
676 676
 
677
-		if ( ! $pages ) {
678
-			$pages = get_pages( array( 'sort_column' => 'menu_order' ) );
677
+		if ( ! $pages) {
678
+			$pages = get_pages(array('sort_column' => 'menu_order'));
679 679
 
680
-			if ( ! $pages )
680
+			if ( ! $pages)
681 681
 				return;
682 682
 		}
683 683
 
@@ -688,56 +688,56 @@  discard block
 block discarded – undo
688 688
 		 * It only takes O( N ) to arrange this and it takes O( 1 ) for subsequent lookup operations
689 689
 		 * If searching, ignore hierarchy and treat everything as top level
690 690
 		 */
691
-		if ( empty( $_REQUEST['s'] ) ) {
691
+		if (empty($_REQUEST['s'])) {
692 692
 
693 693
 			$top_level_pages = array();
694 694
 			$children_pages = array();
695 695
 
696
-			foreach ( $pages as $page ) {
696
+			foreach ($pages as $page) {
697 697
 
698 698
 				// Catch and repair bad pages.
699
-				if ( $page->post_parent == $page->ID ) {
699
+				if ($page->post_parent == $page->ID) {
700 700
 					$page->post_parent = 0;
701
-					$wpdb->update( $wpdb->posts, array( 'post_parent' => 0 ), array( 'ID' => $page->ID ) );
702
-					clean_post_cache( $page );
701
+					$wpdb->update($wpdb->posts, array('post_parent' => 0), array('ID' => $page->ID));
702
+					clean_post_cache($page);
703 703
 				}
704 704
 
705
-				if ( 0 == $page->post_parent )
705
+				if (0 == $page->post_parent)
706 706
 					$top_level_pages[] = $page;
707 707
 				else
708
-					$children_pages[ $page->post_parent ][] = $page;
708
+					$children_pages[$page->post_parent][] = $page;
709 709
 			}
710 710
 
711 711
 			$pages = &$top_level_pages;
712 712
 		}
713 713
 
714 714
 		$count = 0;
715
-		$start = ( $pagenum - 1 ) * $per_page;
715
+		$start = ($pagenum - 1) * $per_page;
716 716
 		$end = $start + $per_page;
717 717
 		$to_display = array();
718 718
 
719
-		foreach ( $pages as $page ) {
720
-			if ( $count >= $end )
719
+		foreach ($pages as $page) {
720
+			if ($count >= $end)
721 721
 				break;
722 722
 
723
-			if ( $count >= $start ) {
723
+			if ($count >= $start) {
724 724
 				$to_display[$page->ID] = $level;
725 725
 			}
726 726
 
727 727
 			$count++;
728 728
 
729
-			if ( isset( $children_pages ) )
730
-				$this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display );
729
+			if (isset($children_pages))
730
+				$this->_page_rows($children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display);
731 731
 		}
732 732
 
733 733
 		// If it is the last pagenum and there are orphaned pages, display them with paging as well.
734
-		if ( isset( $children_pages ) && $count < $end ){
735
-			foreach ( $children_pages as $orphans ){
736
-				foreach ( $orphans as $op ) {
737
-					if ( $count >= $end )
734
+		if (isset($children_pages) && $count < $end) {
735
+			foreach ($children_pages as $orphans) {
736
+				foreach ($orphans as $op) {
737
+					if ($count >= $end)
738 738
 						break;
739 739
 
740
-					if ( $count >= $start ) {
740
+					if ($count >= $start) {
741 741
 						$to_display[$op->ID] = 0;
742 742
 					}
743 743
 
@@ -746,16 +746,16 @@  discard block
 block discarded – undo
746 746
 			}
747 747
 		}
748 748
 
749
-		$ids = array_keys( $to_display );
750
-		_prime_post_caches( $ids );
749
+		$ids = array_keys($to_display);
750
+		_prime_post_caches($ids);
751 751
 
752
-		if ( ! isset( $GLOBALS['post'] ) ) {
753
-			$GLOBALS['post'] = reset( $ids );
752
+		if ( ! isset($GLOBALS['post'])) {
753
+			$GLOBALS['post'] = reset($ids);
754 754
 		}
755 755
 
756
-		foreach ( $to_display as $page_id => $level ) {
756
+		foreach ($to_display as $page_id => $level) {
757 757
 			echo "\t";
758
-			$this->single_row( $page_id, $level );
758
+			$this->single_row($page_id, $level);
759 759
 		}
760 760
 	}
761 761
 
@@ -774,51 +774,51 @@  discard block
 block discarded – undo
774 774
 	 * @param int $per_page
775 775
 	 * @param array $to_display List of pages to be displayed. Passed by reference.
776 776
 	 */
777
-	private function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page, &$to_display ) {
778
-		if ( ! isset( $children_pages[$parent] ) )
777
+	private function _page_rows(&$children_pages, &$count, $parent, $level, $pagenum, $per_page, &$to_display) {
778
+		if ( ! isset($children_pages[$parent]))
779 779
 			return;
780 780
 
781
-		$start = ( $pagenum - 1 ) * $per_page;
781
+		$start = ($pagenum - 1) * $per_page;
782 782
 		$end = $start + $per_page;
783 783
 
784
-		foreach ( $children_pages[$parent] as $page ) {
785
-			if ( $count >= $end )
784
+		foreach ($children_pages[$parent] as $page) {
785
+			if ($count >= $end)
786 786
 				break;
787 787
 
788 788
 			// If the page starts in a subtree, print the parents.
789
-			if ( $count == $start && $page->post_parent > 0 ) {
789
+			if ($count == $start && $page->post_parent > 0) {
790 790
 				$my_parents = array();
791 791
 				$my_parent = $page->post_parent;
792
-				while ( $my_parent ) {
792
+				while ($my_parent) {
793 793
 					// Get the ID from the list or the attribute if my_parent is an object
794 794
 					$parent_id = $my_parent;
795
-					if ( is_object( $my_parent ) ) {
795
+					if (is_object($my_parent)) {
796 796
 						$parent_id = $my_parent->ID;
797 797
 					}
798 798
 
799
-					$my_parent = get_post( $parent_id );
799
+					$my_parent = get_post($parent_id);
800 800
 					$my_parents[] = $my_parent;
801
-					if ( !$my_parent->post_parent )
801
+					if ( ! $my_parent->post_parent)
802 802
 						break;
803 803
 					$my_parent = $my_parent->post_parent;
804 804
 				}
805
-				$num_parents = count( $my_parents );
806
-				while ( $my_parent = array_pop( $my_parents ) ) {
805
+				$num_parents = count($my_parents);
806
+				while ($my_parent = array_pop($my_parents)) {
807 807
 					$to_display[$my_parent->ID] = $level - $num_parents;
808 808
 					$num_parents--;
809 809
 				}
810 810
 			}
811 811
 
812
-			if ( $count >= $start ) {
812
+			if ($count >= $start) {
813 813
 				$to_display[$page->ID] = $level;
814 814
 			}
815 815
 
816 816
 			$count++;
817 817
 
818
-			$this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display );
818
+			$this->_page_rows($children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display);
819 819
 		}
820 820
 
821
-		unset( $children_pages[$parent] ); //required in order to keep track of orphans
821
+		unset($children_pages[$parent]); //required in order to keep track of orphans
822 822
 	}
823 823
 
824 824
 	/**
@@ -829,10 +829,10 @@  discard block
 block discarded – undo
829 829
 	 *
830 830
 	 * @param WP_Post $post The current WP_Post object.
831 831
 	 */
832
-	public function column_cb( $post ) {
833
-		if ( current_user_can( 'edit_post', $post->ID ) ): ?>
832
+	public function column_cb($post) {
833
+		if (current_user_can('edit_post', $post->ID)): ?>
834 834
 			<label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"><?php
835
-				printf( __( 'Select %s' ), _draft_or_post_title() );
835
+				printf(__('Select %s'), _draft_or_post_title());
836 836
 			?></label>
837 837
 			<input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" />
838 838
 			<div class="locked-indicator">
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
 				<span class="screen-reader-text"><?php
841 841
 				printf(
842 842
 					/* translators: %s: post title */
843
-					__( '&#8220;%s&#8221; is locked' ),
843
+					__('&#8220;%s&#8221; is locked'),
844 844
 					_draft_or_post_title()
845 845
 				);
846 846
 				?></span>
@@ -857,10 +857,10 @@  discard block
 block discarded – undo
857 857
 	 * @param string  $data
858 858
 	 * @param string  $primary
859 859
 	 */
860
-	protected function _column_title( $post, $classes, $data, $primary ) {
861
-		echo '<td class="' . $classes . ' page-title" ', $data, '>';
862
-		echo $this->column_title( $post );
863
-		echo $this->handle_row_actions( $post, 'title', $primary );
860
+	protected function _column_title($post, $classes, $data, $primary) {
861
+		echo '<td class="'.$classes.' page-title" ', $data, '>';
862
+		echo $this->column_title($post);
863
+		echo $this->handle_row_actions($post, 'title', $primary);
864 864
 		echo '</td>';
865 865
 	}
866 866
 
@@ -874,91 +874,91 @@  discard block
 block discarded – undo
874 874
 	 *
875 875
 	 * @param WP_Post $post The current WP_Post object.
876 876
 	 */
877
-	public function column_title( $post ) {
877
+	public function column_title($post) {
878 878
 		global $mode;
879 879
 
880
-		if ( $this->hierarchical_display ) {
881
-			if ( 0 === $this->current_level && (int) $post->post_parent > 0 ) {
880
+		if ($this->hierarchical_display) {
881
+			if (0 === $this->current_level && (int) $post->post_parent > 0) {
882 882
 				// Sent level 0 by accident, by default, or because we don't know the actual level.
883 883
 				$find_main_page = (int) $post->post_parent;
884
-				while ( $find_main_page > 0 ) {
885
-					$parent = get_post( $find_main_page );
884
+				while ($find_main_page > 0) {
885
+					$parent = get_post($find_main_page);
886 886
 
887
-					if ( is_null( $parent ) ) {
887
+					if (is_null($parent)) {
888 888
 						break;
889 889
 					}
890 890
 
891 891
 					$this->current_level++;
892 892
 					$find_main_page = (int) $parent->post_parent;
893 893
 
894
-					if ( ! isset( $parent_name ) ) {
894
+					if ( ! isset($parent_name)) {
895 895
 						/** This filter is documented in wp-includes/post-template.php */
896
-						$parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID );
896
+						$parent_name = apply_filters('the_title', $parent->post_title, $parent->ID);
897 897
 					}
898 898
 				}
899 899
 			}
900 900
 		}
901 901
 
902
-		$can_edit_post = current_user_can( 'edit_post', $post->ID );
902
+		$can_edit_post = current_user_can('edit_post', $post->ID);
903 903
 
904
-		if ( $can_edit_post && $post->post_status != 'trash' ) {
905
-			$lock_holder = wp_check_post_lock( $post->ID );
904
+		if ($can_edit_post && $post->post_status != 'trash') {
905
+			$lock_holder = wp_check_post_lock($post->ID);
906 906
 
907
-			if ( $lock_holder ) {
908
-				$lock_holder = get_userdata( $lock_holder );
909
-				$locked_avatar = get_avatar( $lock_holder->ID, 18 );
910
-				$locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) );
907
+			if ($lock_holder) {
908
+				$lock_holder = get_userdata($lock_holder);
909
+				$locked_avatar = get_avatar($lock_holder->ID, 18);
910
+				$locked_text = esc_html(sprintf(__('%s is currently editing'), $lock_holder->display_name));
911 911
 			} else {
912 912
 				$locked_avatar = $locked_text = '';
913 913
 			}
914 914
 
915
-			echo '<div class="locked-info"><span class="locked-avatar">' . $locked_avatar . '</span> <span class="locked-text">' . $locked_text . "</span></div>\n";
915
+			echo '<div class="locked-info"><span class="locked-avatar">'.$locked_avatar.'</span> <span class="locked-text">'.$locked_text."</span></div>\n";
916 916
 		}
917 917
 
918
-		$pad = str_repeat( '&#8212; ', $this->current_level );
918
+		$pad = str_repeat('&#8212; ', $this->current_level);
919 919
 		echo "<strong>";
920 920
 
921
-		$format = get_post_format( $post->ID );
922
-		if ( $format ) {
923
-			$label = get_post_format_string( $format );
921
+		$format = get_post_format($post->ID);
922
+		if ($format) {
923
+			$label = get_post_format_string($format);
924 924
 
925
-			$format_class = 'post-state-format post-format-icon post-format-' . $format;
925
+			$format_class = 'post-state-format post-format-icon post-format-'.$format;
926 926
 
927 927
 			$format_args = array(
928 928
 				'post_format' => $format,
929 929
 				'post_type' => $post->post_type
930 930
 			);
931 931
 
932
-			echo $this->get_edit_link( $format_args, $label . ':', $format_class );
932
+			echo $this->get_edit_link($format_args, $label.':', $format_class);
933 933
 		}
934 934
 
935 935
 		$title = _draft_or_post_title();
936 936
 
937
-		if ( $can_edit_post && $post->post_status != 'trash' ) {
937
+		if ($can_edit_post && $post->post_status != 'trash') {
938 938
 			printf(
939 939
 				'<a class="row-title" href="%s" aria-label="%s">%s%s</a>',
940
-				get_edit_post_link( $post->ID ),
940
+				get_edit_post_link($post->ID),
941 941
 				/* translators: %s: post title */
942
-				esc_attr( sprintf( __( '&#8220;%s&#8221; (Edit)' ), $title ) ),
942
+				esc_attr(sprintf(__('&#8220;%s&#8221; (Edit)'), $title)),
943 943
 				$pad,
944 944
 				$title
945 945
 			);
946 946
 		} else {
947
-			echo $pad . $title;
947
+			echo $pad.$title;
948 948
 		}
949
-		_post_states( $post );
949
+		_post_states($post);
950 950
 
951
-		if ( isset( $parent_name ) ) {
952
-			$post_type_object = get_post_type_object( $post->post_type );
953
-			echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name );
951
+		if (isset($parent_name)) {
952
+			$post_type_object = get_post_type_object($post->post_type);
953
+			echo ' | '.$post_type_object->labels->parent_item_colon.' '.esc_html($parent_name);
954 954
 		}
955 955
 		echo "</strong>\n";
956 956
 
957
-		if ( ! is_post_type_hierarchical( $this->screen->post_type ) && 'excerpt' === $mode && current_user_can( 'read_post', $post->ID ) ) {
957
+		if ( ! is_post_type_hierarchical($this->screen->post_type) && 'excerpt' === $mode && current_user_can('read_post', $post->ID)) {
958 958
 			the_excerpt();
959 959
 		}
960 960
 
961
-		get_inline_data( $post );
961
+		get_inline_data($post);
962 962
 	}
963 963
 
964 964
 	/**
@@ -971,39 +971,39 @@  discard block
 block discarded – undo
971 971
 	 *
972 972
 	 * @param WP_Post $post The current WP_Post object.
973 973
 	 */
974
-	public function column_date( $post ) {
974
+	public function column_date($post) {
975 975
 		global $mode;
976 976
 
977
-		if ( '0000-00-00 00:00:00' === $post->post_date ) {
978
-			$t_time = $h_time = __( 'Unpublished' );
977
+		if ('0000-00-00 00:00:00' === $post->post_date) {
978
+			$t_time = $h_time = __('Unpublished');
979 979
 			$time_diff = 0;
980 980
 		} else {
981
-			$t_time = get_the_time( __( 'Y/m/d g:i:s a' ) );
981
+			$t_time = get_the_time(__('Y/m/d g:i:s a'));
982 982
 			$m_time = $post->post_date;
983
-			$time = get_post_time( 'G', true, $post );
983
+			$time = get_post_time('G', true, $post);
984 984
 
985 985
 			$time_diff = time() - $time;
986 986
 
987
-			if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) {
988
-				$h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
987
+			if ($time_diff > 0 && $time_diff < DAY_IN_SECONDS) {
988
+				$h_time = sprintf(__('%s ago'), human_time_diff($time));
989 989
 			} else {
990
-				$h_time = mysql2date( __( 'Y/m/d' ), $m_time );
990
+				$h_time = mysql2date(__('Y/m/d'), $m_time);
991 991
 			}
992 992
 		}
993 993
 
994
-		if ( 'publish' === $post->post_status ) {
995
-			_e( 'Published' );
996
-		} elseif ( 'future' === $post->post_status ) {
997
-			if ( $time_diff > 0 ) {
998
-				echo '<strong class="error-message">' . __( 'Missed schedule' ) . '</strong>';
994
+		if ('publish' === $post->post_status) {
995
+			_e('Published');
996
+		} elseif ('future' === $post->post_status) {
997
+			if ($time_diff > 0) {
998
+				echo '<strong class="error-message">'.__('Missed schedule').'</strong>';
999 999
 			} else {
1000
-				_e( 'Scheduled' );
1000
+				_e('Scheduled');
1001 1001
 			}
1002 1002
 		} else {
1003
-			_e( 'Last Modified' );
1003
+			_e('Last Modified');
1004 1004
 		}
1005 1005
 		echo '<br />';
1006
-		if ( 'excerpt' === $mode ) {
1006
+		if ('excerpt' === $mode) {
1007 1007
 			/**
1008 1008
 			 * Filters the published time of the post.
1009 1009
 			 *
@@ -1018,11 +1018,11 @@  discard block
 block discarded – undo
1018 1018
 			 * @param string  $column_name The column name.
1019 1019
 			 * @param string  $mode        The list display mode ('excerpt' or 'list').
1020 1020
 			 */
1021
-			echo apply_filters( 'post_date_column_time', $t_time, $post, 'date', $mode );
1021
+			echo apply_filters('post_date_column_time', $t_time, $post, 'date', $mode);
1022 1022
 		} else {
1023 1023
 
1024 1024
 			/** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */
1025
-			echo '<abbr title="' . $t_time . '">' . apply_filters( 'post_date_column_time', $h_time, $post, 'date', $mode ) . '</abbr>';
1025
+			echo '<abbr title="'.$t_time.'">'.apply_filters('post_date_column_time', $h_time, $post, 'date', $mode).'</abbr>';
1026 1026
 		}
1027 1027
 	}
1028 1028
 
@@ -1034,13 +1034,13 @@  discard block
 block discarded – undo
1034 1034
 	 *
1035 1035
 	 * @param WP_Post $post The current WP_Post object.
1036 1036
 	 */
1037
-	public function column_comments( $post ) {
1037
+	public function column_comments($post) {
1038 1038
 		?>
1039 1039
 		<div class="post-com-count-wrapper">
1040 1040
 		<?php
1041
-			$pending_comments = isset( $this->comment_pending_count[$post->ID] ) ? $this->comment_pending_count[$post->ID] : 0;
1041
+			$pending_comments = isset($this->comment_pending_count[$post->ID]) ? $this->comment_pending_count[$post->ID] : 0;
1042 1042
 
1043
-			$this->comments_bubble( $post->ID, $pending_comments );
1043
+			$this->comments_bubble($post->ID, $pending_comments);
1044 1044
 		?>
1045 1045
 		</div>
1046 1046
 		<?php
@@ -1054,12 +1054,12 @@  discard block
 block discarded – undo
1054 1054
 	 *
1055 1055
 	 * @param WP_Post $post The current WP_Post object.
1056 1056
 	 */
1057
-	public function column_author( $post ) {
1057
+	public function column_author($post) {
1058 1058
 		$args = array(
1059 1059
 			'post_type' => $post->post_type,
1060
-			'author' => get_the_author_meta( 'ID' )
1060
+			'author' => get_the_author_meta('ID')
1061 1061
 		);
1062
-		echo $this->get_edit_link( $args, get_the_author() );
1062
+		echo $this->get_edit_link($args, get_the_author());
1063 1063
 	}
1064 1064
 
1065 1065
 	/**
@@ -1071,45 +1071,45 @@  discard block
 block discarded – undo
1071 1071
 	 * @param WP_Post $post        The current WP_Post object.
1072 1072
 	 * @param string  $column_name The current column name.
1073 1073
 	 */
1074
-	public function column_default( $post, $column_name ) {
1075
-		if ( 'categories' === $column_name ) {
1074
+	public function column_default($post, $column_name) {
1075
+		if ('categories' === $column_name) {
1076 1076
 			$taxonomy = 'category';
1077
-		} elseif ( 'tags' === $column_name ) {
1077
+		} elseif ('tags' === $column_name) {
1078 1078
 			$taxonomy = 'post_tag';
1079
-		} elseif ( 0 === strpos( $column_name, 'taxonomy-' ) ) {
1080
-			$taxonomy = substr( $column_name, 9 );
1079
+		} elseif (0 === strpos($column_name, 'taxonomy-')) {
1080
+			$taxonomy = substr($column_name, 9);
1081 1081
 		} else {
1082 1082
 			$taxonomy = false;
1083 1083
 		}
1084
-		if ( $taxonomy ) {
1085
-			$taxonomy_object = get_taxonomy( $taxonomy );
1086
-			$terms = get_the_terms( $post->ID, $taxonomy );
1087
-			if ( is_array( $terms ) ) {
1084
+		if ($taxonomy) {
1085
+			$taxonomy_object = get_taxonomy($taxonomy);
1086
+			$terms = get_the_terms($post->ID, $taxonomy);
1087
+			if (is_array($terms)) {
1088 1088
 				$out = array();
1089
-				foreach ( $terms as $t ) {
1089
+				foreach ($terms as $t) {
1090 1090
 					$posts_in_term_qv = array();
1091
-					if ( 'post' != $post->post_type ) {
1091
+					if ('post' != $post->post_type) {
1092 1092
 						$posts_in_term_qv['post_type'] = $post->post_type;
1093 1093
 					}
1094
-					if ( $taxonomy_object->query_var ) {
1095
-						$posts_in_term_qv[ $taxonomy_object->query_var ] = $t->slug;
1094
+					if ($taxonomy_object->query_var) {
1095
+						$posts_in_term_qv[$taxonomy_object->query_var] = $t->slug;
1096 1096
 					} else {
1097 1097
 						$posts_in_term_qv['taxonomy'] = $taxonomy;
1098 1098
 						$posts_in_term_qv['term'] = $t->slug;
1099 1099
 					}
1100 1100
 
1101
-					$label = esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) );
1102
-					$out[] = $this->get_edit_link( $posts_in_term_qv, $label );
1101
+					$label = esc_html(sanitize_term_field('name', $t->name, $t->term_id, $taxonomy, 'display'));
1102
+					$out[] = $this->get_edit_link($posts_in_term_qv, $label);
1103 1103
 				}
1104 1104
 				/* translators: used between list items, there is a space after the comma */
1105
-				echo join( __( ', ' ), $out );
1105
+				echo join(__(', '), $out);
1106 1106
 			} else {
1107
-				echo '<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">' . $taxonomy_object->labels->no_terms . '</span>';
1107
+				echo '<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">'.$taxonomy_object->labels->no_terms.'</span>';
1108 1108
 			}
1109 1109
 			return;
1110 1110
 		}
1111 1111
 
1112
-		if ( is_post_type_hierarchical( $post->post_type ) ) {
1112
+		if (is_post_type_hierarchical($post->post_type)) {
1113 1113
 
1114 1114
 			/**
1115 1115
 			 * Fires in each custom column on the Posts list table.
@@ -1122,7 +1122,7 @@  discard block
 block discarded – undo
1122 1122
 			 * @param string $column_name The name of the column to display.
1123 1123
 			 * @param int    $post_id     The current post ID.
1124 1124
 			 */
1125
-			do_action( 'manage_pages_custom_column', $column_name, $post->ID );
1125
+			do_action('manage_pages_custom_column', $column_name, $post->ID);
1126 1126
 		} else {
1127 1127
 
1128 1128
 			/**
@@ -1136,7 +1136,7 @@  discard block
 block discarded – undo
1136 1136
 			 * @param string $column_name The name of the column to display.
1137 1137
 			 * @param int    $post_id     The current post ID.
1138 1138
 			 */
1139
-			do_action( 'manage_posts_custom_column', $column_name, $post->ID );
1139
+			do_action('manage_posts_custom_column', $column_name, $post->ID);
1140 1140
 		}
1141 1141
 
1142 1142
 		/**
@@ -1149,7 +1149,7 @@  discard block
 block discarded – undo
1149 1149
 		 * @param string $column_name The name of the column to display.
1150 1150
 		 * @param int    $post_id     The current post ID.
1151 1151
 		 */
1152
-		do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID );
1152
+		do_action("manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID);
1153 1153
 	}
1154 1154
 
1155 1155
 	/**
@@ -1158,31 +1158,31 @@  discard block
 block discarded – undo
1158 1158
 	 * @param int|WP_Post $post
1159 1159
 	 * @param int         $level
1160 1160
 	 */
1161
-	public function single_row( $post, $level = 0 ) {
1161
+	public function single_row($post, $level = 0) {
1162 1162
 		$global_post = get_post();
1163 1163
 
1164
-		$post = get_post( $post );
1164
+		$post = get_post($post);
1165 1165
 		$this->current_level = $level;
1166 1166
 
1167 1167
 		$GLOBALS['post'] = $post;
1168
-		setup_postdata( $post );
1168
+		setup_postdata($post);
1169 1169
 
1170
-		$classes = 'iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' );
1170
+		$classes = 'iedit author-'.(get_current_user_id() == $post->post_author ? 'self' : 'other');
1171 1171
 
1172
-		$lock_holder = wp_check_post_lock( $post->ID );
1173
-		if ( $lock_holder ) {
1172
+		$lock_holder = wp_check_post_lock($post->ID);
1173
+		if ($lock_holder) {
1174 1174
 			$classes .= ' wp-locked';
1175 1175
 		}
1176 1176
 
1177
-		if ( $post->post_parent ) {
1178
-		    $count = count( get_post_ancestors( $post->ID ) );
1179
-		    $classes .= ' level-'. $count;
1177
+		if ($post->post_parent) {
1178
+		    $count = count(get_post_ancestors($post->ID));
1179
+		    $classes .= ' level-'.$count;
1180 1180
 		} else {
1181 1181
 		    $classes .= ' level-0';
1182 1182
 		}
1183 1183
 	?>
1184
-		<tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>">
1185
-			<?php $this->single_row_columns( $post ); ?>
1184
+		<tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode(' ', get_post_class($classes, $post->ID)); ?>">
1185
+			<?php $this->single_row_columns($post); ?>
1186 1186
 		</tr>
1187 1187
 	<?php
1188 1188
 		$GLOBALS['post'] = $global_post;
@@ -1211,85 +1211,85 @@  discard block
 block discarded – undo
1211 1211
 	 * @param string $primary     Primary column name.
1212 1212
 	 * @return string Row actions output for posts.
1213 1213
 	 */
1214
-	protected function handle_row_actions( $post, $column_name, $primary ) {
1215
-		if ( $primary !== $column_name ) {
1214
+	protected function handle_row_actions($post, $column_name, $primary) {
1215
+		if ($primary !== $column_name) {
1216 1216
 			return '';
1217 1217
 		}
1218 1218
 
1219
-		$post_type_object = get_post_type_object( $post->post_type );
1220
-		$can_edit_post = current_user_can( 'edit_post', $post->ID );
1219
+		$post_type_object = get_post_type_object($post->post_type);
1220
+		$can_edit_post = current_user_can('edit_post', $post->ID);
1221 1221
 		$actions = array();
1222 1222
 		$title = _draft_or_post_title();
1223 1223
 
1224
-		if ( $can_edit_post && 'trash' != $post->post_status ) {
1224
+		if ($can_edit_post && 'trash' != $post->post_status) {
1225 1225
 			$actions['edit'] = sprintf(
1226 1226
 				'<a href="%s" aria-label="%s">%s</a>',
1227
-				get_edit_post_link( $post->ID ),
1227
+				get_edit_post_link($post->ID),
1228 1228
 				/* translators: %s: post title */
1229
-				esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ),
1230
-				__( 'Edit' )
1229
+				esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $title)),
1230
+				__('Edit')
1231 1231
 			);
1232 1232
 			$actions['inline hide-if-no-js'] = sprintf(
1233 1233
 				'<a href="#" class="editinline" aria-label="%s">%s</a>',
1234 1234
 				/* translators: %s: post title */
1235
-				esc_attr( sprintf( __( 'Quick edit &#8220;%s&#8221; inline' ), $title ) ),
1236
-				__( 'Quick&nbsp;Edit' )
1235
+				esc_attr(sprintf(__('Quick edit &#8220;%s&#8221; inline'), $title)),
1236
+				__('Quick&nbsp;Edit')
1237 1237
 			);
1238 1238
 		}
1239 1239
 
1240
-		if ( current_user_can( 'delete_post', $post->ID ) ) {
1241
-			if ( 'trash' === $post->post_status ) {
1240
+		if (current_user_can('delete_post', $post->ID)) {
1241
+			if ('trash' === $post->post_status) {
1242 1242
 				$actions['untrash'] = sprintf(
1243 1243
 					'<a href="%s" aria-label="%s">%s</a>',
1244
-					wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&amp;action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ),
1244
+					wp_nonce_url(admin_url(sprintf($post_type_object->_edit_link.'&amp;action=untrash', $post->ID)), 'untrash-post_'.$post->ID),
1245 1245
 					/* translators: %s: post title */
1246
-					esc_attr( sprintf( __( 'Restore &#8220;%s&#8221; from the Trash' ), $title ) ),
1247
-					__( 'Restore' )
1246
+					esc_attr(sprintf(__('Restore &#8220;%s&#8221; from the Trash'), $title)),
1247
+					__('Restore')
1248 1248
 				);
1249
-			} elseif ( EMPTY_TRASH_DAYS ) {
1249
+			} elseif (EMPTY_TRASH_DAYS) {
1250 1250
 				$actions['trash'] = sprintf(
1251 1251
 					'<a href="%s" class="submitdelete" aria-label="%s">%s</a>',
1252
-					get_delete_post_link( $post->ID ),
1252
+					get_delete_post_link($post->ID),
1253 1253
 					/* translators: %s: post title */
1254
-					esc_attr( sprintf( __( 'Move &#8220;%s&#8221; to the Trash' ), $title ) ),
1255
-					_x( 'Trash', 'verb' )
1254
+					esc_attr(sprintf(__('Move &#8220;%s&#8221; to the Trash'), $title)),
1255
+					_x('Trash', 'verb')
1256 1256
 				);
1257 1257
 			}
1258
-			if ( 'trash' === $post->post_status || ! EMPTY_TRASH_DAYS ) {
1258
+			if ('trash' === $post->post_status || ! EMPTY_TRASH_DAYS) {
1259 1259
 				$actions['delete'] = sprintf(
1260 1260
 					'<a href="%s" class="submitdelete" aria-label="%s">%s</a>',
1261
-					get_delete_post_link( $post->ID, '', true ),
1261
+					get_delete_post_link($post->ID, '', true),
1262 1262
 					/* translators: %s: post title */
1263
-					esc_attr( sprintf( __( 'Delete &#8220;%s&#8221; permanently' ), $title ) ),
1264
-					__( 'Delete Permanently' )
1263
+					esc_attr(sprintf(__('Delete &#8220;%s&#8221; permanently'), $title)),
1264
+					__('Delete Permanently')
1265 1265
 				);
1266 1266
 			}
1267 1267
 		}
1268 1268
 
1269
-		if ( is_post_type_viewable( $post_type_object ) ) {
1270
-			if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) {
1271
-				if ( $can_edit_post ) {
1272
-					$preview_link = get_preview_post_link( $post );
1269
+		if (is_post_type_viewable($post_type_object)) {
1270
+			if (in_array($post->post_status, array('pending', 'draft', 'future'))) {
1271
+				if ($can_edit_post) {
1272
+					$preview_link = get_preview_post_link($post);
1273 1273
 					$actions['view'] = sprintf(
1274 1274
 						'<a href="%s" rel="permalink" aria-label="%s">%s</a>',
1275
-						esc_url( $preview_link ),
1275
+						esc_url($preview_link),
1276 1276
 						/* translators: %s: post title */
1277
-						esc_attr( sprintf( __( 'Preview &#8220;%s&#8221;' ), $title ) ),
1278
-						__( 'Preview' )
1277
+						esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $title)),
1278
+						__('Preview')
1279 1279
 					);
1280 1280
 				}
1281
-			} elseif ( 'trash' != $post->post_status ) {
1281
+			} elseif ('trash' != $post->post_status) {
1282 1282
 				$actions['view'] = sprintf(
1283 1283
 					'<a href="%s" rel="permalink" aria-label="%s">%s</a>',
1284
-					get_permalink( $post->ID ),
1284
+					get_permalink($post->ID),
1285 1285
 					/* translators: %s: post title */
1286
-					esc_attr( sprintf( __( 'View &#8220;%s&#8221;' ), $title ) ),
1287
-					__( 'View' )
1286
+					esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)),
1287
+					__('View')
1288 1288
 				);
1289 1289
 			}
1290 1290
 		}
1291 1291
 
1292
-		if ( is_post_type_hierarchical( $post->post_type ) ) {
1292
+		if (is_post_type_hierarchical($post->post_type)) {
1293 1293
 
1294 1294
 			/**
1295 1295
 			 * Filters the array of row action links on the Pages list table.
@@ -1303,7 +1303,7 @@  discard block
 block discarded – undo
1303 1303
 			 *                         'Delete Permanently', 'Preview', and 'View'.
1304 1304
 			 * @param WP_Post $post The post object.
1305 1305
 			 */
1306
-			$actions = apply_filters( 'page_row_actions', $actions, $post );
1306
+			$actions = apply_filters('page_row_actions', $actions, $post);
1307 1307
 		} else {
1308 1308
 
1309 1309
 			/**
@@ -1318,10 +1318,10 @@  discard block
 block discarded – undo
1318 1318
 			 *                         'Delete Permanently', 'Preview', and 'View'.
1319 1319
 			 * @param WP_Post $post The post object.
1320 1320
 			 */
1321
-			$actions = apply_filters( 'post_row_actions', $actions, $post );
1321
+			$actions = apply_filters('post_row_actions', $actions, $post);
1322 1322
 		}
1323 1323
 
1324
-		return $this->row_actions( $actions );
1324
+		return $this->row_actions($actions);
1325 1325
 	}
1326 1326
 
1327 1327
 	/**
@@ -1336,15 +1336,15 @@  discard block
 block discarded – undo
1336 1336
 
1337 1337
 		$screen = $this->screen;
1338 1338
 
1339
-		$post = get_default_post_to_edit( $screen->post_type );
1340
-		$post_type_object = get_post_type_object( $screen->post_type );
1339
+		$post = get_default_post_to_edit($screen->post_type);
1340
+		$post_type_object = get_post_type_object($screen->post_type);
1341 1341
 
1342
-		$taxonomy_names = get_object_taxonomies( $screen->post_type );
1342
+		$taxonomy_names = get_object_taxonomies($screen->post_type);
1343 1343
 		$hierarchical_taxonomies = array();
1344 1344
 		$flat_taxonomies = array();
1345
-		foreach ( $taxonomy_names as $taxonomy_name ) {
1345
+		foreach ($taxonomy_names as $taxonomy_name) {
1346 1346
 
1347
-			$taxonomy = get_taxonomy( $taxonomy_name );
1347
+			$taxonomy = get_taxonomy($taxonomy_name);
1348 1348
 
1349 1349
 			$show_in_quick_edit = $taxonomy->show_in_quick_edit;
1350 1350
 
@@ -1357,39 +1357,39 @@  discard block
 block discarded – undo
1357 1357
 			 * @param string $taxonomy_name      Taxonomy name.
1358 1358
 			 * @param string $post_type          Post type of current Quick Edit post.
1359 1359
 			 */
1360
-			if ( ! apply_filters( 'quick_edit_show_taxonomy', $show_in_quick_edit, $taxonomy_name, $screen->post_type ) ) {
1360
+			if ( ! apply_filters('quick_edit_show_taxonomy', $show_in_quick_edit, $taxonomy_name, $screen->post_type)) {
1361 1361
 				continue;
1362 1362
 			}
1363 1363
 
1364
-			if ( $taxonomy->hierarchical )
1364
+			if ($taxonomy->hierarchical)
1365 1365
 				$hierarchical_taxonomies[] = $taxonomy;
1366 1366
 			else
1367 1367
 				$flat_taxonomies[] = $taxonomy;
1368 1368
 		}
1369 1369
 
1370
-		$m = ( isset( $mode ) && 'excerpt' === $mode ) ? 'excerpt' : 'list';
1371
-		$can_publish = current_user_can( $post_type_object->cap->publish_posts );
1372
-		$core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true );
1370
+		$m = (isset($mode) && 'excerpt' === $mode) ? 'excerpt' : 'list';
1371
+		$can_publish = current_user_can($post_type_object->cap->publish_posts);
1372
+		$core_columns = array('cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true);
1373 1373
 
1374 1374
 	?>
1375 1375
 
1376 1376
 	<form method="get"><table style="display: none"><tbody id="inlineedit">
1377 1377
 		<?php
1378
-		$hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page';
1378
+		$hclass = count($hierarchical_taxonomies) ? 'post' : 'page';
1379 1379
 		$bulk = 0;
1380
-		while ( $bulk < 2 ) { ?>
1380
+		while ($bulk < 2) { ?>
1381 1381
 
1382
-		<tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-" . $screen->post_type;
1382
+		<tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-".$screen->post_type;
1383 1383
 			echo $bulk ? " bulk-edit-row bulk-edit-row-$hclass bulk-edit-{$screen->post_type}" : " quick-edit-row quick-edit-row-$hclass inline-edit-{$screen->post_type}";
1384 1384
 		?>" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
1385 1385
 
1386 1386
 		<fieldset class="inline-edit-col-left">
1387
-			<legend class="inline-edit-legend"><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></legend>
1387
+			<legend class="inline-edit-legend"><?php echo $bulk ? __('Bulk Edit') : __('Quick Edit'); ?></legend>
1388 1388
 			<div class="inline-edit-col">
1389 1389
 	<?php
1390 1390
 
1391
-	if ( post_type_supports( $screen->post_type, 'title' ) ) :
1392
-		if ( $bulk ) : ?>
1391
+	if (post_type_supports($screen->post_type, 'title')) :
1392
+		if ($bulk) : ?>
1393 1393
 			<div id="bulk-title-div">
1394 1394
 				<div id="bulk-titles"></div>
1395 1395
 			</div>
@@ -1397,30 +1397,30 @@  discard block
 block discarded – undo
1397 1397
 	<?php else : // $bulk ?>
1398 1398
 
1399 1399
 			<label>
1400
-				<span class="title"><?php _e( 'Title' ); ?></span>
1400
+				<span class="title"><?php _e('Title'); ?></span>
1401 1401
 				<span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span>
1402 1402
 			</label>
1403 1403
 
1404 1404
 			<label>
1405
-				<span class="title"><?php _e( 'Slug' ); ?></span>
1405
+				<span class="title"><?php _e('Slug'); ?></span>
1406 1406
 				<span class="input-text-wrap"><input type="text" name="post_name" value="" /></span>
1407 1407
 			</label>
1408 1408
 
1409 1409
 	<?php endif; // $bulk
1410 1410
 	endif; // post_type_supports title ?>
1411 1411
 
1412
-	<?php if ( !$bulk ) : ?>
1412
+	<?php if ( ! $bulk) : ?>
1413 1413
 			<fieldset class="inline-edit-date">
1414
-			<legend><span class="title"><?php _e( 'Date' ); ?></span></legend>
1415
-				<?php touch_time( 1, 1, 0, 1 ); ?>
1414
+			<legend><span class="title"><?php _e('Date'); ?></span></legend>
1415
+				<?php touch_time(1, 1, 0, 1); ?>
1416 1416
 			</fieldset>
1417 1417
 			<br class="clear" />
1418 1418
 	<?php endif; // $bulk
1419 1419
 
1420
-		if ( post_type_supports( $screen->post_type, 'author' ) ) :
1420
+		if (post_type_supports($screen->post_type, 'author')) :
1421 1421
 			$authors_dropdown = '';
1422 1422
 
1423
-			if ( current_user_can( $post_type_object->cap->edit_others_posts ) ) :
1423
+			if (current_user_can($post_type_object->cap->edit_others_posts)) :
1424 1424
 				$users_opt = array(
1425 1425
 					'hide_if_only_one_author' => false,
1426 1426
 					'who' => 'authors',
@@ -1430,39 +1430,39 @@  discard block
 block discarded – undo
1430 1430
 					'echo' => 0,
1431 1431
 					'show' => 'display_name_with_login',
1432 1432
 				);
1433
-				if ( $bulk )
1434
-					$users_opt['show_option_none'] = __( '&mdash; No Change &mdash;' );
1433
+				if ($bulk)
1434
+					$users_opt['show_option_none'] = __('&mdash; No Change &mdash;');
1435 1435
 
1436
-				if ( $authors = wp_dropdown_users( $users_opt ) ) :
1436
+				if ($authors = wp_dropdown_users($users_opt)) :
1437 1437
 					$authors_dropdown  = '<label class="inline-edit-author">';
1438
-					$authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>';
1438
+					$authors_dropdown .= '<span class="title">'.__('Author').'</span>';
1439 1439
 					$authors_dropdown .= $authors;
1440 1440
 					$authors_dropdown .= '</label>';
1441 1441
 				endif;
1442 1442
 			endif; // authors
1443 1443
 	?>
1444 1444
 
1445
-	<?php if ( !$bulk ) echo $authors_dropdown;
1445
+	<?php if ( ! $bulk) echo $authors_dropdown;
1446 1446
 	endif; // post_type_supports author
1447 1447
 
1448
-	if ( !$bulk && $can_publish ) :
1448
+	if ( ! $bulk && $can_publish) :
1449 1449
 	?>
1450 1450
 
1451 1451
 			<div class="inline-edit-group wp-clearfix">
1452 1452
 				<label class="alignleft">
1453
-					<span class="title"><?php _e( 'Password' ); ?></span>
1453
+					<span class="title"><?php _e('Password'); ?></span>
1454 1454
 					<span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span>
1455 1455
 				</label>
1456 1456
 
1457 1457
 				<em class="alignleft inline-edit-or">
1458 1458
 					<?php
1459 1459
 					/* translators: Between password field and private checkbox on post quick edit interface */
1460
-					_e( '&ndash;OR&ndash;' );
1460
+					_e('&ndash;OR&ndash;');
1461 1461
 					?>
1462 1462
 				</em>
1463 1463
 				<label class="alignleft inline-edit-private">
1464 1464
 					<input type="checkbox" name="keep_private" value="private" />
1465
-					<span class="checkbox-title"><?php _e( 'Private' ); ?></span>
1465
+					<span class="checkbox-title"><?php _e('Private'); ?></span>
1466 1466
 				</label>
1467 1467
 			</div>
1468 1468
 
@@ -1470,16 +1470,16 @@  discard block
 block discarded – undo
1470 1470
 
1471 1471
 		</div></fieldset>
1472 1472
 
1473
-	<?php if ( count( $hierarchical_taxonomies ) && !$bulk ) : ?>
1473
+	<?php if (count($hierarchical_taxonomies) && ! $bulk) : ?>
1474 1474
 
1475 1475
 		<fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col">
1476 1476
 
1477
-	<?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?>
1477
+	<?php foreach ($hierarchical_taxonomies as $taxonomy) : ?>
1478 1478
 
1479
-			<span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ) ?></span>
1480
-			<input type="hidden" name="<?php echo ( $taxonomy->name === 'category' ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" />
1481
-			<ul class="cat-checklist <?php echo esc_attr( $taxonomy->name )?>-checklist">
1482
-				<?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ) ?>
1479
+			<span class="title inline-edit-categories-label"><?php echo esc_html($taxonomy->labels->name) ?></span>
1480
+			<input type="hidden" name="<?php echo ($taxonomy->name === 'category') ? 'post_category[]' : 'tax_input['.esc_attr($taxonomy->name).'][]'; ?>" value="0" />
1481
+			<ul class="cat-checklist <?php echo esc_attr($taxonomy->name)?>-checklist">
1482
+				<?php wp_terms_checklist(null, array('taxonomy' => $taxonomy->name)) ?>
1483 1483
 			</ul>
1484 1484
 
1485 1485
 	<?php endforeach; //$hierarchical_taxonomies as $taxonomy ?>
@@ -1491,27 +1491,27 @@  discard block
 block discarded – undo
1491 1491
 		<fieldset class="inline-edit-col-right"><div class="inline-edit-col">
1492 1492
 
1493 1493
 	<?php
1494
-		if ( post_type_supports( $screen->post_type, 'author' ) && $bulk )
1494
+		if (post_type_supports($screen->post_type, 'author') && $bulk)
1495 1495
 			echo $authors_dropdown;
1496 1496
 
1497
-		if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) :
1497
+		if (post_type_supports($screen->post_type, 'page-attributes')) :
1498 1498
 
1499
-			if ( $post_type_object->hierarchical ) :
1499
+			if ($post_type_object->hierarchical) :
1500 1500
 		?>
1501 1501
 			<label>
1502
-				<span class="title"><?php _e( 'Parent' ); ?></span>
1502
+				<span class="title"><?php _e('Parent'); ?></span>
1503 1503
 	<?php
1504 1504
 		$dropdown_args = array(
1505 1505
 			'post_type'         => $post_type_object->name,
1506 1506
 			'selected'          => $post->post_parent,
1507 1507
 			'name'              => 'post_parent',
1508
-			'show_option_none'  => __( 'Main Page (no parent)' ),
1508
+			'show_option_none'  => __('Main Page (no parent)'),
1509 1509
 			'option_none_value' => 0,
1510 1510
 			'sort_column'       => 'menu_order, post_title',
1511 1511
 		);
1512 1512
 
1513
-		if ( $bulk )
1514
-			$dropdown_args['show_option_no_change'] =  __( '&mdash; No Change &mdash;' );
1513
+		if ($bulk)
1514
+			$dropdown_args['show_option_no_change'] = __('&mdash; No Change &mdash;');
1515 1515
 
1516 1516
 		/**
1517 1517
 		 * Filters the arguments used to generate the Quick Edit page-parent drop-down.
@@ -1522,19 +1522,19 @@  discard block
 block discarded – undo
1522 1522
 		 *
1523 1523
 		 * @param array $dropdown_args An array of arguments.
1524 1524
 		 */
1525
-		$dropdown_args = apply_filters( 'quick_edit_dropdown_pages_args', $dropdown_args );
1525
+		$dropdown_args = apply_filters('quick_edit_dropdown_pages_args', $dropdown_args);
1526 1526
 
1527
-		wp_dropdown_pages( $dropdown_args );
1527
+		wp_dropdown_pages($dropdown_args);
1528 1528
 	?>
1529 1529
 			</label>
1530 1530
 
1531 1531
 	<?php
1532 1532
 			endif; // hierarchical
1533 1533
 
1534
-			if ( !$bulk ) : ?>
1534
+			if ( ! $bulk) : ?>
1535 1535
 
1536 1536
 			<label>
1537
-				<span class="title"><?php _e( 'Order' ); ?></span>
1537
+				<span class="title"><?php _e('Order'); ?></span>
1538 1538
 				<span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span>
1539 1539
 			</label>
1540 1540
 
@@ -1543,32 +1543,32 @@  discard block
 block discarded – undo
1543 1543
 		endif; // page-attributes
1544 1544
 	?>
1545 1545
 
1546
-	<?php if ( 0 < count( get_page_templates( null, $screen->post_type ) ) ) : ?>
1546
+	<?php if (0 < count(get_page_templates(null, $screen->post_type))) : ?>
1547 1547
 		<label>
1548
-			<span class="title"><?php _e( 'Template' ); ?></span>
1548
+			<span class="title"><?php _e('Template'); ?></span>
1549 1549
 			<select name="page_template">
1550
-<?php	if ( $bulk ) : ?>
1551
-				<option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
1550
+<?php	if ($bulk) : ?>
1551
+				<option value="-1"><?php _e('&mdash; No Change &mdash;'); ?></option>
1552 1552
 <?php	endif; // $bulk ?>
1553 1553
                 <?php
1554 1554
 				/** This filter is documented in wp-admin/includes/meta-boxes.php */
1555
-				$default_title = apply_filters( 'default_page_template_title',  __( 'Default Template' ), 'quick-edit' );
1555
+				$default_title = apply_filters('default_page_template_title', __('Default Template'), 'quick-edit');
1556 1556
                 ?>
1557
-				<option value="default"><?php echo esc_html( $default_title ); ?></option>
1558
-				<?php page_template_dropdown( '', $screen->post_type ) ?>
1557
+				<option value="default"><?php echo esc_html($default_title); ?></option>
1558
+				<?php page_template_dropdown('', $screen->post_type) ?>
1559 1559
 			</select>
1560 1560
 		</label>
1561 1561
 	<?php endif; ?>
1562 1562
 
1563
-	<?php if ( count( $flat_taxonomies ) && !$bulk ) : ?>
1563
+	<?php if (count($flat_taxonomies) && ! $bulk) : ?>
1564 1564
 
1565
-	<?php foreach ( $flat_taxonomies as $taxonomy ) : ?>
1566
-		<?php if ( current_user_can( $taxonomy->cap->assign_terms ) ) :
1567
-			$taxonomy_name = esc_attr( $taxonomy->name );
1565
+	<?php foreach ($flat_taxonomies as $taxonomy) : ?>
1566
+		<?php if (current_user_can($taxonomy->cap->assign_terms)) :
1567
+			$taxonomy_name = esc_attr($taxonomy->name);
1568 1568
 
1569 1569
 			?>
1570 1570
 			<label class="inline-edit-tags">
1571
-				<span class="title"><?php echo esc_html( $taxonomy->labels->name ) ?></span>
1571
+				<span class="title"><?php echo esc_html($taxonomy->labels->name) ?></span>
1572 1572
 				<textarea data-wp-taxonomy="<?php echo $taxonomy_name; ?>" cols="22" rows="1" name="tax_input[<?php echo $taxonomy_name; ?>]" class="tax_input_<?php echo $taxonomy_name; ?>"></textarea>
1573 1573
 			</label>
1574 1574
 		<?php endif; ?>
@@ -1577,26 +1577,26 @@  discard block
 block discarded – undo
1577 1577
 
1578 1578
 	<?php endif; // count( $flat_taxonomies ) && !$bulk  ?>
1579 1579
 
1580
-	<?php if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) :
1581
-		if ( $bulk ) : ?>
1580
+	<?php if (post_type_supports($screen->post_type, 'comments') || post_type_supports($screen->post_type, 'trackbacks')) :
1581
+		if ($bulk) : ?>
1582 1582
 
1583 1583
 			<div class="inline-edit-group wp-clearfix">
1584
-		<?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
1584
+		<?php if (post_type_supports($screen->post_type, 'comments')) : ?>
1585 1585
 			<label class="alignleft">
1586
-				<span class="title"><?php _e( 'Comments' ); ?></span>
1586
+				<span class="title"><?php _e('Comments'); ?></span>
1587 1587
 				<select name="comment_status">
1588
-					<option value=""><?php _e( '&mdash; No Change &mdash;' ); ?></option>
1589
-					<option value="open"><?php _e( 'Allow' ); ?></option>
1590
-					<option value="closed"><?php _e( 'Do not allow' ); ?></option>
1588
+					<option value=""><?php _e('&mdash; No Change &mdash;'); ?></option>
1589
+					<option value="open"><?php _e('Allow'); ?></option>
1590
+					<option value="closed"><?php _e('Do not allow'); ?></option>
1591 1591
 				</select>
1592 1592
 			</label>
1593
-		<?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
1593
+		<?php endif; if (post_type_supports($screen->post_type, 'trackbacks')) : ?>
1594 1594
 			<label class="alignright">
1595
-				<span class="title"><?php _e( 'Pings' ); ?></span>
1595
+				<span class="title"><?php _e('Pings'); ?></span>
1596 1596
 				<select name="ping_status">
1597
-					<option value=""><?php _e( '&mdash; No Change &mdash;' ); ?></option>
1598
-					<option value="open"><?php _e( 'Allow' ); ?></option>
1599
-					<option value="closed"><?php _e( 'Do not allow' ); ?></option>
1597
+					<option value=""><?php _e('&mdash; No Change &mdash;'); ?></option>
1598
+					<option value="open"><?php _e('Allow'); ?></option>
1599
+					<option value="closed"><?php _e('Do not allow'); ?></option>
1600 1600
 				</select>
1601 1601
 			</label>
1602 1602
 		<?php endif; ?>
@@ -1605,15 +1605,15 @@  discard block
 block discarded – undo
1605 1605
 	<?php else : // $bulk ?>
1606 1606
 
1607 1607
 			<div class="inline-edit-group wp-clearfix">
1608
-			<?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
1608
+			<?php if (post_type_supports($screen->post_type, 'comments')) : ?>
1609 1609
 				<label class="alignleft">
1610 1610
 					<input type="checkbox" name="comment_status" value="open" />
1611
-					<span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span>
1611
+					<span class="checkbox-title"><?php _e('Allow Comments'); ?></span>
1612 1612
 				</label>
1613
-			<?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
1613
+			<?php endif; if (post_type_supports($screen->post_type, 'trackbacks')) : ?>
1614 1614
 				<label class="alignleft">
1615 1615
 					<input type="checkbox" name="ping_status" value="open" />
1616
-					<span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span>
1616
+					<span class="checkbox-title"><?php _e('Allow Pings'); ?></span>
1617 1617
 				</label>
1618 1618
 			<?php endif; ?>
1619 1619
 			</div>
@@ -1623,33 +1623,33 @@  discard block
 block discarded – undo
1623 1623
 
1624 1624
 			<div class="inline-edit-group wp-clearfix">
1625 1625
 				<label class="inline-edit-status alignleft">
1626
-					<span class="title"><?php _e( 'Status' ); ?></span>
1626
+					<span class="title"><?php _e('Status'); ?></span>
1627 1627
 					<select name="_status">
1628
-	<?php if ( $bulk ) : ?>
1629
-						<option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
1628
+	<?php if ($bulk) : ?>
1629
+						<option value="-1"><?php _e('&mdash; No Change &mdash;'); ?></option>
1630 1630
 	<?php endif; // $bulk ?>
1631
-					<?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review" ?>
1632
-						<option value="publish"><?php _e( 'Published' ); ?></option>
1633
-						<option value="future"><?php _e( 'Scheduled' ); ?></option>
1634
-	<?php if ( $bulk ) : ?>
1635
-						<option value="private"><?php _e( 'Private' ) ?></option>
1631
+					<?php if ($can_publish) : // Contributors only get "Unpublished" and "Pending Review" ?>
1632
+						<option value="publish"><?php _e('Published'); ?></option>
1633
+						<option value="future"><?php _e('Scheduled'); ?></option>
1634
+	<?php if ($bulk) : ?>
1635
+						<option value="private"><?php _e('Private') ?></option>
1636 1636
 	<?php endif; // $bulk ?>
1637 1637
 					<?php endif; ?>
1638
-						<option value="pending"><?php _e( 'Pending Review' ); ?></option>
1639
-						<option value="draft"><?php _e( 'Draft' ); ?></option>
1638
+						<option value="pending"><?php _e('Pending Review'); ?></option>
1639
+						<option value="draft"><?php _e('Draft'); ?></option>
1640 1640
 					</select>
1641 1641
 				</label>
1642 1642
 
1643
-	<?php if ( 'post' === $screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?>
1643
+	<?php if ('post' === $screen->post_type && $can_publish && current_user_can($post_type_object->cap->edit_others_posts)) : ?>
1644 1644
 
1645
-	<?php	if ( $bulk ) : ?>
1645
+	<?php	if ($bulk) : ?>
1646 1646
 
1647 1647
 				<label class="alignright">
1648
-					<span class="title"><?php _e( 'Sticky' ); ?></span>
1648
+					<span class="title"><?php _e('Sticky'); ?></span>
1649 1649
 					<select name="sticky">
1650
-						<option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
1651
-						<option value="sticky"><?php _e( 'Sticky' ); ?></option>
1652
-						<option value="unsticky"><?php _e( 'Not Sticky' ); ?></option>
1650
+						<option value="-1"><?php _e('&mdash; No Change &mdash;'); ?></option>
1651
+						<option value="sticky"><?php _e('Sticky'); ?></option>
1652
+						<option value="unsticky"><?php _e('Not Sticky'); ?></option>
1653 1653
 					</select>
1654 1654
 				</label>
1655 1655
 
@@ -1657,7 +1657,7 @@  discard block
 block discarded – undo
1657 1657
 
1658 1658
 				<label class="alignleft">
1659 1659
 					<input type="checkbox" name="sticky" value="sticky" />
1660
-					<span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span>
1660
+					<span class="checkbox-title"><?php _e('Make this post sticky'); ?></span>
1661 1661
 				</label>
1662 1662
 
1663 1663
 	<?php	endif; // $bulk ?>
@@ -1668,20 +1668,20 @@  discard block
 block discarded – undo
1668 1668
 
1669 1669
 	<?php
1670 1670
 
1671
-	if ( $bulk && current_theme_supports( 'post-formats' ) && post_type_supports( $screen->post_type, 'post-formats' ) ) {
1672
-		$post_formats = get_theme_support( 'post-formats' );
1671
+	if ($bulk && current_theme_supports('post-formats') && post_type_supports($screen->post_type, 'post-formats')) {
1672
+		$post_formats = get_theme_support('post-formats');
1673 1673
 
1674 1674
 		?>
1675 1675
 		<label class="alignleft">
1676
-		<span class="title"><?php _ex( 'Format', 'post format' ); ?></span>
1676
+		<span class="title"><?php _ex('Format', 'post format'); ?></span>
1677 1677
 		<select name="post_format">
1678
-			<option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
1679
-			<option value="0"><?php echo get_post_format_string( 'standard' ); ?></option>
1678
+			<option value="-1"><?php _e('&mdash; No Change &mdash;'); ?></option>
1679
+			<option value="0"><?php echo get_post_format_string('standard'); ?></option>
1680 1680
 			<?php
1681
-			if ( is_array( $post_formats[0] ) ) {
1682
-				foreach ( $post_formats[0] as $format ) {
1681
+			if (is_array($post_formats[0])) {
1682
+				foreach ($post_formats[0] as $format) {
1683 1683
 					?>
1684
-					<option value="<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></option>
1684
+					<option value="<?php echo esc_attr($format); ?>"><?php echo esc_html(get_post_format_string($format)); ?></option>
1685 1685
 					<?php
1686 1686
 				}
1687 1687
 			}
@@ -1696,13 +1696,13 @@  discard block
 block discarded – undo
1696 1696
 		</div></fieldset>
1697 1697
 
1698 1698
 	<?php
1699
-		list( $columns ) = $this->get_column_info();
1699
+		list($columns) = $this->get_column_info();
1700 1700
 
1701
-		foreach ( $columns as $column_name => $column_display_name ) {
1702
-			if ( isset( $core_columns[$column_name] ) )
1701
+		foreach ($columns as $column_name => $column_display_name) {
1702
+			if (isset($core_columns[$column_name]))
1703 1703
 				continue;
1704 1704
 
1705
-			if ( $bulk ) {
1705
+			if ($bulk) {
1706 1706
 
1707 1707
 				/**
1708 1708
 				 * Fires once for each column in Bulk Edit mode.
@@ -1712,7 +1712,7 @@  discard block
 block discarded – undo
1712 1712
 				 * @param string  $column_name Name of the column to edit.
1713 1713
 				 * @param WP_Post $post_type   The post type slug.
1714 1714
 				 */
1715
-				do_action( 'bulk_edit_custom_box', $column_name, $screen->post_type );
1715
+				do_action('bulk_edit_custom_box', $column_name, $screen->post_type);
1716 1716
 			} else {
1717 1717
 
1718 1718
 				/**
@@ -1723,25 +1723,25 @@  discard block
 block discarded – undo
1723 1723
 				 * @param string $column_name Name of the column to edit.
1724 1724
 				 * @param string $post_type   The post type slug.
1725 1725
 				 */
1726
-				do_action( 'quick_edit_custom_box', $column_name, $screen->post_type );
1726
+				do_action('quick_edit_custom_box', $column_name, $screen->post_type);
1727 1727
 			}
1728 1728
 
1729 1729
 		}
1730 1730
 	?>
1731 1731
 		<p class="submit inline-edit-save">
1732
-			<button type="button" class="button cancel alignleft"><?php _e( 'Cancel' ); ?></button>
1733
-			<?php if ( ! $bulk ) {
1734
-				wp_nonce_field( 'inlineeditnonce', '_inline_edit', false );
1732
+			<button type="button" class="button cancel alignleft"><?php _e('Cancel'); ?></button>
1733
+			<?php if ( ! $bulk) {
1734
+				wp_nonce_field('inlineeditnonce', '_inline_edit', false);
1735 1735
 				?>
1736
-				<button type="button" class="button button-primary save alignright"><?php _e( 'Update' ); ?></button>
1736
+				<button type="button" class="button button-primary save alignright"><?php _e('Update'); ?></button>
1737 1737
 				<span class="spinner"></span>
1738 1738
 			<?php } else {
1739
-				submit_button( __( 'Update' ), 'primary alignright', 'bulk_edit', false );
1739
+				submit_button(__('Update'), 'primary alignright', 'bulk_edit', false);
1740 1740
 			} ?>
1741
-			<input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" />
1742
-			<input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" />
1743
-			<?php if ( ! $bulk && ! post_type_supports( $screen->post_type, 'author' ) ) { ?>
1744
-				<input type="hidden" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" />
1741
+			<input type="hidden" name="post_view" value="<?php echo esc_attr($m); ?>" />
1742
+			<input type="hidden" name="screen" value="<?php echo esc_attr($screen->id); ?>" />
1743
+			<?php if ( ! $bulk && ! post_type_supports($screen->post_type, 'author')) { ?>
1744
+				<input type="hidden" name="post_author" value="<?php echo esc_attr($post->post_author); ?>" />
1745 1745
 			<?php } ?>
1746 1746
 			<span class="error" style="display:none"></span>
1747 1747
 			<br class="clear" />
Please login to merge, or discard this patch.
src/wp-admin/includes/deprecated.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -127,8 +127,8 @@
 block discarded – undo
127 127
  * @param int $currentparent Optional. Current parent category ID. Default 0.
128 128
  * @param int $parent        Optional. Parent ID to retrieve categories for. Default 0.
129 129
  * @param int $level         Optional. Number of levels deep to display. Default 0.
130
- * @param array $categories  Optional. Categories to include in the control. Default 0.
131
- * @return bool|null False if no categories were found.
130
+ * @param integer $categories  Optional. Categories to include in the control. Default 0.
131
+ * @return null|false False if no categories were found.
132 132
  */
133 133
 function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) {
134 134
 	_deprecated_function( __FUNCTION__, '3.0', 'wp_dropdown_categories()' );
Please login to merge, or discard this patch.
Braces   +83 added lines, -56 removed lines patch added patch discarded remove patch
@@ -132,8 +132,9 @@  discard block
 block discarded – undo
132 132
  */
133 133
 function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) {
134 134
 	_deprecated_function( __FUNCTION__, '3.0', 'wp_dropdown_categories()' );
135
-	if (!$categories )
136
-		$categories = get_categories( array('hide_empty' => 0) );
135
+	if (!$categories ) {
136
+			$categories = get_categories( array('hide_empty' => 0) );
137
+	}
137 138
 
138 139
 	if ( $categories ) {
139 140
 		foreach ( $categories as $category ) {
@@ -141,8 +142,9 @@  discard block
 block discarded – undo
141 142
 				$pad = str_repeat( '&#8211; ', $level );
142 143
 				$category->name = esc_html( $category->name );
143 144
 				echo "\n\t<option value='$category->term_id'";
144
-				if ( $currentparent == $category->term_id )
145
-					echo " selected='selected'";
145
+				if ( $currentparent == $category->term_id ) {
146
+									echo " selected='selected'";
147
+				}
146 148
 				echo ">$pad$category->name</option>";
147 149
 				wp_dropdown_cats( $currentcat, $currentparent, $category->term_id, $level +1, $categories );
148 150
 			}
@@ -228,10 +230,12 @@  discard block
 block discarded – undo
228 230
 	_deprecated_function( __FUNCTION__, '3.1', 'get_users()' );
229 231
 
230 232
 	global $wpdb;
231
-	if ( !is_multisite() )
232
-		$level_key = $wpdb->get_blog_prefix() . 'user_level';
233
-	else
234
-		$level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
233
+	if ( !is_multisite() ) {
234
+			$level_key = $wpdb->get_blog_prefix() . 'user_level';
235
+	} else {
236
+			$level_key = $wpdb->get_blog_prefix() . 'capabilities';
237
+	}
238
+	// wpmu site admins don't have user_levels
235 239
 
236 240
 	return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value != '0'", $level_key) );
237 241
 }
@@ -275,25 +279,30 @@  discard block
 block discarded – undo
275 279
 
276 280
 	global $wpdb;
277 281
 
278
-	if ( ! $user = get_userdata( $user_id ) )
279
-		return array();
282
+	if ( ! $user = get_userdata( $user_id ) ) {
283
+			return array();
284
+	}
280 285
 	$post_type_obj = get_post_type_object($post_type);
281 286
 
282 287
 	if ( ! $user->has_cap($post_type_obj->cap->edit_others_posts) ) {
283
-		if ( $user->has_cap($post_type_obj->cap->edit_posts) || ! $exclude_zeros )
284
-			return array($user->ID);
285
-		else
286
-			return array();
288
+		if ( $user->has_cap($post_type_obj->cap->edit_posts) || ! $exclude_zeros ) {
289
+					return array($user->ID);
290
+		} else {
291
+					return array();
292
+		}
287 293
 	}
288 294
 
289
-	if ( !is_multisite() )
290
-		$level_key = $wpdb->get_blog_prefix() . 'user_level';
291
-	else
292
-		$level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
295
+	if ( !is_multisite() ) {
296
+			$level_key = $wpdb->get_blog_prefix() . 'user_level';
297
+	} else {
298
+			$level_key = $wpdb->get_blog_prefix() . 'capabilities';
299
+	}
300
+	// wpmu site admins don't have user_levels
293 301
 
294 302
 	$query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s", $level_key);
295
-	if ( $exclude_zeros )
296
-		$query .= " AND meta_value != '0'";
303
+	if ( $exclude_zeros ) {
304
+			$query .= " AND meta_value != '0'";
305
+	}
297 306
 
298 307
 	return $wpdb->get_col( $query );
299 308
 }
@@ -308,10 +317,12 @@  discard block
 block discarded – undo
308 317
 
309 318
 	global $wpdb;
310 319
 
311
-	if ( !is_multisite() )
312
-		$level_key = $wpdb->get_blog_prefix() . 'user_level';
313
-	else
314
-		$level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
320
+	if ( !is_multisite() ) {
321
+			$level_key = $wpdb->get_blog_prefix() . 'user_level';
322
+	} else {
323
+			$level_key = $wpdb->get_blog_prefix() . 'capabilities';
324
+	}
325
+	// wpmu site admins don't have user_levels
315 326
 
316 327
 	return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) );
317 328
 }
@@ -523,8 +534,9 @@  discard block
 block discarded – undo
523 534
 		if ( $this->search_term ) {
524 535
 			$searches = array();
525 536
 			$search_sql = 'AND (';
526
-			foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col )
527
-				$searches[] = $wpdb->prepare( $col . ' LIKE %s', '%' . like_escape($this->search_term) . '%' );
537
+			foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col ) {
538
+							$searches[] = $wpdb->prepare( $col . ' LIKE %s', '%' . like_escape($this->search_term) . '%' );
539
+			}
528 540
 			$search_sql .= implode(' OR ', $searches);
529 541
 			$search_sql .= ')';
530 542
 		}
@@ -555,10 +567,13 @@  discard block
 block discarded – undo
555 567
 
556 568
 		$this->results = $wpdb->get_col("SELECT DISTINCT($wpdb->users.ID)" . $this->query_from . $this->query_where . $this->query_orderby . $this->query_limit);
557 569
 
558
-		if ( $this->results )
559
-			$this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))" . $this->query_from . $this->query_where); // no limit
560
-		else
561
-			$this->search_errors = new WP_Error('no_matching_users_found', __('No users found.'));
570
+		if ( $this->results ) {
571
+					$this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))" . $this->query_from . $this->query_where);
572
+		}
573
+		// no limit
574
+		else {
575
+					$this->search_errors = new WP_Error('no_matching_users_found', __('No users found.'));
576
+		}
562 577
 	}
563 578
 
564 579
 	/**
@@ -578,10 +593,12 @@  discard block
 block discarded – undo
578 593
 	public function do_paging() {
579 594
 		if ( $this->total_users_for_query > $this->users_per_page ) { // have to page the results
580 595
 			$args = array();
581
-			if ( ! empty($this->search_term) )
582
-				$args['usersearch'] = urlencode($this->search_term);
583
-			if ( ! empty($this->role) )
584
-				$args['role'] = urlencode($this->role);
596
+			if ( ! empty($this->search_term) ) {
597
+							$args['usersearch'] = urlencode($this->search_term);
598
+			}
599
+			if ( ! empty($this->role) ) {
600
+							$args['role'] = urlencode($this->role);
601
+			}
585 602
 
586 603
 			$this->paging_text = paginate_links( array(
587 604
 				'total' => ceil($this->total_users_for_query / $this->users_per_page),
@@ -636,8 +653,9 @@  discard block
 block discarded – undo
636 653
 	 * @return bool
637 654
 	 */
638 655
 	function results_are_paged() {
639
-		if ( $this->paging_text )
640
-			return true;
656
+		if ( $this->paging_text ) {
657
+					return true;
658
+		}
641 659
 		return false;
642 660
 	}
643 661
 
@@ -650,8 +668,9 @@  discard block
 block discarded – undo
650 668
 	 * @return bool
651 669
 	 */
652 670
 	function is_search() {
653
-		if ( $this->search_term )
654
-			return true;
671
+		if ( $this->search_term ) {
672
+					return true;
673
+		}
655 674
 		return false;
656 675
 	}
657 676
 }
@@ -676,10 +695,11 @@  discard block
 block discarded – undo
676 695
 
677 696
 	$editable = get_editable_user_ids( $user_id );
678 697
 
679
-	if ( in_array($type, array('draft', 'pending')) )
680
-		$type_sql = " post_status = '$type' ";
681
-	else
682
-		$type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) ";
698
+	if ( in_array($type, array('draft', 'pending')) ) {
699
+			$type_sql = " post_status = '$type' ";
700
+	} else {
701
+			$type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) ";
702
+	}
683 703
 
684 704
 	$dir = ( 'pending' == $type ) ? 'ASC' : 'DESC';
685 705
 
@@ -749,8 +769,9 @@  discard block
 block discarded – undo
749 769
 
750 770
 	static $num = 1;
751 771
 
752
-	if ( ! class_exists( '_WP_Editors', false ) )
753
-		require_once( ABSPATH . WPINC . '/class-wp-editor.php' );
772
+	if ( ! class_exists( '_WP_Editors', false ) ) {
773
+			require_once( ABSPATH . WPINC . '/class-wp-editor.php' );
774
+	}
754 775
 
755 776
 	$editor_id = 'content' . $num++;
756 777
 
@@ -806,8 +827,9 @@  discard block
 block discarded – undo
806 827
 
807 828
 	$current_screen = get_current_screen();
808 829
 
809
-	if ( ! $current_screen )
810
-		return '';
830
+	if ( ! $current_screen ) {
831
+			return '';
832
+	}
811 833
 
812 834
 	ob_start();
813 835
 	$current_screen->render_screen_layout();
@@ -826,8 +848,9 @@  discard block
 block discarded – undo
826 848
 
827 849
 	$current_screen = get_current_screen();
828 850
 
829
-	if ( ! $current_screen )
830
-		return '';
851
+	if ( ! $current_screen ) {
852
+			return '';
853
+	}
831 854
 
832 855
 	ob_start();
833 856
 	$current_screen->render_per_page_options();
@@ -976,8 +999,9 @@  discard block
 block discarded – undo
976 999
 function add_contextual_help( $screen, $help ) {
977 1000
 	_deprecated_function( __FUNCTION__, '3.3', 'get_current_screen()->add_help_tab()' );
978 1001
 
979
-	if ( is_string( $screen ) )
980
-		$screen = convert_to_screen( $screen );
1002
+	if ( is_string( $screen ) ) {
1003
+			$screen = convert_to_screen( $screen );
1004
+	}
981 1005
 
982 1006
 	WP_Screen::add_old_compat_help( $screen, $help );
983 1007
 }
@@ -1141,8 +1165,9 @@  discard block
 block discarded – undo
1141 1165
 function wp_update_core($current, $feedback = '') {
1142 1166
 	_deprecated_function( __FUNCTION__, '3.7', 'new Core_Upgrader();' );
1143 1167
 
1144
-	if ( !empty($feedback) )
1145
-		add_filter('update_feedback', $feedback);
1168
+	if ( !empty($feedback) ) {
1169
+			add_filter('update_feedback', $feedback);
1170
+	}
1146 1171
 
1147 1172
 	include( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
1148 1173
 	$upgrader = new Core_Upgrader();
@@ -1164,8 +1189,9 @@  discard block
 block discarded – undo
1164 1189
 function wp_update_plugin($plugin, $feedback = '') {
1165 1190
 	_deprecated_function( __FUNCTION__, '3.7', 'new Plugin_Upgrader();' );
1166 1191
 
1167
-	if ( !empty($feedback) )
1168
-		add_filter('update_feedback', $feedback);
1192
+	if ( !empty($feedback) ) {
1193
+			add_filter('update_feedback', $feedback);
1194
+	}
1169 1195
 
1170 1196
 	include( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
1171 1197
 	$upgrader = new Plugin_Upgrader();
@@ -1186,8 +1212,9 @@  discard block
 block discarded – undo
1186 1212
 function wp_update_theme($theme, $feedback = '') {
1187 1213
 	_deprecated_function( __FUNCTION__, '3.7', 'new Theme_Upgrader();' );
1188 1214
 
1189
-	if ( !empty($feedback) )
1190
-		add_filter('update_feedback', $feedback);
1215
+	if ( !empty($feedback) ) {
1216
+			add_filter('update_feedback', $feedback);
1217
+	}
1191 1218
 
1192 1219
 	include( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
1193 1220
 	$upgrader = new Theme_Upgrader();
Please login to merge, or discard this patch.
Spacing   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
  * @see wp_editor()
19 19
  */
20 20
 function tinymce_include() {
21
-	_deprecated_function( __FUNCTION__, '2.1.0', 'wp_editor()' );
21
+	_deprecated_function(__FUNCTION__, '2.1.0', 'wp_editor()');
22 22
 
23 23
 	wp_tiny_mce();
24 24
 }
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
  *
32 32
  */
33 33
 function documentation_link() {
34
-	_deprecated_function( __FUNCTION__, '2.5.0' );
34
+	_deprecated_function(__FUNCTION__, '2.5.0');
35 35
 }
36 36
 
37 37
 /**
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
  * @param int $hmax Maximum wanted height
48 48
  * @return array Shrunk dimensions (width, height).
49 49
  */
50
-function wp_shrink_dimensions( $width, $height, $wmax = 128, $hmax = 96 ) {
51
-	_deprecated_function( __FUNCTION__, '3.0.0', 'wp_constrain_dimensions()' );
52
-	return wp_constrain_dimensions( $width, $height, $wmax, $hmax );
50
+function wp_shrink_dimensions($width, $height, $wmax = 128, $hmax = 96) {
51
+	_deprecated_function(__FUNCTION__, '3.0.0', 'wp_constrain_dimensions()');
52
+	return wp_constrain_dimensions($width, $height, $wmax, $hmax);
53 53
 }
54 54
 
55 55
 /**
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
  * @param int $height Current height of the image
64 64
  * @return array Shrunk dimensions (width, height).
65 65
  */
66
-function get_udims( $width, $height ) {
67
-	_deprecated_function( __FUNCTION__, '3.5.0', 'wp_constrain_dimensions()' );
68
-	return wp_constrain_dimensions( $width, $height, 128, 96 );
66
+function get_udims($width, $height) {
67
+	_deprecated_function(__FUNCTION__, '3.5.0', 'wp_constrain_dimensions()');
68
+	return wp_constrain_dimensions($width, $height, 128, 96);
69 69
 }
70 70
 
71 71
 /**
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
  * @param int $parent        Unused.
80 80
  * @param array $popular_ids Unused.
81 81
  */
82
-function dropdown_categories( $default = 0, $parent = 0, $popular_ids = array() ) {
83
-	_deprecated_function( __FUNCTION__, '2.6.0', 'wp_category_checklist()' );
82
+function dropdown_categories($default = 0, $parent = 0, $popular_ids = array()) {
83
+	_deprecated_function(__FUNCTION__, '2.6.0', 'wp_category_checklist()');
84 84
 	global $post_ID;
85
-	wp_category_checklist( $post_ID );
85
+	wp_category_checklist($post_ID);
86 86
 }
87 87
 
88 88
 /**
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
  *
95 95
  * @param int $default Unused.
96 96
  */
97
-function dropdown_link_categories( $default = 0 ) {
98
-	_deprecated_function( __FUNCTION__, '2.6.0', 'wp_link_category_checklist()' );
97
+function dropdown_link_categories($default = 0) {
98
+	_deprecated_function(__FUNCTION__, '2.6.0', 'wp_link_category_checklist()');
99 99
 	global $link_id;
100
-	wp_link_category_checklist( $link_id );
100
+	wp_link_category_checklist($link_id);
101 101
 }
102 102
 
103 103
 /**
@@ -110,10 +110,10 @@  discard block
 block discarded – undo
110 110
  * @param string $file Filesystem path relative to the wp-content directory.
111 111
  * @return string Full filesystem path to edit.
112 112
  */
113
-function get_real_file_to_edit( $file ) {
114
-	_deprecated_function( __FUNCTION__, '2.9.0' );
113
+function get_real_file_to_edit($file) {
114
+	_deprecated_function(__FUNCTION__, '2.9.0');
115 115
 
116
-	return WP_CONTENT_DIR . $file;
116
+	return WP_CONTENT_DIR.$file;
117 117
 }
118 118
 
119 119
 /**
@@ -130,21 +130,21 @@  discard block
 block discarded – undo
130 130
  * @param array $categories  Optional. Categories to include in the control. Default 0.
131 131
  * @return bool|null False if no categories were found.
132 132
  */
133
-function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) {
134
-	_deprecated_function( __FUNCTION__, '3.0.0', 'wp_dropdown_categories()' );
135
-	if (!$categories )
136
-		$categories = get_categories( array('hide_empty' => 0) );
133
+function wp_dropdown_cats($currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0) {
134
+	_deprecated_function(__FUNCTION__, '3.0.0', 'wp_dropdown_categories()');
135
+	if ( ! $categories)
136
+		$categories = get_categories(array('hide_empty' => 0));
137 137
 
138
-	if ( $categories ) {
139
-		foreach ( $categories as $category ) {
140
-			if ( $currentcat != $category->term_id && $parent == $category->parent) {
141
-				$pad = str_repeat( '&#8211; ', $level );
142
-				$category->name = esc_html( $category->name );
138
+	if ($categories) {
139
+		foreach ($categories as $category) {
140
+			if ($currentcat != $category->term_id && $parent == $category->parent) {
141
+				$pad = str_repeat('&#8211; ', $level);
142
+				$category->name = esc_html($category->name);
143 143
 				echo "\n\t<option value='$category->term_id'";
144
-				if ( $currentparent == $category->term_id )
144
+				if ($currentparent == $category->term_id)
145 145
 					echo " selected='selected'";
146 146
 				echo ">$pad$category->name</option>";
147
-				wp_dropdown_cats( $currentcat, $currentparent, $category->term_id, $level +1, $categories );
147
+				wp_dropdown_cats($currentcat, $currentparent, $category->term_id, $level + 1, $categories);
148 148
 			}
149 149
 		}
150 150
 	} else {
@@ -164,9 +164,9 @@  discard block
 block discarded – undo
164 164
  * @param string $option_name The name of an option to sanitize and save.
165 165
  * @param callable $sanitize_callback A callback function that sanitizes the option's value.
166 166
  */
167
-function add_option_update_handler( $option_group, $option_name, $sanitize_callback = '' ) {
168
-	_deprecated_function( __FUNCTION__, '3.0.0', 'register_setting()' );
169
-	register_setting( $option_group, $option_name, $sanitize_callback );
167
+function add_option_update_handler($option_group, $option_name, $sanitize_callback = '') {
168
+	_deprecated_function(__FUNCTION__, '3.0.0', 'register_setting()');
169
+	register_setting($option_group, $option_name, $sanitize_callback);
170 170
 }
171 171
 
172 172
 /**
@@ -180,9 +180,9 @@  discard block
 block discarded – undo
180 180
  * @param string $option_name
181 181
  * @param callable $sanitize_callback
182 182
  */
183
-function remove_option_update_handler( $option_group, $option_name, $sanitize_callback = '' ) {
184
-	_deprecated_function( __FUNCTION__, '3.0.0', 'unregister_setting()' );
185
-	unregister_setting( $option_group, $option_name, $sanitize_callback );
183
+function remove_option_update_handler($option_group, $option_name, $sanitize_callback = '') {
184
+	_deprecated_function(__FUNCTION__, '3.0.0', 'unregister_setting()');
185
+	unregister_setting($option_group, $option_name, $sanitize_callback);
186 186
 }
187 187
 
188 188
 /**
@@ -193,8 +193,8 @@  discard block
 block discarded – undo
193 193
  *
194 194
  * @param string $filename
195 195
 **/
196
-function codepress_get_lang( $filename ) {
197
-	_deprecated_function( __FUNCTION__, '3.0.0' );
196
+function codepress_get_lang($filename) {
197
+	_deprecated_function(__FUNCTION__, '3.0.0');
198 198
 }
199 199
 
200 200
 /**
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
  * @deprecated 3.0.0
205 205
 **/
206 206
 function codepress_footer_js() {
207
-	_deprecated_function( __FUNCTION__, '3.0.0' );
207
+	_deprecated_function(__FUNCTION__, '3.0.0');
208 208
 }
209 209
 
210 210
 /**
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
  * @deprecated 3.0.0
215 215
 **/
216 216
 function use_codepress() {
217
-	_deprecated_function( __FUNCTION__, '3.0.0' );
217
+	_deprecated_function(__FUNCTION__, '3.0.0');
218 218
 }
219 219
 
220 220
 /**
@@ -225,15 +225,15 @@  discard block
 block discarded – undo
225 225
  * @return array List of user IDs.
226 226
  */
227 227
 function get_author_user_ids() {
228
-	_deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' );
228
+	_deprecated_function(__FUNCTION__, '3.1.0', 'get_users()');
229 229
 
230 230
 	global $wpdb;
231
-	if ( !is_multisite() )
232
-		$level_key = $wpdb->get_blog_prefix() . 'user_level';
231
+	if ( ! is_multisite())
232
+		$level_key = $wpdb->get_blog_prefix().'user_level';
233 233
 	else
234
-		$level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
234
+		$level_key = $wpdb->get_blog_prefix().'capabilities'; // wpmu site admins don't have user_levels
235 235
 
236
-	return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value != '0'", $level_key) );
236
+	return $wpdb->get_col($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value != '0'", $level_key));
237 237
 }
238 238
 
239 239
 /**
@@ -244,18 +244,18 @@  discard block
 block discarded – undo
244 244
  * @param int $user_id User ID.
245 245
  * @return array|bool List of editable authors. False if no editable users.
246 246
  */
247
-function get_editable_authors( $user_id ) {
248
-	_deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' );
247
+function get_editable_authors($user_id) {
248
+	_deprecated_function(__FUNCTION__, '3.1.0', 'get_users()');
249 249
 
250 250
 	global $wpdb;
251 251
 
252
-	$editable = get_editable_user_ids( $user_id );
252
+	$editable = get_editable_user_ids($user_id);
253 253
 
254
-	if ( !$editable ) {
254
+	if ( ! $editable) {
255 255
 		return false;
256 256
 	} else {
257 257
 		$editable = join(',', $editable);
258
-		$authors = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($editable) ORDER BY display_name" );
258
+		$authors = $wpdb->get_results("SELECT * FROM $wpdb->users WHERE ID IN ($editable) ORDER BY display_name");
259 259
 	}
260 260
 
261 261
 	return apply_filters('get_editable_authors', $authors);
@@ -270,32 +270,32 @@  discard block
 block discarded – undo
270 270
  * @param bool $exclude_zeros Optional. Whether to exclude zeroes. Default true.
271 271
  * @return array Array of editable user IDs, empty array otherwise.
272 272
  */
273
-function get_editable_user_ids( $user_id, $exclude_zeros = true, $post_type = 'post' ) {
274
-	_deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' );
273
+function get_editable_user_ids($user_id, $exclude_zeros = true, $post_type = 'post') {
274
+	_deprecated_function(__FUNCTION__, '3.1.0', 'get_users()');
275 275
 
276 276
 	global $wpdb;
277 277
 
278
-	if ( ! $user = get_userdata( $user_id ) )
278
+	if ( ! $user = get_userdata($user_id))
279 279
 		return array();
280 280
 	$post_type_obj = get_post_type_object($post_type);
281 281
 
282
-	if ( ! $user->has_cap($post_type_obj->cap->edit_others_posts) ) {
283
-		if ( $user->has_cap($post_type_obj->cap->edit_posts) || ! $exclude_zeros )
282
+	if ( ! $user->has_cap($post_type_obj->cap->edit_others_posts)) {
283
+		if ($user->has_cap($post_type_obj->cap->edit_posts) || ! $exclude_zeros)
284 284
 			return array($user->ID);
285 285
 		else
286 286
 			return array();
287 287
 	}
288 288
 
289
-	if ( !is_multisite() )
290
-		$level_key = $wpdb->get_blog_prefix() . 'user_level';
289
+	if ( ! is_multisite())
290
+		$level_key = $wpdb->get_blog_prefix().'user_level';
291 291
 	else
292
-		$level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
292
+		$level_key = $wpdb->get_blog_prefix().'capabilities'; // wpmu site admins don't have user_levels
293 293
 
294 294
 	$query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s", $level_key);
295
-	if ( $exclude_zeros )
295
+	if ($exclude_zeros)
296 296
 		$query .= " AND meta_value != '0'";
297 297
 
298
-	return $wpdb->get_col( $query );
298
+	return $wpdb->get_col($query);
299 299
 }
300 300
 
301 301
 /**
@@ -304,19 +304,19 @@  discard block
 block discarded – undo
304 304
  * @deprecated 3.1.0 Use get_users()
305 305
  */
306 306
 function get_nonauthor_user_ids() {
307
-	_deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' );
307
+	_deprecated_function(__FUNCTION__, '3.1.0', 'get_users()');
308 308
 
309 309
 	global $wpdb;
310 310
 
311
-	if ( !is_multisite() )
312
-		$level_key = $wpdb->get_blog_prefix() . 'user_level';
311
+	if ( ! is_multisite())
312
+		$level_key = $wpdb->get_blog_prefix().'user_level';
313 313
 	else
314
-		$level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
314
+		$level_key = $wpdb->get_blog_prefix().'capabilities'; // wpmu site admins don't have user_levels
315 315
 
316
-	return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) );
316
+	return $wpdb->get_col($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key));
317 317
 }
318 318
 
319
-if ( ! class_exists( 'WP_User_Search', false ) ) :
319
+if ( ! class_exists('WP_User_Search', false)) :
320 320
 /**
321 321
  * WordPress User Search class.
322 322
  *
@@ -479,12 +479,12 @@  discard block
 block discarded – undo
479 479
 	 * @param string $role Role name.
480 480
 	 * @return WP_User_Search
481 481
 	 */
482
-	function __construct( $search_term = '', $page = '', $role = '' ) {
483
-		_deprecated_function( __FUNCTION__, '3.1.0', 'WP_User_Query' );
482
+	function __construct($search_term = '', $page = '', $role = '') {
483
+		_deprecated_function(__FUNCTION__, '3.1.0', 'WP_User_Query');
484 484
 
485
-		$this->search_term = wp_unslash( $search_term );
486
-		$this->raw_page = ( '' == $page ) ? false : (int) $page;
487
-		$this->page = (int) ( '' == $page ) ? 1 : $page;
485
+		$this->search_term = wp_unslash($search_term);
486
+		$this->raw_page = ('' == $page) ? false : (int) $page;
487
+		$this->page = (int) ('' == $page) ? 1 : $page;
488 488
 		$this->role = $role;
489 489
 
490 490
 		$this->prepare_query();
@@ -502,8 +502,8 @@  discard block
 block discarded – undo
502 502
 	 * @param string $role Role name.
503 503
 	 * @return WP_User_Search
504 504
 	 */
505
-	public function WP_User_Search( $search_term = '', $page = '', $role = '' ) {
506
-		self::__construct( $search_term, $page, $role );
505
+	public function WP_User_Search($search_term = '', $page = '', $role = '') {
506
+		self::__construct($search_term, $page, $role);
507 507
 	}
508 508
 
509 509
 	/**
@@ -520,11 +520,11 @@  discard block
 block discarded – undo
520 520
 		$this->query_orderby = ' ORDER BY user_login';
521 521
 
522 522
 		$search_sql = '';
523
-		if ( $this->search_term ) {
523
+		if ($this->search_term) {
524 524
 			$searches = array();
525 525
 			$search_sql = 'AND (';
526
-			foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col )
527
-				$searches[] = $wpdb->prepare( $col . ' LIKE %s', '%' . like_escape($this->search_term) . '%' );
526
+			foreach (array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col)
527
+				$searches[] = $wpdb->prepare($col.' LIKE %s', '%'.like_escape($this->search_term).'%');
528 528
 			$search_sql .= implode(' OR ', $searches);
529 529
 			$search_sql .= ')';
530 530
 		}
@@ -532,16 +532,16 @@  discard block
 block discarded – undo
532 532
 		$this->query_from = " FROM $wpdb->users";
533 533
 		$this->query_where = " WHERE 1=1 $search_sql";
534 534
 
535
-		if ( $this->role ) {
535
+		if ($this->role) {
536 536
 			$this->query_from .= " INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id";
537
-			$this->query_where .= $wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $this->role . '%');
538
-		} elseif ( is_multisite() ) {
539
-			$level_key = $wpdb->prefix . 'capabilities'; // wpmu site admins don't have user_levels
537
+			$this->query_where .= $wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%'.$this->role.'%');
538
+		} elseif (is_multisite()) {
539
+			$level_key = $wpdb->prefix.'capabilities'; // wpmu site admins don't have user_levels
540 540
 			$this->query_from .= ", $wpdb->usermeta";
541 541
 			$this->query_where .= " AND $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '{$level_key}'";
542 542
 		}
543 543
 
544
-		do_action_ref_array( 'pre_user_search', array( &$this ) );
544
+		do_action_ref_array('pre_user_search', array(&$this));
545 545
 	}
546 546
 
547 547
 	/**
@@ -553,10 +553,10 @@  discard block
 block discarded – undo
553 553
 	public function query() {
554 554
 		global $wpdb;
555 555
 
556
-		$this->results = $wpdb->get_col("SELECT DISTINCT($wpdb->users.ID)" . $this->query_from . $this->query_where . $this->query_orderby . $this->query_limit);
556
+		$this->results = $wpdb->get_col("SELECT DISTINCT($wpdb->users.ID)".$this->query_from.$this->query_where.$this->query_orderby.$this->query_limit);
557 557
 
558
-		if ( $this->results )
559
-			$this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))" . $this->query_from . $this->query_where); // no limit
558
+		if ($this->results)
559
+			$this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))".$this->query_from.$this->query_where); // no limit
560 560
 		else
561 561
 			$this->search_errors = new WP_Error('no_matching_users_found', __('No users found.'));
562 562
 	}
@@ -576,25 +576,25 @@  discard block
 block discarded – undo
576 576
 	 * @access public
577 577
 	 */
578 578
 	public function do_paging() {
579
-		if ( $this->total_users_for_query > $this->users_per_page ) { // have to page the results
579
+		if ($this->total_users_for_query > $this->users_per_page) { // have to page the results
580 580
 			$args = array();
581
-			if ( ! empty($this->search_term) )
581
+			if ( ! empty($this->search_term))
582 582
 				$args['usersearch'] = urlencode($this->search_term);
583
-			if ( ! empty($this->role) )
583
+			if ( ! empty($this->role))
584 584
 				$args['role'] = urlencode($this->role);
585 585
 
586
-			$this->paging_text = paginate_links( array(
586
+			$this->paging_text = paginate_links(array(
587 587
 				'total' => ceil($this->total_users_for_query / $this->users_per_page),
588 588
 				'current' => $this->page,
589 589
 				'base' => 'users.php?%_%',
590 590
 				'format' => 'userspage=%#%',
591 591
 				'add_args' => $args
592
-			) );
593
-			if ( $this->paging_text ) {
594
-				$this->paging_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>%s',
595
-					number_format_i18n( ( $this->page - 1 ) * $this->users_per_page + 1 ),
596
-					number_format_i18n( min( $this->page * $this->users_per_page, $this->total_users_for_query ) ),
597
-					number_format_i18n( $this->total_users_for_query ),
592
+			));
593
+			if ($this->paging_text) {
594
+				$this->paging_text = sprintf('<span class="displaying-num">'.__('Displaying %s&#8211;%s of %s').'</span>%s',
595
+					number_format_i18n(($this->page - 1) * $this->users_per_page + 1),
596
+					number_format_i18n(min($this->page * $this->users_per_page, $this->total_users_for_query)),
597
+					number_format_i18n($this->total_users_for_query),
598 598
 					$this->paging_text
599 599
 				);
600 600
 			}
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
 	 * @return bool
637 637
 	 */
638 638
 	function results_are_paged() {
639
-		if ( $this->paging_text )
639
+		if ($this->paging_text)
640 640
 			return true;
641 641
 		return false;
642 642
 	}
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
 	 * @return bool
651 651
 	 */
652 652
 	function is_search() {
653
-		if ( $this->search_term )
653
+		if ($this->search_term)
654 654
 			return true;
655 655
 		return false;
656 656
 	}
@@ -669,25 +669,25 @@  discard block
 block discarded – undo
669 669
  *                        Default 'any'.
670 670
  * @return array List of posts from others.
671 671
  */
672
-function get_others_unpublished_posts( $user_id, $type = 'any' ) {
673
-	_deprecated_function( __FUNCTION__, '3.1.0' );
672
+function get_others_unpublished_posts($user_id, $type = 'any') {
673
+	_deprecated_function(__FUNCTION__, '3.1.0');
674 674
 
675 675
 	global $wpdb;
676 676
 
677
-	$editable = get_editable_user_ids( $user_id );
677
+	$editable = get_editable_user_ids($user_id);
678 678
 
679
-	if ( in_array($type, array('draft', 'pending')) )
679
+	if (in_array($type, array('draft', 'pending')))
680 680
 		$type_sql = " post_status = '$type' ";
681 681
 	else
682 682
 		$type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) ";
683 683
 
684
-	$dir = ( 'pending' == $type ) ? 'ASC' : 'DESC';
684
+	$dir = ('pending' == $type) ? 'ASC' : 'DESC';
685 685
 
686
-	if ( !$editable ) {
686
+	if ( ! $editable) {
687 687
 		$other_unpubs = '';
688 688
 	} else {
689 689
 		$editable = join(',', $editable);
690
-		$other_unpubs = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_title, post_author FROM $wpdb->posts WHERE post_type = 'post' AND $type_sql AND post_author IN ($editable) AND post_author != %d ORDER BY post_modified $dir", $user_id) );
690
+		$other_unpubs = $wpdb->get_results($wpdb->prepare("SELECT ID, post_title, post_author FROM $wpdb->posts WHERE post_type = 'post' AND $type_sql AND post_author IN ($editable) AND post_author != %d ORDER BY post_modified $dir", $user_id));
691 691
 	}
692 692
 
693 693
 	return apply_filters('get_others_drafts', $other_unpubs);
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
  * @return array List of drafts from other users.
704 704
  */
705 705
 function get_others_drafts($user_id) {
706
-	_deprecated_function( __FUNCTION__, '3.1.0' );
706
+	_deprecated_function(__FUNCTION__, '3.1.0');
707 707
 
708 708
 	return get_others_unpublished_posts($user_id, 'draft');
709 709
 }
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
  * @return array List of posts with pending review post type from other users.
719 719
  */
720 720
 function get_others_pending($user_id) {
721
-	_deprecated_function( __FUNCTION__, '3.1.0' );
721
+	_deprecated_function(__FUNCTION__, '3.1.0');
722 722
 
723 723
 	return get_others_unpublished_posts($user_id, 'pending');
724 724
 }
@@ -731,7 +731,7 @@  discard block
 block discarded – undo
731 731
  * @see wp_dashboard_quick_press()
732 732
  */
733 733
 function wp_dashboard_quick_press_output() {
734
-	_deprecated_function( __FUNCTION__, '3.2.0', 'wp_dashboard_quick_press()' );
734
+	_deprecated_function(__FUNCTION__, '3.2.0', 'wp_dashboard_quick_press()');
735 735
 	wp_dashboard_quick_press();
736 736
 }
737 737
 
@@ -744,15 +744,15 @@  discard block
 block discarded – undo
744 744
  *
745 745
  * @staticvar int $num
746 746
  */
747
-function wp_tiny_mce( $teeny = false, $settings = false ) {
748
-	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' );
747
+function wp_tiny_mce($teeny = false, $settings = false) {
748
+	_deprecated_function(__FUNCTION__, '3.3.0', 'wp_editor()');
749 749
 
750 750
 	static $num = 1;
751 751
 
752
-	if ( ! class_exists( '_WP_Editors', false ) )
753
-		require_once( ABSPATH . WPINC . '/class-wp-editor.php' );
752
+	if ( ! class_exists('_WP_Editors', false))
753
+		require_once(ABSPATH.WPINC.'/class-wp-editor.php');
754 754
 
755
-	$editor_id = 'content' . $num++;
755
+	$editor_id = 'content'.$num++;
756 756
 
757 757
 	$set = array(
758 758
 		'teeny' => $teeny,
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
  * @see wp_editor()
772 772
  */
773 773
 function wp_preload_dialogs() {
774
-	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' );
774
+	_deprecated_function(__FUNCTION__, '3.3.0', 'wp_editor()');
775 775
 }
776 776
 
777 777
 /**
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
  * @see wp_editor()
782 782
  */
783 783
 function wp_print_editor_js() {
784
-	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' );
784
+	_deprecated_function(__FUNCTION__, '3.3.0', 'wp_editor()');
785 785
 }
786 786
 
787 787
 /**
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
  * @see wp_editor()
792 792
  */
793 793
 function wp_quicktags() {
794
-	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' );
794
+	_deprecated_function(__FUNCTION__, '3.3.0', 'wp_editor()');
795 795
 }
796 796
 
797 797
 /**
@@ -801,12 +801,12 @@  discard block
 block discarded – undo
801 801
  * @deprecated 3.3.0 WP_Screen::render_screen_layout()
802 802
  * @see WP_Screen::render_screen_layout()
803 803
  */
804
-function screen_layout( $screen ) {
805
-	_deprecated_function( __FUNCTION__, '3.3.0', '$current_screen->render_screen_layout()' );
804
+function screen_layout($screen) {
805
+	_deprecated_function(__FUNCTION__, '3.3.0', '$current_screen->render_screen_layout()');
806 806
 
807 807
 	$current_screen = get_current_screen();
808 808
 
809
-	if ( ! $current_screen )
809
+	if ( ! $current_screen)
810 810
 		return '';
811 811
 
812 812
 	ob_start();
@@ -821,12 +821,12 @@  discard block
 block discarded – undo
821 821
  * @deprecated 3.3.0 Use WP_Screen::render_per_page_options()
822 822
  * @see WP_Screen::render_per_page_options()
823 823
  */
824
-function screen_options( $screen ) {
825
-	_deprecated_function( __FUNCTION__, '3.3.0', '$current_screen->render_per_page_options()' );
824
+function screen_options($screen) {
825
+	_deprecated_function(__FUNCTION__, '3.3.0', '$current_screen->render_per_page_options()');
826 826
 
827 827
 	$current_screen = get_current_screen();
828 828
 
829
-	if ( ! $current_screen )
829
+	if ( ! $current_screen)
830 830
 		return '';
831 831
 
832 832
 	ob_start();
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
  * @deprecated 3.3.0 Use WP_Screen::render_screen_meta()
842 842
  * @see WP_Screen::render_screen_meta()
843 843
  */
844
-function screen_meta( $screen ) {
844
+function screen_meta($screen) {
845 845
 	$current_screen = get_current_screen();
846 846
 	$current_screen->render_screen_meta();
847 847
 }
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
  * @see WP_Admin_Bar
855 855
  */
856 856
 function favorite_actions() {
857
-	_deprecated_function( __FUNCTION__, '3.2.0', 'WP_Admin_Bar' );
857
+	_deprecated_function(__FUNCTION__, '3.2.0', 'WP_Admin_Bar');
858 858
 }
859 859
 
860 860
 /**
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
  * @return null|string
867 867
  */
868 868
 function media_upload_image() {
869
-	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_media_upload_handler()' );
869
+	_deprecated_function(__FUNCTION__, '3.3.0', 'wp_media_upload_handler()');
870 870
 	return wp_media_upload_handler();
871 871
 }
872 872
 
@@ -879,7 +879,7 @@  discard block
 block discarded – undo
879 879
  * @return null|string
880 880
  */
881 881
 function media_upload_audio() {
882
-	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_media_upload_handler()' );
882
+	_deprecated_function(__FUNCTION__, '3.3.0', 'wp_media_upload_handler()');
883 883
 	return wp_media_upload_handler();
884 884
 }
885 885
 
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
  * @return null|string
893 893
  */
894 894
 function media_upload_video() {
895
-	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_media_upload_handler()' );
895
+	_deprecated_function(__FUNCTION__, '3.3.0', 'wp_media_upload_handler()');
896 896
 	return wp_media_upload_handler();
897 897
 }
898 898
 
@@ -905,7 +905,7 @@  discard block
 block discarded – undo
905 905
  * @return null|string
906 906
  */
907 907
 function media_upload_file() {
908
-	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_media_upload_handler()' );
908
+	_deprecated_function(__FUNCTION__, '3.3.0', 'wp_media_upload_handler()');
909 909
 	return wp_media_upload_handler();
910 910
 }
911 911
 
@@ -918,8 +918,8 @@  discard block
 block discarded – undo
918 918
  * @return string
919 919
  */
920 920
 function type_url_form_image() {
921
-	_deprecated_function( __FUNCTION__, '3.3.0', "wp_media_insert_url_form('image')" );
922
-	return wp_media_insert_url_form( 'image' );
921
+	_deprecated_function(__FUNCTION__, '3.3.0', "wp_media_insert_url_form('image')");
922
+	return wp_media_insert_url_form('image');
923 923
 }
924 924
 
925 925
 /**
@@ -931,8 +931,8 @@  discard block
 block discarded – undo
931 931
  * @return string
932 932
  */
933 933
 function type_url_form_audio() {
934
-	_deprecated_function( __FUNCTION__, '3.3.0', "wp_media_insert_url_form('audio')" );
935
-	return wp_media_insert_url_form( 'audio' );
934
+	_deprecated_function(__FUNCTION__, '3.3.0', "wp_media_insert_url_form('audio')");
935
+	return wp_media_insert_url_form('audio');
936 936
 }
937 937
 
938 938
 /**
@@ -944,8 +944,8 @@  discard block
 block discarded – undo
944 944
  * @return string
945 945
  */
946 946
 function type_url_form_video() {
947
-	_deprecated_function( __FUNCTION__, '3.3.0', "wp_media_insert_url_form('video')" );
948
-	return wp_media_insert_url_form( 'video' );
947
+	_deprecated_function(__FUNCTION__, '3.3.0', "wp_media_insert_url_form('video')");
948
+	return wp_media_insert_url_form('video');
949 949
 }
950 950
 
951 951
 /**
@@ -957,8 +957,8 @@  discard block
 block discarded – undo
957 957
  * @return string
958 958
  */
959 959
 function type_url_form_file() {
960
-	_deprecated_function( __FUNCTION__, '3.3.0', "wp_media_insert_url_form('file')" );
961
-	return wp_media_insert_url_form( 'file' );
960
+	_deprecated_function(__FUNCTION__, '3.3.0', "wp_media_insert_url_form('file')");
961
+	return wp_media_insert_url_form('file');
962 962
 }
963 963
 
964 964
 /**
@@ -973,13 +973,13 @@  discard block
 block discarded – undo
973 973
  * @param string    $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
974 974
  * @param string    $help   The content of an 'Overview' help tab.
975 975
  */
976
-function add_contextual_help( $screen, $help ) {
977
-	_deprecated_function( __FUNCTION__, '3.3.0', 'get_current_screen()->add_help_tab()' );
976
+function add_contextual_help($screen, $help) {
977
+	_deprecated_function(__FUNCTION__, '3.3.0', 'get_current_screen()->add_help_tab()');
978 978
 
979
-	if ( is_string( $screen ) )
980
-		$screen = convert_to_screen( $screen );
979
+	if (is_string($screen))
980
+		$screen = convert_to_screen($screen);
981 981
 
982
-	WP_Screen::add_old_compat_help( $screen, $help );
982
+	WP_Screen::add_old_compat_help($screen, $help);
983 983
 }
984 984
 
985 985
 /**
@@ -992,13 +992,13 @@  discard block
 block discarded – undo
992 992
  * @return array $themes Array of allowed themes.
993 993
  */
994 994
 function get_allowed_themes() {
995
-	_deprecated_function( __FUNCTION__, '3.4.0', "wp_get_themes( array( 'allowed' => true ) )" );
995
+	_deprecated_function(__FUNCTION__, '3.4.0', "wp_get_themes( array( 'allowed' => true ) )");
996 996
 
997
-	$themes = wp_get_themes( array( 'allowed' => true ) );
997
+	$themes = wp_get_themes(array('allowed' => true));
998 998
 
999 999
 	$wp_themes = array();
1000
-	foreach ( $themes as $theme ) {
1001
-		$wp_themes[ $theme->get('Name') ] = $theme;
1000
+	foreach ($themes as $theme) {
1001
+		$wp_themes[$theme->get('Name')] = $theme;
1002 1002
 	}
1003 1003
 
1004 1004
 	return $wp_themes;
@@ -1014,13 +1014,13 @@  discard block
 block discarded – undo
1014 1014
  * @return array
1015 1015
  */
1016 1016
 function get_broken_themes() {
1017
-	_deprecated_function( __FUNCTION__, '3.4.0', "wp_get_themes( array( 'errors' => true )" );
1017
+	_deprecated_function(__FUNCTION__, '3.4.0', "wp_get_themes( array( 'errors' => true )");
1018 1018
 
1019
-	$themes = wp_get_themes( array( 'errors' => true ) );
1019
+	$themes = wp_get_themes(array('errors' => true));
1020 1020
 	$broken = array();
1021
-	foreach ( $themes as $theme ) {
1021
+	foreach ($themes as $theme) {
1022 1022
 		$name = $theme->get('Name');
1023
-		$broken[ $name ] = array(
1023
+		$broken[$name] = array(
1024 1024
 			'Name' => $name,
1025 1025
 			'Title' => $name,
1026 1026
 			'Description' => $theme->errors()->get_error_message(),
@@ -1039,7 +1039,7 @@  discard block
 block discarded – undo
1039 1039
  * @return WP_Theme
1040 1040
  */
1041 1041
 function current_theme_info() {
1042
-	_deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme()' );
1042
+	_deprecated_function(__FUNCTION__, '3.4.0', 'wp_get_theme()');
1043 1043
 
1044 1044
 	return wp_get_theme();
1045 1045
 }
@@ -1051,8 +1051,8 @@  discard block
 block discarded – undo
1051 1051
  *
1052 1052
  * @deprecated 3.5.0
1053 1053
  */
1054
-function _insert_into_post_button( $type ) {
1055
-	_deprecated_function( __FUNCTION__, '3.5.0' );
1054
+function _insert_into_post_button($type) {
1055
+	_deprecated_function(__FUNCTION__, '3.5.0');
1056 1056
 }
1057 1057
 
1058 1058
 /**
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
  * @deprecated 3.5.0
1064 1064
  */
1065 1065
 function _media_button($title, $icon, $type, $id) {
1066
-	_deprecated_function( __FUNCTION__, '3.5.0' );
1066
+	_deprecated_function(__FUNCTION__, '3.5.0');
1067 1067
 }
1068 1068
 
1069 1069
 /**
@@ -1076,10 +1076,10 @@  discard block
 block discarded – undo
1076 1076
  * @param int $id
1077 1077
  * @return object
1078 1078
  */
1079
-function get_post_to_edit( $id ) {
1080
-	_deprecated_function( __FUNCTION__, '3.5.0', 'get_post()' );
1079
+function get_post_to_edit($id) {
1080
+	_deprecated_function(__FUNCTION__, '3.5.0', 'get_post()');
1081 1081
 
1082
-	return get_post( $id, OBJECT, 'edit' );
1082
+	return get_post($id, OBJECT, 'edit');
1083 1083
 }
1084 1084
 
1085 1085
 /**
@@ -1092,7 +1092,7 @@  discard block
 block discarded – undo
1092 1092
  * @return WP_Post Post object containing all the default post data as attributes
1093 1093
  */
1094 1094
 function get_default_page_to_edit() {
1095
-	_deprecated_function( __FUNCTION__, '3.5.0', "get_default_post_to_edit( 'page' )" );
1095
+	_deprecated_function(__FUNCTION__, '3.5.0', "get_default_post_to_edit( 'page' )");
1096 1096
 
1097 1097
 	$page = get_default_post_to_edit();
1098 1098
 	$page->post_type = 'page';
@@ -1111,9 +1111,9 @@  discard block
 block discarded – undo
1111 1111
  * @param mixed $deprecated Never used.
1112 1112
  * @return string Thumbnail path on success, Error string on failure.
1113 1113
  */
1114
-function wp_create_thumbnail( $file, $max_side, $deprecated = '' ) {
1115
-	_deprecated_function( __FUNCTION__, '3.5.0', 'image_resize()' );
1116
-	return apply_filters( 'wp_create_thumbnail', image_resize( $file, $max_side, $max_side ) );
1114
+function wp_create_thumbnail($file, $max_side, $deprecated = '') {
1115
+	_deprecated_function(__FUNCTION__, '3.5.0', 'image_resize()');
1116
+	return apply_filters('wp_create_thumbnail', image_resize($file, $max_side, $max_side));
1117 1117
 }
1118 1118
 
1119 1119
 /**
@@ -1125,7 +1125,7 @@  discard block
 block discarded – undo
1125 1125
  * @deprecated 3.6.0
1126 1126
  */
1127 1127
 function wp_nav_menu_locations_meta_box() {
1128
-	_deprecated_function( __FUNCTION__, '3.6.0' );
1128
+	_deprecated_function(__FUNCTION__, '3.6.0');
1129 1129
 }
1130 1130
 
1131 1131
 /**
@@ -1139,12 +1139,12 @@  discard block
 block discarded – undo
1139 1139
  * @see Core_Upgrader
1140 1140
  */
1141 1141
 function wp_update_core($current, $feedback = '') {
1142
-	_deprecated_function( __FUNCTION__, '3.7.0', 'new Core_Upgrader();' );
1142
+	_deprecated_function(__FUNCTION__, '3.7.0', 'new Core_Upgrader();');
1143 1143
 
1144
-	if ( !empty($feedback) )
1144
+	if ( ! empty($feedback))
1145 1145
 		add_filter('update_feedback', $feedback);
1146 1146
 
1147
-	include( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
1147
+	include(ABSPATH.'wp-admin/includes/class-wp-upgrader.php');
1148 1148
 	$upgrader = new Core_Upgrader();
1149 1149
 	return $upgrader->upgrade($current);
1150 1150
 
@@ -1162,12 +1162,12 @@  discard block
 block discarded – undo
1162 1162
  * @see Plugin_Upgrader
1163 1163
  */
1164 1164
 function wp_update_plugin($plugin, $feedback = '') {
1165
-	_deprecated_function( __FUNCTION__, '3.7.0', 'new Plugin_Upgrader();' );
1165
+	_deprecated_function(__FUNCTION__, '3.7.0', 'new Plugin_Upgrader();');
1166 1166
 
1167
-	if ( !empty($feedback) )
1167
+	if ( ! empty($feedback))
1168 1168
 		add_filter('update_feedback', $feedback);
1169 1169
 
1170
-	include( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
1170
+	include(ABSPATH.'wp-admin/includes/class-wp-upgrader.php');
1171 1171
 	$upgrader = new Plugin_Upgrader();
1172 1172
 	return $upgrader->upgrade($plugin);
1173 1173
 }
@@ -1184,12 +1184,12 @@  discard block
 block discarded – undo
1184 1184
  * @see Theme_Upgrader
1185 1185
  */
1186 1186
 function wp_update_theme($theme, $feedback = '') {
1187
-	_deprecated_function( __FUNCTION__, '3.7.0', 'new Theme_Upgrader();' );
1187
+	_deprecated_function(__FUNCTION__, '3.7.0', 'new Theme_Upgrader();');
1188 1188
 
1189
-	if ( !empty($feedback) )
1189
+	if ( ! empty($feedback))
1190 1190
 		add_filter('update_feedback', $feedback);
1191 1191
 
1192
-	include( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
1192
+	include(ABSPATH.'wp-admin/includes/class-wp-upgrader.php');
1193 1193
 	$upgrader = new Theme_Upgrader();
1194 1194
 	return $upgrader->upgrade($theme);
1195 1195
 }
@@ -1202,8 +1202,8 @@  discard block
 block discarded – undo
1202 1202
  *
1203 1203
  * @param int|bool $id
1204 1204
  */
1205
-function the_attachment_links( $id = false ) {
1206
-	_deprecated_function( __FUNCTION__, '3.7.0' );
1205
+function the_attachment_links($id = false) {
1206
+	_deprecated_function(__FUNCTION__, '3.7.0');
1207 1207
 }
1208 1208
 
1209 1209
 /**
@@ -1304,8 +1304,8 @@  discard block
 block discarded – undo
1304 1304
  * @param int $old_ID
1305 1305
  * @param int $new_ID
1306 1306
  */
1307
-function _relocate_children( $old_ID, $new_ID ) {
1308
-	_deprecated_function( __FUNCTION__, '3.9.0' );
1307
+function _relocate_children($old_ID, $new_ID) {
1308
+	_deprecated_function(__FUNCTION__, '3.9.0');
1309 1309
 }
1310 1310
 
1311 1311
 /**
@@ -1331,8 +1331,8 @@  discard block
 block discarded – undo
1331 1331
  * @param string   $icon_url   The url to the icon to be used for this menu.
1332 1332
  * @return string The resulting page's hook_suffix.
1333 1333
  */
1334
-function add_object_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '') {
1335
-	_deprecated_function( __FUNCTION__, '4.5.0', 'add_menu_page()' );
1334
+function add_object_page($page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '') {
1335
+	_deprecated_function(__FUNCTION__, '4.5.0', 'add_menu_page()');
1336 1336
 
1337 1337
 	global $_wp_last_object_menu;
1338 1338
 
@@ -1364,8 +1364,8 @@  discard block
 block discarded – undo
1364 1364
  * @param string   $icon_url   The url to the icon to be used for this menu.
1365 1365
  * @return string The resulting page's hook_suffix.
1366 1366
  */
1367
-function add_utility_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '') {
1368
-	_deprecated_function( __FUNCTION__, '4.5.0', 'add_menu_page()' );
1367
+function add_utility_page($page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '') {
1368
+	_deprecated_function(__FUNCTION__, '4.5.0', 'add_menu_page()');
1369 1369
 
1370 1370
 	global $_wp_last_utility_menu;
1371 1371
 
@@ -1390,9 +1390,9 @@  discard block
 block discarded – undo
1390 1390
 function post_form_autocomplete_off() {
1391 1391
 	global $is_safari, $is_chrome;
1392 1392
 
1393
-	_deprecated_function( __FUNCTION__, '4.6.0' );
1393
+	_deprecated_function(__FUNCTION__, '4.6.0');
1394 1394
 
1395
-	if ( $is_safari || $is_chrome ) {
1395
+	if ($is_safari || $is_chrome) {
1396 1396
 		echo ' autocomplete="off"';
1397 1397
 	}
1398 1398
 }
Please login to merge, or discard this patch.
src/wp-admin/includes/post.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1372,7 +1372,7 @@
 block discarded – undo
1372 1372
  * @global array $_wp_additional_image_sizes
1373 1373
  *
1374 1374
  * @param int $thumbnail_id ID of the attachment used for thumbnail
1375
- * @param mixed $post The post ID or object associated with the thumbnail, defaults to global $post.
1375
+ * @param integer $post The post ID or object associated with the thumbnail, defaults to global $post.
1376 1376
  * @return string html
1377 1377
  */
1378 1378
 function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) {
Please login to merge, or discard this patch.
Spacing   +513 added lines, -513 removed lines patch added patch discarded remove patch
@@ -18,157 +18,157 @@  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', __( 'Sorry, 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', __('Sorry, you are not allowed to edit pages as this user.'));
34 34
 		else
35
-			return new WP_Error( 'edit_others_posts', __( 'Sorry, 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', __( 'Sorry, you are not allowed to create pages as this user.' ) );
35
+			return new WP_Error('edit_others_posts', __('Sorry, 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', __('Sorry, you are not allowed to create pages as this user.'));
39 39
 		else
40
-			return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to create posts as this user.' ) );
40
+			return new WP_Error('edit_others_posts', __('Sorry, 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', __( 'Sorry, 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', __('Sorry, you are not allowed to edit pages as this user.'));
72 72
 			else
73
-				return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to edit posts as this user.' ) );
73
+				return new WP_Error('edit_others_posts', __('Sorry, 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', __( 'Sorry, 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', __('Sorry, you are not allowed to create pages as this user.'));
77 77
 			else
78
-				return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to create posts as this user.' ) );
78
+				return new WP_Error('edit_others_posts', __('Sorry, 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', __( 'Invalid date.' ) );
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', __('Invalid date.'));
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
-	if ( isset( $post_data['post_category'] ) ) {
169
-		$category_object = get_taxonomy( 'category' );
170
-		if ( ! current_user_can( $category_object->cap->assign_terms ) ) {
171
-			unset( $post_data['post_category'] );
168
+	if (isset($post_data['post_category'])) {
169
+		$category_object = get_taxonomy('category');
170
+		if ( ! current_user_can($category_object->cap->assign_terms)) {
171
+			unset($post_data['post_category']);
172 172
 		}
173 173
 	}
174 174
 
@@ -185,151 +185,151 @@  discard block
 block discarded – undo
185 185
  * @param array $post_data Optional.
186 186
  * @return int Post ID.
187 187
  */
188
-function edit_post( $post_data = null ) {
188
+function edit_post($post_data = null) {
189 189
 	global $wpdb;
190 190
 
191
-	if ( empty($post_data) )
191
+	if (empty($post_data))
192 192
 		$post_data = &$_POST;
193 193
 
194 194
 	// Clear out any data in internal vars.
195
-	unset( $post_data['filter'] );
195
+	unset($post_data['filter']);
196 196
 
197 197
 	$post_ID = (int) $post_data['post_ID'];
198
-	$post = get_post( $post_ID );
198
+	$post = get_post($post_ID);
199 199
 	$post_data['post_type'] = $post->post_type;
200 200
 	$post_data['post_mime_type'] = $post->post_mime_type;
201 201
 
202
-	if ( ! empty( $post_data['post_status'] ) ) {
203
-		$post_data['post_status'] = sanitize_key( $post_data['post_status'] );
202
+	if ( ! empty($post_data['post_status'])) {
203
+		$post_data['post_status'] = sanitize_key($post_data['post_status']);
204 204
 
205
-		if ( 'inherit' == $post_data['post_status'] ) {
206
-			unset( $post_data['post_status'] );
205
+		if ('inherit' == $post_data['post_status']) {
206
+			unset($post_data['post_status']);
207 207
 		}
208 208
 	}
209 209
 
210 210
 	$ptype = get_post_type_object($post_data['post_type']);
211
-	if ( !current_user_can( 'edit_post', $post_ID ) ) {
212
-		if ( 'page' == $post_data['post_type'] )
213
-			wp_die( __('Sorry, you are not allowed to edit this page.' ));
211
+	if ( ! current_user_can('edit_post', $post_ID)) {
212
+		if ('page' == $post_data['post_type'])
213
+			wp_die(__('Sorry, you are not allowed to edit this page.'));
214 214
 		else
215
-			wp_die( __('Sorry, you are not allowed to edit this post.' ));
215
+			wp_die(__('Sorry, you are not allowed to edit this post.'));
216 216
 	}
217 217
 
218
-	if ( post_type_supports( $ptype->name, 'revisions' ) ) {
219
-		$revisions = wp_get_post_revisions( $post_ID, array( 'order' => 'ASC', 'posts_per_page' => 1 ) );
220
-		$revision = current( $revisions );
218
+	if (post_type_supports($ptype->name, 'revisions')) {
219
+		$revisions = wp_get_post_revisions($post_ID, array('order' => 'ASC', 'posts_per_page' => 1));
220
+		$revision = current($revisions);
221 221
 
222 222
 		// Check if the revisions have been upgraded
223
-		if ( $revisions && _wp_get_post_revision_version( $revision ) < 1 )
224
-			_wp_upgrade_revisions_of_post( $post, wp_get_post_revisions( $post_ID ) );
223
+		if ($revisions && _wp_get_post_revision_version($revision) < 1)
224
+			_wp_upgrade_revisions_of_post($post, wp_get_post_revisions($post_ID));
225 225
 	}
226 226
 
227
-	if ( isset($post_data['visibility']) ) {
228
-		switch ( $post_data['visibility'] ) {
227
+	if (isset($post_data['visibility'])) {
228
+		switch ($post_data['visibility']) {
229 229
 			case 'public' :
230 230
 				$post_data['post_password'] = '';
231 231
 				break;
232 232
 			case 'password' :
233
-				unset( $post_data['sticky'] );
233
+				unset($post_data['sticky']);
234 234
 				break;
235 235
 			case 'private' :
236 236
 				$post_data['post_status'] = 'private';
237 237
 				$post_data['post_password'] = '';
238
-				unset( $post_data['sticky'] );
238
+				unset($post_data['sticky']);
239 239
 				break;
240 240
 		}
241 241
 	}
242 242
 
243
-	$post_data = _wp_translate_postdata( true, $post_data );
244
-	if ( is_wp_error($post_data) )
245
-		wp_die( $post_data->get_error_message() );
243
+	$post_data = _wp_translate_postdata(true, $post_data);
244
+	if (is_wp_error($post_data))
245
+		wp_die($post_data->get_error_message());
246 246
 
247 247
 	// Post Formats
248
-	if ( isset( $post_data['post_format'] ) )
249
-		set_post_format( $post_ID, $post_data['post_format'] );
248
+	if (isset($post_data['post_format']))
249
+		set_post_format($post_ID, $post_data['post_format']);
250 250
 
251
-	$format_meta_urls = array( 'url', 'link_url', 'quote_source_url' );
252
-	foreach ( $format_meta_urls as $format_meta_url ) {
253
-		$keyed = '_format_' . $format_meta_url;
254
-		if ( isset( $post_data[ $keyed ] ) )
255
-			update_post_meta( $post_ID, $keyed, wp_slash( esc_url_raw( wp_unslash( $post_data[ $keyed ] ) ) ) );
251
+	$format_meta_urls = array('url', 'link_url', 'quote_source_url');
252
+	foreach ($format_meta_urls as $format_meta_url) {
253
+		$keyed = '_format_'.$format_meta_url;
254
+		if (isset($post_data[$keyed]))
255
+			update_post_meta($post_ID, $keyed, wp_slash(esc_url_raw(wp_unslash($post_data[$keyed]))));
256 256
 	}
257 257
 
258
-	$format_keys = array( 'quote', 'quote_source_name', 'image', 'gallery', 'audio_embed', 'video_embed' );
258
+	$format_keys = array('quote', 'quote_source_name', 'image', 'gallery', 'audio_embed', 'video_embed');
259 259
 
260
-	foreach ( $format_keys as $key ) {
261
-		$keyed = '_format_' . $key;
262
-		if ( isset( $post_data[ $keyed ] ) ) {
263
-			if ( current_user_can( 'unfiltered_html' ) )
264
-				update_post_meta( $post_ID, $keyed, $post_data[ $keyed ] );
260
+	foreach ($format_keys as $key) {
261
+		$keyed = '_format_'.$key;
262
+		if (isset($post_data[$keyed])) {
263
+			if (current_user_can('unfiltered_html'))
264
+				update_post_meta($post_ID, $keyed, $post_data[$keyed]);
265 265
 			else
266
-				update_post_meta( $post_ID, $keyed, wp_filter_post_kses( $post_data[ $keyed ] ) );
266
+				update_post_meta($post_ID, $keyed, wp_filter_post_kses($post_data[$keyed]));
267 267
 		}
268 268
 	}
269 269
 
270
-	if ( 'attachment' === $post_data['post_type'] && preg_match( '#^(audio|video)/#', $post_data['post_mime_type'] ) ) {
271
-		$id3data = wp_get_attachment_metadata( $post_ID );
272
-		if ( ! is_array( $id3data ) ) {
270
+	if ('attachment' === $post_data['post_type'] && preg_match('#^(audio|video)/#', $post_data['post_mime_type'])) {
271
+		$id3data = wp_get_attachment_metadata($post_ID);
272
+		if ( ! is_array($id3data)) {
273 273
 			$id3data = array();
274 274
 		}
275 275
 
276
-		foreach ( wp_get_attachment_id3_keys( $post, 'edit' ) as $key => $label ) {
277
-			if ( isset( $post_data[ 'id3_' . $key ] ) ) {
278
-				$id3data[ $key ] = sanitize_text_field( wp_unslash( $post_data[ 'id3_' . $key ] ) );
276
+		foreach (wp_get_attachment_id3_keys($post, 'edit') as $key => $label) {
277
+			if (isset($post_data['id3_'.$key])) {
278
+				$id3data[$key] = sanitize_text_field(wp_unslash($post_data['id3_'.$key]));
279 279
 			}
280 280
 		}
281
-		wp_update_attachment_metadata( $post_ID, $id3data );
281
+		wp_update_attachment_metadata($post_ID, $id3data);
282 282
 	}
283 283
 
284 284
 	// Meta Stuff
285
-	if ( isset($post_data['meta']) && $post_data['meta'] ) {
286
-		foreach ( $post_data['meta'] as $key => $value ) {
287
-			if ( !$meta = get_post_meta_by_id( $key ) )
285
+	if (isset($post_data['meta']) && $post_data['meta']) {
286
+		foreach ($post_data['meta'] as $key => $value) {
287
+			if ( ! $meta = get_post_meta_by_id($key))
288 288
 				continue;
289
-			if ( $meta->post_id != $post_ID )
289
+			if ($meta->post_id != $post_ID)
290 290
 				continue;
291
-			if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $meta->meta_key ) )
291
+			if (is_protected_meta($meta->meta_key, 'post') || ! current_user_can('edit_post_meta', $post_ID, $meta->meta_key))
292 292
 				continue;
293
-			if ( is_protected_meta( $value['key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $value['key'] ) )
293
+			if (is_protected_meta($value['key'], 'post') || ! current_user_can('edit_post_meta', $post_ID, $value['key']))
294 294
 				continue;
295
-			update_meta( $key, $value['key'], $value['value'] );
295
+			update_meta($key, $value['key'], $value['value']);
296 296
 		}
297 297
 	}
298 298
 
299
-	if ( isset($post_data['deletemeta']) && $post_data['deletemeta'] ) {
300
-		foreach ( $post_data['deletemeta'] as $key => $value ) {
301
-			if ( !$meta = get_post_meta_by_id( $key ) )
299
+	if (isset($post_data['deletemeta']) && $post_data['deletemeta']) {
300
+		foreach ($post_data['deletemeta'] as $key => $value) {
301
+			if ( ! $meta = get_post_meta_by_id($key))
302 302
 				continue;
303
-			if ( $meta->post_id != $post_ID )
303
+			if ($meta->post_id != $post_ID)
304 304
 				continue;
305
-			if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $post_ID, $meta->meta_key ) )
305
+			if (is_protected_meta($meta->meta_key, 'post') || ! current_user_can('delete_post_meta', $post_ID, $meta->meta_key))
306 306
 				continue;
307
-			delete_meta( $key );
307
+			delete_meta($key);
308 308
 		}
309 309
 	}
310 310
 
311 311
 	// Attachment stuff
312
-	if ( 'attachment' == $post_data['post_type'] ) {
313
-		if ( isset( $post_data[ '_wp_attachment_image_alt' ] ) ) {
314
-			$image_alt = wp_unslash( $post_data['_wp_attachment_image_alt'] );
315
-			if ( $image_alt != get_post_meta( $post_ID, '_wp_attachment_image_alt', true ) ) {
316
-				$image_alt = wp_strip_all_tags( $image_alt, true );
312
+	if ('attachment' == $post_data['post_type']) {
313
+		if (isset($post_data['_wp_attachment_image_alt'])) {
314
+			$image_alt = wp_unslash($post_data['_wp_attachment_image_alt']);
315
+			if ($image_alt != get_post_meta($post_ID, '_wp_attachment_image_alt', true)) {
316
+				$image_alt = wp_strip_all_tags($image_alt, true);
317 317
 				// update_meta expects slashed.
318
-				update_post_meta( $post_ID, '_wp_attachment_image_alt', wp_slash( $image_alt ) );
318
+				update_post_meta($post_ID, '_wp_attachment_image_alt', wp_slash($image_alt));
319 319
 			}
320 320
 		}
321 321
 
322
-		$attachment_data = isset( $post_data['attachments'][ $post_ID ] ) ? $post_data['attachments'][ $post_ID ] : array();
322
+		$attachment_data = isset($post_data['attachments'][$post_ID]) ? $post_data['attachments'][$post_ID] : array();
323 323
 
324 324
 		/** This filter is documented in wp-admin/includes/media.php */
325
-		$post_data = apply_filters( 'attachment_fields_to_save', $post_data, $attachment_data );
325
+		$post_data = apply_filters('attachment_fields_to_save', $post_data, $attachment_data);
326 326
 	}
327 327
 
328 328
 	// Convert taxonomy input to term IDs, to avoid ambiguity.
329
-	if ( isset( $post_data['tax_input'] ) ) {
330
-		foreach ( (array) $post_data['tax_input'] as $taxonomy => $terms ) {
329
+	if (isset($post_data['tax_input'])) {
330
+		foreach ((array) $post_data['tax_input'] as $taxonomy => $terms) {
331 331
 			// Hierarchical taxonomy data is already sent as term IDs, so no conversion is necessary.
332
-			if ( is_taxonomy_hierarchical( $taxonomy ) ) {
332
+			if (is_taxonomy_hierarchical($taxonomy)) {
333 333
 				continue;
334 334
 			}
335 335
 
@@ -338,67 +338,67 @@  discard block
 block discarded – undo
338 338
 			 * Some languages may use a character other than a comma as a delimiter, so we standardize on
339 339
 			 * commas before parsing the list.
340 340
 			 */
341
-			if ( ! is_array( $terms ) ) {
342
-				$comma = _x( ',', 'tag delimiter' );
343
-				if ( ',' !== $comma ) {
344
-					$terms = str_replace( $comma, ',', $terms );
341
+			if ( ! is_array($terms)) {
342
+				$comma = _x(',', 'tag delimiter');
343
+				if (',' !== $comma) {
344
+					$terms = str_replace($comma, ',', $terms);
345 345
 				}
346
-				$terms = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) );
346
+				$terms = explode(',', trim($terms, " \n\t\r\0\x0B,"));
347 347
 			}
348 348
 
349 349
 			$clean_terms = array();
350
-			foreach ( $terms as $term ) {
350
+			foreach ($terms as $term) {
351 351
 				// Empty terms are invalid input.
352
-				if ( empty( $term ) ) {
352
+				if (empty($term)) {
353 353
 					continue;
354 354
 				}
355 355
 
356
-				$_term = get_terms( $taxonomy, array(
356
+				$_term = get_terms($taxonomy, array(
357 357
 					'name' => $term,
358 358
 					'fields' => 'ids',
359 359
 					'hide_empty' => false,
360
-				) );
360
+				));
361 361
 
362
-				if ( ! empty( $_term ) ) {
363
-					$clean_terms[] = intval( $_term[0] );
362
+				if ( ! empty($_term)) {
363
+					$clean_terms[] = intval($_term[0]);
364 364
 				} else {
365 365
 					// No existing term was found, so pass the string. A new term will be created.
366 366
 					$clean_terms[] = $term;
367 367
 				}
368 368
 			}
369 369
 
370
-			$post_data['tax_input'][ $taxonomy ] = $clean_terms;
370
+			$post_data['tax_input'][$taxonomy] = $clean_terms;
371 371
 		}
372 372
 	}
373 373
 
374
-	add_meta( $post_ID );
374
+	add_meta($post_ID);
375 375
 
376
-	update_post_meta( $post_ID, '_edit_last', get_current_user_id() );
376
+	update_post_meta($post_ID, '_edit_last', get_current_user_id());
377 377
 
378
-	$success = wp_update_post( $post_data );
378
+	$success = wp_update_post($post_data);
379 379
 	// If the save failed, see if we can sanity check the main fields and try again
380
-	if ( ! $success && is_callable( array( $wpdb, 'strip_invalid_text_for_column' ) ) ) {
381
-		$fields = array( 'post_title', 'post_content', 'post_excerpt' );
380
+	if ( ! $success && is_callable(array($wpdb, 'strip_invalid_text_for_column'))) {
381
+		$fields = array('post_title', 'post_content', 'post_excerpt');
382 382
 
383
-		foreach ( $fields as $field ) {
384
-			if ( isset( $post_data[ $field ] ) ) {
385
-				$post_data[ $field ] = $wpdb->strip_invalid_text_for_column( $wpdb->posts, $field, $post_data[ $field ] );
383
+		foreach ($fields as $field) {
384
+			if (isset($post_data[$field])) {
385
+				$post_data[$field] = $wpdb->strip_invalid_text_for_column($wpdb->posts, $field, $post_data[$field]);
386 386
 			}
387 387
 		}
388 388
 
389
-		wp_update_post( $post_data );
389
+		wp_update_post($post_data);
390 390
 	}
391 391
 
392 392
 	// Now that we have an ID we can fix any attachment anchor hrefs
393
-	_fix_attachment_links( $post_ID );
393
+	_fix_attachment_links($post_ID);
394 394
 
395
-	wp_set_post_lock( $post_ID );
395
+	wp_set_post_lock($post_ID);
396 396
 
397
-	if ( current_user_can( $ptype->cap->edit_others_posts ) && current_user_can( $ptype->cap->publish_posts ) ) {
398
-		if ( ! empty( $post_data['sticky'] ) )
399
-			stick_post( $post_ID );
397
+	if (current_user_can($ptype->cap->edit_others_posts) && current_user_can($ptype->cap->publish_posts)) {
398
+		if ( ! empty($post_data['sticky']))
399
+			stick_post($post_ID);
400 400
 		else
401
-			unstick_post( $post_ID );
401
+			unstick_post($post_ID);
402 402
 	}
403 403
 
404 404
 	return $post_ID;
@@ -417,22 +417,22 @@  discard block
 block discarded – undo
417 417
  * @param array $post_data Optional, the array of post data to process if not provided will use $_POST superglobal.
418 418
  * @return array
419 419
  */
420
-function bulk_edit_posts( $post_data = null ) {
420
+function bulk_edit_posts($post_data = null) {
421 421
 	global $wpdb;
422 422
 
423
-	if ( empty($post_data) )
423
+	if (empty($post_data))
424 424
 		$post_data = &$_POST;
425 425
 
426
-	if ( isset($post_data['post_type']) )
426
+	if (isset($post_data['post_type']))
427 427
 		$ptype = get_post_type_object($post_data['post_type']);
428 428
 	else
429 429
 		$ptype = get_post_type_object('post');
430 430
 
431
-	if ( !current_user_can( $ptype->cap->edit_posts ) ) {
432
-		if ( 'page' == $ptype->name )
433
-			wp_die( __('Sorry, you are not allowed to edit pages.'));
431
+	if ( ! current_user_can($ptype->cap->edit_posts)) {
432
+		if ('page' == $ptype->name)
433
+			wp_die(__('Sorry, you are not allowed to edit pages.'));
434 434
 		else
435
-			wp_die( __('Sorry, you are not allowed to edit posts.'));
435
+			wp_die(__('Sorry, you are not allowed to edit posts.'));
436 436
 	}
437 437
 
438 438
 	if ( -1 == $post_data['_status'] ) {
@@ -443,15 +443,15 @@  discard block
 block discarded – undo
443 443
 	}
444 444
 	unset($post_data['_status']);
445 445
 
446
-	if ( ! empty( $post_data['post_status'] ) ) {
447
-		$post_data['post_status'] = sanitize_key( $post_data['post_status'] );
446
+	if ( ! empty($post_data['post_status'])) {
447
+		$post_data['post_status'] = sanitize_key($post_data['post_status']);
448 448
 
449
-		if ( 'inherit' == $post_data['post_status'] ) {
450
-			unset( $post_data['post_status'] );
449
+		if ('inherit' == $post_data['post_status']) {
450
+			unset($post_data['post_status']);
451 451
 		}
452 452
 	}
453 453
 
454
-	$post_IDs = array_map( 'intval', (array) $post_data['post'] );
454
+	$post_IDs = array_map('intval', (array) $post_data['post']);
455 455
 
456 456
 	$reset = array(
457 457
 		'post_author', 'post_status', 'post_password',
@@ -460,43 +460,43 @@  discard block
 block discarded – undo
460 460
 		'post_category', 'sticky', 'post_format',
461 461
 	);
462 462
 
463
-	foreach ( $reset as $field ) {
464
-		if ( isset($post_data[$field]) && ( '' == $post_data[$field] || -1 == $post_data[$field] ) )
463
+	foreach ($reset as $field) {
464
+		if (isset($post_data[$field]) && ('' == $post_data[$field] || -1 == $post_data[$field]))
465 465
 			unset($post_data[$field]);
466 466
 	}
467 467
 
468
-	if ( isset($post_data['post_category']) ) {
469
-		if ( is_array($post_data['post_category']) && ! empty($post_data['post_category']) )
470
-			$new_cats = array_map( 'absint', $post_data['post_category'] );
468
+	if (isset($post_data['post_category'])) {
469
+		if (is_array($post_data['post_category']) && ! empty($post_data['post_category']))
470
+			$new_cats = array_map('absint', $post_data['post_category']);
471 471
 		else
472 472
 			unset($post_data['post_category']);
473 473
 	}
474 474
 
475 475
 	$tax_input = array();
476
-	if ( isset($post_data['tax_input'])) {
477
-		foreach ( $post_data['tax_input'] as $tax_name => $terms ) {
478
-			if ( empty($terms) )
476
+	if (isset($post_data['tax_input'])) {
477
+		foreach ($post_data['tax_input'] as $tax_name => $terms) {
478
+			if (empty($terms))
479 479
 				continue;
480
-			if ( is_taxonomy_hierarchical( $tax_name ) ) {
481
-				$tax_input[ $tax_name ] = array_map( 'absint', $terms );
480
+			if (is_taxonomy_hierarchical($tax_name)) {
481
+				$tax_input[$tax_name] = array_map('absint', $terms);
482 482
 			} else {
483
-				$comma = _x( ',', 'tag delimiter' );
484
-				if ( ',' !== $comma )
485
-					$terms = str_replace( $comma, ',', $terms );
486
-				$tax_input[ $tax_name ] = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) );
483
+				$comma = _x(',', 'tag delimiter');
484
+				if (',' !== $comma)
485
+					$terms = str_replace($comma, ',', $terms);
486
+				$tax_input[$tax_name] = explode(',', trim($terms, " \n\t\r\0\x0B,"));
487 487
 			}
488 488
 		}
489 489
 	}
490 490
 
491
-	if ( isset($post_data['post_parent']) && ($parent = (int) $post_data['post_parent']) ) {
491
+	if (isset($post_data['post_parent']) && ($parent = (int) $post_data['post_parent'])) {
492 492
 		$pages = $wpdb->get_results("SELECT ID, post_parent FROM $wpdb->posts WHERE post_type = 'page'");
493 493
 		$children = array();
494 494
 
495
-		for ( $i = 0; $i < 50 && $parent > 0; $i++ ) {
495
+		for ($i = 0; $i < 50 && $parent > 0; $i++) {
496 496
 			$children[] = $parent;
497 497
 
498
-			foreach ( $pages as $page ) {
499
-				if ( $page->ID == $parent ) {
498
+			foreach ($pages as $page) {
499
+				if ($page->ID == $parent) {
500 500
 					$parent = $page->post_parent;
501 501
 					break;
502 502
 				}
@@ -507,78 +507,78 @@  discard block
 block discarded – undo
507 507
 	$updated = $skipped = $locked = array();
508 508
 	$shared_post_data = $post_data;
509 509
 
510
-	foreach ( $post_IDs as $post_ID ) {
510
+	foreach ($post_IDs as $post_ID) {
511 511
 		// Start with fresh post data with each iteration.
512 512
 		$post_data = $shared_post_data;
513 513
 
514
-		$post_type_object = get_post_type_object( get_post_type( $post_ID ) );
514
+		$post_type_object = get_post_type_object(get_post_type($post_ID));
515 515
 
516
-		if ( !isset( $post_type_object ) || ( isset($children) && in_array($post_ID, $children) ) || !current_user_can( 'edit_post', $post_ID ) ) {
516
+		if ( ! isset($post_type_object) || (isset($children) && in_array($post_ID, $children)) || ! current_user_can('edit_post', $post_ID)) {
517 517
 			$skipped[] = $post_ID;
518 518
 			continue;
519 519
 		}
520 520
 
521
-		if ( wp_check_post_lock( $post_ID ) ) {
521
+		if (wp_check_post_lock($post_ID)) {
522 522
 			$locked[] = $post_ID;
523 523
 			continue;
524 524
 		}
525 525
 
526
-		$post = get_post( $post_ID );
527
-		$tax_names = get_object_taxonomies( $post );
528
-		foreach ( $tax_names as $tax_name ) {
526
+		$post = get_post($post_ID);
527
+		$tax_names = get_object_taxonomies($post);
528
+		foreach ($tax_names as $tax_name) {
529 529
 			$taxonomy_obj = get_taxonomy($tax_name);
530
-			if ( isset( $tax_input[$tax_name]) && current_user_can( $taxonomy_obj->cap->assign_terms ) )
530
+			if (isset($tax_input[$tax_name]) && current_user_can($taxonomy_obj->cap->assign_terms))
531 531
 				$new_terms = $tax_input[$tax_name];
532 532
 			else
533 533
 				$new_terms = array();
534 534
 
535
-			if ( $taxonomy_obj->hierarchical )
536
-				$current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'ids') );
535
+			if ($taxonomy_obj->hierarchical)
536
+				$current_terms = (array) wp_get_object_terms($post_ID, $tax_name, array('fields' => 'ids'));
537 537
 			else
538
-				$current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'names') );
538
+				$current_terms = (array) wp_get_object_terms($post_ID, $tax_name, array('fields' => 'names'));
539 539
 
540
-			$post_data['tax_input'][$tax_name] = array_merge( $current_terms, $new_terms );
540
+			$post_data['tax_input'][$tax_name] = array_merge($current_terms, $new_terms);
541 541
 		}
542 542
 
543
-		if ( isset($new_cats) && in_array( 'category', $tax_names ) ) {
543
+		if (isset($new_cats) && in_array('category', $tax_names)) {
544 544
 			$cats = (array) wp_get_post_categories($post_ID);
545
-			$post_data['post_category'] = array_unique( array_merge($cats, $new_cats) );
546
-			unset( $post_data['tax_input']['category'] );
545
+			$post_data['post_category'] = array_unique(array_merge($cats, $new_cats));
546
+			unset($post_data['tax_input']['category']);
547 547
 		}
548 548
 
549 549
 		$post_data['post_type'] = $post->post_type;
550 550
 		$post_data['post_mime_type'] = $post->post_mime_type;
551 551
 		$post_data['guid'] = $post->guid;
552 552
 
553
-		foreach ( array( 'comment_status', 'ping_status', 'post_author' ) as $field ) {
554
-			if ( ! isset( $post_data[ $field ] ) ) {
555
-				$post_data[ $field ] = $post->$field;
553
+		foreach (array('comment_status', 'ping_status', 'post_author') as $field) {
554
+			if ( ! isset($post_data[$field])) {
555
+				$post_data[$field] = $post->$field;
556 556
 			}
557 557
 		}
558 558
 
559 559
 		$post_data['ID'] = $post_ID;
560 560
 		$post_data['post_ID'] = $post_ID;
561 561
 
562
-		$post_data = _wp_translate_postdata( true, $post_data );
563
-		if ( is_wp_error( $post_data ) ) {
562
+		$post_data = _wp_translate_postdata(true, $post_data);
563
+		if (is_wp_error($post_data)) {
564 564
 			$skipped[] = $post_ID;
565 565
 			continue;
566 566
 		}
567 567
 
568
-		$updated[] = wp_update_post( $post_data );
568
+		$updated[] = wp_update_post($post_data);
569 569
 
570
-		if ( isset( $post_data['sticky'] ) && current_user_can( $ptype->cap->edit_others_posts ) ) {
571
-			if ( 'sticky' == $post_data['sticky'] )
572
-				stick_post( $post_ID );
570
+		if (isset($post_data['sticky']) && current_user_can($ptype->cap->edit_others_posts)) {
571
+			if ('sticky' == $post_data['sticky'])
572
+				stick_post($post_ID);
573 573
 			else
574
-				unstick_post( $post_ID );
574
+				unstick_post($post_ID);
575 575
 		}
576 576
 
577
-		if ( isset( $post_data['post_format'] ) )
578
-			set_post_format( $post_ID, $post_data['post_format'] );
577
+		if (isset($post_data['post_format']))
578
+			set_post_format($post_ID, $post_data['post_format']);
579 579
 	}
580 580
 
581
-	return array( 'updated' => $updated, 'skipped' => $skipped, 'locked' => $locked );
581
+	return array('updated' => $updated, 'skipped' => $skipped, 'locked' => $locked);
582 582
 }
583 583
 
584 584
 /**
@@ -590,24 +590,24 @@  discard block
 block discarded – undo
590 590
  * @param bool   $create_in_db Optional. Whether to insert the post into database. Default false.
591 591
  * @return WP_Post Post object containing all the default post data as attributes
592 592
  */
593
-function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) {
593
+function get_default_post_to_edit($post_type = 'post', $create_in_db = false) {
594 594
 	$post_title = '';
595
-	if ( !empty( $_REQUEST['post_title'] ) )
596
-		$post_title = esc_html( wp_unslash( $_REQUEST['post_title'] ));
595
+	if ( ! empty($_REQUEST['post_title']))
596
+		$post_title = esc_html(wp_unslash($_REQUEST['post_title']));
597 597
 
598 598
 	$post_content = '';
599
-	if ( !empty( $_REQUEST['content'] ) )
600
-		$post_content = esc_html( wp_unslash( $_REQUEST['content'] ));
599
+	if ( ! empty($_REQUEST['content']))
600
+		$post_content = esc_html(wp_unslash($_REQUEST['content']));
601 601
 
602 602
 	$post_excerpt = '';
603
-	if ( !empty( $_REQUEST['excerpt'] ) )
604
-		$post_excerpt = esc_html( wp_unslash( $_REQUEST['excerpt'] ));
605
-
606
-	if ( $create_in_db ) {
607
-		$post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) );
608
-		$post = get_post( $post_id );
609
-		if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) )
610
-			set_post_format( $post, get_option( 'default_post_format' ) );
603
+	if ( ! empty($_REQUEST['excerpt']))
604
+		$post_excerpt = esc_html(wp_unslash($_REQUEST['excerpt']));
605
+
606
+	if ($create_in_db) {
607
+		$post_id = wp_insert_post(array('post_title' => __('Auto Draft'), 'post_type' => $post_type, 'post_status' => 'auto-draft'));
608
+		$post = get_post($post_id);
609
+		if (current_theme_supports('post-formats') && post_type_supports($post->post_type, 'post-formats') && get_option('default_post_format'))
610
+			set_post_format($post, get_option('default_post_format'));
611 611
 	} else {
612 612
 		$post = new stdClass;
613 613
 		$post->ID = 0;
@@ -620,14 +620,14 @@  discard block
 block discarded – undo
620 620
 		$post->post_status = 'draft';
621 621
 		$post->to_ping = '';
622 622
 		$post->pinged = '';
623
-		$post->comment_status = get_default_comment_status( $post_type );
624
-		$post->ping_status = get_default_comment_status( $post_type, 'pingback' );
625
-		$post->post_pingback = get_option( 'default_pingback_flag' );
626
-		$post->post_category = get_option( 'default_category' );
623
+		$post->comment_status = get_default_comment_status($post_type);
624
+		$post->ping_status = get_default_comment_status($post_type, 'pingback');
625
+		$post->post_pingback = get_option('default_pingback_flag');
626
+		$post->post_category = get_option('default_category');
627 627
 		$post->page_template = 'default';
628 628
 		$post->post_parent = 0;
629 629
 		$post->menu_order = 0;
630
-		$post = new WP_Post( $post );
630
+		$post = new WP_Post($post);
631 631
 	}
632 632
 
633 633
 	/**
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
 	 * @param string  $post_content Default post content.
639 639
 	 * @param WP_Post $post         Post object.
640 640
 	 */
641
-	$post->post_content = apply_filters( 'default_content', $post_content, $post );
641
+	$post->post_content = apply_filters('default_content', $post_content, $post);
642 642
 
643 643
 	/**
644 644
 	 * Filters the default post title initially used in the "Write Post" form.
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
 	 * @param string  $post_title Default post title.
649 649
 	 * @param WP_Post $post       Post object.
650 650
 	 */
651
-	$post->post_title = apply_filters( 'default_title', $post_title, $post );
651
+	$post->post_title = apply_filters('default_title', $post_title, $post);
652 652
 
653 653
 	/**
654 654
 	 * Filters the default post excerpt initially used in the "Write Post" form.
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 	 * @param string  $post_excerpt Default post excerpt.
659 659
 	 * @param WP_Post $post         Post object.
660 660
 	 */
661
-	$post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt, $post );
661
+	$post->post_excerpt = apply_filters('default_excerpt', $post_excerpt, $post);
662 662
 
663 663
 	return $post;
664 664
 }
@@ -678,30 +678,30 @@  discard block
 block discarded – undo
678 678
 function post_exists($title, $content = '', $date = '') {
679 679
 	global $wpdb;
680 680
 
681
-	$post_title = wp_unslash( sanitize_post_field( 'post_title', $title, 0, 'db' ) );
682
-	$post_content = wp_unslash( sanitize_post_field( 'post_content', $content, 0, 'db' ) );
683
-	$post_date = wp_unslash( sanitize_post_field( 'post_date', $date, 0, 'db' ) );
681
+	$post_title = wp_unslash(sanitize_post_field('post_title', $title, 0, 'db'));
682
+	$post_content = wp_unslash(sanitize_post_field('post_content', $content, 0, 'db'));
683
+	$post_date = wp_unslash(sanitize_post_field('post_date', $date, 0, 'db'));
684 684
 
685 685
 	$query = "SELECT ID FROM $wpdb->posts WHERE 1=1";
686 686
 	$args = array();
687 687
 
688
-	if ( !empty ( $date ) ) {
688
+	if ( ! empty ($date)) {
689 689
 		$query .= ' AND post_date = %s';
690 690
 		$args[] = $post_date;
691 691
 	}
692 692
 
693
-	if ( !empty ( $title ) ) {
693
+	if ( ! empty ($title)) {
694 694
 		$query .= ' AND post_title = %s';
695 695
 		$args[] = $post_title;
696 696
 	}
697 697
 
698
-	if ( !empty ( $content ) ) {
698
+	if ( ! empty ($content)) {
699 699
 		$query .= ' AND post_content = %s';
700 700
 		$args[] = $post_content;
701 701
 	}
702 702
 
703
-	if ( !empty ( $args ) )
704
-		return (int) $wpdb->get_var( $wpdb->prepare($query, $args) );
703
+	if ( ! empty ($args))
704
+		return (int) $wpdb->get_var($wpdb->prepare($query, $args));
705 705
 
706 706
 	return 0;
707 707
 }
@@ -716,63 +716,63 @@  discard block
 block discarded – undo
716 716
  * @return int|WP_Error
717 717
  */
718 718
 function wp_write_post() {
719
-	if ( isset($_POST['post_type']) )
719
+	if (isset($_POST['post_type']))
720 720
 		$ptype = get_post_type_object($_POST['post_type']);
721 721
 	else
722 722
 		$ptype = get_post_type_object('post');
723 723
 
724
-	if ( !current_user_can( $ptype->cap->edit_posts ) ) {
725
-		if ( 'page' == $ptype->name )
726
-			return new WP_Error( 'edit_pages', __( 'Sorry, you are not allowed to create pages on this site.' ) );
724
+	if ( ! current_user_can($ptype->cap->edit_posts)) {
725
+		if ('page' == $ptype->name)
726
+			return new WP_Error('edit_pages', __('Sorry, you are not allowed to create pages on this site.'));
727 727
 		else
728
-			return new WP_Error( 'edit_posts', __( 'Sorry, you are not allowed to create posts or drafts on this site.' ) );
728
+			return new WP_Error('edit_posts', __('Sorry, you are not allowed to create posts or drafts on this site.'));
729 729
 	}
730 730
 
731 731
 	$_POST['post_mime_type'] = '';
732 732
 
733 733
 	// Clear out any data in internal vars.
734
-	unset( $_POST['filter'] );
734
+	unset($_POST['filter']);
735 735
 
736 736
 	// Edit don't write if we have a post id.
737
-	if ( isset( $_POST['post_ID'] ) )
737
+	if (isset($_POST['post_ID']))
738 738
 		return edit_post();
739 739
 
740
-	if ( isset($_POST['visibility']) ) {
741
-		switch ( $_POST['visibility'] ) {
740
+	if (isset($_POST['visibility'])) {
741
+		switch ($_POST['visibility']) {
742 742
 			case 'public' :
743 743
 				$_POST['post_password'] = '';
744 744
 				break;
745 745
 			case 'password' :
746
-				unset( $_POST['sticky'] );
746
+				unset($_POST['sticky']);
747 747
 				break;
748 748
 			case 'private' :
749 749
 				$_POST['post_status'] = 'private';
750 750
 				$_POST['post_password'] = '';
751
-				unset( $_POST['sticky'] );
751
+				unset($_POST['sticky']);
752 752
 				break;
753 753
 		}
754 754
 	}
755 755
 
756
-	$translated = _wp_translate_postdata( false );
757
-	if ( is_wp_error($translated) )
756
+	$translated = _wp_translate_postdata(false);
757
+	if (is_wp_error($translated))
758 758
 		return $translated;
759 759
 
760 760
 	// Create the post.
761
-	$post_ID = wp_insert_post( $_POST );
762
-	if ( is_wp_error( $post_ID ) )
761
+	$post_ID = wp_insert_post($_POST);
762
+	if (is_wp_error($post_ID))
763 763
 		return $post_ID;
764 764
 
765
-	if ( empty($post_ID) )
765
+	if (empty($post_ID))
766 766
 		return 0;
767 767
 
768
-	add_meta( $post_ID );
768
+	add_meta($post_ID);
769 769
 
770
-	add_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID );
770
+	add_post_meta($post_ID, '_edit_last', $GLOBALS['current_user']->ID);
771 771
 
772 772
 	// Now that we have an ID we can fix any attachment anchor hrefs
773
-	_fix_attachment_links( $post_ID );
773
+	_fix_attachment_links($post_ID);
774 774
 
775
-	wp_set_post_lock( $post_ID );
775
+	wp_set_post_lock($post_ID);
776 776
 
777 777
 	return $post_ID;
778 778
 }
@@ -786,8 +786,8 @@  discard block
 block discarded – undo
786 786
  */
787 787
 function write_post() {
788 788
 	$result = wp_write_post();
789
-	if ( is_wp_error( $result ) )
790
-		wp_die( $result->get_error_message() );
789
+	if (is_wp_error($result))
790
+		wp_die($result->get_error_message());
791 791
 	else
792 792
 		return $result;
793 793
 }
@@ -804,32 +804,32 @@  discard block
 block discarded – undo
804 804
  * @param int $post_ID
805 805
  * @return int|bool
806 806
  */
807
-function add_meta( $post_ID ) {
807
+function add_meta($post_ID) {
808 808
 	$post_ID = (int) $post_ID;
809 809
 
810
-	$metakeyselect = isset($_POST['metakeyselect']) ? wp_unslash( trim( $_POST['metakeyselect'] ) ) : '';
811
-	$metakeyinput = isset($_POST['metakeyinput']) ? wp_unslash( trim( $_POST['metakeyinput'] ) ) : '';
810
+	$metakeyselect = isset($_POST['metakeyselect']) ? wp_unslash(trim($_POST['metakeyselect'])) : '';
811
+	$metakeyinput = isset($_POST['metakeyinput']) ? wp_unslash(trim($_POST['metakeyinput'])) : '';
812 812
 	$metavalue = isset($_POST['metavalue']) ? $_POST['metavalue'] : '';
813
-	if ( is_string( $metavalue ) )
814
-		$metavalue = trim( $metavalue );
813
+	if (is_string($metavalue))
814
+		$metavalue = trim($metavalue);
815 815
 
816
-	if ( ('0' === $metavalue || ! empty ( $metavalue ) ) && ( ( ( '#NONE#' != $metakeyselect ) && !empty ( $metakeyselect) ) || !empty ( $metakeyinput ) ) ) {
816
+	if (('0' === $metavalue || ! empty ($metavalue)) && ((('#NONE#' != $metakeyselect) && ! empty ($metakeyselect)) || ! empty ($metakeyinput))) {
817 817
 		/*
818 818
 		 * We have a key/value pair. If both the select and the input
819 819
 		 * for the key have data, the input takes precedence.
820 820
 		 */
821
- 		if ( '#NONE#' != $metakeyselect )
821
+ 		if ('#NONE#' != $metakeyselect)
822 822
 			$metakey = $metakeyselect;
823 823
 
824
-		if ( $metakeyinput )
824
+		if ($metakeyinput)
825 825
 			$metakey = $metakeyinput; // default
826 826
 
827
-		if ( is_protected_meta( $metakey, 'post' ) || ! current_user_can( 'add_post_meta', $post_ID, $metakey ) )
827
+		if (is_protected_meta($metakey, 'post') || ! current_user_can('add_post_meta', $post_ID, $metakey))
828 828
 			return false;
829 829
 
830
-		$metakey = wp_slash( $metakey );
830
+		$metakey = wp_slash($metakey);
831 831
 
832
-		return add_post_meta( $post_ID, $metakey, $metavalue );
832
+		return add_post_meta($post_ID, $metakey, $metavalue);
833 833
 	}
834 834
 
835 835
 	return false;
@@ -843,8 +843,8 @@  discard block
 block discarded – undo
843 843
  * @param int $mid
844 844
  * @return bool
845 845
  */
846
-function delete_meta( $mid ) {
847
-	return delete_metadata_by_mid( 'post' , $mid );
846
+function delete_meta($mid) {
847
+	return delete_metadata_by_mid('post', $mid);
848 848
 }
849 849
 
850 850
 /**
@@ -859,11 +859,11 @@  discard block
 block discarded – undo
859 859
 function get_meta_keys() {
860 860
 	global $wpdb;
861 861
 
862
-	$keys = $wpdb->get_col( "
862
+	$keys = $wpdb->get_col("
863 863
 			SELECT meta_key
864 864
 			FROM $wpdb->postmeta
865 865
 			GROUP BY meta_key
866
-			ORDER BY meta_key" );
866
+			ORDER BY meta_key");
867 867
 
868 868
 	return $keys;
869 869
 }
@@ -876,8 +876,8 @@  discard block
 block discarded – undo
876 876
  * @param int $mid
877 877
  * @return object|bool
878 878
  */
879
-function get_post_meta_by_id( $mid ) {
880
-	return get_metadata_by_mid( 'post', $mid );
879
+function get_post_meta_by_id($mid) {
880
+	return get_metadata_by_mid('post', $mid);
881 881
 }
882 882
 
883 883
 /**
@@ -890,12 +890,12 @@  discard block
 block discarded – undo
890 890
  * @param int $postid
891 891
  * @return mixed
892 892
  */
893
-function has_meta( $postid ) {
893
+function has_meta($postid) {
894 894
 	global $wpdb;
895 895
 
896
-	return $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value, meta_id, post_id
896
+	return $wpdb->get_results($wpdb->prepare("SELECT meta_key, meta_value, meta_id, post_id
897 897
 			FROM $wpdb->postmeta WHERE post_id = %d
898
-			ORDER BY meta_key,meta_id", $postid), ARRAY_A );
898
+			ORDER BY meta_key,meta_id", $postid), ARRAY_A);
899 899
 }
900 900
 
901 901
 /**
@@ -908,11 +908,11 @@  discard block
 block discarded – undo
908 908
  * @param string $meta_value Expect Slashed
909 909
  * @return bool
910 910
  */
911
-function update_meta( $meta_id, $meta_key, $meta_value ) {
912
-	$meta_key = wp_unslash( $meta_key );
913
-	$meta_value = wp_unslash( $meta_value );
911
+function update_meta($meta_id, $meta_key, $meta_value) {
912
+	$meta_key = wp_unslash($meta_key);
913
+	$meta_value = wp_unslash($meta_value);
914 914
 
915
-	return update_metadata_by_mid( 'post', $meta_id, $meta_value, $meta_key );
915
+	return update_metadata_by_mid('post', $meta_id, $meta_value, $meta_key);
916 916
 }
917 917
 
918 918
 //
@@ -928,42 +928,42 @@  discard block
 block discarded – undo
928 928
  * @param int|object $post Post ID or post object.
929 929
  * @return void|int|WP_Error Void if nothing fixed. 0 or WP_Error on update failure. The post ID on update success.
930 930
  */
931
-function _fix_attachment_links( $post ) {
932
-	$post = get_post( $post, ARRAY_A );
931
+function _fix_attachment_links($post) {
932
+	$post = get_post($post, ARRAY_A);
933 933
 	$content = $post['post_content'];
934 934
 
935 935
 	// Don't run if no pretty permalinks or post is not published, scheduled, or privately published.
936
-	if ( ! get_option( 'permalink_structure' ) || ! in_array( $post['post_status'], array( 'publish', 'future', 'private' ) ) )
936
+	if ( ! get_option('permalink_structure') || ! in_array($post['post_status'], array('publish', 'future', 'private')))
937 937
 		return;
938 938
 
939 939
 	// Short if there aren't any links or no '?attachment_id=' strings (strpos cannot be zero)
940
-	if ( !strpos($content, '?attachment_id=') || !preg_match_all( '/<a ([^>]+)>[\s\S]+?<\/a>/', $content, $link_matches ) )
940
+	if ( ! strpos($content, '?attachment_id=') || ! preg_match_all('/<a ([^>]+)>[\s\S]+?<\/a>/', $content, $link_matches))
941 941
 		return;
942 942
 
943 943
 	$site_url = get_bloginfo('url');
944
-	$site_url = substr( $site_url, (int) strpos($site_url, '://') ); // remove the http(s)
944
+	$site_url = substr($site_url, (int) strpos($site_url, '://')); // remove the http(s)
945 945
 	$replace = '';
946 946
 
947
-	foreach ( $link_matches[1] as $key => $value ) {
948
-		if ( !strpos($value, '?attachment_id=') || !strpos($value, 'wp-att-')
949
-			|| !preg_match( '/href=(["\'])[^"\']*\?attachment_id=(\d+)[^"\']*\\1/', $value, $url_match )
950
-			|| !preg_match( '/rel=["\'][^"\']*wp-att-(\d+)/', $value, $rel_match ) )
947
+	foreach ($link_matches[1] as $key => $value) {
948
+		if ( ! strpos($value, '?attachment_id=') || ! strpos($value, 'wp-att-')
949
+			|| ! preg_match('/href=(["\'])[^"\']*\?attachment_id=(\d+)[^"\']*\\1/', $value, $url_match)
950
+			|| ! preg_match('/rel=["\'][^"\']*wp-att-(\d+)/', $value, $rel_match))
951 951
 				continue;
952 952
 
953 953
 		$quote = $url_match[1]; // the quote (single or double)
954 954
 		$url_id = (int) $url_match[2];
955 955
 		$rel_id = (int) $rel_match[1];
956 956
 
957
-		if ( !$url_id || !$rel_id || $url_id != $rel_id || strpos($url_match[0], $site_url) === false )
957
+		if ( ! $url_id || ! $rel_id || $url_id != $rel_id || strpos($url_match[0], $site_url) === false)
958 958
 			continue;
959 959
 
960 960
 		$link = $link_matches[0][$key];
961
-		$replace = str_replace( $url_match[0], 'href=' . $quote . get_attachment_link( $url_id ) . $quote, $link );
961
+		$replace = str_replace($url_match[0], 'href='.$quote.get_attachment_link($url_id).$quote, $link);
962 962
 
963
-		$content = str_replace( $link, $replace, $content );
963
+		$content = str_replace($link, $replace, $content);
964 964
 	}
965 965
 
966
-	if ( $replace ) {
966
+	if ($replace) {
967 967
 		$post['post_content'] = $content;
968 968
 		// Escape data pulled from DB.
969 969
 		$post = add_magic_quotes($post);
@@ -994,40 +994,40 @@  discard block
 block discarded – undo
994 994
  * @param array|bool $q Array of query variables to use to build the query or false to use $_GET superglobal.
995 995
  * @return array
996 996
  */
997
-function wp_edit_posts_query( $q = false ) {
998
-	if ( false === $q )
997
+function wp_edit_posts_query($q = false) {
998
+	if (false === $q)
999 999
 		$q = $_GET;
1000 1000
 	$q['m'] = isset($q['m']) ? (int) $q['m'] : 0;
1001 1001
 	$q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0;
1002
-	$post_stati  = get_post_stati();
1002
+	$post_stati = get_post_stati();
1003 1003
 
1004
-	if ( isset($q['post_type']) && in_array( $q['post_type'], get_post_types() ) )
1004
+	if (isset($q['post_type']) && in_array($q['post_type'], get_post_types()))
1005 1005
 		$post_type = $q['post_type'];
1006 1006
 	else
1007 1007
 		$post_type = 'post';
1008 1008
 
1009 1009
 	$avail_post_stati = get_available_post_statuses($post_type);
1010 1010
 
1011
-	if ( isset($q['post_status']) && in_array( $q['post_status'], $post_stati ) ) {
1011
+	if (isset($q['post_status']) && in_array($q['post_status'], $post_stati)) {
1012 1012
 		$post_status = $q['post_status'];
1013 1013
 		$perm = 'readable';
1014 1014
 	}
1015 1015
 
1016
-	if ( isset( $q['orderby'] ) ) {
1016
+	if (isset($q['orderby'])) {
1017 1017
 		$orderby = $q['orderby'];
1018
-	} elseif ( isset( $q['post_status'] ) && in_array( $q['post_status'], array( 'pending', 'draft' ) ) ) {
1018
+	} elseif (isset($q['post_status']) && in_array($q['post_status'], array('pending', 'draft'))) {
1019 1019
 		$orderby = 'modified';
1020 1020
 	}
1021 1021
 
1022
-	if ( isset( $q['order'] ) ) {
1022
+	if (isset($q['order'])) {
1023 1023
 		$order = $q['order'];
1024
-	} elseif ( isset( $q['post_status'] ) && 'pending' == $q['post_status'] ) {
1024
+	} elseif (isset($q['post_status']) && 'pending' == $q['post_status']) {
1025 1025
 		$order = 'ASC';
1026 1026
 	}
1027 1027
 
1028 1028
 	$per_page = "edit_{$post_type}_per_page";
1029
-	$posts_per_page = (int) get_user_option( $per_page );
1030
-	if ( empty( $posts_per_page ) || $posts_per_page < 1 )
1029
+	$posts_per_page = (int) get_user_option($per_page);
1030
+	if (empty($posts_per_page) || $posts_per_page < 1)
1031 1031
 		$posts_per_page = 20;
1032 1032
 
1033 1033
 	/**
@@ -1043,7 +1043,7 @@  discard block
 block discarded – undo
1043 1043
 	 * @param int $posts_per_page Number of posts to display per page for the given post
1044 1044
 	 *                            type. Default 20.
1045 1045
 	 */
1046
-	$posts_per_page = apply_filters( "edit_{$post_type}_per_page", $posts_per_page );
1046
+	$posts_per_page = apply_filters("edit_{$post_type}_per_page", $posts_per_page);
1047 1047
 
1048 1048
 	/**
1049 1049
 	 * Filters the number of posts displayed per page when specifically listing "posts".
@@ -1053,12 +1053,12 @@  discard block
 block discarded – undo
1053 1053
 	 * @param int    $posts_per_page Number of posts to be displayed. Default 20.
1054 1054
 	 * @param string $post_type      The post type.
1055 1055
 	 */
1056
-	$posts_per_page = apply_filters( 'edit_posts_per_page', $posts_per_page, $post_type );
1056
+	$posts_per_page = apply_filters('edit_posts_per_page', $posts_per_page, $post_type);
1057 1057
 
1058 1058
 	$query = compact('post_type', 'post_status', 'perm', 'order', 'orderby', 'posts_per_page');
1059 1059
 
1060 1060
 	// Hierarchical types require special args.
1061
-	if ( is_post_type_hierarchical( $post_type ) && !isset($orderby) ) {
1061
+	if (is_post_type_hierarchical($post_type) && ! isset($orderby)) {
1062 1062
 		$query['orderby'] = 'menu_order title';
1063 1063
 		$query['order'] = 'asc';
1064 1064
 		$query['posts_per_page'] = -1;
@@ -1066,10 +1066,10 @@  discard block
 block discarded – undo
1066 1066
 		$query['fields'] = 'id=>parent';
1067 1067
 	}
1068 1068
 
1069
-	if ( ! empty( $q['show_sticky'] ) )
1070
-		$query['post__in'] = (array) get_option( 'sticky_posts' );
1069
+	if ( ! empty($q['show_sticky']))
1070
+		$query['post__in'] = (array) get_option('sticky_posts');
1071 1071
 
1072
-	wp( $query );
1072
+	wp($query);
1073 1073
 
1074 1074
 	return $avail_post_stati;
1075 1075
 }
@@ -1100,24 +1100,24 @@  discard block
 block discarded – undo
1100 1100
  *                       to use $_GET superglobal. Default false.
1101 1101
  * @return array The parsed query vars.
1102 1102
  */
1103
-function wp_edit_attachments_query_vars( $q = false ) {
1104
-	if ( false === $q ) {
1103
+function wp_edit_attachments_query_vars($q = false) {
1104
+	if (false === $q) {
1105 1105
 		$q = $_GET;
1106 1106
 	}
1107
-	$q['m']   = isset( $q['m'] ) ? (int) $q['m'] : 0;
1108
-	$q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0;
1107
+	$q['m']   = isset($q['m']) ? (int) $q['m'] : 0;
1108
+	$q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0;
1109 1109
 	$q['post_type'] = 'attachment';
1110
-	$post_type = get_post_type_object( 'attachment' );
1110
+	$post_type = get_post_type_object('attachment');
1111 1111
 	$states = 'inherit';
1112
-	if ( current_user_can( $post_type->cap->read_private_posts ) ) {
1112
+	if (current_user_can($post_type->cap->read_private_posts)) {
1113 1113
 		$states .= ',private';
1114 1114
 	}
1115 1115
 
1116
-	$q['post_status'] = isset( $q['status'] ) && 'trash' == $q['status'] ? 'trash' : $states;
1117
-	$q['post_status'] = isset( $q['attachment-filter'] ) && 'trash' == $q['attachment-filter'] ? 'trash' : $states;
1116
+	$q['post_status'] = isset($q['status']) && 'trash' == $q['status'] ? 'trash' : $states;
1117
+	$q['post_status'] = isset($q['attachment-filter']) && 'trash' == $q['attachment-filter'] ? 'trash' : $states;
1118 1118
 
1119
-	$media_per_page = (int) get_user_option( 'upload_per_page' );
1120
-	if ( empty( $media_per_page ) || $media_per_page < 1 ) {
1119
+	$media_per_page = (int) get_user_option('upload_per_page');
1120
+	if (empty($media_per_page) || $media_per_page < 1) {
1121 1121
 		$media_per_page = 20;
1122 1122
 	}
1123 1123
 
@@ -1128,27 +1128,27 @@  discard block
 block discarded – undo
1128 1128
 	 *
1129 1129
 	 * @param int $media_per_page Number of media to list. Default 20.
1130 1130
 	 */
1131
-	$q['posts_per_page'] = apply_filters( 'upload_per_page', $media_per_page );
1131
+	$q['posts_per_page'] = apply_filters('upload_per_page', $media_per_page);
1132 1132
 
1133 1133
 	$post_mime_types = get_post_mime_types();
1134
-	if ( isset($q['post_mime_type']) && !array_intersect( (array) $q['post_mime_type'], array_keys($post_mime_types) ) ) {
1134
+	if (isset($q['post_mime_type']) && ! array_intersect((array) $q['post_mime_type'], array_keys($post_mime_types))) {
1135 1135
 		unset($q['post_mime_type']);
1136 1136
 	}
1137 1137
 
1138
-	foreach ( array_keys( $post_mime_types ) as $type ) {
1139
-		if ( isset( $q['attachment-filter'] ) && "post_mime_type:$type" == $q['attachment-filter'] ) {
1138
+	foreach (array_keys($post_mime_types) as $type) {
1139
+		if (isset($q['attachment-filter']) && "post_mime_type:$type" == $q['attachment-filter']) {
1140 1140
 			$q['post_mime_type'] = $type;
1141 1141
 			break;
1142 1142
 		}
1143 1143
 	}
1144 1144
 
1145
-	if ( isset( $q['detached'] ) || ( isset( $q['attachment-filter'] ) && 'detached' == $q['attachment-filter'] ) ) {
1145
+	if (isset($q['detached']) || (isset($q['attachment-filter']) && 'detached' == $q['attachment-filter'])) {
1146 1146
 		$q['post_parent'] = 0;
1147 1147
 	}
1148 1148
 
1149 1149
 	// Filter query clauses to include filenames.
1150
-	if ( isset( $q['s'] ) ) {
1151
-		add_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
1150
+	if (isset($q['s'])) {
1151
+		add_filter('posts_clauses', '_filter_query_attachment_filenames');
1152 1152
 	}
1153 1153
 
1154 1154
 	return $q;
@@ -1163,13 +1163,13 @@  discard block
 block discarded – undo
1163 1163
  * @param array|false $q Array of query variables to use to build the query or false to use $_GET superglobal.
1164 1164
  * @return array
1165 1165
  */
1166
-function wp_edit_attachments_query( $q = false ) {
1167
-	wp( wp_edit_attachments_query_vars( $q ) );
1166
+function wp_edit_attachments_query($q = false) {
1167
+	wp(wp_edit_attachments_query_vars($q));
1168 1168
 
1169 1169
 	$post_mime_types = get_post_mime_types();
1170
-	$avail_post_mime_types = get_available_post_mime_types( 'attachment' );
1170
+	$avail_post_mime_types = get_available_post_mime_types('attachment');
1171 1171
 
1172
-	return array( $post_mime_types, $avail_post_mime_types );
1172
+	return array($post_mime_types, $avail_post_mime_types);
1173 1173
 }
1174 1174
 
1175 1175
 /**
@@ -1181,17 +1181,17 @@  discard block
 block discarded – undo
1181 1181
  * @param string $page
1182 1182
  * @return string
1183 1183
  */
1184
-function postbox_classes( $id, $page ) {
1185
-	if ( isset( $_GET['edit'] ) && $_GET['edit'] == $id ) {
1186
-		$classes = array( '' );
1187
-	} elseif ( $closed = get_user_option('closedpostboxes_'.$page ) ) {
1188
-		if ( !is_array( $closed ) ) {
1189
-			$classes = array( '' );
1184
+function postbox_classes($id, $page) {
1185
+	if (isset($_GET['edit']) && $_GET['edit'] == $id) {
1186
+		$classes = array('');
1187
+	} elseif ($closed = get_user_option('closedpostboxes_'.$page)) {
1188
+		if ( ! is_array($closed)) {
1189
+			$classes = array('');
1190 1190
 		} else {
1191
-			$classes = in_array( $id, $closed ) ? array( 'closed' ) : array( '' );
1191
+			$classes = in_array($id, $closed) ? array('closed') : array('');
1192 1192
 		}
1193 1193
 	} else {
1194
-		$classes = array( '' );
1194
+		$classes = array('');
1195 1195
 	}
1196 1196
 
1197 1197
 	/**
@@ -1204,8 +1204,8 @@  discard block
 block discarded – undo
1204 1204
 	 *
1205 1205
 	 * @param array $classes An array of postbox classes.
1206 1206
 	 */
1207
-	$classes = apply_filters( "postbox_classes_{$page}_{$id}", $classes );
1208
-	return implode( ' ', $classes );
1207
+	$classes = apply_filters("postbox_classes_{$page}_{$id}", $classes);
1208
+	return implode(' ', $classes);
1209 1209
 }
1210 1210
 
1211 1211
 /**
@@ -1219,9 +1219,9 @@  discard block
 block discarded – undo
1219 1219
  * @return array Array containing the sample permalink with placeholder for the post name, and the post name.
1220 1220
  */
1221 1221
 function get_sample_permalink($id, $title = null, $name = null) {
1222
-	$post = get_post( $id );
1223
-	if ( ! $post )
1224
-		return array( '', '' );
1222
+	$post = get_post($id);
1223
+	if ( ! $post)
1224
+		return array('', '');
1225 1225
 
1226 1226
 	$ptype = get_post_type_object($post->post_type);
1227 1227
 
@@ -1230,14 +1230,14 @@  discard block
 block discarded – undo
1230 1230
 	$original_name = $post->post_name;
1231 1231
 
1232 1232
 	// Hack: get_permalink() would return ugly permalink for drafts, so we will fake that our post is published.
1233
-	if ( in_array( $post->post_status, array( 'draft', 'pending', 'future' ) ) ) {
1233
+	if (in_array($post->post_status, array('draft', 'pending', 'future'))) {
1234 1234
 		$post->post_status = 'publish';
1235 1235
 		$post->post_name = sanitize_title($post->post_name ? $post->post_name : $post->post_title, $post->ID);
1236 1236
 	}
1237 1237
 
1238 1238
 	// If the user wants to set a new name -- override the current one
1239 1239
 	// Note: if empty name is supplied -- use the title instead, see #6072
1240
-	if ( !is_null($name) )
1240
+	if ( ! is_null($name))
1241 1241
 		$post->post_name = sanitize_title($name ? $name : $title, $post->ID);
1242 1242
 
1243 1243
 	$post->post_name = wp_unique_post_slug($post->post_name, $post->ID, $post->post_status, $post->post_type, $post->post_parent);
@@ -1250,23 +1250,23 @@  discard block
 block discarded – undo
1250 1250
 	$permalink = str_replace("%$post->post_type%", '%pagename%', $permalink);
1251 1251
 
1252 1252
 	// Handle page hierarchy
1253
-	if ( $ptype->hierarchical ) {
1253
+	if ($ptype->hierarchical) {
1254 1254
 		$uri = get_page_uri($post);
1255
-		if ( $uri ) {
1255
+		if ($uri) {
1256 1256
 			$uri = untrailingslashit($uri);
1257
-			$uri = strrev( stristr( strrev( $uri ), '/' ) );
1257
+			$uri = strrev(stristr(strrev($uri), '/'));
1258 1258
 			$uri = untrailingslashit($uri);
1259 1259
 		}
1260 1260
 
1261 1261
 		/** This filter is documented in wp-admin/edit-tag-form.php */
1262
-		$uri = apply_filters( 'editable_slug', $uri, $post );
1263
-		if ( !empty($uri) )
1262
+		$uri = apply_filters('editable_slug', $uri, $post);
1263
+		if ( ! empty($uri))
1264 1264
 			$uri .= '/';
1265 1265
 		$permalink = str_replace('%pagename%', "{$uri}%pagename%", $permalink);
1266 1266
 	}
1267 1267
 
1268 1268
 	/** This filter is documented in wp-admin/edit-tag-form.php */
1269
-	$permalink = array( $permalink, apply_filters( 'editable_slug', $post->post_name, $post ) );
1269
+	$permalink = array($permalink, apply_filters('editable_slug', $post->post_name, $post));
1270 1270
 	$post->post_status = $original_status;
1271 1271
 	$post->post_date = $original_date;
1272 1272
 	$post->post_name = $original_name;
@@ -1283,7 +1283,7 @@  discard block
 block discarded – undo
1283 1283
 	 * @param string  $name      Post name (slug).
1284 1284
 	 * @param WP_Post $post      Post object.
1285 1285
 	 */
1286
-	return apply_filters( 'get_sample_permalink', $permalink, $post->ID, $title, $name, $post );
1286
+	return apply_filters('get_sample_permalink', $permalink, $post->ID, $title, $name, $post);
1287 1287
 }
1288 1288
 
1289 1289
 /**
@@ -1296,9 +1296,9 @@  discard block
 block discarded – undo
1296 1296
  * @param string $new_slug  Optional. New slug. Default null.
1297 1297
  * @return string The HTML of the sample permalink slug editor.
1298 1298
  */
1299
-function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
1300
-	$post = get_post( $id );
1301
-	if ( ! $post )
1299
+function get_sample_permalink_html($id, $new_title = null, $new_slug = null) {
1300
+	$post = get_post($id);
1301
+	if ( ! $post)
1302 1302
 		return '';
1303 1303
 
1304 1304
 	list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug);
@@ -1306,50 +1306,50 @@  discard block
 block discarded – undo
1306 1306
 	$view_link = false;
1307 1307
 	$preview_target = '';
1308 1308
 
1309
-	if ( current_user_can( 'read_post', $post->ID ) ) {
1310
-		if ( 'draft' === $post->post_status || empty( $post->post_name ) ) {
1311
-			$view_link = get_preview_post_link( $post );
1309
+	if (current_user_can('read_post', $post->ID)) {
1310
+		if ('draft' === $post->post_status || empty($post->post_name)) {
1311
+			$view_link = get_preview_post_link($post);
1312 1312
 			$preview_target = " target='wp-preview-{$post->ID}'";
1313 1313
 		} else {
1314
-			if ( 'publish' === $post->post_status || 'attachment' === $post->post_type ) {
1315
-				$view_link = get_permalink( $post );
1314
+			if ('publish' === $post->post_status || 'attachment' === $post->post_type) {
1315
+				$view_link = get_permalink($post);
1316 1316
 			} else {
1317 1317
 				// Allow non-published (private, future) to be viewed at a pretty permalink, in case $post->post_name is set
1318
-				$view_link = str_replace( array( '%pagename%', '%postname%' ), $post->post_name, $permalink );
1318
+				$view_link = str_replace(array('%pagename%', '%postname%'), $post->post_name, $permalink);
1319 1319
 			}
1320 1320
 		}
1321 1321
 	}
1322 1322
 
1323 1323
 	// Permalinks without a post/page name placeholder don't have anything to edit
1324
-	if ( false === strpos( $permalink, '%postname%' ) && false === strpos( $permalink, '%pagename%' ) ) {
1325
-		$return = '<strong>' . __( 'Permalink:' ) . "</strong>\n";
1324
+	if (false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%')) {
1325
+		$return = '<strong>'.__('Permalink:')."</strong>\n";
1326 1326
 
1327
-		if ( false !== $view_link ) {
1328
-			$display_link = urldecode( $view_link );
1329
-			$return .= '<a id="sample-permalink" href="' . esc_url( $view_link ) . '"' . $preview_target . '>' . esc_html( $display_link ) . "</a>\n";
1327
+		if (false !== $view_link) {
1328
+			$display_link = urldecode($view_link);
1329
+			$return .= '<a id="sample-permalink" href="'.esc_url($view_link).'"'.$preview_target.'>'.esc_html($display_link)."</a>\n";
1330 1330
 		} else {
1331
-			$return .= '<span id="sample-permalink">' . $permalink . "</span>\n";
1331
+			$return .= '<span id="sample-permalink">'.$permalink."</span>\n";
1332 1332
 		}
1333 1333
 
1334 1334
 		// Encourage a pretty permalink setting
1335
-		if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && !( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) ) {
1336
-			$return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small" target="_blank">' . __('Change Permalinks') . "</a></span>\n";
1335
+		if ('' == get_option('permalink_structure') && current_user_can('manage_options') && ! ('page' == get_option('show_on_front') && $id == get_option('page_on_front'))) {
1336
+			$return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small" target="_blank">'.__('Change Permalinks')."</a></span>\n";
1337 1337
 		}
1338 1338
 	} else {
1339
-		if ( mb_strlen( $post_name ) > 34 ) {
1340
-			$post_name_abridged = mb_substr( $post_name, 0, 16 ) . '&hellip;' . mb_substr( $post_name, -16 );
1339
+		if (mb_strlen($post_name) > 34) {
1340
+			$post_name_abridged = mb_substr($post_name, 0, 16).'&hellip;'.mb_substr($post_name, -16);
1341 1341
 		} else {
1342 1342
 			$post_name_abridged = $post_name;
1343 1343
 		}
1344 1344
 
1345
-		$post_name_html = '<span id="editable-post-name">' . esc_html( $post_name_abridged ) . '</span>';
1346
-		$display_link = str_replace( array( '%pagename%', '%postname%' ), $post_name_html, esc_html( urldecode( $permalink ) ) );
1345
+		$post_name_html = '<span id="editable-post-name">'.esc_html($post_name_abridged).'</span>';
1346
+		$display_link = str_replace(array('%pagename%', '%postname%'), $post_name_html, esc_html(urldecode($permalink)));
1347 1347
 
1348
-		$return = '<strong>' . __( 'Permalink:' ) . "</strong>\n";
1349
-		$return .= '<span id="sample-permalink"><a href="' . esc_url( $view_link ) . '"' . $preview_target . '>' . $display_link . "</a></span>\n";
1348
+		$return = '<strong>'.__('Permalink:')."</strong>\n";
1349
+		$return .= '<span id="sample-permalink"><a href="'.esc_url($view_link).'"'.$preview_target.'>'.$display_link."</a></span>\n";
1350 1350
 		$return .= '&lrm;'; // Fix bi-directional text display defect in RTL languages.
1351
-		$return .= '<span id="edit-slug-buttons"><button type="button" class="edit-slug button button-small hide-if-no-js" aria-label="' . __( 'Edit permalink' ) . '">' . __( 'Edit' ) . "</button></span>\n";
1352
-		$return .= '<span id="editable-post-name-full">' . esc_html( $post_name ) . "</span>\n";
1351
+		$return .= '<span id="edit-slug-buttons"><button type="button" class="edit-slug button button-small hide-if-no-js" aria-label="'.__('Edit permalink').'">'.__('Edit')."</button></span>\n";
1352
+		$return .= '<span id="editable-post-name-full">'.esc_html($post_name)."</span>\n";
1353 1353
 	}
1354 1354
 
1355 1355
 	/**
@@ -1364,7 +1364,7 @@  discard block
 block discarded – undo
1364 1364
 	 * @param string  $new_slug  New sample permalink slug.
1365 1365
 	 * @param WP_Post $post      Post object.
1366 1366
 	 */
1367
-	$return = apply_filters( 'get_sample_permalink_html', $return, $post->ID, $new_title, $new_slug, $post );
1367
+	$return = apply_filters('get_sample_permalink_html', $return, $post->ID, $new_title, $new_slug, $post);
1368 1368
 
1369 1369
 	return $return;
1370 1370
 }
@@ -1378,22 +1378,22 @@  discard block
 block discarded – undo
1378 1378
  * @param mixed $post The post ID or object associated with the thumbnail, defaults to global $post.
1379 1379
  * @return string html
1380 1380
  */
1381
-function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) {
1381
+function _wp_post_thumbnail_html($thumbnail_id = null, $post = null) {
1382 1382
 	$_wp_additional_image_sizes = wp_get_additional_image_sizes();
1383 1383
 
1384
-	$post               = get_post( $post );
1385
-	$post_type_object   = get_post_type_object( $post->post_type );
1384
+	$post               = get_post($post);
1385
+	$post_type_object   = get_post_type_object($post->post_type);
1386 1386
 	$set_thumbnail_link = '<p class="hide-if-no-js"><a href="%s" id="set-post-thumbnail"%s class="thickbox">%s</a></p>';
1387
-	$upload_iframe_src  = get_upload_iframe_src( 'image', $post->ID );
1387
+	$upload_iframe_src  = get_upload_iframe_src('image', $post->ID);
1388 1388
 
1389
-	$content = sprintf( $set_thumbnail_link,
1390
-		esc_url( $upload_iframe_src ),
1389
+	$content = sprintf($set_thumbnail_link,
1390
+		esc_url($upload_iframe_src),
1391 1391
 		'', // Empty when there's no featured image set, `aria-describedby` attribute otherwise.
1392
-		esc_html( $post_type_object->labels->set_featured_image )
1392
+		esc_html($post_type_object->labels->set_featured_image)
1393 1393
 	);
1394 1394
 
1395
-	if ( $thumbnail_id && get_post( $thumbnail_id ) ) {
1396
-		$size = isset( $_wp_additional_image_sizes['post-thumbnail'] ) ? 'post-thumbnail' : array( 266, 266 );
1395
+	if ($thumbnail_id && get_post($thumbnail_id)) {
1396
+		$size = isset($_wp_additional_image_sizes['post-thumbnail']) ? 'post-thumbnail' : array(266, 266);
1397 1397
 
1398 1398
 		/**
1399 1399
 		 * Filters the size used to display the post thumbnail image in the 'Featured Image' meta box.
@@ -1412,22 +1412,22 @@  discard block
 block discarded – undo
1412 1412
 		 * @param int          $thumbnail_id Post thumbnail attachment ID.
1413 1413
 		 * @param WP_Post      $post         The post object associated with the thumbnail.
1414 1414
 		 */
1415
-		$size = apply_filters( 'admin_post_thumbnail_size', $size, $thumbnail_id, $post );
1415
+		$size = apply_filters('admin_post_thumbnail_size', $size, $thumbnail_id, $post);
1416 1416
 
1417
-		$thumbnail_html = wp_get_attachment_image( $thumbnail_id, $size );
1417
+		$thumbnail_html = wp_get_attachment_image($thumbnail_id, $size);
1418 1418
 
1419
-		if ( ! empty( $thumbnail_html ) ) {
1420
-			$content = sprintf( $set_thumbnail_link,
1421
-				esc_url( $upload_iframe_src ),
1419
+		if ( ! empty($thumbnail_html)) {
1420
+			$content = sprintf($set_thumbnail_link,
1421
+				esc_url($upload_iframe_src),
1422 1422
 				' aria-describedby="set-post-thumbnail-desc"',
1423 1423
 				$thumbnail_html
1424 1424
 			);
1425
-			$content .= '<p class="hide-if-no-js howto" id="set-post-thumbnail-desc">' . __( 'Click the image to edit or update' ) . '</p>';
1426
-			$content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail">' . esc_html( $post_type_object->labels->remove_featured_image ) . '</a></p>';
1425
+			$content .= '<p class="hide-if-no-js howto" id="set-post-thumbnail-desc">'.__('Click the image to edit or update').'</p>';
1426
+			$content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail">'.esc_html($post_type_object->labels->remove_featured_image).'</a></p>';
1427 1427
 		}
1428 1428
 	}
1429 1429
 
1430
-	$content .= '<input type="hidden" id="_thumbnail_id" name="_thumbnail_id" value="' . esc_attr( $thumbnail_id ? $thumbnail_id : '-1' ) . '" />';
1430
+	$content .= '<input type="hidden" id="_thumbnail_id" name="_thumbnail_id" value="'.esc_attr($thumbnail_id ? $thumbnail_id : '-1').'" />';
1431 1431
 
1432 1432
 	/**
1433 1433
 	 * Filters the admin post thumbnail HTML markup to return.
@@ -1440,7 +1440,7 @@  discard block
 block discarded – undo
1440 1440
 	 * @param int    $post_id      Post ID.
1441 1441
 	 * @param int    $thumbnail_id Thumbnail ID.
1442 1442
 	 */
1443
-	return apply_filters( 'admin_post_thumbnail_html', $content, $post->ID, $thumbnail_id );
1443
+	return apply_filters('admin_post_thumbnail_html', $content, $post->ID, $thumbnail_id);
1444 1444
 }
1445 1445
 
1446 1446
 /**
@@ -1451,21 +1451,21 @@  discard block
 block discarded – undo
1451 1451
  * @param int $post_id ID of the post to check for editing
1452 1452
  * @return integer False: not locked or locked by current user. Int: user ID of user with lock.
1453 1453
  */
1454
-function wp_check_post_lock( $post_id ) {
1455
-	if ( !$post = get_post( $post_id ) )
1454
+function wp_check_post_lock($post_id) {
1455
+	if ( ! $post = get_post($post_id))
1456 1456
 		return false;
1457 1457
 
1458
-	if ( !$lock = get_post_meta( $post->ID, '_edit_lock', true ) )
1458
+	if ( ! $lock = get_post_meta($post->ID, '_edit_lock', true))
1459 1459
 		return false;
1460 1460
 
1461
-	$lock = explode( ':', $lock );
1461
+	$lock = explode(':', $lock);
1462 1462
 	$time = $lock[0];
1463
-	$user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true );
1463
+	$user = isset($lock[1]) ? $lock[1] : get_post_meta($post->ID, '_edit_last', true);
1464 1464
 
1465 1465
 	/** This filter is documented in wp-admin/includes/ajax-actions.php */
1466
-	$time_window = apply_filters( 'wp_check_post_lock_window', 150 );
1466
+	$time_window = apply_filters('wp_check_post_lock_window', 150);
1467 1467
 
1468
-	if ( $time && $time > time() - $time_window && $user != get_current_user_id() )
1468
+	if ($time && $time > time() - $time_window && $user != get_current_user_id())
1469 1469
 		return $user;
1470 1470
 	return false;
1471 1471
 }
@@ -1479,17 +1479,17 @@  discard block
 block discarded – undo
1479 1479
  * @return bool|array Returns false if the post doesn't exist of there is no current user, or
1480 1480
  * 	an array of the lock time and the user ID.
1481 1481
  */
1482
-function wp_set_post_lock( $post_id ) {
1483
-	if ( !$post = get_post( $post_id ) )
1482
+function wp_set_post_lock($post_id) {
1483
+	if ( ! $post = get_post($post_id))
1484 1484
 		return false;
1485
-	if ( 0 == ($user_id = get_current_user_id()) )
1485
+	if (0 == ($user_id = get_current_user_id()))
1486 1486
 		return false;
1487 1487
 
1488 1488
 	$now = time();
1489 1489
 	$lock = "$now:$user_id";
1490 1490
 
1491
-	update_post_meta( $post->ID, '_edit_lock', $lock );
1492
-	return array( $now, $user_id );
1491
+	update_post_meta($post->ID, '_edit_lock', $lock);
1492
+	return array($now, $user_id);
1493 1493
 }
1494 1494
 
1495 1495
 /**
@@ -1499,14 +1499,14 @@  discard block
 block discarded – undo
1499 1499
  * @return none
1500 1500
  */
1501 1501
 function _admin_notice_post_locked() {
1502
-	if ( ! $post = get_post() )
1502
+	if ( ! $post = get_post())
1503 1503
 		return;
1504 1504
 
1505 1505
 	$user = null;
1506
-	if (  $user_id = wp_check_post_lock( $post->ID ) )
1507
-		$user = get_userdata( $user_id );
1506
+	if ($user_id = wp_check_post_lock($post->ID))
1507
+		$user = get_userdata($user_id);
1508 1508
 
1509
-	if ( $user ) {
1509
+	if ($user) {
1510 1510
 
1511 1511
 		/**
1512 1512
 		 * Filters whether to show the post locked dialog.
@@ -1519,7 +1519,7 @@  discard block
 block discarded – undo
1519 1519
 		 * @param WP_Post      $post    Post object.
1520 1520
 		 * @param WP_User|bool $user    WP_User object on success, false otherwise.
1521 1521
 		 */
1522
-		if ( ! apply_filters( 'show_post_locked_dialog', true, $post, $user ) )
1522
+		if ( ! apply_filters('show_post_locked_dialog', true, $post, $user))
1523 1523
 			return;
1524 1524
 
1525 1525
 		$locked = true;
@@ -1527,17 +1527,17 @@  discard block
 block discarded – undo
1527 1527
 		$locked = false;
1528 1528
 	}
1529 1529
 
1530
-	if ( $locked && ( $sendback = wp_get_referer() ) &&
1531
-		false === strpos( $sendback, 'post.php' ) && false === strpos( $sendback, 'post-new.php' ) ) {
1530
+	if ($locked && ($sendback = wp_get_referer()) &&
1531
+		false === strpos($sendback, 'post.php') && false === strpos($sendback, 'post-new.php')) {
1532 1532
 
1533 1533
 		$sendback_text = __('Go back');
1534 1534
 	} else {
1535
-		$sendback = admin_url( 'edit.php' );
1535
+		$sendback = admin_url('edit.php');
1536 1536
 
1537
-		if ( 'post' != $post->post_type )
1538
-			$sendback = add_query_arg( 'post_type', $post->post_type, $sendback );
1537
+		if ('post' != $post->post_type)
1538
+			$sendback = add_query_arg('post_type', $post->post_type, $sendback);
1539 1539
 
1540
-		$sendback_text = get_post_type_object( $post->post_type )->labels->all_items;
1540
+		$sendback_text = get_post_type_object($post->post_type)->labels->all_items;
1541 1541
 	}
1542 1542
 
1543 1543
 	$hidden = $locked ? '' : ' hidden';
@@ -1548,18 +1548,18 @@  discard block
 block discarded – undo
1548 1548
 	<div class="notification-dialog">
1549 1549
 	<?php
1550 1550
 
1551
-	if ( $locked ) {
1551
+	if ($locked) {
1552 1552
 		$query_args = array();
1553
-		if ( get_post_type_object( $post->post_type )->public ) {
1554
-			if ( 'publish' == $post->post_status || $user->ID != $post->post_author ) {
1553
+		if (get_post_type_object($post->post_type)->public) {
1554
+			if ('publish' == $post->post_status || $user->ID != $post->post_author) {
1555 1555
 				// Latest content is in autosave
1556
-				$nonce = wp_create_nonce( 'post_preview_' . $post->ID );
1556
+				$nonce = wp_create_nonce('post_preview_'.$post->ID);
1557 1557
 				$query_args['preview_id'] = $post->ID;
1558 1558
 				$query_args['preview_nonce'] = $nonce;
1559 1559
 			}
1560 1560
 		}
1561 1561
 
1562
-		$preview_link = get_preview_post_link( $post->ID, $query_args );
1562
+		$preview_link = get_preview_post_link($post->ID, $query_args);
1563 1563
 
1564 1564
 		/**
1565 1565
 		 * Filters whether to allow the post lock to be overridden.
@@ -1573,17 +1573,17 @@  discard block
 block discarded – undo
1573 1573
 		 * @param WP_Post $post     Post object.
1574 1574
 		 * @param WP_User $user     User object.
1575 1575
 		 */
1576
-		$override = apply_filters( 'override_post_lock', true, $post, $user );
1576
+		$override = apply_filters('override_post_lock', true, $post, $user);
1577 1577
 		$tab_last = $override ? '' : ' wp-tab-last';
1578 1578
 
1579 1579
 		?>
1580 1580
 		<div class="post-locked-message">
1581
-		<div class="post-locked-avatar"><?php echo get_avatar( $user->ID, 64 ); ?></div>
1581
+		<div class="post-locked-avatar"><?php echo get_avatar($user->ID, 64); ?></div>
1582 1582
 		<p class="currently-editing wp-tab-first" tabindex="0">
1583 1583
 		<?php
1584
-			_e( 'This content is currently locked.' );
1585
-			if ( $override )
1586
-				printf( ' ' . __( 'If you take over, %s will be blocked from continuing to edit.' ), esc_html( $user->display_name ) );
1584
+			_e('This content is currently locked.');
1585
+			if ($override)
1586
+				printf(' '.__('If you take over, %s will be blocked from continuing to edit.'), esc_html($user->display_name));
1587 1587
 		?>
1588 1588
 		</p>
1589 1589
 		<?php
@@ -1594,19 +1594,19 @@  discard block
 block discarded – undo
1594 1594
 		 *
1595 1595
 		 * @param WP_Post $post Post object.
1596 1596
 		 */
1597
-		do_action( 'post_locked_dialog', $post );
1597
+		do_action('post_locked_dialog', $post);
1598 1598
 		?>
1599 1599
 		<p>
1600
-		<a class="button" href="<?php echo esc_url( $sendback ); ?>"><?php echo $sendback_text; ?></a>
1601
-		<?php if ( $preview_link ) { ?>
1602
-		<a class="button<?php echo $tab_last; ?>" href="<?php echo esc_url( $preview_link ); ?>"><?php _e('Preview'); ?></a>
1600
+		<a class="button" href="<?php echo esc_url($sendback); ?>"><?php echo $sendback_text; ?></a>
1601
+		<?php if ($preview_link) { ?>
1602
+		<a class="button<?php echo $tab_last; ?>" href="<?php echo esc_url($preview_link); ?>"><?php _e('Preview'); ?></a>
1603 1603
 		<?php
1604 1604
 		}
1605 1605
 
1606 1606
 		// Allow plugins to prevent some users overriding the post lock
1607
-		if ( $override ) {
1607
+		if ($override) {
1608 1608
 			?>
1609
-			<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>
1609
+			<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>
1610 1610
 			<?php
1611 1611
 		}
1612 1612
 
@@ -1620,7 +1620,7 @@  discard block
 block discarded – undo
1620 1620
 			<div class="post-locked-avatar"></div>
1621 1621
 			<p class="wp-tab-first" tabindex="0">
1622 1622
 			<span class="currently-editing"></span><br />
1623
-			<span class="locked-saving hidden"><img src="<?php echo esc_url( admin_url( 'images/spinner-2x.gif' ) ); ?>" width="16" height="16" alt="" /> <?php _e( 'Saving revision&hellip;' ); ?></span>
1623
+			<span class="locked-saving hidden"><img src="<?php echo esc_url(admin_url('images/spinner-2x.gif')); ?>" width="16" height="16" alt="" /> <?php _e('Saving revision&hellip;'); ?></span>
1624 1624
 			<span class="locked-saved hidden"><?php _e('Your latest changes were saved as a revision.'); ?></span>
1625 1625
 			</p>
1626 1626
 			<?php
@@ -1631,9 +1631,9 @@  discard block
 block discarded – undo
1631 1631
 			 *
1632 1632
 			 * @param WP_Post $post Post object.
1633 1633
 			 */
1634
-			do_action( 'post_lock_lost_dialog', $post );
1634
+			do_action('post_lock_lost_dialog', $post);
1635 1635
 			?>
1636
-			<p><a class="button button-primary wp-tab-last" href="<?php echo esc_url( $sendback ); ?>"><?php echo $sendback_text; ?></a></p>
1636
+			<p><a class="button button-primary wp-tab-last" href="<?php echo esc_url($sendback); ?>"><?php echo $sendback_text; ?></a></p>
1637 1637
 		</div>
1638 1638
 		<?php
1639 1639
 	}
@@ -1654,38 +1654,38 @@  discard block
 block discarded – undo
1654 1654
  * @param mixed $post_data Associative array containing the post data or int post ID.
1655 1655
  * @return mixed The autosave revision ID. WP_Error or 0 on error.
1656 1656
  */
1657
-function wp_create_post_autosave( $post_data ) {
1658
-	if ( is_numeric( $post_data ) ) {
1657
+function wp_create_post_autosave($post_data) {
1658
+	if (is_numeric($post_data)) {
1659 1659
 		$post_id = $post_data;
1660 1660
 		$post_data = $_POST;
1661 1661
 	} else {
1662 1662
 		$post_id = (int) $post_data['post_ID'];
1663 1663
 	}
1664 1664
 
1665
-	$post_data = _wp_translate_postdata( true, $post_data );
1666
-	if ( is_wp_error( $post_data ) )
1665
+	$post_data = _wp_translate_postdata(true, $post_data);
1666
+	if (is_wp_error($post_data))
1667 1667
 		return $post_data;
1668 1668
 
1669 1669
 	$post_author = get_current_user_id();
1670 1670
 
1671 1671
 	// Store one autosave per author. If there is already an autosave, overwrite it.
1672
-	if ( $old_autosave = wp_get_post_autosave( $post_id, $post_author ) ) {
1673
-		$new_autosave = _wp_post_revision_data( $post_data, true );
1672
+	if ($old_autosave = wp_get_post_autosave($post_id, $post_author)) {
1673
+		$new_autosave = _wp_post_revision_data($post_data, true);
1674 1674
 		$new_autosave['ID'] = $old_autosave->ID;
1675 1675
 		$new_autosave['post_author'] = $post_author;
1676 1676
 
1677 1677
 		// If the new autosave has the same content as the post, delete the autosave.
1678
-		$post = get_post( $post_id );
1678
+		$post = get_post($post_id);
1679 1679
 		$autosave_is_different = false;
1680
-		foreach ( array_intersect( array_keys( $new_autosave ), array_keys( _wp_post_revision_fields( $post ) ) ) as $field ) {
1681
-			if ( normalize_whitespace( $new_autosave[ $field ] ) != normalize_whitespace( $post->$field ) ) {
1680
+		foreach (array_intersect(array_keys($new_autosave), array_keys(_wp_post_revision_fields($post))) as $field) {
1681
+			if (normalize_whitespace($new_autosave[$field]) != normalize_whitespace($post->$field)) {
1682 1682
 				$autosave_is_different = true;
1683 1683
 				break;
1684 1684
 			}
1685 1685
 		}
1686 1686
 
1687
-		if ( ! $autosave_is_different ) {
1688
-			wp_delete_post_revision( $old_autosave->ID );
1687
+		if ( ! $autosave_is_different) {
1688
+			wp_delete_post_revision($old_autosave->ID);
1689 1689
 			return 0;
1690 1690
 		}
1691 1691
 
@@ -1696,16 +1696,16 @@  discard block
 block discarded – undo
1696 1696
 		 *
1697 1697
 		 * @param array $new_autosave Post array - the autosave that is about to be saved.
1698 1698
 		 */
1699
-		do_action( 'wp_creating_autosave', $new_autosave );
1699
+		do_action('wp_creating_autosave', $new_autosave);
1700 1700
 
1701
-		return wp_update_post( $new_autosave );
1701
+		return wp_update_post($new_autosave);
1702 1702
 	}
1703 1703
 
1704 1704
 	// _wp_put_post_revision() expects unescaped.
1705
-	$post_data = wp_unslash( $post_data );
1705
+	$post_data = wp_unslash($post_data);
1706 1706
 
1707 1707
 	// Otherwise create the new autosave as a special post revision
1708
-	return _wp_put_post_revision( $post_data, true );
1708
+	return _wp_put_post_revision($post_data, true);
1709 1709
 }
1710 1710
 
1711 1711
 /**
@@ -1721,46 +1721,46 @@  discard block
 block discarded – undo
1721 1721
 	$post_ID = (int) $_POST['post_ID'];
1722 1722
 	$_POST['ID'] = $post_ID;
1723 1723
 
1724
-	if ( ! $post = get_post( $post_ID ) ) {
1725
-		wp_die( __( 'Sorry, you are not allowed to edit this post.' ) );
1724
+	if ( ! $post = get_post($post_ID)) {
1725
+		wp_die(__('Sorry, you are not allowed to edit this post.'));
1726 1726
 	}
1727 1727
 
1728
-	if ( ! current_user_can( 'edit_post', $post->ID ) ) {
1729
-		wp_die( __( 'Sorry, you are not allowed to edit this post.' ) );
1728
+	if ( ! current_user_can('edit_post', $post->ID)) {
1729
+		wp_die(__('Sorry, you are not allowed to edit this post.'));
1730 1730
 	}
1731 1731
 
1732 1732
 	$is_autosave = false;
1733 1733
 
1734
-	if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author && ( 'draft' == $post->post_status || 'auto-draft' == $post->post_status ) ) {
1734
+	if ( ! wp_check_post_lock($post->ID) && get_current_user_id() == $post->post_author && ('draft' == $post->post_status || 'auto-draft' == $post->post_status)) {
1735 1735
 		$saved_post_id = edit_post();
1736 1736
 	} else {
1737 1737
 		$is_autosave = true;
1738 1738
 
1739
-		if ( isset( $_POST['post_status'] ) && 'auto-draft' == $_POST['post_status'] )
1739
+		if (isset($_POST['post_status']) && 'auto-draft' == $_POST['post_status'])
1740 1740
 			$_POST['post_status'] = 'draft';
1741 1741
 
1742
-		$saved_post_id = wp_create_post_autosave( $post->ID );
1742
+		$saved_post_id = wp_create_post_autosave($post->ID);
1743 1743
 	}
1744 1744
 
1745
-	if ( is_wp_error( $saved_post_id ) )
1746
-		wp_die( $saved_post_id->get_error_message() );
1745
+	if (is_wp_error($saved_post_id))
1746
+		wp_die($saved_post_id->get_error_message());
1747 1747
 
1748 1748
 	$query_args = array();
1749 1749
 
1750
-	if ( $is_autosave && $saved_post_id ) {
1750
+	if ($is_autosave && $saved_post_id) {
1751 1751
 		$query_args['preview_id'] = $post->ID;
1752
-		$query_args['preview_nonce'] = wp_create_nonce( 'post_preview_' . $post->ID );
1752
+		$query_args['preview_nonce'] = wp_create_nonce('post_preview_'.$post->ID);
1753 1753
 
1754
-		if ( isset( $_POST['post_format'] ) ) {
1755
-			$query_args['post_format'] = empty( $_POST['post_format'] ) ? 'standard' : sanitize_key( $_POST['post_format'] );
1754
+		if (isset($_POST['post_format'])) {
1755
+			$query_args['post_format'] = empty($_POST['post_format']) ? 'standard' : sanitize_key($_POST['post_format']);
1756 1756
 		}
1757 1757
 
1758
-		if ( isset( $_POST['_thumbnail_id'] ) ) {
1759
-			$query_args['_thumbnail_id'] = ( intval( $_POST['_thumbnail_id'] ) <= 0 ) ? '-1' : intval( $_POST['_thumbnail_id'] );
1758
+		if (isset($_POST['_thumbnail_id'])) {
1759
+			$query_args['_thumbnail_id'] = (intval($_POST['_thumbnail_id']) <= 0) ? '-1' : intval($_POST['_thumbnail_id']);
1760 1760
 		}
1761 1761
 	}
1762 1762
 
1763
-	return get_preview_post_link( $post, $query_args );
1763
+	return get_preview_post_link($post, $query_args);
1764 1764
 }
1765 1765
 
1766 1766
 /**
@@ -1774,36 +1774,36 @@  discard block
 block discarded – undo
1774 1774
  * @return mixed The value 0 or WP_Error on failure. The saved post ID on success.
1775 1775
  *               The ID can be the draft post_id or the autosave revision post_id.
1776 1776
  */
1777
-function wp_autosave( $post_data ) {
1777
+function wp_autosave($post_data) {
1778 1778
 	// Back-compat
1779
-	if ( ! defined( 'DOING_AUTOSAVE' ) )
1780
-		define( 'DOING_AUTOSAVE', true );
1779
+	if ( ! defined('DOING_AUTOSAVE'))
1780
+		define('DOING_AUTOSAVE', true);
1781 1781
 
1782 1782
 	$post_id = (int) $post_data['post_id'];
1783 1783
 	$post_data['ID'] = $post_data['post_ID'] = $post_id;
1784 1784
 
1785
-	if ( false === wp_verify_nonce( $post_data['_wpnonce'], 'update-post_' . $post_id ) ) {
1786
-		return new WP_Error( 'invalid_nonce', __( 'Error while saving.' ) );
1785
+	if (false === wp_verify_nonce($post_data['_wpnonce'], 'update-post_'.$post_id)) {
1786
+		return new WP_Error('invalid_nonce', __('Error while saving.'));
1787 1787
 	}
1788 1788
 
1789
-	$post = get_post( $post_id );
1789
+	$post = get_post($post_id);
1790 1790
 
1791
-	if ( ! current_user_can( 'edit_post', $post->ID ) ) {
1792
-		return new WP_Error( 'edit_posts', __( 'Sorry, you are not allowed to edit this item.' ) );
1791
+	if ( ! current_user_can('edit_post', $post->ID)) {
1792
+		return new WP_Error('edit_posts', __('Sorry, you are not allowed to edit this item.'));
1793 1793
 	}
1794 1794
 
1795
-	if ( 'auto-draft' == $post->post_status )
1795
+	if ('auto-draft' == $post->post_status)
1796 1796
 		$post_data['post_status'] = 'draft';
1797 1797
 
1798
-	if ( $post_data['post_type'] != 'page' && ! empty( $post_data['catslist'] ) )
1799
-		$post_data['post_category'] = explode( ',', $post_data['catslist'] );
1798
+	if ($post_data['post_type'] != 'page' && ! empty($post_data['catslist']))
1799
+		$post_data['post_category'] = explode(',', $post_data['catslist']);
1800 1800
 
1801
-	if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author && ( 'auto-draft' == $post->post_status || 'draft' == $post->post_status ) ) {
1801
+	if ( ! wp_check_post_lock($post->ID) && get_current_user_id() == $post->post_author && ('auto-draft' == $post->post_status || 'draft' == $post->post_status)) {
1802 1802
 		// Drafts and auto-drafts are just overwritten by autosave for the same user if the post is not locked
1803
-		return edit_post( wp_slash( $post_data ) );
1803
+		return edit_post(wp_slash($post_data));
1804 1804
 	} else {
1805 1805
 		// Non drafts or other users drafts are not overwritten. The autosave is stored in a special post revision for each user.
1806
-		return wp_create_post_autosave( wp_slash( $post_data ) );
1806
+		return wp_create_post_autosave(wp_slash($post_data));
1807 1807
 	}
1808 1808
 }
1809 1809
 
@@ -1813,11 +1813,11 @@  discard block
 block discarded – undo
1813 1813
  * @param int $post_id Optional. Post ID.
1814 1814
  */
1815 1815
 function redirect_post($post_id = '') {
1816
-	if ( isset($_POST['save']) || isset($_POST['publish']) ) {
1817
-		$status = get_post_status( $post_id );
1816
+	if (isset($_POST['save']) || isset($_POST['publish'])) {
1817
+		$status = get_post_status($post_id);
1818 1818
 
1819
-		if ( isset( $_POST['publish'] ) ) {
1820
-			switch ( $status ) {
1819
+		if (isset($_POST['publish'])) {
1820
+			switch ($status) {
1821 1821
 				case 'pending':
1822 1822
 					$message = 8;
1823 1823
 					break;
@@ -1831,17 +1831,17 @@  discard block
 block discarded – undo
1831 1831
 			$message = 'draft' == $status ? 10 : 1;
1832 1832
 		}
1833 1833
 
1834
-		$location = add_query_arg( 'message', $message, get_edit_post_link( $post_id, 'url' ) );
1835
-	} elseif ( isset($_POST['addmeta']) && $_POST['addmeta'] ) {
1836
-		$location = add_query_arg( 'message', 2, wp_get_referer() );
1834
+		$location = add_query_arg('message', $message, get_edit_post_link($post_id, 'url'));
1835
+	} elseif (isset($_POST['addmeta']) && $_POST['addmeta']) {
1836
+		$location = add_query_arg('message', 2, wp_get_referer());
1837 1837
 		$location = explode('#', $location);
1838
-		$location = $location[0] . '#postcustom';
1839
-	} elseif ( isset($_POST['deletemeta']) && $_POST['deletemeta'] ) {
1840
-		$location = add_query_arg( 'message', 3, wp_get_referer() );
1838
+		$location = $location[0].'#postcustom';
1839
+	} elseif (isset($_POST['deletemeta']) && $_POST['deletemeta']) {
1840
+		$location = add_query_arg('message', 3, wp_get_referer());
1841 1841
 		$location = explode('#', $location);
1842
-		$location = $location[0] . '#postcustom';
1842
+		$location = $location[0].'#postcustom';
1843 1843
 	} else {
1844
-		$location = add_query_arg( 'message', 4, get_edit_post_link( $post_id, 'url' ) );
1844
+		$location = add_query_arg('message', 4, get_edit_post_link($post_id, 'url'));
1845 1845
 	}
1846 1846
 
1847 1847
 	/**
@@ -1852,6 +1852,6 @@  discard block
 block discarded – undo
1852 1852
 	 * @param string $location The destination URL.
1853 1853
 	 * @param int    $post_id  The post ID.
1854 1854
 	 */
1855
-	wp_redirect( apply_filters( 'redirect_post_location', $location, $post_id ) );
1855
+	wp_redirect(apply_filters('redirect_post_location', $location, $post_id));
1856 1856
 	exit;
1857 1857
 }
Please login to merge, or discard this patch.
Braces   +306 added lines, -216 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', __( 'Sorry, you are not allowed to edit pages as this user.' ) );
34
-		else
35
-			return new WP_Error( 'edit_others_posts', __( 'Sorry, 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', __( 'Sorry, you are not allowed to edit pages as this user.' ) );
36
+		} else {
37
+					return new WP_Error( 'edit_others_posts', __( 'Sorry, 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', __( 'Sorry, you are not allowed to create pages as this user.' ) );
39
-		else
40
-			return new WP_Error( 'edit_others_posts', __( 'Sorry, 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', __( 'Sorry, you are not allowed to create pages as this user.' ) );
42
+		} else {
43
+					return new WP_Error( 'edit_others_posts', __( 'Sorry, 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', __( 'Sorry, you are not allowed to edit pages as this user.' ) );
72
-			else
73
-				return new WP_Error( 'edit_others_posts', __( 'Sorry, 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', __( 'Sorry, you are not allowed to edit pages as this user.' ) );
80
+			} else {
81
+							return new WP_Error( 'edit_others_posts', __( 'Sorry, 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', __( 'Sorry, you are not allowed to create pages as this user.' ) );
77
-			else
78
-				return new WP_Error( 'edit_others_posts', __( 'Sorry, 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', __( 'Sorry, you are not allowed to create pages as this user.' ) );
86
+			} else {
87
+							return new WP_Error( 'edit_others_posts', __( 'Sorry, 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] ) {
@@ -188,8 +207,9 @@  discard block
 block discarded – undo
188 207
 function edit_post( $post_data = null ) {
189 208
 	global $wpdb;
190 209
 
191
-	if ( empty($post_data) )
192
-		$post_data = &$_POST;
210
+	if ( empty($post_data) ) {
211
+			$post_data = &$_POST;
212
+	}
193 213
 
194 214
 	// Clear out any data in internal vars.
195 215
 	unset( $post_data['filter'] );
@@ -209,10 +229,11 @@  discard block
 block discarded – undo
209 229
 
210 230
 	$ptype = get_post_type_object($post_data['post_type']);
211 231
 	if ( !current_user_can( 'edit_post', $post_ID ) ) {
212
-		if ( 'page' == $post_data['post_type'] )
213
-			wp_die( __('Sorry, you are not allowed to edit this page.' ));
214
-		else
215
-			wp_die( __('Sorry, you are not allowed to edit this post.' ));
232
+		if ( 'page' == $post_data['post_type'] ) {
233
+					wp_die( __('Sorry, you are not allowed to edit this page.' ));
234
+		} else {
235
+					wp_die( __('Sorry, you are not allowed to edit this post.' ));
236
+		}
216 237
 	}
217 238
 
218 239
 	if ( post_type_supports( $ptype->name, 'revisions' ) ) {
@@ -220,8 +241,9 @@  discard block
 block discarded – undo
220 241
 		$revision = current( $revisions );
221 242
 
222 243
 		// Check if the revisions have been upgraded
223
-		if ( $revisions && _wp_get_post_revision_version( $revision ) < 1 )
224
-			_wp_upgrade_revisions_of_post( $post, wp_get_post_revisions( $post_ID ) );
244
+		if ( $revisions && _wp_get_post_revision_version( $revision ) < 1 ) {
245
+					_wp_upgrade_revisions_of_post( $post, wp_get_post_revisions( $post_ID ) );
246
+		}
225 247
 	}
226 248
 
227 249
 	if ( isset($post_data['visibility']) ) {
@@ -241,18 +263,21 @@  discard block
 block discarded – undo
241 263
 	}
242 264
 
243 265
 	$post_data = _wp_translate_postdata( true, $post_data );
244
-	if ( is_wp_error($post_data) )
245
-		wp_die( $post_data->get_error_message() );
266
+	if ( is_wp_error($post_data) ) {
267
+			wp_die( $post_data->get_error_message() );
268
+	}
246 269
 
247 270
 	// Post Formats
248
-	if ( isset( $post_data['post_format'] ) )
249
-		set_post_format( $post_ID, $post_data['post_format'] );
271
+	if ( isset( $post_data['post_format'] ) ) {
272
+			set_post_format( $post_ID, $post_data['post_format'] );
273
+	}
250 274
 
251 275
 	$format_meta_urls = array( 'url', 'link_url', 'quote_source_url' );
252 276
 	foreach ( $format_meta_urls as $format_meta_url ) {
253 277
 		$keyed = '_format_' . $format_meta_url;
254
-		if ( isset( $post_data[ $keyed ] ) )
255
-			update_post_meta( $post_ID, $keyed, wp_slash( esc_url_raw( wp_unslash( $post_data[ $keyed ] ) ) ) );
278
+		if ( isset( $post_data[ $keyed ] ) ) {
279
+					update_post_meta( $post_ID, $keyed, wp_slash( esc_url_raw( wp_unslash( $post_data[ $keyed ] ) ) ) );
280
+		}
256 281
 	}
257 282
 
258 283
 	$format_keys = array( 'quote', 'quote_source_name', 'image', 'gallery', 'audio_embed', 'video_embed' );
@@ -260,10 +285,11 @@  discard block
 block discarded – undo
260 285
 	foreach ( $format_keys as $key ) {
261 286
 		$keyed = '_format_' . $key;
262 287
 		if ( isset( $post_data[ $keyed ] ) ) {
263
-			if ( current_user_can( 'unfiltered_html' ) )
264
-				update_post_meta( $post_ID, $keyed, $post_data[ $keyed ] );
265
-			else
266
-				update_post_meta( $post_ID, $keyed, wp_filter_post_kses( $post_data[ $keyed ] ) );
288
+			if ( current_user_can( 'unfiltered_html' ) ) {
289
+							update_post_meta( $post_ID, $keyed, $post_data[ $keyed ] );
290
+			} else {
291
+							update_post_meta( $post_ID, $keyed, wp_filter_post_kses( $post_data[ $keyed ] ) );
292
+			}
267 293
 		}
268 294
 	}
269 295
 
@@ -284,26 +310,33 @@  discard block
 block discarded – undo
284 310
 	// Meta Stuff
285 311
 	if ( isset($post_data['meta']) && $post_data['meta'] ) {
286 312
 		foreach ( $post_data['meta'] as $key => $value ) {
287
-			if ( !$meta = get_post_meta_by_id( $key ) )
288
-				continue;
289
-			if ( $meta->post_id != $post_ID )
290
-				continue;
291
-			if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $meta->meta_key ) )
292
-				continue;
293
-			if ( is_protected_meta( $value['key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $value['key'] ) )
294
-				continue;
313
+			if ( !$meta = get_post_meta_by_id( $key ) ) {
314
+							continue;
315
+			}
316
+			if ( $meta->post_id != $post_ID ) {
317
+							continue;
318
+			}
319
+			if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $meta->meta_key ) ) {
320
+							continue;
321
+			}
322
+			if ( is_protected_meta( $value['key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $value['key'] ) ) {
323
+							continue;
324
+			}
295 325
 			update_meta( $key, $value['key'], $value['value'] );
296 326
 		}
297 327
 	}
298 328
 
299 329
 	if ( isset($post_data['deletemeta']) && $post_data['deletemeta'] ) {
300 330
 		foreach ( $post_data['deletemeta'] as $key => $value ) {
301
-			if ( !$meta = get_post_meta_by_id( $key ) )
302
-				continue;
303
-			if ( $meta->post_id != $post_ID )
304
-				continue;
305
-			if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $post_ID, $meta->meta_key ) )
306
-				continue;
331
+			if ( !$meta = get_post_meta_by_id( $key ) ) {
332
+							continue;
333
+			}
334
+			if ( $meta->post_id != $post_ID ) {
335
+							continue;
336
+			}
337
+			if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $post_ID, $meta->meta_key ) ) {
338
+							continue;
339
+			}
307 340
 			delete_meta( $key );
308 341
 		}
309 342
 	}
@@ -395,10 +428,11 @@  discard block
 block discarded – undo
395 428
 	wp_set_post_lock( $post_ID );
396 429
 
397 430
 	if ( current_user_can( $ptype->cap->edit_others_posts ) && current_user_can( $ptype->cap->publish_posts ) ) {
398
-		if ( ! empty( $post_data['sticky'] ) )
399
-			stick_post( $post_ID );
400
-		else
401
-			unstick_post( $post_ID );
431
+		if ( ! empty( $post_data['sticky'] ) ) {
432
+					stick_post( $post_ID );
433
+		} else {
434
+					unstick_post( $post_ID );
435
+		}
402 436
 	}
403 437
 
404 438
 	return $post_ID;
@@ -420,19 +454,22 @@  discard block
 block discarded – undo
420 454
 function bulk_edit_posts( $post_data = null ) {
421 455
 	global $wpdb;
422 456
 
423
-	if ( empty($post_data) )
424
-		$post_data = &$_POST;
457
+	if ( empty($post_data) ) {
458
+			$post_data = &$_POST;
459
+	}
425 460
 
426
-	if ( isset($post_data['post_type']) )
427
-		$ptype = get_post_type_object($post_data['post_type']);
428
-	else
429
-		$ptype = get_post_type_object('post');
461
+	if ( isset($post_data['post_type']) ) {
462
+			$ptype = get_post_type_object($post_data['post_type']);
463
+	} else {
464
+			$ptype = get_post_type_object('post');
465
+	}
430 466
 
431 467
 	if ( !current_user_can( $ptype->cap->edit_posts ) ) {
432
-		if ( 'page' == $ptype->name )
433
-			wp_die( __('Sorry, you are not allowed to edit pages.'));
434
-		else
435
-			wp_die( __('Sorry, you are not allowed to edit posts.'));
468
+		if ( 'page' == $ptype->name ) {
469
+					wp_die( __('Sorry, you are not allowed to edit pages.'));
470
+		} else {
471
+					wp_die( __('Sorry, you are not allowed to edit posts.'));
472
+		}
436 473
 	}
437 474
 
438 475
 	if ( -1 == $post_data['_status'] ) {
@@ -461,28 +498,32 @@  discard block
 block discarded – undo
461 498
 	);
462 499
 
463 500
 	foreach ( $reset as $field ) {
464
-		if ( isset($post_data[$field]) && ( '' == $post_data[$field] || -1 == $post_data[$field] ) )
465
-			unset($post_data[$field]);
501
+		if ( isset($post_data[$field]) && ( '' == $post_data[$field] || -1 == $post_data[$field] ) ) {
502
+					unset($post_data[$field]);
503
+		}
466 504
 	}
467 505
 
468 506
 	if ( isset($post_data['post_category']) ) {
469
-		if ( is_array($post_data['post_category']) && ! empty($post_data['post_category']) )
470
-			$new_cats = array_map( 'absint', $post_data['post_category'] );
471
-		else
472
-			unset($post_data['post_category']);
507
+		if ( is_array($post_data['post_category']) && ! empty($post_data['post_category']) ) {
508
+					$new_cats = array_map( 'absint', $post_data['post_category'] );
509
+		} else {
510
+					unset($post_data['post_category']);
511
+		}
473 512
 	}
474 513
 
475 514
 	$tax_input = array();
476 515
 	if ( isset($post_data['tax_input'])) {
477 516
 		foreach ( $post_data['tax_input'] as $tax_name => $terms ) {
478
-			if ( empty($terms) )
479
-				continue;
517
+			if ( empty($terms) ) {
518
+							continue;
519
+			}
480 520
 			if ( is_taxonomy_hierarchical( $tax_name ) ) {
481 521
 				$tax_input[ $tax_name ] = array_map( 'absint', $terms );
482 522
 			} else {
483 523
 				$comma = _x( ',', 'tag delimiter' );
484
-				if ( ',' !== $comma )
485
-					$terms = str_replace( $comma, ',', $terms );
524
+				if ( ',' !== $comma ) {
525
+									$terms = str_replace( $comma, ',', $terms );
526
+				}
486 527
 				$tax_input[ $tax_name ] = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) );
487 528
 			}
488 529
 		}
@@ -527,15 +568,17 @@  discard block
 block discarded – undo
527 568
 		$tax_names = get_object_taxonomies( $post );
528 569
 		foreach ( $tax_names as $tax_name ) {
529 570
 			$taxonomy_obj = get_taxonomy($tax_name);
530
-			if ( isset( $tax_input[$tax_name]) && current_user_can( $taxonomy_obj->cap->assign_terms ) )
531
-				$new_terms = $tax_input[$tax_name];
532
-			else
533
-				$new_terms = array();
571
+			if ( isset( $tax_input[$tax_name]) && current_user_can( $taxonomy_obj->cap->assign_terms ) ) {
572
+							$new_terms = $tax_input[$tax_name];
573
+			} else {
574
+							$new_terms = array();
575
+			}
534 576
 
535
-			if ( $taxonomy_obj->hierarchical )
536
-				$current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'ids') );
537
-			else
538
-				$current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'names') );
577
+			if ( $taxonomy_obj->hierarchical ) {
578
+							$current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'ids') );
579
+			} else {
580
+							$current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'names') );
581
+			}
539 582
 
540 583
 			$post_data['tax_input'][$tax_name] = array_merge( $current_terms, $new_terms );
541 584
 		}
@@ -568,14 +611,16 @@  discard block
 block discarded – undo
568 611
 		$updated[] = wp_update_post( $post_data );
569 612
 
570 613
 		if ( isset( $post_data['sticky'] ) && current_user_can( $ptype->cap->edit_others_posts ) ) {
571
-			if ( 'sticky' == $post_data['sticky'] )
572
-				stick_post( $post_ID );
573
-			else
574
-				unstick_post( $post_ID );
614
+			if ( 'sticky' == $post_data['sticky'] ) {
615
+							stick_post( $post_ID );
616
+			} else {
617
+							unstick_post( $post_ID );
618
+			}
575 619
 		}
576 620
 
577
-		if ( isset( $post_data['post_format'] ) )
578
-			set_post_format( $post_ID, $post_data['post_format'] );
621
+		if ( isset( $post_data['post_format'] ) ) {
622
+					set_post_format( $post_ID, $post_data['post_format'] );
623
+		}
579 624
 	}
580 625
 
581 626
 	return array( 'updated' => $updated, 'skipped' => $skipped, 'locked' => $locked );
@@ -592,22 +637,26 @@  discard block
 block discarded – undo
592 637
  */
593 638
 function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) {
594 639
 	$post_title = '';
595
-	if ( !empty( $_REQUEST['post_title'] ) )
596
-		$post_title = esc_html( wp_unslash( $_REQUEST['post_title'] ));
640
+	if ( !empty( $_REQUEST['post_title'] ) ) {
641
+			$post_title = esc_html( wp_unslash( $_REQUEST['post_title'] ));
642
+	}
597 643
 
598 644
 	$post_content = '';
599
-	if ( !empty( $_REQUEST['content'] ) )
600
-		$post_content = esc_html( wp_unslash( $_REQUEST['content'] ));
645
+	if ( !empty( $_REQUEST['content'] ) ) {
646
+			$post_content = esc_html( wp_unslash( $_REQUEST['content'] ));
647
+	}
601 648
 
602 649
 	$post_excerpt = '';
603
-	if ( !empty( $_REQUEST['excerpt'] ) )
604
-		$post_excerpt = esc_html( wp_unslash( $_REQUEST['excerpt'] ));
650
+	if ( !empty( $_REQUEST['excerpt'] ) ) {
651
+			$post_excerpt = esc_html( wp_unslash( $_REQUEST['excerpt'] ));
652
+	}
605 653
 
606 654
 	if ( $create_in_db ) {
607 655
 		$post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) );
608 656
 		$post = get_post( $post_id );
609
-		if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) )
610
-			set_post_format( $post, get_option( 'default_post_format' ) );
657
+		if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) ) {
658
+					set_post_format( $post, get_option( 'default_post_format' ) );
659
+		}
611 660
 	} else {
612 661
 		$post = new stdClass;
613 662
 		$post->ID = 0;
@@ -700,8 +749,9 @@  discard block
 block discarded – undo
700 749
 		$args[] = $post_content;
701 750
 	}
702 751
 
703
-	if ( !empty ( $args ) )
704
-		return (int) $wpdb->get_var( $wpdb->prepare($query, $args) );
752
+	if ( !empty ( $args ) ) {
753
+			return (int) $wpdb->get_var( $wpdb->prepare($query, $args) );
754
+	}
705 755
 
706 756
 	return 0;
707 757
 }
@@ -716,16 +766,18 @@  discard block
 block discarded – undo
716 766
  * @return int|WP_Error
717 767
  */
718 768
 function wp_write_post() {
719
-	if ( isset($_POST['post_type']) )
720
-		$ptype = get_post_type_object($_POST['post_type']);
721
-	else
722
-		$ptype = get_post_type_object('post');
769
+	if ( isset($_POST['post_type']) ) {
770
+			$ptype = get_post_type_object($_POST['post_type']);
771
+	} else {
772
+			$ptype = get_post_type_object('post');
773
+	}
723 774
 
724 775
 	if ( !current_user_can( $ptype->cap->edit_posts ) ) {
725
-		if ( 'page' == $ptype->name )
726
-			return new WP_Error( 'edit_pages', __( 'Sorry, you are not allowed to create pages on this site.' ) );
727
-		else
728
-			return new WP_Error( 'edit_posts', __( 'Sorry, you are not allowed to create posts or drafts on this site.' ) );
776
+		if ( 'page' == $ptype->name ) {
777
+					return new WP_Error( 'edit_pages', __( 'Sorry, you are not allowed to create pages on this site.' ) );
778
+		} else {
779
+					return new WP_Error( 'edit_posts', __( 'Sorry, you are not allowed to create posts or drafts on this site.' ) );
780
+		}
729 781
 	}
730 782
 
731 783
 	$_POST['post_mime_type'] = '';
@@ -734,8 +786,9 @@  discard block
 block discarded – undo
734 786
 	unset( $_POST['filter'] );
735 787
 
736 788
 	// Edit don't write if we have a post id.
737
-	if ( isset( $_POST['post_ID'] ) )
738
-		return edit_post();
789
+	if ( isset( $_POST['post_ID'] ) ) {
790
+			return edit_post();
791
+	}
739 792
 
740 793
 	if ( isset($_POST['visibility']) ) {
741 794
 		switch ( $_POST['visibility'] ) {
@@ -754,16 +807,19 @@  discard block
 block discarded – undo
754 807
 	}
755 808
 
756 809
 	$translated = _wp_translate_postdata( false );
757
-	if ( is_wp_error($translated) )
758
-		return $translated;
810
+	if ( is_wp_error($translated) ) {
811
+			return $translated;
812
+	}
759 813
 
760 814
 	// Create the post.
761 815
 	$post_ID = wp_insert_post( $_POST );
762
-	if ( is_wp_error( $post_ID ) )
763
-		return $post_ID;
816
+	if ( is_wp_error( $post_ID ) ) {
817
+			return $post_ID;
818
+	}
764 819
 
765
-	if ( empty($post_ID) )
766
-		return 0;
820
+	if ( empty($post_ID) ) {
821
+			return 0;
822
+	}
767 823
 
768 824
 	add_meta( $post_ID );
769 825
 
@@ -786,11 +842,12 @@  discard block
 block discarded – undo
786 842
  */
787 843
 function write_post() {
788 844
 	$result = wp_write_post();
789
-	if ( is_wp_error( $result ) )
790
-		wp_die( $result->get_error_message() );
791
-	else
792
-		return $result;
793
-}
845
+	if ( is_wp_error( $result ) ) {
846
+			wp_die( $result->get_error_message() );
847
+	} else {
848
+			return $result;
849
+	}
850
+	}
794 851
 
795 852
 //
796 853
 // Post Meta
@@ -810,22 +867,27 @@  discard block
 block discarded – undo
810 867
 	$metakeyselect = isset($_POST['metakeyselect']) ? wp_unslash( trim( $_POST['metakeyselect'] ) ) : '';
811 868
 	$metakeyinput = isset($_POST['metakeyinput']) ? wp_unslash( trim( $_POST['metakeyinput'] ) ) : '';
812 869
 	$metavalue = isset($_POST['metavalue']) ? $_POST['metavalue'] : '';
813
-	if ( is_string( $metavalue ) )
814
-		$metavalue = trim( $metavalue );
870
+	if ( is_string( $metavalue ) ) {
871
+			$metavalue = trim( $metavalue );
872
+	}
815 873
 
816 874
 	if ( ('0' === $metavalue || ! empty ( $metavalue ) ) && ( ( ( '#NONE#' != $metakeyselect ) && !empty ( $metakeyselect) ) || !empty ( $metakeyinput ) ) ) {
817 875
 		/*
818 876
 		 * We have a key/value pair. If both the select and the input
819 877
 		 * for the key have data, the input takes precedence.
820 878
 		 */
821
- 		if ( '#NONE#' != $metakeyselect )
822
-			$metakey = $metakeyselect;
879
+ 		if ( '#NONE#' != $metakeyselect ) {
880
+ 					$metakey = $metakeyselect;
881
+ 		}
823 882
 
824
-		if ( $metakeyinput )
825
-			$metakey = $metakeyinput; // default
883
+		if ( $metakeyinput ) {
884
+					$metakey = $metakeyinput;
885
+		}
886
+		// default
826 887
 
827
-		if ( is_protected_meta( $metakey, 'post' ) || ! current_user_can( 'add_post_meta', $post_ID, $metakey ) )
828
-			return false;
888
+		if ( is_protected_meta( $metakey, 'post' ) || ! current_user_can( 'add_post_meta', $post_ID, $metakey ) ) {
889
+					return false;
890
+		}
829 891
 
830 892
 		$metakey = wp_slash( $metakey );
831 893
 
@@ -933,12 +995,14 @@  discard block
 block discarded – undo
933 995
 	$content = $post['post_content'];
934 996
 
935 997
 	// Don't run if no pretty permalinks or post is not published, scheduled, or privately published.
936
-	if ( ! get_option( 'permalink_structure' ) || ! in_array( $post['post_status'], array( 'publish', 'future', 'private' ) ) )
937
-		return;
998
+	if ( ! get_option( 'permalink_structure' ) || ! in_array( $post['post_status'], array( 'publish', 'future', 'private' ) ) ) {
999
+			return;
1000
+	}
938 1001
 
939 1002
 	// Short if there aren't any links or no '?attachment_id=' strings (strpos cannot be zero)
940
-	if ( !strpos($content, '?attachment_id=') || !preg_match_all( '/<a ([^>]+)>[\s\S]+?<\/a>/', $content, $link_matches ) )
941
-		return;
1003
+	if ( !strpos($content, '?attachment_id=') || !preg_match_all( '/<a ([^>]+)>[\s\S]+?<\/a>/', $content, $link_matches ) ) {
1004
+			return;
1005
+	}
942 1006
 
943 1007
 	$site_url = get_bloginfo('url');
944 1008
 	$site_url = substr( $site_url, (int) strpos($site_url, '://') ); // remove the http(s)
@@ -947,15 +1011,17 @@  discard block
 block discarded – undo
947 1011
 	foreach ( $link_matches[1] as $key => $value ) {
948 1012
 		if ( !strpos($value, '?attachment_id=') || !strpos($value, 'wp-att-')
949 1013
 			|| !preg_match( '/href=(["\'])[^"\']*\?attachment_id=(\d+)[^"\']*\\1/', $value, $url_match )
950
-			|| !preg_match( '/rel=["\'][^"\']*wp-att-(\d+)/', $value, $rel_match ) )
951
-				continue;
1014
+			|| !preg_match( '/rel=["\'][^"\']*wp-att-(\d+)/', $value, $rel_match ) ) {
1015
+						continue;
1016
+		}
952 1017
 
953 1018
 		$quote = $url_match[1]; // the quote (single or double)
954 1019
 		$url_id = (int) $url_match[2];
955 1020
 		$rel_id = (int) $rel_match[1];
956 1021
 
957
-		if ( !$url_id || !$rel_id || $url_id != $rel_id || strpos($url_match[0], $site_url) === false )
958
-			continue;
1022
+		if ( !$url_id || !$rel_id || $url_id != $rel_id || strpos($url_match[0], $site_url) === false ) {
1023
+					continue;
1024
+		}
959 1025
 
960 1026
 		$link = $link_matches[0][$key];
961 1027
 		$replace = str_replace( $url_match[0], 'href=' . $quote . get_attachment_link( $url_id ) . $quote, $link );
@@ -995,16 +1061,18 @@  discard block
 block discarded – undo
995 1061
  * @return array
996 1062
  */
997 1063
 function wp_edit_posts_query( $q = false ) {
998
-	if ( false === $q )
999
-		$q = $_GET;
1064
+	if ( false === $q ) {
1065
+			$q = $_GET;
1066
+	}
1000 1067
 	$q['m'] = isset($q['m']) ? (int) $q['m'] : 0;
1001 1068
 	$q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0;
1002 1069
 	$post_stati  = get_post_stati();
1003 1070
 
1004
-	if ( isset($q['post_type']) && in_array( $q['post_type'], get_post_types() ) )
1005
-		$post_type = $q['post_type'];
1006
-	else
1007
-		$post_type = 'post';
1071
+	if ( isset($q['post_type']) && in_array( $q['post_type'], get_post_types() ) ) {
1072
+			$post_type = $q['post_type'];
1073
+	} else {
1074
+			$post_type = 'post';
1075
+	}
1008 1076
 
1009 1077
 	$avail_post_stati = get_available_post_statuses($post_type);
1010 1078
 
@@ -1027,8 +1095,9 @@  discard block
 block discarded – undo
1027 1095
 
1028 1096
 	$per_page = "edit_{$post_type}_per_page";
1029 1097
 	$posts_per_page = (int) get_user_option( $per_page );
1030
-	if ( empty( $posts_per_page ) || $posts_per_page < 1 )
1031
-		$posts_per_page = 20;
1098
+	if ( empty( $posts_per_page ) || $posts_per_page < 1 ) {
1099
+			$posts_per_page = 20;
1100
+	}
1032 1101
 
1033 1102
 	/**
1034 1103
 	 * Filters the number of items per page to show for a specific 'per_page' type.
@@ -1066,8 +1135,9 @@  discard block
 block discarded – undo
1066 1135
 		$query['fields'] = 'id=>parent';
1067 1136
 	}
1068 1137
 
1069
-	if ( ! empty( $q['show_sticky'] ) )
1070
-		$query['post__in'] = (array) get_option( 'sticky_posts' );
1138
+	if ( ! empty( $q['show_sticky'] ) ) {
1139
+			$query['post__in'] = (array) get_option( 'sticky_posts' );
1140
+	}
1071 1141
 
1072 1142
 	wp( $query );
1073 1143
 
@@ -1220,8 +1290,9 @@  discard block
 block discarded – undo
1220 1290
  */
1221 1291
 function get_sample_permalink($id, $title = null, $name = null) {
1222 1292
 	$post = get_post( $id );
1223
-	if ( ! $post )
1224
-		return array( '', '' );
1293
+	if ( ! $post ) {
1294
+			return array( '', '' );
1295
+	}
1225 1296
 
1226 1297
 	$ptype = get_post_type_object($post->post_type);
1227 1298
 
@@ -1237,8 +1308,9 @@  discard block
 block discarded – undo
1237 1308
 
1238 1309
 	// If the user wants to set a new name -- override the current one
1239 1310
 	// Note: if empty name is supplied -- use the title instead, see #6072
1240
-	if ( !is_null($name) )
1241
-		$post->post_name = sanitize_title($name ? $name : $title, $post->ID);
1311
+	if ( !is_null($name) ) {
1312
+			$post->post_name = sanitize_title($name ? $name : $title, $post->ID);
1313
+	}
1242 1314
 
1243 1315
 	$post->post_name = wp_unique_post_slug($post->post_name, $post->ID, $post->post_status, $post->post_type, $post->post_parent);
1244 1316
 
@@ -1260,8 +1332,9 @@  discard block
 block discarded – undo
1260 1332
 
1261 1333
 		/** This filter is documented in wp-admin/edit-tag-form.php */
1262 1334
 		$uri = apply_filters( 'editable_slug', $uri, $post );
1263
-		if ( !empty($uri) )
1264
-			$uri .= '/';
1335
+		if ( !empty($uri) ) {
1336
+					$uri .= '/';
1337
+		}
1265 1338
 		$permalink = str_replace('%pagename%', "{$uri}%pagename%", $permalink);
1266 1339
 	}
1267 1340
 
@@ -1298,8 +1371,9 @@  discard block
 block discarded – undo
1298 1371
  */
1299 1372
 function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
1300 1373
 	$post = get_post( $id );
1301
-	if ( ! $post )
1302
-		return '';
1374
+	if ( ! $post ) {
1375
+			return '';
1376
+	}
1303 1377
 
1304 1378
 	list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug);
1305 1379
 
@@ -1452,11 +1526,13 @@  discard block
 block discarded – undo
1452 1526
  * @return integer False: not locked or locked by current user. Int: user ID of user with lock.
1453 1527
  */
1454 1528
 function wp_check_post_lock( $post_id ) {
1455
-	if ( !$post = get_post( $post_id ) )
1456
-		return false;
1529
+	if ( !$post = get_post( $post_id ) ) {
1530
+			return false;
1531
+	}
1457 1532
 
1458
-	if ( !$lock = get_post_meta( $post->ID, '_edit_lock', true ) )
1459
-		return false;
1533
+	if ( !$lock = get_post_meta( $post->ID, '_edit_lock', true ) ) {
1534
+			return false;
1535
+	}
1460 1536
 
1461 1537
 	$lock = explode( ':', $lock );
1462 1538
 	$time = $lock[0];
@@ -1465,8 +1541,9 @@  discard block
 block discarded – undo
1465 1541
 	/** This filter is documented in wp-admin/includes/ajax-actions.php */
1466 1542
 	$time_window = apply_filters( 'wp_check_post_lock_window', 150 );
1467 1543
 
1468
-	if ( $time && $time > time() - $time_window && $user != get_current_user_id() )
1469
-		return $user;
1544
+	if ( $time && $time > time() - $time_window && $user != get_current_user_id() ) {
1545
+			return $user;
1546
+	}
1470 1547
 	return false;
1471 1548
 }
1472 1549
 
@@ -1480,10 +1557,12 @@  discard block
 block discarded – undo
1480 1557
  * 	an array of the lock time and the user ID.
1481 1558
  */
1482 1559
 function wp_set_post_lock( $post_id ) {
1483
-	if ( !$post = get_post( $post_id ) )
1484
-		return false;
1485
-	if ( 0 == ($user_id = get_current_user_id()) )
1486
-		return false;
1560
+	if ( !$post = get_post( $post_id ) ) {
1561
+			return false;
1562
+	}
1563
+	if ( 0 == ($user_id = get_current_user_id()) ) {
1564
+			return false;
1565
+	}
1487 1566
 
1488 1567
 	$now = time();
1489 1568
 	$lock = "$now:$user_id";
@@ -1499,12 +1578,14 @@  discard block
 block discarded – undo
1499 1578
  * @return none
1500 1579
  */
1501 1580
 function _admin_notice_post_locked() {
1502
-	if ( ! $post = get_post() )
1503
-		return;
1581
+	if ( ! $post = get_post() ) {
1582
+			return;
1583
+	}
1504 1584
 
1505 1585
 	$user = null;
1506
-	if (  $user_id = wp_check_post_lock( $post->ID ) )
1507
-		$user = get_userdata( $user_id );
1586
+	if (  $user_id = wp_check_post_lock( $post->ID ) ) {
1587
+			$user = get_userdata( $user_id );
1588
+	}
1508 1589
 
1509 1590
 	if ( $user ) {
1510 1591
 
@@ -1519,8 +1600,9 @@  discard block
 block discarded – undo
1519 1600
 		 * @param WP_Post      $post    Post object.
1520 1601
 		 * @param WP_User|bool $user    WP_User object on success, false otherwise.
1521 1602
 		 */
1522
-		if ( ! apply_filters( 'show_post_locked_dialog', true, $post, $user ) )
1523
-			return;
1603
+		if ( ! apply_filters( 'show_post_locked_dialog', true, $post, $user ) ) {
1604
+					return;
1605
+		}
1524 1606
 
1525 1607
 		$locked = true;
1526 1608
 	} else {
@@ -1534,8 +1616,9 @@  discard block
 block discarded – undo
1534 1616
 	} else {
1535 1617
 		$sendback = admin_url( 'edit.php' );
1536 1618
 
1537
-		if ( 'post' != $post->post_type )
1538
-			$sendback = add_query_arg( 'post_type', $post->post_type, $sendback );
1619
+		if ( 'post' != $post->post_type ) {
1620
+					$sendback = add_query_arg( 'post_type', $post->post_type, $sendback );
1621
+		}
1539 1622
 
1540 1623
 		$sendback_text = get_post_type_object( $post->post_type )->labels->all_items;
1541 1624
 	}
@@ -1582,8 +1665,9 @@  discard block
 block discarded – undo
1582 1665
 		<p class="currently-editing wp-tab-first" tabindex="0">
1583 1666
 		<?php
1584 1667
 			_e( 'This content is currently locked.' );
1585
-			if ( $override )
1586
-				printf( ' ' . __( 'If you take over, %s will be blocked from continuing to edit.' ), esc_html( $user->display_name ) );
1668
+			if ( $override ) {
1669
+							printf( ' ' . __( 'If you take over, %s will be blocked from continuing to edit.' ), esc_html( $user->display_name ) );
1670
+			}
1587 1671
 		?>
1588 1672
 		</p>
1589 1673
 		<?php
@@ -1663,8 +1747,9 @@  discard block
 block discarded – undo
1663 1747
 	}
1664 1748
 
1665 1749
 	$post_data = _wp_translate_postdata( true, $post_data );
1666
-	if ( is_wp_error( $post_data ) )
1667
-		return $post_data;
1750
+	if ( is_wp_error( $post_data ) ) {
1751
+			return $post_data;
1752
+	}
1668 1753
 
1669 1754
 	$post_author = get_current_user_id();
1670 1755
 
@@ -1736,14 +1821,16 @@  discard block
 block discarded – undo
1736 1821
 	} else {
1737 1822
 		$is_autosave = true;
1738 1823
 
1739
-		if ( isset( $_POST['post_status'] ) && 'auto-draft' == $_POST['post_status'] )
1740
-			$_POST['post_status'] = 'draft';
1824
+		if ( isset( $_POST['post_status'] ) && 'auto-draft' == $_POST['post_status'] ) {
1825
+					$_POST['post_status'] = 'draft';
1826
+		}
1741 1827
 
1742 1828
 		$saved_post_id = wp_create_post_autosave( $post->ID );
1743 1829
 	}
1744 1830
 
1745
-	if ( is_wp_error( $saved_post_id ) )
1746
-		wp_die( $saved_post_id->get_error_message() );
1831
+	if ( is_wp_error( $saved_post_id ) ) {
1832
+			wp_die( $saved_post_id->get_error_message() );
1833
+	}
1747 1834
 
1748 1835
 	$query_args = array();
1749 1836
 
@@ -1776,8 +1863,9 @@  discard block
 block discarded – undo
1776 1863
  */
1777 1864
 function wp_autosave( $post_data ) {
1778 1865
 	// Back-compat
1779
-	if ( ! defined( 'DOING_AUTOSAVE' ) )
1780
-		define( 'DOING_AUTOSAVE', true );
1866
+	if ( ! defined( 'DOING_AUTOSAVE' ) ) {
1867
+			define( 'DOING_AUTOSAVE', true );
1868
+	}
1781 1869
 
1782 1870
 	$post_id = (int) $post_data['post_id'];
1783 1871
 	$post_data['ID'] = $post_data['post_ID'] = $post_id;
@@ -1792,11 +1880,13 @@  discard block
 block discarded – undo
1792 1880
 		return new WP_Error( 'edit_posts', __( 'Sorry, you are not allowed to edit this item.' ) );
1793 1881
 	}
1794 1882
 
1795
-	if ( 'auto-draft' == $post->post_status )
1796
-		$post_data['post_status'] = 'draft';
1883
+	if ( 'auto-draft' == $post->post_status ) {
1884
+			$post_data['post_status'] = 'draft';
1885
+	}
1797 1886
 
1798
-	if ( $post_data['post_type'] != 'page' && ! empty( $post_data['catslist'] ) )
1799
-		$post_data['post_category'] = explode( ',', $post_data['catslist'] );
1887
+	if ( $post_data['post_type'] != 'page' && ! empty( $post_data['catslist'] ) ) {
1888
+			$post_data['post_category'] = explode( ',', $post_data['catslist'] );
1889
+	}
1800 1890
 
1801 1891
 	if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author && ( 'auto-draft' == $post->post_status || 'draft' == $post->post_status ) ) {
1802 1892
 		// 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-includes/capabilities.php 4 patches
Doc Comments   -9 removed lines patch added patch discarded remove patch
@@ -20,10 +20,6 @@  discard block
 block discarded – undo
20 20
  *
21 21
  * @param string $cap       Capability name.
22 22
  * @param int    $user_id   User ID.
23
- * @param int    $object_id Optional. ID of the specific object to check against if `$cap` is a "meta" cap.
24
- *                          "Meta" capabilities, e.g. 'edit_post', 'edit_user', etc., are capabilities used
25
- *                          by map_meta_cap() to map to other "primitive" capabilities, e.g. 'edit_posts',
26
- *                          'edit_others_posts', etc. The parameter is accessed via func_get_args().
27 23
  * @return array Actual capabilities for meta capability.
28 24
  */
29 25
 function map_meta_cap( $cap, $user_id ) {
@@ -416,11 +412,6 @@  discard block
 block discarded – undo
416 412
  * @see map_meta_cap()
417 413
  *
418 414
  * @param string $capability Capability name.
419
- * @param int    $object_id  Optional. ID of the specific object to check against if `$capability` is a "meta" cap.
420
- *                           "Meta" capabilities, e.g. 'edit_post', 'edit_user', etc., are capabilities used
421
- *                           by map_meta_cap() to map to other "primitive" capabilities, e.g. 'edit_posts',
422
- *                           'edit_others_posts', etc. Accessed via func_get_args() and passed to WP_User::has_cap(),
423
- *                           then map_meta_cap().
424 415
  * @return bool Whether the current user has the given capability. If `$capability` is a meta cap and `$object_id` is
425 416
  *              passed, whether the current user has the given meta capability for the given object.
426 417
  */
Please login to merge, or discard this patch.
Switch Indentation   +343 added lines, -343 removed lines patch added patch discarded remove patch
@@ -31,235 +31,235 @@  discard block
 block discarded – undo
31 31
 	$caps = array();
32 32
 
33 33
 	switch ( $cap ) {
34
-	case 'remove_user':
35
-		// In multisite the user must be a super admin to remove themselves.
36
-		if ( isset( $args[0] ) && $user_id == $args[0] && ! is_super_admin( $user_id ) ) {
37
-			$caps[] = 'do_not_allow';
38
-		} else {
39
-			$caps[] = 'remove_users';
40
-		}
41
-		break;
42
-	case 'promote_user':
43
-	case 'add_users':
44
-		$caps[] = 'promote_users';
45
-		break;
46
-	case 'edit_user':
47
-	case 'edit_users':
48
-		// Allow user to edit itself
49
-		if ( 'edit_user' == $cap && isset( $args[0] ) && $user_id == $args[0] )
34
+		case 'remove_user':
35
+			// In multisite the user must be a super admin to remove themselves.
36
+			if ( isset( $args[0] ) && $user_id == $args[0] && ! is_super_admin( $user_id ) ) {
37
+				$caps[] = 'do_not_allow';
38
+			} else {
39
+				$caps[] = 'remove_users';
40
+			}
50 41
 			break;
51
-
52
-		// In multisite the user must have manage_network_users caps. If editing a super admin, the user must be a super admin.
53
-		if ( is_multisite() && ( ( ! is_super_admin( $user_id ) && 'edit_user' === $cap && is_super_admin( $args[0] ) ) || ! user_can( $user_id, 'manage_network_users' ) ) ) {
54
-			$caps[] = 'do_not_allow';
55
-		} else {
56
-			$caps[] = 'edit_users'; // edit_user maps to edit_users.
57
-		}
58
-		break;
59
-	case 'delete_post':
60
-	case 'delete_page':
61
-		$post = get_post( $args[0] );
62
-		if ( ! $post ) {
63
-			$caps[] = 'do_not_allow';
42
+		case 'promote_user':
43
+		case 'add_users':
44
+			$caps[] = 'promote_users';
64 45
 			break;
65
-		}
46
+		case 'edit_user':
47
+		case 'edit_users':
48
+			// Allow user to edit itself
49
+			if ( 'edit_user' == $cap && isset( $args[0] ) && $user_id == $args[0] )
50
+				break;
66 51
 
67
-		if ( 'revision' == $post->post_type ) {
68
-			$post = get_post( $post->post_parent );
52
+			// In multisite the user must have manage_network_users caps. If editing a super admin, the user must be a super admin.
53
+			if ( is_multisite() && ( ( ! is_super_admin( $user_id ) && 'edit_user' === $cap && is_super_admin( $args[0] ) ) || ! user_can( $user_id, 'manage_network_users' ) ) ) {
54
+				$caps[] = 'do_not_allow';
55
+			} else {
56
+				$caps[] = 'edit_users'; // edit_user maps to edit_users.
57
+			}
58
+			break;
59
+		case 'delete_post':
60
+		case 'delete_page':
61
+			$post = get_post( $args[0] );
69 62
 			if ( ! $post ) {
70 63
 				$caps[] = 'do_not_allow';
71 64
 				break;
72 65
 			}
73
-		}
74 66
 
75
-		if ( ( get_option( 'page_for_posts' ) == $post->ID ) || ( get_option( 'page_on_front' ) == $post->ID ) ) {
76
-			$caps[] = 'manage_options';
77
-			break;
78
-		}
67
+			if ( 'revision' == $post->post_type ) {
68
+				$post = get_post( $post->post_parent );
69
+				if ( ! $post ) {
70
+					$caps[] = 'do_not_allow';
71
+					break;
72
+				}
73
+			}
79 74
 
80
-		$post_type = get_post_type_object( $post->post_type );
81
-		if ( ! $post_type ) {
82
-			/* translators: 1: post type, 2: capability name */
83
-			_doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' );
84
-			$caps[] = 'edit_others_posts';
85
-			break;
86
-		}
75
+			if ( ( get_option( 'page_for_posts' ) == $post->ID ) || ( get_option( 'page_on_front' ) == $post->ID ) ) {
76
+				$caps[] = 'manage_options';
77
+				break;
78
+			}
87 79
 
88
-		if ( ! $post_type->map_meta_cap ) {
89
-			$caps[] = $post_type->cap->$cap;
90
-			// Prior to 3.1 we would re-call map_meta_cap here.
91
-			if ( 'delete_post' == $cap )
92
-				$cap = $post_type->cap->$cap;
93
-			break;
94
-		}
80
+			$post_type = get_post_type_object( $post->post_type );
81
+			if ( ! $post_type ) {
82
+				/* translators: 1: post type, 2: capability name */
83
+				_doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' );
84
+				$caps[] = 'edit_others_posts';
85
+				break;
86
+			}
95 87
 
96
-		// If the post author is set and the user is the author...
97
-		if ( $post->post_author && $user_id == $post->post_author ) {
98
-			// If the post is published or scheduled...
99
-			if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
100
-				$caps[] = $post_type->cap->delete_published_posts;
101
-			} elseif ( 'trash' == $post->post_status ) {
102
-				$status = get_post_meta( $post->ID, '_wp_trash_meta_status', true );
103
-				if ( in_array( $status, array( 'publish', 'future' ), true ) ) {
88
+			if ( ! $post_type->map_meta_cap ) {
89
+				$caps[] = $post_type->cap->$cap;
90
+				// Prior to 3.1 we would re-call map_meta_cap here.
91
+				if ( 'delete_post' == $cap )
92
+					$cap = $post_type->cap->$cap;
93
+				break;
94
+			}
95
+
96
+			// If the post author is set and the user is the author...
97
+			if ( $post->post_author && $user_id == $post->post_author ) {
98
+				// If the post is published or scheduled...
99
+				if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
104 100
 					$caps[] = $post_type->cap->delete_published_posts;
101
+				} elseif ( 'trash' == $post->post_status ) {
102
+					$status = get_post_meta( $post->ID, '_wp_trash_meta_status', true );
103
+					if ( in_array( $status, array( 'publish', 'future' ), true ) ) {
104
+						$caps[] = $post_type->cap->delete_published_posts;
105
+					} else {
106
+						$caps[] = $post_type->cap->delete_posts;
107
+					}
105 108
 				} else {
109
+					// If the post is draft...
106 110
 					$caps[] = $post_type->cap->delete_posts;
107 111
 				}
108 112
 			} else {
109
-				// If the post is draft...
110
-				$caps[] = $post_type->cap->delete_posts;
111
-			}
112
-		} else {
113
-			// The user is trying to edit someone else's post.
114
-			$caps[] = $post_type->cap->delete_others_posts;
115
-			// The post is published or scheduled, extra cap required.
116
-			if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
117
-				$caps[] = $post_type->cap->delete_published_posts;
118
-			} elseif ( 'private' == $post->post_status ) {
119
-				$caps[] = $post_type->cap->delete_private_posts;
113
+				// The user is trying to edit someone else's post.
114
+				$caps[] = $post_type->cap->delete_others_posts;
115
+				// The post is published or scheduled, extra cap required.
116
+				if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
117
+					$caps[] = $post_type->cap->delete_published_posts;
118
+				} elseif ( 'private' == $post->post_status ) {
119
+					$caps[] = $post_type->cap->delete_private_posts;
120
+				}
120 121
 			}
121
-		}
122
-		break;
123
-		// edit_post breaks down to edit_posts, edit_published_posts, or
124
-		// edit_others_posts
125
-	case 'edit_post':
126
-	case 'edit_page':
127
-		$post = get_post( $args[0] );
128
-		if ( ! $post ) {
129
-			$caps[] = 'do_not_allow';
130 122
 			break;
131
-		}
132
-
133
-		if ( 'revision' == $post->post_type ) {
134
-			$post = get_post( $post->post_parent );
123
+			// edit_post breaks down to edit_posts, edit_published_posts, or
124
+			// edit_others_posts
125
+		case 'edit_post':
126
+		case 'edit_page':
127
+			$post = get_post( $args[0] );
135 128
 			if ( ! $post ) {
136 129
 				$caps[] = 'do_not_allow';
137 130
 				break;
138 131
 			}
139
-		}
140 132
 
141
-		$post_type = get_post_type_object( $post->post_type );
142
-		if ( ! $post_type ) {
143
-			/* translators: 1: post type, 2: capability name */
144
-			_doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' );
145
-			$caps[] = 'edit_others_posts';
146
-			break;
147
-		}
133
+			if ( 'revision' == $post->post_type ) {
134
+				$post = get_post( $post->post_parent );
135
+				if ( ! $post ) {
136
+					$caps[] = 'do_not_allow';
137
+					break;
138
+				}
139
+			}
148 140
 
149
-		if ( ! $post_type->map_meta_cap ) {
150
-			$caps[] = $post_type->cap->$cap;
151
-			// Prior to 3.1 we would re-call map_meta_cap here.
152
-			if ( 'edit_post' == $cap )
153
-				$cap = $post_type->cap->$cap;
154
-			break;
155
-		}
141
+			$post_type = get_post_type_object( $post->post_type );
142
+			if ( ! $post_type ) {
143
+				/* translators: 1: post type, 2: capability name */
144
+				_doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' );
145
+				$caps[] = 'edit_others_posts';
146
+				break;
147
+			}
156 148
 
157
-		// If the post author is set and the user is the author...
158
-		if ( $post->post_author && $user_id == $post->post_author ) {
159
-			// If the post is published or scheduled...
160
-			if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
161
-				$caps[] = $post_type->cap->edit_published_posts;
162
-			} elseif ( 'trash' == $post->post_status ) {
163
-				$status = get_post_meta( $post->ID, '_wp_trash_meta_status', true );
164
-				if ( in_array( $status, array( 'publish', 'future' ), true ) ) {
149
+			if ( ! $post_type->map_meta_cap ) {
150
+				$caps[] = $post_type->cap->$cap;
151
+				// Prior to 3.1 we would re-call map_meta_cap here.
152
+				if ( 'edit_post' == $cap )
153
+					$cap = $post_type->cap->$cap;
154
+				break;
155
+			}
156
+
157
+			// If the post author is set and the user is the author...
158
+			if ( $post->post_author && $user_id == $post->post_author ) {
159
+				// If the post is published or scheduled...
160
+				if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
165 161
 					$caps[] = $post_type->cap->edit_published_posts;
162
+				} elseif ( 'trash' == $post->post_status ) {
163
+					$status = get_post_meta( $post->ID, '_wp_trash_meta_status', true );
164
+					if ( in_array( $status, array( 'publish', 'future' ), true ) ) {
165
+						$caps[] = $post_type->cap->edit_published_posts;
166
+					} else {
167
+						$caps[] = $post_type->cap->edit_posts;
168
+					}
166 169
 				} else {
170
+					// If the post is draft...
167 171
 					$caps[] = $post_type->cap->edit_posts;
168 172
 				}
169 173
 			} else {
170
-				// If the post is draft...
171
-				$caps[] = $post_type->cap->edit_posts;
172
-			}
173
-		} else {
174
-			// The user is trying to edit someone else's post.
175
-			$caps[] = $post_type->cap->edit_others_posts;
176
-			// The post is published or scheduled, extra cap required.
177
-			if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
178
-				$caps[] = $post_type->cap->edit_published_posts;
179
-			} elseif ( 'private' == $post->post_status ) {
180
-				$caps[] = $post_type->cap->edit_private_posts;
174
+				// The user is trying to edit someone else's post.
175
+				$caps[] = $post_type->cap->edit_others_posts;
176
+				// The post is published or scheduled, extra cap required.
177
+				if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
178
+					$caps[] = $post_type->cap->edit_published_posts;
179
+				} elseif ( 'private' == $post->post_status ) {
180
+					$caps[] = $post_type->cap->edit_private_posts;
181
+				}
181 182
 			}
182
-		}
183
-		break;
184
-	case 'read_post':
185
-	case 'read_page':
186
-		$post = get_post( $args[0] );
187
-		if ( ! $post ) {
188
-			$caps[] = 'do_not_allow';
189 183
 			break;
190
-		}
191
-
192
-		if ( 'revision' == $post->post_type ) {
193
-			$post = get_post( $post->post_parent );
184
+		case 'read_post':
185
+		case 'read_page':
186
+			$post = get_post( $args[0] );
194 187
 			if ( ! $post ) {
195 188
 				$caps[] = 'do_not_allow';
196 189
 				break;
197 190
 			}
198
-		}
199 191
 
200
-		$post_type = get_post_type_object( $post->post_type );
201
-		if ( ! $post_type ) {
202
-			/* translators: 1: post type, 2: capability name */
203
-			_doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' );
204
-			$caps[] = 'edit_others_posts';
205
-			break;
206
-		}
192
+			if ( 'revision' == $post->post_type ) {
193
+				$post = get_post( $post->post_parent );
194
+				if ( ! $post ) {
195
+					$caps[] = 'do_not_allow';
196
+					break;
197
+				}
198
+			}
207 199
 
208
-		if ( ! $post_type->map_meta_cap ) {
209
-			$caps[] = $post_type->cap->$cap;
210
-			// Prior to 3.1 we would re-call map_meta_cap here.
211
-			if ( 'read_post' == $cap )
212
-				$cap = $post_type->cap->$cap;
213
-			break;
214
-		}
200
+			$post_type = get_post_type_object( $post->post_type );
201
+			if ( ! $post_type ) {
202
+				/* translators: 1: post type, 2: capability name */
203
+				_doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' );
204
+				$caps[] = 'edit_others_posts';
205
+				break;
206
+			}
215 207
 
216
-		$status_obj = get_post_status_object( $post->post_status );
217
-		if ( $status_obj->public ) {
218
-			$caps[] = $post_type->cap->read;
219
-			break;
220
-		}
208
+			if ( ! $post_type->map_meta_cap ) {
209
+				$caps[] = $post_type->cap->$cap;
210
+				// Prior to 3.1 we would re-call map_meta_cap here.
211
+				if ( 'read_post' == $cap )
212
+					$cap = $post_type->cap->$cap;
213
+				break;
214
+			}
221 215
 
222
-		if ( $post->post_author && $user_id == $post->post_author ) {
223
-			$caps[] = $post_type->cap->read;
224
-		} elseif ( $status_obj->private ) {
225
-			$caps[] = $post_type->cap->read_private_posts;
226
-		} else {
227
-			$caps = map_meta_cap( 'edit_post', $user_id, $post->ID );
228
-		}
229
-		break;
230
-	case 'publish_post':
231
-		$post = get_post( $args[0] );
232
-		if ( ! $post ) {
233
-			$caps[] = 'do_not_allow';
234
-			break;
235
-		}
216
+			$status_obj = get_post_status_object( $post->post_status );
217
+			if ( $status_obj->public ) {
218
+				$caps[] = $post_type->cap->read;
219
+				break;
220
+			}
236 221
 
237
-		$post_type = get_post_type_object( $post->post_type );
238
-		if ( ! $post_type ) {
239
-			/* translators: 1: post type, 2: capability name */
240
-			_doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' );
241
-			$caps[] = 'edit_others_posts';
222
+			if ( $post->post_author && $user_id == $post->post_author ) {
223
+				$caps[] = $post_type->cap->read;
224
+			} elseif ( $status_obj->private ) {
225
+				$caps[] = $post_type->cap->read_private_posts;
226
+			} else {
227
+				$caps = map_meta_cap( 'edit_post', $user_id, $post->ID );
228
+			}
242 229
 			break;
243
-		}
230
+		case 'publish_post':
231
+			$post = get_post( $args[0] );
232
+			if ( ! $post ) {
233
+				$caps[] = 'do_not_allow';
234
+				break;
235
+			}
244 236
 
245
-		$caps[] = $post_type->cap->publish_posts;
246
-		break;
247
-	case 'edit_post_meta':
248
-	case 'delete_post_meta':
249
-	case 'add_post_meta':
250
-	case 'edit_comment_meta':
251
-	case 'delete_comment_meta':
252
-	case 'add_comment_meta':
253
-	case 'edit_term_meta':
254
-	case 'delete_term_meta':
255
-	case 'add_term_meta':
256
-	case 'edit_user_meta':
257
-	case 'delete_user_meta':
258
-	case 'add_user_meta':
259
-		list( $_, $object_type, $_ ) = explode( '_', $cap );
260
-		$object_id = (int) $args[0];
261
-
262
-		switch ( $object_type ) {
237
+			$post_type = get_post_type_object( $post->post_type );
238
+			if ( ! $post_type ) {
239
+				/* translators: 1: post type, 2: capability name */
240
+				_doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' );
241
+				$caps[] = 'edit_others_posts';
242
+				break;
243
+			}
244
+
245
+			$caps[] = $post_type->cap->publish_posts;
246
+			break;
247
+		case 'edit_post_meta':
248
+		case 'delete_post_meta':
249
+		case 'add_post_meta':
250
+		case 'edit_comment_meta':
251
+		case 'delete_comment_meta':
252
+		case 'add_comment_meta':
253
+		case 'edit_term_meta':
254
+		case 'delete_term_meta':
255
+		case 'add_term_meta':
256
+		case 'edit_user_meta':
257
+		case 'delete_user_meta':
258
+		case 'add_user_meta':
259
+			list( $_, $object_type, $_ ) = explode( '_', $cap );
260
+			$object_id = (int) $args[0];
261
+
262
+			switch ( $object_type ) {
263 263
 			case 'post':
264 264
 				$post = get_post( $object_id );
265 265
 				if ( ! $post ) {
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 
296 296
 				$sub_type = 'user';
297 297
 				break;
298
-		}
298
+			}
299 299
 
300 300
 		if ( empty( $sub_type ) ) {
301 301
 			$caps[] = 'do_not_allow';
@@ -321,175 +321,175 @@  discard block
 block discarded – undo
321 321
 			$caps[] = $cap;
322 322
 		}
323 323
 		break;
324
-	case 'edit_comment':
325
-		$comment = get_comment( $args[0] );
326
-		if ( ! $comment ) {
327
-			$caps[] = 'do_not_allow';
328
-			break;
329
-		}
324
+		case 'edit_comment':
325
+			$comment = get_comment( $args[0] );
326
+			if ( ! $comment ) {
327
+				$caps[] = 'do_not_allow';
328
+				break;
329
+			}
330 330
 
331
-		$post = get_post( $comment->comment_post_ID );
331
+			$post = get_post( $comment->comment_post_ID );
332 332
 
333
-		/*
333
+			/*
334 334
 		 * If the post doesn't exist, we have an orphaned comment.
335 335
 		 * Fall back to the edit_posts capability, instead.
336 336
 		 */
337
-		if ( $post ) {
338
-			$caps = map_meta_cap( 'edit_post', $user_id, $post->ID );
339
-		} else {
340
-			$caps = map_meta_cap( 'edit_posts', $user_id );
341
-		}
342
-		break;
343
-	case 'unfiltered_upload':
344
-		if ( defined('ALLOW_UNFILTERED_UPLOADS') && ALLOW_UNFILTERED_UPLOADS && ( !is_multisite() || is_super_admin( $user_id ) )  )
345
-			$caps[] = $cap;
346
-		else
347
-			$caps[] = 'do_not_allow';
348
-		break;
349
-	case 'edit_css' :
350
-	case 'unfiltered_html' :
351
-		// Disallow unfiltered_html for all users, even admins and super admins.
352
-		if ( defined( 'DISALLOW_UNFILTERED_HTML' ) && DISALLOW_UNFILTERED_HTML )
353
-			$caps[] = 'do_not_allow';
354
-		elseif ( is_multisite() && ! is_super_admin( $user_id ) )
355
-			$caps[] = 'do_not_allow';
356
-		else
357
-			$caps[] = 'unfiltered_html';
358
-		break;
359
-	case 'edit_files':
360
-	case 'edit_plugins':
361
-	case 'edit_themes':
362
-		// Disallow the file editors.
363
-		if ( defined( 'DISALLOW_FILE_EDIT' ) && DISALLOW_FILE_EDIT )
364
-			$caps[] = 'do_not_allow';
365
-		elseif ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS )
366
-			$caps[] = 'do_not_allow';
367
-		elseif ( is_multisite() && ! is_super_admin( $user_id ) )
368
-			$caps[] = 'do_not_allow';
369
-		else
370
-			$caps[] = $cap;
371
-		break;
372
-	case 'update_plugins':
373
-	case 'delete_plugins':
374
-	case 'install_plugins':
375
-	case 'upload_plugins':
376
-	case 'update_themes':
377
-	case 'delete_themes':
378
-	case 'install_themes':
379
-	case 'upload_themes':
380
-	case 'update_core':
381
-		// Disallow anything that creates, deletes, or updates core, plugin, or theme files.
382
-		// Files in uploads are excepted.
383
-		if ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS ) {
384
-			$caps[] = 'do_not_allow';
385
-		} elseif ( is_multisite() && ! is_super_admin( $user_id ) ) {
386
-			$caps[] = 'do_not_allow';
387
-		} elseif ( 'upload_themes' === $cap ) {
388
-			$caps[] = 'install_themes';
389
-		} elseif ( 'upload_plugins' === $cap ) {
390
-			$caps[] = 'install_plugins';
391
-		} else {
392
-			$caps[] = $cap;
393
-		}
394
-		break;
395
-	case 'activate_plugins':
396
-		$caps[] = $cap;
397
-		if ( is_multisite() ) {
398
-			// update_, install_, and delete_ are handled above with is_super_admin().
399
-			$menu_perms = get_site_option( 'menu_items', array() );
400
-			if ( empty( $menu_perms['plugins'] ) )
401
-				$caps[] = 'manage_network_plugins';
402
-		}
403
-		break;
404
-	case 'delete_user':
405
-	case 'delete_users':
406
-		// If multisite only super admins can delete users.
407
-		if ( is_multisite() && ! is_super_admin( $user_id ) )
408
-			$caps[] = 'do_not_allow';
409
-		else
410
-			$caps[] = 'delete_users'; // delete_user maps to delete_users.
411
-		break;
412
-	case 'create_users':
413
-		if ( !is_multisite() )
414
-			$caps[] = $cap;
415
-		elseif ( is_super_admin( $user_id ) || get_site_option( 'add_new_users' ) )
416
-			$caps[] = $cap;
417
-		else
418
-			$caps[] = 'do_not_allow';
419
-		break;
420
-	case 'manage_links' :
421
-		if ( get_option( 'link_manager_enabled' ) )
337
+			if ( $post ) {
338
+				$caps = map_meta_cap( 'edit_post', $user_id, $post->ID );
339
+			} else {
340
+				$caps = map_meta_cap( 'edit_posts', $user_id );
341
+			}
342
+			break;
343
+		case 'unfiltered_upload':
344
+			if ( defined('ALLOW_UNFILTERED_UPLOADS') && ALLOW_UNFILTERED_UPLOADS && ( !is_multisite() || is_super_admin( $user_id ) )  )
345
+				$caps[] = $cap;
346
+			else
347
+				$caps[] = 'do_not_allow';
348
+			break;
349
+		case 'edit_css' :
350
+		case 'unfiltered_html' :
351
+			// Disallow unfiltered_html for all users, even admins and super admins.
352
+			if ( defined( 'DISALLOW_UNFILTERED_HTML' ) && DISALLOW_UNFILTERED_HTML )
353
+				$caps[] = 'do_not_allow';
354
+			elseif ( is_multisite() && ! is_super_admin( $user_id ) )
355
+				$caps[] = 'do_not_allow';
356
+			else
357
+				$caps[] = 'unfiltered_html';
358
+			break;
359
+		case 'edit_files':
360
+		case 'edit_plugins':
361
+		case 'edit_themes':
362
+			// Disallow the file editors.
363
+			if ( defined( 'DISALLOW_FILE_EDIT' ) && DISALLOW_FILE_EDIT )
364
+				$caps[] = 'do_not_allow';
365
+			elseif ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS )
366
+				$caps[] = 'do_not_allow';
367
+			elseif ( is_multisite() && ! is_super_admin( $user_id ) )
368
+				$caps[] = 'do_not_allow';
369
+			else
370
+				$caps[] = $cap;
371
+			break;
372
+		case 'update_plugins':
373
+		case 'delete_plugins':
374
+		case 'install_plugins':
375
+		case 'upload_plugins':
376
+		case 'update_themes':
377
+		case 'delete_themes':
378
+		case 'install_themes':
379
+		case 'upload_themes':
380
+		case 'update_core':
381
+			// Disallow anything that creates, deletes, or updates core, plugin, or theme files.
382
+			// Files in uploads are excepted.
383
+			if ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS ) {
384
+				$caps[] = 'do_not_allow';
385
+			} elseif ( is_multisite() && ! is_super_admin( $user_id ) ) {
386
+				$caps[] = 'do_not_allow';
387
+			} elseif ( 'upload_themes' === $cap ) {
388
+				$caps[] = 'install_themes';
389
+			} elseif ( 'upload_plugins' === $cap ) {
390
+				$caps[] = 'install_plugins';
391
+			} else {
392
+				$caps[] = $cap;
393
+			}
394
+			break;
395
+		case 'activate_plugins':
422 396
 			$caps[] = $cap;
423
-		else
424
-			$caps[] = 'do_not_allow';
425
-		break;
426
-	case 'customize' :
427
-		$caps[] = 'edit_theme_options';
428
-		break;
429
-	case 'delete_site':
430
-		if ( is_multisite() ) {
431
-			$caps[] = 'manage_options';
432
-		} else {
433
-			$caps[] = 'do_not_allow';
434
-		}
435
-		break;
436
-	case 'edit_term':
437
-	case 'delete_term':
438
-	case 'assign_term':
439
-		$term_id = (int) $args[0];
440
-		$term = get_term( $term_id );
441
-		if ( ! $term || is_wp_error( $term ) ) {
442
-			$caps[] = 'do_not_allow';
397
+			if ( is_multisite() ) {
398
+				// update_, install_, and delete_ are handled above with is_super_admin().
399
+				$menu_perms = get_site_option( 'menu_items', array() );
400
+				if ( empty( $menu_perms['plugins'] ) )
401
+					$caps[] = 'manage_network_plugins';
402
+			}
443 403
 			break;
444
-		}
445
-
446
-		$tax = get_taxonomy( $term->taxonomy );
447
-		if ( ! $tax ) {
448
-			$caps[] = 'do_not_allow';
404
+		case 'delete_user':
405
+		case 'delete_users':
406
+			// If multisite only super admins can delete users.
407
+			if ( is_multisite() && ! is_super_admin( $user_id ) )
408
+				$caps[] = 'do_not_allow';
409
+			else
410
+				$caps[] = 'delete_users'; // delete_user maps to delete_users.
449 411
 			break;
450
-		}
451
-
452
-		if ( 'delete_term' === $cap && ( $term->term_id == get_option( 'default_' . $term->taxonomy ) ) ) {
453
-			$caps[] = 'do_not_allow';
412
+		case 'create_users':
413
+			if ( !is_multisite() )
414
+				$caps[] = $cap;
415
+			elseif ( is_super_admin( $user_id ) || get_site_option( 'add_new_users' ) )
416
+				$caps[] = $cap;
417
+			else
418
+				$caps[] = 'do_not_allow';
454 419
 			break;
455
-		}
420
+		case 'manage_links' :
421
+			if ( get_option( 'link_manager_enabled' ) )
422
+				$caps[] = $cap;
423
+			else
424
+				$caps[] = 'do_not_allow';
425
+			break;
426
+		case 'customize' :
427
+			$caps[] = 'edit_theme_options';
428
+			break;
429
+		case 'delete_site':
430
+			if ( is_multisite() ) {
431
+				$caps[] = 'manage_options';
432
+			} else {
433
+				$caps[] = 'do_not_allow';
434
+			}
435
+			break;
436
+		case 'edit_term':
437
+		case 'delete_term':
438
+		case 'assign_term':
439
+			$term_id = (int) $args[0];
440
+			$term = get_term( $term_id );
441
+			if ( ! $term || is_wp_error( $term ) ) {
442
+				$caps[] = 'do_not_allow';
443
+				break;
444
+			}
456 445
 
457
-		$taxo_cap = $cap . 's';
446
+			$tax = get_taxonomy( $term->taxonomy );
447
+			if ( ! $tax ) {
448
+				$caps[] = 'do_not_allow';
449
+				break;
450
+			}
458 451
 
459
-		$caps = map_meta_cap( $tax->cap->$taxo_cap, $user_id, $term_id );
452
+			if ( 'delete_term' === $cap && ( $term->term_id == get_option( 'default_' . $term->taxonomy ) ) ) {
453
+				$caps[] = 'do_not_allow';
454
+				break;
455
+			}
460 456
 
461
-		break;
462
-	case 'manage_post_tags':
463
-	case 'edit_categories':
464
-	case 'edit_post_tags':
465
-	case 'delete_categories':
466
-	case 'delete_post_tags':
467
-		$caps[] = 'manage_categories';
468
-		break;
469
-	case 'assign_categories':
470
-	case 'assign_post_tags':
471
-		$caps[] = 'edit_posts';
472
-		break;
473
-	case 'create_sites':
474
-	case 'delete_sites':
475
-	case 'manage_network':
476
-	case 'manage_sites':
477
-	case 'manage_network_users':
478
-	case 'manage_network_plugins':
479
-	case 'manage_network_themes':
480
-	case 'manage_network_options':
481
-		$caps[] = $cap;
482
-		break;
483
-	default:
484
-		// Handle meta capabilities for custom post types.
485
-		global $post_type_meta_caps;
486
-		if ( isset( $post_type_meta_caps[ $cap ] ) ) {
487
-			$args = array_merge( array( $post_type_meta_caps[ $cap ], $user_id ), $args );
488
-			return call_user_func_array( 'map_meta_cap', $args );
489
-		}
457
+			$taxo_cap = $cap . 's';
458
+
459
+			$caps = map_meta_cap( $tax->cap->$taxo_cap, $user_id, $term_id );
460
+
461
+			break;
462
+		case 'manage_post_tags':
463
+		case 'edit_categories':
464
+		case 'edit_post_tags':
465
+		case 'delete_categories':
466
+		case 'delete_post_tags':
467
+			$caps[] = 'manage_categories';
468
+			break;
469
+		case 'assign_categories':
470
+		case 'assign_post_tags':
471
+			$caps[] = 'edit_posts';
472
+			break;
473
+		case 'create_sites':
474
+		case 'delete_sites':
475
+		case 'manage_network':
476
+		case 'manage_sites':
477
+		case 'manage_network_users':
478
+		case 'manage_network_plugins':
479
+		case 'manage_network_themes':
480
+		case 'manage_network_options':
481
+			$caps[] = $cap;
482
+			break;
483
+		default:
484
+			// Handle meta capabilities for custom post types.
485
+			global $post_type_meta_caps;
486
+			if ( isset( $post_type_meta_caps[ $cap ] ) ) {
487
+				$args = array_merge( array( $post_type_meta_caps[ $cap ], $user_id ), $args );
488
+				return call_user_func_array( 'map_meta_cap', $args );
489
+			}
490 490
 
491
-		// If no meta caps match, return the original cap.
492
-		$caps[] = $cap;
491
+			// If no meta caps match, return the original cap.
492
+			$caps[] = $cap;
493 493
 	}
494 494
 
495 495
 	/**
Please login to merge, or discard this patch.
Spacing   +179 added lines, -179 removed lines patch added patch discarded remove patch
@@ -26,14 +26,14 @@  discard block
 block discarded – undo
26 26
  *                          'edit_others_posts', etc. The parameter is accessed via func_get_args().
27 27
  * @return array Actual capabilities for meta capability.
28 28
  */
29
-function map_meta_cap( $cap, $user_id ) {
30
-	$args = array_slice( func_get_args(), 2 );
29
+function map_meta_cap($cap, $user_id) {
30
+	$args = array_slice(func_get_args(), 2);
31 31
 	$caps = array();
32 32
 
33
-	switch ( $cap ) {
33
+	switch ($cap) {
34 34
 	case 'remove_user':
35 35
 		// In multisite the user must be a super admin to remove themselves.
36
-		if ( isset( $args[0] ) && $user_id == $args[0] && ! is_super_admin( $user_id ) ) {
36
+		if (isset($args[0]) && $user_id == $args[0] && ! is_super_admin($user_id)) {
37 37
 			$caps[] = 'do_not_allow';
38 38
 		} else {
39 39
 			$caps[] = 'remove_users';
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
46 46
 	case 'edit_user':
47 47
 	case 'edit_users':
48 48
 		// Allow user to edit itself
49
-		if ( 'edit_user' == $cap && isset( $args[0] ) && $user_id == $args[0] )
49
+		if ('edit_user' == $cap && isset($args[0]) && $user_id == $args[0])
50 50
 			break;
51 51
 
52 52
 		// In multisite the user must have manage_network_users caps. If editing a super admin, the user must be a super admin.
53
-		if ( is_multisite() && ( ( ! is_super_admin( $user_id ) && 'edit_user' === $cap && is_super_admin( $args[0] ) ) || ! user_can( $user_id, 'manage_network_users' ) ) ) {
53
+		if (is_multisite() && (( ! is_super_admin($user_id) && 'edit_user' === $cap && is_super_admin($args[0])) || ! user_can($user_id, 'manage_network_users'))) {
54 54
 			$caps[] = 'do_not_allow';
55 55
 		} else {
56 56
 			$caps[] = 'edit_users'; // edit_user maps to edit_users.
@@ -58,49 +58,49 @@  discard block
 block discarded – undo
58 58
 		break;
59 59
 	case 'delete_post':
60 60
 	case 'delete_page':
61
-		$post = get_post( $args[0] );
62
-		if ( ! $post ) {
61
+		$post = get_post($args[0]);
62
+		if ( ! $post) {
63 63
 			$caps[] = 'do_not_allow';
64 64
 			break;
65 65
 		}
66 66
 
67
-		if ( 'revision' == $post->post_type ) {
68
-			$post = get_post( $post->post_parent );
69
-			if ( ! $post ) {
67
+		if ('revision' == $post->post_type) {
68
+			$post = get_post($post->post_parent);
69
+			if ( ! $post) {
70 70
 				$caps[] = 'do_not_allow';
71 71
 				break;
72 72
 			}
73 73
 		}
74 74
 
75
-		if ( ( get_option( 'page_for_posts' ) == $post->ID ) || ( get_option( 'page_on_front' ) == $post->ID ) ) {
75
+		if ((get_option('page_for_posts') == $post->ID) || (get_option('page_on_front') == $post->ID)) {
76 76
 			$caps[] = 'manage_options';
77 77
 			break;
78 78
 		}
79 79
 
80
-		$post_type = get_post_type_object( $post->post_type );
81
-		if ( ! $post_type ) {
80
+		$post_type = get_post_type_object($post->post_type);
81
+		if ( ! $post_type) {
82 82
 			/* translators: 1: post type, 2: capability name */
83
-			_doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' );
83
+			_doing_it_wrong(__FUNCTION__, sprintf(__('The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.'), $post->post_type, $cap), '4.4.0');
84 84
 			$caps[] = 'edit_others_posts';
85 85
 			break;
86 86
 		}
87 87
 
88
-		if ( ! $post_type->map_meta_cap ) {
88
+		if ( ! $post_type->map_meta_cap) {
89 89
 			$caps[] = $post_type->cap->$cap;
90 90
 			// Prior to 3.1 we would re-call map_meta_cap here.
91
-			if ( 'delete_post' == $cap )
91
+			if ('delete_post' == $cap)
92 92
 				$cap = $post_type->cap->$cap;
93 93
 			break;
94 94
 		}
95 95
 
96 96
 		// If the post author is set and the user is the author...
97
-		if ( $post->post_author && $user_id == $post->post_author ) {
97
+		if ($post->post_author && $user_id == $post->post_author) {
98 98
 			// If the post is published or scheduled...
99
-			if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
99
+			if (in_array($post->post_status, array('publish', 'future'), true)) {
100 100
 				$caps[] = $post_type->cap->delete_published_posts;
101
-			} elseif ( 'trash' == $post->post_status ) {
102
-				$status = get_post_meta( $post->ID, '_wp_trash_meta_status', true );
103
-				if ( in_array( $status, array( 'publish', 'future' ), true ) ) {
101
+			} elseif ('trash' == $post->post_status) {
102
+				$status = get_post_meta($post->ID, '_wp_trash_meta_status', true);
103
+				if (in_array($status, array('publish', 'future'), true)) {
104 104
 					$caps[] = $post_type->cap->delete_published_posts;
105 105
 				} else {
106 106
 					$caps[] = $post_type->cap->delete_posts;
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 			// The user is trying to edit someone else's post.
114 114
 			$caps[] = $post_type->cap->delete_others_posts;
115 115
 			// The post is published or scheduled, extra cap required.
116
-			if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
116
+			if (in_array($post->post_status, array('publish', 'future'), true)) {
117 117
 				$caps[] = $post_type->cap->delete_published_posts;
118
-			} elseif ( 'private' == $post->post_status ) {
118
+			} elseif ('private' == $post->post_status) {
119 119
 				$caps[] = $post_type->cap->delete_private_posts;
120 120
 			}
121 121
 		}
@@ -124,44 +124,44 @@  discard block
 block discarded – undo
124 124
 		// edit_others_posts
125 125
 	case 'edit_post':
126 126
 	case 'edit_page':
127
-		$post = get_post( $args[0] );
128
-		if ( ! $post ) {
127
+		$post = get_post($args[0]);
128
+		if ( ! $post) {
129 129
 			$caps[] = 'do_not_allow';
130 130
 			break;
131 131
 		}
132 132
 
133
-		if ( 'revision' == $post->post_type ) {
134
-			$post = get_post( $post->post_parent );
135
-			if ( ! $post ) {
133
+		if ('revision' == $post->post_type) {
134
+			$post = get_post($post->post_parent);
135
+			if ( ! $post) {
136 136
 				$caps[] = 'do_not_allow';
137 137
 				break;
138 138
 			}
139 139
 		}
140 140
 
141
-		$post_type = get_post_type_object( $post->post_type );
142
-		if ( ! $post_type ) {
141
+		$post_type = get_post_type_object($post->post_type);
142
+		if ( ! $post_type) {
143 143
 			/* translators: 1: post type, 2: capability name */
144
-			_doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' );
144
+			_doing_it_wrong(__FUNCTION__, sprintf(__('The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.'), $post->post_type, $cap), '4.4.0');
145 145
 			$caps[] = 'edit_others_posts';
146 146
 			break;
147 147
 		}
148 148
 
149
-		if ( ! $post_type->map_meta_cap ) {
149
+		if ( ! $post_type->map_meta_cap) {
150 150
 			$caps[] = $post_type->cap->$cap;
151 151
 			// Prior to 3.1 we would re-call map_meta_cap here.
152
-			if ( 'edit_post' == $cap )
152
+			if ('edit_post' == $cap)
153 153
 				$cap = $post_type->cap->$cap;
154 154
 			break;
155 155
 		}
156 156
 
157 157
 		// If the post author is set and the user is the author...
158
-		if ( $post->post_author && $user_id == $post->post_author ) {
158
+		if ($post->post_author && $user_id == $post->post_author) {
159 159
 			// If the post is published or scheduled...
160
-			if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
160
+			if (in_array($post->post_status, array('publish', 'future'), true)) {
161 161
 				$caps[] = $post_type->cap->edit_published_posts;
162
-			} elseif ( 'trash' == $post->post_status ) {
163
-				$status = get_post_meta( $post->ID, '_wp_trash_meta_status', true );
164
-				if ( in_array( $status, array( 'publish', 'future' ), true ) ) {
162
+			} elseif ('trash' == $post->post_status) {
163
+				$status = get_post_meta($post->ID, '_wp_trash_meta_status', true);
164
+				if (in_array($status, array('publish', 'future'), true)) {
165 165
 					$caps[] = $post_type->cap->edit_published_posts;
166 166
 				} else {
167 167
 					$caps[] = $post_type->cap->edit_posts;
@@ -174,70 +174,70 @@  discard block
 block discarded – undo
174 174
 			// The user is trying to edit someone else's post.
175 175
 			$caps[] = $post_type->cap->edit_others_posts;
176 176
 			// The post is published or scheduled, extra cap required.
177
-			if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
177
+			if (in_array($post->post_status, array('publish', 'future'), true)) {
178 178
 				$caps[] = $post_type->cap->edit_published_posts;
179
-			} elseif ( 'private' == $post->post_status ) {
179
+			} elseif ('private' == $post->post_status) {
180 180
 				$caps[] = $post_type->cap->edit_private_posts;
181 181
 			}
182 182
 		}
183 183
 		break;
184 184
 	case 'read_post':
185 185
 	case 'read_page':
186
-		$post = get_post( $args[0] );
187
-		if ( ! $post ) {
186
+		$post = get_post($args[0]);
187
+		if ( ! $post) {
188 188
 			$caps[] = 'do_not_allow';
189 189
 			break;
190 190
 		}
191 191
 
192
-		if ( 'revision' == $post->post_type ) {
193
-			$post = get_post( $post->post_parent );
194
-			if ( ! $post ) {
192
+		if ('revision' == $post->post_type) {
193
+			$post = get_post($post->post_parent);
194
+			if ( ! $post) {
195 195
 				$caps[] = 'do_not_allow';
196 196
 				break;
197 197
 			}
198 198
 		}
199 199
 
200
-		$post_type = get_post_type_object( $post->post_type );
201
-		if ( ! $post_type ) {
200
+		$post_type = get_post_type_object($post->post_type);
201
+		if ( ! $post_type) {
202 202
 			/* translators: 1: post type, 2: capability name */
203
-			_doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' );
203
+			_doing_it_wrong(__FUNCTION__, sprintf(__('The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.'), $post->post_type, $cap), '4.4.0');
204 204
 			$caps[] = 'edit_others_posts';
205 205
 			break;
206 206
 		}
207 207
 
208
-		if ( ! $post_type->map_meta_cap ) {
208
+		if ( ! $post_type->map_meta_cap) {
209 209
 			$caps[] = $post_type->cap->$cap;
210 210
 			// Prior to 3.1 we would re-call map_meta_cap here.
211
-			if ( 'read_post' == $cap )
211
+			if ('read_post' == $cap)
212 212
 				$cap = $post_type->cap->$cap;
213 213
 			break;
214 214
 		}
215 215
 
216
-		$status_obj = get_post_status_object( $post->post_status );
217
-		if ( $status_obj->public ) {
216
+		$status_obj = get_post_status_object($post->post_status);
217
+		if ($status_obj->public) {
218 218
 			$caps[] = $post_type->cap->read;
219 219
 			break;
220 220
 		}
221 221
 
222
-		if ( $post->post_author && $user_id == $post->post_author ) {
222
+		if ($post->post_author && $user_id == $post->post_author) {
223 223
 			$caps[] = $post_type->cap->read;
224
-		} elseif ( $status_obj->private ) {
224
+		} elseif ($status_obj->private) {
225 225
 			$caps[] = $post_type->cap->read_private_posts;
226 226
 		} else {
227
-			$caps = map_meta_cap( 'edit_post', $user_id, $post->ID );
227
+			$caps = map_meta_cap('edit_post', $user_id, $post->ID);
228 228
 		}
229 229
 		break;
230 230
 	case 'publish_post':
231
-		$post = get_post( $args[0] );
232
-		if ( ! $post ) {
231
+		$post = get_post($args[0]);
232
+		if ( ! $post) {
233 233
 			$caps[] = 'do_not_allow';
234 234
 			break;
235 235
 		}
236 236
 
237
-		$post_type = get_post_type_object( $post->post_type );
238
-		if ( ! $post_type ) {
237
+		$post_type = get_post_type_object($post->post_type);
238
+		if ( ! $post_type) {
239 239
 			/* translators: 1: post type, 2: capability name */
240
-			_doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' );
240
+			_doing_it_wrong(__FUNCTION__, sprintf(__('The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.'), $post->post_type, $cap), '4.4.0');
241 241
 			$caps[] = 'edit_others_posts';
242 242
 			break;
243 243
 		}
@@ -256,31 +256,31 @@  discard block
 block discarded – undo
256 256
 	case 'edit_user_meta':
257 257
 	case 'delete_user_meta':
258 258
 	case 'add_user_meta':
259
-		list( $_, $object_type, $_ ) = explode( '_', $cap );
259
+		list($_, $object_type, $_) = explode('_', $cap);
260 260
 		$object_id = (int) $args[0];
261 261
 
262
-		switch ( $object_type ) {
262
+		switch ($object_type) {
263 263
 			case 'post':
264
-				$post = get_post( $object_id );
265
-				if ( ! $post ) {
264
+				$post = get_post($object_id);
265
+				if ( ! $post) {
266 266
 					break;
267 267
 				}
268 268
 
269
-				$sub_type = get_post_type( $post );
269
+				$sub_type = get_post_type($post);
270 270
 				break;
271 271
 
272 272
 			case 'comment':
273
-				$comment = get_comment( $object_id );
274
-				if ( ! $comment ) {
273
+				$comment = get_comment($object_id);
274
+				if ( ! $comment) {
275 275
 					break;
276 276
 				}
277 277
 
278
-				$sub_type = empty( $comment->comment_type ) ? 'comment' : $comment->comment_type;
278
+				$sub_type = empty($comment->comment_type) ? 'comment' : $comment->comment_type;
279 279
 				break;
280 280
 
281 281
 			case 'term':
282
-				$term = get_term( $object_id );
283
-				if ( ! $term ) {
282
+				$term = get_term($object_id);
283
+				if ( ! $term) {
284 284
 					break;
285 285
 				}
286 286
 
@@ -288,8 +288,8 @@  discard block
 block discarded – undo
288 288
 				break;
289 289
 
290 290
 			case 'user':
291
-				$user = get_user_by( 'id', $object_id );
292
-				if ( ! $user ) {
291
+				$user = get_user_by('id', $object_id);
292
+				if ( ! $user) {
293 293
 					break;
294 294
 				}
295 295
 
@@ -297,51 +297,51 @@  discard block
 block discarded – undo
297 297
 				break;
298 298
 		}
299 299
 
300
-		if ( empty( $sub_type ) ) {
300
+		if (empty($sub_type)) {
301 301
 			$caps[] = 'do_not_allow';
302 302
 			break;
303 303
 		}
304 304
 
305
-		$caps = map_meta_cap( "edit_{$object_type}", $user_id, $object_id );
305
+		$caps = map_meta_cap("edit_{$object_type}", $user_id, $object_id);
306 306
 
307
-		$meta_key = isset( $args[1] ) ? $args[1] : false;
307
+		$meta_key = isset($args[1]) ? $args[1] : false;
308 308
 
309
-		$has_filter = has_filter( "auth_{$object_type}_meta_{$meta_key}" ) || has_filter( "auth_{$object_type}_{$sub_type}_meta_{$meta_key}" );
310
-		if ( $meta_key && $has_filter ) {
309
+		$has_filter = has_filter("auth_{$object_type}_meta_{$meta_key}") || has_filter("auth_{$object_type}_{$sub_type}_meta_{$meta_key}");
310
+		if ($meta_key && $has_filter) {
311 311
 			/** This filter is documented in wp-includes/meta.php */
312
-			$allowed = apply_filters( "auth_{$object_type}_meta_{$meta_key}", false, $meta_key, $object_id, $user_id, $cap, $caps );
312
+			$allowed = apply_filters("auth_{$object_type}_meta_{$meta_key}", false, $meta_key, $object_id, $user_id, $cap, $caps);
313 313
 
314 314
 			/** This filter is documented in wp-includes/meta.php */
315
-			$allowed = apply_filters( "auth_{$object_type}_{$sub_type}_meta_{$meta_key}", $allowed, $meta_key, $object_id, $user_id, $cap, $caps );
315
+			$allowed = apply_filters("auth_{$object_type}_{$sub_type}_meta_{$meta_key}", $allowed, $meta_key, $object_id, $user_id, $cap, $caps);
316 316
 
317
-			if ( ! $allowed ) {
317
+			if ( ! $allowed) {
318 318
 				$caps[] = $cap;
319 319
 			}
320
-		} elseif ( $meta_key && is_protected_meta( $meta_key, $object_type ) ) {
320
+		} elseif ($meta_key && is_protected_meta($meta_key, $object_type)) {
321 321
 			$caps[] = $cap;
322 322
 		}
323 323
 		break;
324 324
 	case 'edit_comment':
325
-		$comment = get_comment( $args[0] );
326
-		if ( ! $comment ) {
325
+		$comment = get_comment($args[0]);
326
+		if ( ! $comment) {
327 327
 			$caps[] = 'do_not_allow';
328 328
 			break;
329 329
 		}
330 330
 
331
-		$post = get_post( $comment->comment_post_ID );
331
+		$post = get_post($comment->comment_post_ID);
332 332
 
333 333
 		/*
334 334
 		 * If the post doesn't exist, we have an orphaned comment.
335 335
 		 * Fall back to the edit_posts capability, instead.
336 336
 		 */
337
-		if ( $post ) {
338
-			$caps = map_meta_cap( 'edit_post', $user_id, $post->ID );
337
+		if ($post) {
338
+			$caps = map_meta_cap('edit_post', $user_id, $post->ID);
339 339
 		} else {
340
-			$caps = map_meta_cap( 'edit_posts', $user_id );
340
+			$caps = map_meta_cap('edit_posts', $user_id);
341 341
 		}
342 342
 		break;
343 343
 	case 'unfiltered_upload':
344
-		if ( defined('ALLOW_UNFILTERED_UPLOADS') && ALLOW_UNFILTERED_UPLOADS && ( !is_multisite() || is_super_admin( $user_id ) )  )
344
+		if (defined('ALLOW_UNFILTERED_UPLOADS') && ALLOW_UNFILTERED_UPLOADS && ( ! is_multisite() || is_super_admin($user_id)))
345 345
 			$caps[] = $cap;
346 346
 		else
347 347
 			$caps[] = 'do_not_allow';
@@ -349,9 +349,9 @@  discard block
 block discarded – undo
349 349
 	case 'edit_css' :
350 350
 	case 'unfiltered_html' :
351 351
 		// Disallow unfiltered_html for all users, even admins and super admins.
352
-		if ( defined( 'DISALLOW_UNFILTERED_HTML' ) && DISALLOW_UNFILTERED_HTML )
352
+		if (defined('DISALLOW_UNFILTERED_HTML') && DISALLOW_UNFILTERED_HTML)
353 353
 			$caps[] = 'do_not_allow';
354
-		elseif ( is_multisite() && ! is_super_admin( $user_id ) )
354
+		elseif (is_multisite() && ! is_super_admin($user_id))
355 355
 			$caps[] = 'do_not_allow';
356 356
 		else
357 357
 			$caps[] = 'unfiltered_html';
@@ -360,11 +360,11 @@  discard block
 block discarded – undo
360 360
 	case 'edit_plugins':
361 361
 	case 'edit_themes':
362 362
 		// Disallow the file editors.
363
-		if ( defined( 'DISALLOW_FILE_EDIT' ) && DISALLOW_FILE_EDIT )
363
+		if (defined('DISALLOW_FILE_EDIT') && DISALLOW_FILE_EDIT)
364 364
 			$caps[] = 'do_not_allow';
365
-		elseif ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS )
365
+		elseif (defined('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS)
366 366
 			$caps[] = 'do_not_allow';
367
-		elseif ( is_multisite() && ! is_super_admin( $user_id ) )
367
+		elseif (is_multisite() && ! is_super_admin($user_id))
368 368
 			$caps[] = 'do_not_allow';
369 369
 		else
370 370
 			$caps[] = $cap;
@@ -380,13 +380,13 @@  discard block
 block discarded – undo
380 380
 	case 'update_core':
381 381
 		// Disallow anything that creates, deletes, or updates core, plugin, or theme files.
382 382
 		// Files in uploads are excepted.
383
-		if ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS ) {
383
+		if (defined('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS) {
384 384
 			$caps[] = 'do_not_allow';
385
-		} elseif ( is_multisite() && ! is_super_admin( $user_id ) ) {
385
+		} elseif (is_multisite() && ! is_super_admin($user_id)) {
386 386
 			$caps[] = 'do_not_allow';
387
-		} elseif ( 'upload_themes' === $cap ) {
387
+		} elseif ('upload_themes' === $cap) {
388 388
 			$caps[] = 'install_themes';
389
-		} elseif ( 'upload_plugins' === $cap ) {
389
+		} elseif ('upload_plugins' === $cap) {
390 390
 			$caps[] = 'install_plugins';
391 391
 		} else {
392 392
 			$caps[] = $cap;
@@ -394,31 +394,31 @@  discard block
 block discarded – undo
394 394
 		break;
395 395
 	case 'activate_plugins':
396 396
 		$caps[] = $cap;
397
-		if ( is_multisite() ) {
397
+		if (is_multisite()) {
398 398
 			// update_, install_, and delete_ are handled above with is_super_admin().
399
-			$menu_perms = get_site_option( 'menu_items', array() );
400
-			if ( empty( $menu_perms['plugins'] ) )
399
+			$menu_perms = get_site_option('menu_items', array());
400
+			if (empty($menu_perms['plugins']))
401 401
 				$caps[] = 'manage_network_plugins';
402 402
 		}
403 403
 		break;
404 404
 	case 'delete_user':
405 405
 	case 'delete_users':
406 406
 		// If multisite only super admins can delete users.
407
-		if ( is_multisite() && ! is_super_admin( $user_id ) )
407
+		if (is_multisite() && ! is_super_admin($user_id))
408 408
 			$caps[] = 'do_not_allow';
409 409
 		else
410 410
 			$caps[] = 'delete_users'; // delete_user maps to delete_users.
411 411
 		break;
412 412
 	case 'create_users':
413
-		if ( !is_multisite() )
413
+		if ( ! is_multisite())
414 414
 			$caps[] = $cap;
415
-		elseif ( is_super_admin( $user_id ) || get_site_option( 'add_new_users' ) )
415
+		elseif (is_super_admin($user_id) || get_site_option('add_new_users'))
416 416
 			$caps[] = $cap;
417 417
 		else
418 418
 			$caps[] = 'do_not_allow';
419 419
 		break;
420 420
 	case 'manage_links' :
421
-		if ( get_option( 'link_manager_enabled' ) )
421
+		if (get_option('link_manager_enabled'))
422 422
 			$caps[] = $cap;
423 423
 		else
424 424
 			$caps[] = 'do_not_allow';
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 		$caps[] = 'edit_theme_options';
428 428
 		break;
429 429
 	case 'delete_site':
430
-		if ( is_multisite() ) {
430
+		if (is_multisite()) {
431 431
 			$caps[] = 'manage_options';
432 432
 		} else {
433 433
 			$caps[] = 'do_not_allow';
@@ -437,26 +437,26 @@  discard block
 block discarded – undo
437 437
 	case 'delete_term':
438 438
 	case 'assign_term':
439 439
 		$term_id = (int) $args[0];
440
-		$term = get_term( $term_id );
441
-		if ( ! $term || is_wp_error( $term ) ) {
440
+		$term = get_term($term_id);
441
+		if ( ! $term || is_wp_error($term)) {
442 442
 			$caps[] = 'do_not_allow';
443 443
 			break;
444 444
 		}
445 445
 
446
-		$tax = get_taxonomy( $term->taxonomy );
447
-		if ( ! $tax ) {
446
+		$tax = get_taxonomy($term->taxonomy);
447
+		if ( ! $tax) {
448 448
 			$caps[] = 'do_not_allow';
449 449
 			break;
450 450
 		}
451 451
 
452
-		if ( 'delete_term' === $cap && ( $term->term_id == get_option( 'default_' . $term->taxonomy ) ) ) {
452
+		if ('delete_term' === $cap && ($term->term_id == get_option('default_'.$term->taxonomy))) {
453 453
 			$caps[] = 'do_not_allow';
454 454
 			break;
455 455
 		}
456 456
 
457
-		$taxo_cap = $cap . 's';
457
+		$taxo_cap = $cap.'s';
458 458
 
459
-		$caps = map_meta_cap( $tax->cap->$taxo_cap, $user_id, $term_id );
459
+		$caps = map_meta_cap($tax->cap->$taxo_cap, $user_id, $term_id);
460 460
 
461 461
 		break;
462 462
 	case 'manage_post_tags':
@@ -483,9 +483,9 @@  discard block
 block discarded – undo
483 483
 	default:
484 484
 		// Handle meta capabilities for custom post types.
485 485
 		global $post_type_meta_caps;
486
-		if ( isset( $post_type_meta_caps[ $cap ] ) ) {
487
-			$args = array_merge( array( $post_type_meta_caps[ $cap ], $user_id ), $args );
488
-			return call_user_func_array( 'map_meta_cap', $args );
486
+		if (isset($post_type_meta_caps[$cap])) {
487
+			$args = array_merge(array($post_type_meta_caps[$cap], $user_id), $args);
488
+			return call_user_func_array('map_meta_cap', $args);
489 489
 		}
490 490
 
491 491
 		// If no meta caps match, return the original cap.
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 	 * @param int    $user_id The user ID.
503 503
 	 * @param array  $args    Adds the context to the cap. Typically the object ID.
504 504
 	 */
505
-	return apply_filters( 'map_meta_cap', $caps, $cap, $user_id, $args );
505
+	return apply_filters('map_meta_cap', $caps, $cap, $user_id, $args);
506 506
 }
507 507
 
508 508
 /**
@@ -527,16 +527,16 @@  discard block
 block discarded – undo
527 527
  * @return bool Whether the current user has the given capability. If `$capability` is a meta cap and `$object_id` is
528 528
  *              passed, whether the current user has the given meta capability for the given object.
529 529
  */
530
-function current_user_can( $capability ) {
530
+function current_user_can($capability) {
531 531
 	$current_user = wp_get_current_user();
532 532
 
533
-	if ( empty( $current_user ) )
533
+	if (empty($current_user))
534 534
 		return false;
535 535
 
536
-	$args = array_slice( func_get_args(), 1 );
537
-	$args = array_merge( array( $capability ), $args );
536
+	$args = array_slice(func_get_args(), 1);
537
+	$args = array_merge(array($capability), $args);
538 538
 
539
-	return call_user_func_array( array( $current_user, 'has_cap' ), $args );
539
+	return call_user_func_array(array($current_user, 'has_cap'), $args);
540 540
 }
541 541
 
542 542
 /**
@@ -548,24 +548,24 @@  discard block
 block discarded – undo
548 548
  * @param string $capability Capability or role name.
549 549
  * @return bool
550 550
  */
551
-function current_user_can_for_blog( $blog_id, $capability ) {
552
-	$switched = is_multisite() ? switch_to_blog( $blog_id ) : false;
551
+function current_user_can_for_blog($blog_id, $capability) {
552
+	$switched = is_multisite() ? switch_to_blog($blog_id) : false;
553 553
 
554 554
 	$current_user = wp_get_current_user();
555 555
 
556
-	if ( empty( $current_user ) ) {
557
-		if ( $switched ) {
556
+	if (empty($current_user)) {
557
+		if ($switched) {
558 558
 			restore_current_blog();
559 559
 		}
560 560
 		return false;
561 561
 	}
562 562
 
563
-	$args = array_slice( func_get_args(), 2 );
564
-	$args = array_merge( array( $capability ), $args );
563
+	$args = array_slice(func_get_args(), 2);
564
+	$args = array_merge(array($capability), $args);
565 565
 
566
-	$can = call_user_func_array( array( $current_user, 'has_cap' ), $args );
566
+	$can = call_user_func_array(array($current_user, 'has_cap'), $args);
567 567
 
568
-	if ( $switched ) {
568
+	if ($switched) {
569 569
 		restore_current_blog();
570 570
 	}
571 571
 
@@ -581,19 +581,19 @@  discard block
 block discarded – undo
581 581
  * @param string $capability Capability or role name.
582 582
  * @return bool
583 583
  */
584
-function author_can( $post, $capability ) {
585
-	if ( !$post = get_post($post) )
584
+function author_can($post, $capability) {
585
+	if ( ! $post = get_post($post))
586 586
 		return false;
587 587
 
588
-	$author = get_userdata( $post->post_author );
588
+	$author = get_userdata($post->post_author);
589 589
 
590
-	if ( ! $author )
590
+	if ( ! $author)
591 591
 		return false;
592 592
 
593
-	$args = array_slice( func_get_args(), 2 );
594
-	$args = array_merge( array( $capability ), $args );
593
+	$args = array_slice(func_get_args(), 2);
594
+	$args = array_merge(array($capability), $args);
595 595
 
596
-	return call_user_func_array( array( $author, 'has_cap' ), $args );
596
+	return call_user_func_array(array($author, 'has_cap'), $args);
597 597
 }
598 598
 
599 599
 /**
@@ -605,17 +605,17 @@  discard block
 block discarded – undo
605 605
  * @param string $capability Capability or role name.
606 606
  * @return bool
607 607
  */
608
-function user_can( $user, $capability ) {
609
-	if ( ! is_object( $user ) )
610
-		$user = get_userdata( $user );
608
+function user_can($user, $capability) {
609
+	if ( ! is_object($user))
610
+		$user = get_userdata($user);
611 611
 
612
-	if ( ! $user || ! $user->exists() )
612
+	if ( ! $user || ! $user->exists())
613 613
 		return false;
614 614
 
615
-	$args = array_slice( func_get_args(), 2 );
616
-	$args = array_merge( array( $capability ), $args );
615
+	$args = array_slice(func_get_args(), 2);
616
+	$args = array_merge(array($capability), $args);
617 617
 
618
-	return call_user_func_array( array( $user, 'has_cap' ), $args );
618
+	return call_user_func_array(array($user, 'has_cap'), $args);
619 619
 }
620 620
 
621 621
 /**
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 function wp_roles() {
631 631
 	global $wp_roles;
632 632
 
633
-	if ( ! isset( $wp_roles ) ) {
633
+	if ( ! isset($wp_roles)) {
634 634
 		$wp_roles = new WP_Roles();
635 635
 	}
636 636
 	return $wp_roles;
@@ -644,8 +644,8 @@  discard block
 block discarded – undo
644 644
  * @param string $role Role name.
645 645
  * @return WP_Role|null WP_Role object if found, null if the role does not exist.
646 646
  */
647
-function get_role( $role ) {
648
-	return wp_roles()->get_role( $role );
647
+function get_role($role) {
648
+	return wp_roles()->get_role($role);
649 649
 }
650 650
 
651 651
 /**
@@ -658,11 +658,11 @@  discard block
 block discarded – undo
658 658
  * @param array $capabilities List of capabilities, e.g. array( 'edit_posts' => true, 'delete_posts' => false );
659 659
  * @return WP_Role|null WP_Role object if role is added, null if already exists.
660 660
  */
661
-function add_role( $role, $display_name, $capabilities = array() ) {
662
-	if ( empty( $role ) ) {
661
+function add_role($role, $display_name, $capabilities = array()) {
662
+	if (empty($role)) {
663 663
 		return;
664 664
 	}
665
-	return wp_roles()->add_role( $role, $display_name, $capabilities );
665
+	return wp_roles()->add_role($role, $display_name, $capabilities);
666 666
 }
667 667
 
668 668
 /**
@@ -672,8 +672,8 @@  discard block
 block discarded – undo
672 672
  *
673 673
  * @param string $role Role name.
674 674
  */
675
-function remove_role( $role ) {
676
-	wp_roles()->remove_role( $role );
675
+function remove_role($role) {
676
+	wp_roles()->remove_role($role);
677 677
 }
678 678
 
679 679
 /**
@@ -688,10 +688,10 @@  discard block
 block discarded – undo
688 688
 function get_super_admins() {
689 689
 	global $super_admins;
690 690
 
691
-	if ( isset($super_admins) )
691
+	if (isset($super_admins))
692 692
 		return $super_admins;
693 693
 	else
694
-		return get_site_option( 'site_admins', array('admin') );
694
+		return get_site_option('site_admins', array('admin'));
695 695
 }
696 696
 
697 697
 /**
@@ -702,21 +702,21 @@  discard block
 block discarded – undo
702 702
  * @param int $user_id (Optional) The ID of a user. Defaults to the current user.
703 703
  * @return bool True if the user is a site admin.
704 704
  */
705
-function is_super_admin( $user_id = false ) {
706
-	if ( ! $user_id || $user_id == get_current_user_id() )
705
+function is_super_admin($user_id = false) {
706
+	if ( ! $user_id || $user_id == get_current_user_id())
707 707
 		$user = wp_get_current_user();
708 708
 	else
709
-		$user = get_userdata( $user_id );
709
+		$user = get_userdata($user_id);
710 710
 
711
-	if ( ! $user || ! $user->exists() )
711
+	if ( ! $user || ! $user->exists())
712 712
 		return false;
713 713
 
714
-	if ( is_multisite() ) {
714
+	if (is_multisite()) {
715 715
 		$super_admins = get_super_admins();
716
-		if ( is_array( $super_admins ) && in_array( $user->user_login, $super_admins ) )
716
+		if (is_array($super_admins) && in_array($user->user_login, $super_admins))
717 717
 			return true;
718 718
 	} else {
719
-		if ( $user->has_cap('delete_users') )
719
+		if ($user->has_cap('delete_users'))
720 720
 			return true;
721 721
 	}
722 722
 
@@ -734,9 +734,9 @@  discard block
 block discarded – undo
734 734
  * @return bool True on success, false on failure. This can fail when the user is
735 735
  *              already a super admin or when the `$super_admins` global is defined.
736 736
  */
737
-function grant_super_admin( $user_id ) {
737
+function grant_super_admin($user_id) {
738 738
 	// If global super_admins override is defined, there is nothing to do here.
739
-	if ( isset( $GLOBALS['super_admins'] ) || ! is_multisite() ) {
739
+	if (isset($GLOBALS['super_admins']) || ! is_multisite()) {
740 740
 		return false;
741 741
 	}
742 742
 
@@ -747,15 +747,15 @@  discard block
 block discarded – undo
747 747
 	 *
748 748
 	 * @param int $user_id ID of the user that is about to be granted Super Admin privileges.
749 749
 	 */
750
-	do_action( 'grant_super_admin', $user_id );
750
+	do_action('grant_super_admin', $user_id);
751 751
 
752 752
 	// Directly fetch site_admins instead of using get_super_admins()
753
-	$super_admins = get_site_option( 'site_admins', array( 'admin' ) );
753
+	$super_admins = get_site_option('site_admins', array('admin'));
754 754
 
755
-	$user = get_userdata( $user_id );
756
-	if ( $user && ! in_array( $user->user_login, $super_admins ) ) {
755
+	$user = get_userdata($user_id);
756
+	if ($user && ! in_array($user->user_login, $super_admins)) {
757 757
 		$super_admins[] = $user->user_login;
758
-		update_site_option( 'site_admins' , $super_admins );
758
+		update_site_option('site_admins', $super_admins);
759 759
 
760 760
 		/**
761 761
 		 * Fires after the user is granted Super Admin privileges.
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
 		 *
765 765
 		 * @param int $user_id ID of the user that was granted Super Admin privileges.
766 766
 		 */
767
-		do_action( 'granted_super_admin', $user_id );
767
+		do_action('granted_super_admin', $user_id);
768 768
 		return true;
769 769
 	}
770 770
 	return false;
@@ -781,9 +781,9 @@  discard block
 block discarded – undo
781 781
  * @return bool True on success, false on failure. This can fail when the user's email
782 782
  *              is the network admin email or when the `$super_admins` global is defined.
783 783
  */
784
-function revoke_super_admin( $user_id ) {
784
+function revoke_super_admin($user_id) {
785 785
 	// If global super_admins override is defined, there is nothing to do here.
786
-	if ( isset( $GLOBALS['super_admins'] ) || ! is_multisite() ) {
786
+	if (isset($GLOBALS['super_admins']) || ! is_multisite()) {
787 787
 		return false;
788 788
 	}
789 789
 
@@ -794,16 +794,16 @@  discard block
 block discarded – undo
794 794
 	 *
795 795
 	 * @param int $user_id ID of the user Super Admin privileges are being revoked from.
796 796
 	 */
797
-	do_action( 'revoke_super_admin', $user_id );
797
+	do_action('revoke_super_admin', $user_id);
798 798
 
799 799
 	// Directly fetch site_admins instead of using get_super_admins()
800
-	$super_admins = get_site_option( 'site_admins', array( 'admin' ) );
800
+	$super_admins = get_site_option('site_admins', array('admin'));
801 801
 
802
-	$user = get_userdata( $user_id );
803
-	if ( $user && 0 !== strcasecmp( $user->user_email, get_site_option( 'admin_email' ) ) ) {
804
-		if ( false !== ( $key = array_search( $user->user_login, $super_admins ) ) ) {
805
-			unset( $super_admins[$key] );
806
-			update_site_option( 'site_admins', $super_admins );
802
+	$user = get_userdata($user_id);
803
+	if ($user && 0 !== strcasecmp($user->user_email, get_site_option('admin_email'))) {
804
+		if (false !== ($key = array_search($user->user_login, $super_admins))) {
805
+			unset($super_admins[$key]);
806
+			update_site_option('site_admins', $super_admins);
807 807
 
808 808
 			/**
809 809
 			 * Fires after the user's Super Admin privileges are revoked.
@@ -812,7 +812,7 @@  discard block
 block discarded – undo
812 812
 			 *
813 813
 			 * @param int $user_id ID of the user Super Admin privileges were revoked from.
814 814
 			 */
815
-			do_action( 'revoked_super_admin', $user_id );
815
+			do_action('revoked_super_admin', $user_id);
816 816
 			return true;
817 817
 		}
818 818
 	}
Please login to merge, or discard this patch.
Braces   +89 added lines, -67 removed lines patch added patch discarded remove patch
@@ -46,8 +46,9 @@  discard block
 block discarded – undo
46 46
 	case 'edit_user':
47 47
 	case 'edit_users':
48 48
 		// Allow user to edit itself
49
-		if ( 'edit_user' == $cap && isset( $args[0] ) && $user_id == $args[0] )
50
-			break;
49
+		if ( 'edit_user' == $cap && isset( $args[0] ) && $user_id == $args[0] ) {
50
+					break;
51
+		}
51 52
 
52 53
 		// In multisite the user must have manage_network_users caps. If editing a super admin, the user must be a super admin.
53 54
 		if ( is_multisite() && ( ( ! is_super_admin( $user_id ) && 'edit_user' === $cap && is_super_admin( $args[0] ) ) || ! user_can( $user_id, 'manage_network_users' ) ) ) {
@@ -88,8 +89,9 @@  discard block
 block discarded – undo
88 89
 		if ( ! $post_type->map_meta_cap ) {
89 90
 			$caps[] = $post_type->cap->$cap;
90 91
 			// Prior to 3.1 we would re-call map_meta_cap here.
91
-			if ( 'delete_post' == $cap )
92
-				$cap = $post_type->cap->$cap;
92
+			if ( 'delete_post' == $cap ) {
93
+							$cap = $post_type->cap->$cap;
94
+			}
93 95
 			break;
94 96
 		}
95 97
 
@@ -149,8 +151,9 @@  discard block
 block discarded – undo
149 151
 		if ( ! $post_type->map_meta_cap ) {
150 152
 			$caps[] = $post_type->cap->$cap;
151 153
 			// Prior to 3.1 we would re-call map_meta_cap here.
152
-			if ( 'edit_post' == $cap )
153
-				$cap = $post_type->cap->$cap;
154
+			if ( 'edit_post' == $cap ) {
155
+							$cap = $post_type->cap->$cap;
156
+			}
154 157
 			break;
155 158
 		}
156 159
 
@@ -208,8 +211,9 @@  discard block
 block discarded – undo
208 211
 		if ( ! $post_type->map_meta_cap ) {
209 212
 			$caps[] = $post_type->cap->$cap;
210 213
 			// Prior to 3.1 we would re-call map_meta_cap here.
211
-			if ( 'read_post' == $cap )
212
-				$cap = $post_type->cap->$cap;
214
+			if ( 'read_post' == $cap ) {
215
+							$cap = $post_type->cap->$cap;
216
+			}
213 217
 			break;
214 218
 		}
215 219
 
@@ -341,33 +345,36 @@  discard block
 block discarded – undo
341 345
 		}
342 346
 		break;
343 347
 	case 'unfiltered_upload':
344
-		if ( defined('ALLOW_UNFILTERED_UPLOADS') && ALLOW_UNFILTERED_UPLOADS && ( !is_multisite() || is_super_admin( $user_id ) )  )
345
-			$caps[] = $cap;
346
-		else
347
-			$caps[] = 'do_not_allow';
348
+		if ( defined('ALLOW_UNFILTERED_UPLOADS') && ALLOW_UNFILTERED_UPLOADS && ( !is_multisite() || is_super_admin( $user_id ) )  ) {
349
+					$caps[] = $cap;
350
+		} else {
351
+					$caps[] = 'do_not_allow';
352
+		}
348 353
 		break;
349 354
 	case 'edit_css' :
350 355
 	case 'unfiltered_html' :
351 356
 		// Disallow unfiltered_html for all users, even admins and super admins.
352
-		if ( defined( 'DISALLOW_UNFILTERED_HTML' ) && DISALLOW_UNFILTERED_HTML )
353
-			$caps[] = 'do_not_allow';
354
-		elseif ( is_multisite() && ! is_super_admin( $user_id ) )
355
-			$caps[] = 'do_not_allow';
356
-		else
357
-			$caps[] = 'unfiltered_html';
357
+		if ( defined( 'DISALLOW_UNFILTERED_HTML' ) && DISALLOW_UNFILTERED_HTML ) {
358
+					$caps[] = 'do_not_allow';
359
+		} elseif ( is_multisite() && ! is_super_admin( $user_id ) ) {
360
+					$caps[] = 'do_not_allow';
361
+		} else {
362
+					$caps[] = 'unfiltered_html';
363
+		}
358 364
 		break;
359 365
 	case 'edit_files':
360 366
 	case 'edit_plugins':
361 367
 	case 'edit_themes':
362 368
 		// Disallow the file editors.
363
-		if ( defined( 'DISALLOW_FILE_EDIT' ) && DISALLOW_FILE_EDIT )
364
-			$caps[] = 'do_not_allow';
365
-		elseif ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS )
366
-			$caps[] = 'do_not_allow';
367
-		elseif ( is_multisite() && ! is_super_admin( $user_id ) )
368
-			$caps[] = 'do_not_allow';
369
-		else
370
-			$caps[] = $cap;
369
+		if ( defined( 'DISALLOW_FILE_EDIT' ) && DISALLOW_FILE_EDIT ) {
370
+					$caps[] = 'do_not_allow';
371
+		} elseif ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS ) {
372
+					$caps[] = 'do_not_allow';
373
+		} elseif ( is_multisite() && ! is_super_admin( $user_id ) ) {
374
+					$caps[] = 'do_not_allow';
375
+		} else {
376
+					$caps[] = $cap;
377
+		}
371 378
 		break;
372 379
 	case 'update_plugins':
373 380
 	case 'delete_plugins':
@@ -397,31 +404,36 @@  discard block
 block discarded – undo
397 404
 		if ( is_multisite() ) {
398 405
 			// update_, install_, and delete_ are handled above with is_super_admin().
399 406
 			$menu_perms = get_site_option( 'menu_items', array() );
400
-			if ( empty( $menu_perms['plugins'] ) )
401
-				$caps[] = 'manage_network_plugins';
407
+			if ( empty( $menu_perms['plugins'] ) ) {
408
+							$caps[] = 'manage_network_plugins';
409
+			}
402 410
 		}
403 411
 		break;
404 412
 	case 'delete_user':
405 413
 	case 'delete_users':
406 414
 		// If multisite only super admins can delete users.
407
-		if ( is_multisite() && ! is_super_admin( $user_id ) )
408
-			$caps[] = 'do_not_allow';
409
-		else
410
-			$caps[] = 'delete_users'; // delete_user maps to delete_users.
415
+		if ( is_multisite() && ! is_super_admin( $user_id ) ) {
416
+					$caps[] = 'do_not_allow';
417
+		} else {
418
+					$caps[] = 'delete_users';
419
+		}
420
+		// delete_user maps to delete_users.
411 421
 		break;
412 422
 	case 'create_users':
413
-		if ( !is_multisite() )
414
-			$caps[] = $cap;
415
-		elseif ( is_super_admin( $user_id ) || get_site_option( 'add_new_users' ) )
416
-			$caps[] = $cap;
417
-		else
418
-			$caps[] = 'do_not_allow';
423
+		if ( !is_multisite() ) {
424
+					$caps[] = $cap;
425
+		} elseif ( is_super_admin( $user_id ) || get_site_option( 'add_new_users' ) ) {
426
+					$caps[] = $cap;
427
+		} else {
428
+					$caps[] = 'do_not_allow';
429
+		}
419 430
 		break;
420 431
 	case 'manage_links' :
421
-		if ( get_option( 'link_manager_enabled' ) )
422
-			$caps[] = $cap;
423
-		else
424
-			$caps[] = 'do_not_allow';
432
+		if ( get_option( 'link_manager_enabled' ) ) {
433
+					$caps[] = $cap;
434
+		} else {
435
+					$caps[] = 'do_not_allow';
436
+		}
425 437
 		break;
426 438
 	case 'customize' :
427 439
 		$caps[] = 'edit_theme_options';
@@ -530,8 +542,9 @@  discard block
 block discarded – undo
530 542
 function current_user_can( $capability ) {
531 543
 	$current_user = wp_get_current_user();
532 544
 
533
-	if ( empty( $current_user ) )
534
-		return false;
545
+	if ( empty( $current_user ) ) {
546
+			return false;
547
+	}
535 548
 
536 549
 	$args = array_slice( func_get_args(), 1 );
537 550
 	$args = array_merge( array( $capability ), $args );
@@ -582,13 +595,15 @@  discard block
 block discarded – undo
582 595
  * @return bool
583 596
  */
584 597
 function author_can( $post, $capability ) {
585
-	if ( !$post = get_post($post) )
586
-		return false;
598
+	if ( !$post = get_post($post) ) {
599
+			return false;
600
+	}
587 601
 
588 602
 	$author = get_userdata( $post->post_author );
589 603
 
590
-	if ( ! $author )
591
-		return false;
604
+	if ( ! $author ) {
605
+			return false;
606
+	}
592 607
 
593 608
 	$args = array_slice( func_get_args(), 2 );
594 609
 	$args = array_merge( array( $capability ), $args );
@@ -606,11 +621,13 @@  discard block
 block discarded – undo
606 621
  * @return bool
607 622
  */
608 623
 function user_can( $user, $capability ) {
609
-	if ( ! is_object( $user ) )
610
-		$user = get_userdata( $user );
624
+	if ( ! is_object( $user ) ) {
625
+			$user = get_userdata( $user );
626
+	}
611 627
 
612
-	if ( ! $user || ! $user->exists() )
613
-		return false;
628
+	if ( ! $user || ! $user->exists() ) {
629
+			return false;
630
+	}
614 631
 
615 632
 	$args = array_slice( func_get_args(), 2 );
616 633
 	$args = array_merge( array( $capability ), $args );
@@ -688,11 +705,12 @@  discard block
 block discarded – undo
688 705
 function get_super_admins() {
689 706
 	global $super_admins;
690 707
 
691
-	if ( isset($super_admins) )
692
-		return $super_admins;
693
-	else
694
-		return get_site_option( 'site_admins', array('admin') );
695
-}
708
+	if ( isset($super_admins) ) {
709
+			return $super_admins;
710
+	} else {
711
+			return get_site_option( 'site_admins', array('admin') );
712
+	}
713
+	}
696 714
 
697 715
 /**
698 716
  * Determine if user is a site admin.
@@ -703,21 +721,25 @@  discard block
 block discarded – undo
703 721
  * @return bool True if the user is a site admin.
704 722
  */
705 723
 function is_super_admin( $user_id = false ) {
706
-	if ( ! $user_id || $user_id == get_current_user_id() )
707
-		$user = wp_get_current_user();
708
-	else
709
-		$user = get_userdata( $user_id );
724
+	if ( ! $user_id || $user_id == get_current_user_id() ) {
725
+			$user = wp_get_current_user();
726
+	} else {
727
+			$user = get_userdata( $user_id );
728
+	}
710 729
 
711
-	if ( ! $user || ! $user->exists() )
712
-		return false;
730
+	if ( ! $user || ! $user->exists() ) {
731
+			return false;
732
+	}
713 733
 
714 734
 	if ( is_multisite() ) {
715 735
 		$super_admins = get_super_admins();
716
-		if ( is_array( $super_admins ) && in_array( $user->user_login, $super_admins ) )
717
-			return true;
736
+		if ( is_array( $super_admins ) && in_array( $user->user_login, $super_admins ) ) {
737
+					return true;
738
+		}
718 739
 	} else {
719
-		if ( $user->has_cap('delete_users') )
720
-			return true;
740
+		if ( $user->has_cap('delete_users') ) {
741
+					return true;
742
+		}
721 743
 	}
722 744
 
723 745
 	return false;
Please login to merge, or discard this patch.
src/wp-includes/class-http.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 	 * @since 2.7.0
523 523
 	 *
524 524
 	 * @param string $strResponse The full response string
525
-	 * @return array Array with 'headers' and 'body' keys.
525
+	 * @return string Array with 'headers' and 'body' keys.
526 526
 	 */
527 527
 	public static function processResponse($strResponse) {
528 528
 		$res = explode("\r\n\r\n", $strResponse, 2);
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
 	 *
543 543
 	 * @param string|array $headers
544 544
 	 * @param string $url The URL that was requested
545
-	 * @return array Processed string headers. If duplicate headers are encountered,
545
+	 * @return string Processed string headers. If duplicate headers are encountered,
546 546
 	 * 					Then a numbered array is returned as the value of that header-key.
547 547
 	 */
548 548
 	public static function processHeaders( $headers, $url = '' ) {
Please login to merge, or discard this patch.
Braces   +97 added lines, -66 removed lines patch added patch discarded remove patch
@@ -212,8 +212,9 @@  discard block
 block discarded – undo
212 212
 		$args = wp_parse_args( $args );
213 213
 
214 214
 		// By default, Head requests do not cause redirections.
215
-		if ( isset($args['method']) && 'HEAD' == $args['method'] )
216
-			$defaults['redirection'] = 0;
215
+		if ( isset($args['method']) && 'HEAD' == $args['method'] ) {
216
+					$defaults['redirection'] = 0;
217
+		}
217 218
 
218 219
 		$r = wp_parse_args( $args, $defaults );
219 220
 		/**
@@ -227,8 +228,9 @@  discard block
 block discarded – undo
227 228
 		$r = apply_filters( 'http_request_args', $r, $url );
228 229
 
229 230
 		// The transports decrement this, store a copy of the original value for loop purposes.
230
-		if ( ! isset( $r['_redirection'] ) )
231
-			$r['_redirection'] = $r['redirection'];
231
+		if ( ! isset( $r['_redirection'] ) ) {
232
+					$r['_redirection'] = $r['redirection'];
233
+		}
232 234
 
233 235
 		/**
234 236
 		 * Filters whether to preempt an HTTP request's return value.
@@ -250,8 +252,9 @@  discard block
 block discarded – undo
250 252
 		 */
251 253
 		$pre = apply_filters( 'pre_http_request', false, $r, $url );
252 254
 
253
-		if ( false !== $pre )
254
-			return $pre;
255
+		if ( false !== $pre ) {
256
+					return $pre;
257
+		}
255 258
 
256 259
 		if ( function_exists( 'wp_kses_bad_protocol' ) ) {
257 260
 			if ( $r['reject_unsafe_urls'] ) {
@@ -371,8 +374,7 @@  discard block
 block discarded – undo
371 374
 
372 375
 			// Add the original object to the array.
373 376
 			$response['http_response'] = $http_response;
374
-		}
375
-		catch ( Requests_Exception $e ) {
377
+		} catch ( Requests_Exception $e ) {
376 378
 			$response = new WP_Error( 'http_request_failed', $e->getMessage() );
377 379
 		}
378 380
 
@@ -498,8 +500,9 @@  discard block
 block discarded – undo
498 500
 			$class = 'WP_Http_' . $transport;
499 501
 
500 502
 			// Check to see if this transport is a possibility, calls the transport statically.
501
-			if ( !call_user_func( array( $class, 'test' ), $args, $url ) )
502
-				continue;
503
+			if ( !call_user_func( array( $class, 'test' ), $args, $url ) ) {
504
+							continue;
505
+			}
503 506
 
504 507
 			return $class;
505 508
 		}
@@ -528,20 +531,23 @@  discard block
 block discarded – undo
528 531
 		static $transports = array();
529 532
 
530 533
 		$class = $this->_get_first_available_transport( $args, $url );
531
-		if ( !$class )
532
-			return new WP_Error( 'http_failure', __( 'There are no HTTP transports available which can complete the requested request.' ) );
534
+		if ( !$class ) {
535
+					return new WP_Error( 'http_failure', __( 'There are no HTTP transports available which can complete the requested request.' ) );
536
+		}
533 537
 
534 538
 		// Transport claims to support request, instantiate it and give it a whirl.
535
-		if ( empty( $transports[$class] ) )
536
-			$transports[$class] = new $class;
539
+		if ( empty( $transports[$class] ) ) {
540
+					$transports[$class] = new $class;
541
+		}
537 542
 
538 543
 		$response = $transports[$class]->request( $url, $args );
539 544
 
540 545
 		/** This action is documented in wp-includes/class-http.php */
541 546
 		do_action( 'http_api_debug', $response, 'response', $class, $args, $url );
542 547
 
543
-		if ( is_wp_error( $response ) )
544
-			return $response;
548
+		if ( is_wp_error( $response ) ) {
549
+					return $response;
550
+		}
545 551
 
546 552
 		/**
547 553
 		 * Filters the HTTP API response immediately before the response is returned.
@@ -670,8 +676,9 @@  discard block
 block discarded – undo
670 676
 		$cookies = array();
671 677
 		$newheaders = array();
672 678
 		foreach ( (array) $headers as $tempheader ) {
673
-			if ( empty($tempheader) )
674
-				continue;
679
+			if ( empty($tempheader) ) {
680
+							continue;
681
+			}
675 682
 
676 683
 			if ( false === strpos($tempheader, ':') ) {
677 684
 				$stack = explode(' ', $tempheader, 3);
@@ -686,14 +693,16 @@  discard block
 block discarded – undo
686 693
 			$value = trim( $value );
687 694
 
688 695
 			if ( isset( $newheaders[ $key ] ) ) {
689
-				if ( ! is_array( $newheaders[ $key ] ) )
690
-					$newheaders[$key] = array( $newheaders[ $key ] );
696
+				if ( ! is_array( $newheaders[ $key ] ) ) {
697
+									$newheaders[$key] = array( $newheaders[ $key ] );
698
+				}
691 699
 				$newheaders[ $key ][] = $value;
692 700
 			} else {
693 701
 				$newheaders[ $key ] = $value;
694 702
 			}
695
-			if ( 'set-cookie' == $key )
696
-				$cookies[] = new WP_Http_Cookie( $value, $url );
703
+			if ( 'set-cookie' == $key ) {
704
+							$cookies[] = new WP_Http_Cookie( $value, $url );
705
+			}
697 706
 		}
698 707
 
699 708
 		// Cast the Response Code to an int
@@ -719,8 +728,9 @@  discard block
 block discarded – undo
719 728
 		if ( ! empty($r['cookies']) ) {
720 729
 			// Upgrade any name => value cookie pairs to WP_HTTP_Cookie instances.
721 730
 			foreach ( $r['cookies'] as $name => $value ) {
722
-				if ( ! is_object( $value ) )
723
-					$r['cookies'][ $name ] = new WP_Http_Cookie( array( 'name' => $name, 'value' => $value ) );
731
+				if ( ! is_object( $value ) ) {
732
+									$r['cookies'][ $name ] = new WP_Http_Cookie( array( 'name' => $name, 'value' => $value ) );
733
+				}
724 734
 			}
725 735
 
726 736
 			$cookies_header = '';
@@ -749,8 +759,9 @@  discard block
 block discarded – undo
749 759
 	 */
750 760
 	public static function chunkTransferDecode( $body ) {
751 761
 		// The body is not chunked encoded or is malformed.
752
-		if ( ! preg_match( '/^([0-9a-f]+)[^\r\n]*\r\n/i', trim( $body ) ) )
753
-			return $body;
762
+		if ( ! preg_match( '/^([0-9a-f]+)[^\r\n]*\r\n/i', trim( $body ) ) ) {
763
+					return $body;
764
+		}
754 765
 
755 766
 		$parsed_body = '';
756 767
 
@@ -759,8 +770,9 @@  discard block
 block discarded – undo
759 770
 
760 771
 		while ( true ) {
761 772
 			$has_chunk = (bool) preg_match( '/^([0-9a-f]+)[^\r\n]*\r\n/i', $body, $match );
762
-			if ( ! $has_chunk || empty( $match[1] ) )
763
-				return $body_original;
773
+			if ( ! $has_chunk || empty( $match[1] ) ) {
774
+							return $body_original;
775
+			}
764 776
 
765 777
 			$length = hexdec( $match[1] );
766 778
 			$chunk_length = strlen( $match[0] );
@@ -772,8 +784,9 @@  discard block
 block discarded – undo
772 784
 			$body = substr( $body, $length + $chunk_length );
773 785
 
774 786
 			// End of the document.
775
-			if ( '0' === trim( $body ) )
776
-				return $parsed_body;
787
+			if ( '0' === trim( $body ) ) {
788
+							return $parsed_body;
789
+			}
777 790
 		}
778 791
 	}
779 792
 
@@ -801,12 +814,14 @@  discard block
 block discarded – undo
801 814
 	 */
802 815
 	public function block_request($uri) {
803 816
 		// We don't need to block requests, because nothing is blocked.
804
-		if ( ! defined( 'WP_HTTP_BLOCK_EXTERNAL' ) || ! WP_HTTP_BLOCK_EXTERNAL )
805
-			return false;
817
+		if ( ! defined( 'WP_HTTP_BLOCK_EXTERNAL' ) || ! WP_HTTP_BLOCK_EXTERNAL ) {
818
+					return false;
819
+		}
806 820
 
807 821
 		$check = parse_url($uri);
808
-		if ( ! $check )
809
-			return true;
822
+		if ( ! $check ) {
823
+					return true;
824
+		}
810 825
 
811 826
 		$home = parse_url( get_option('siteurl') );
812 827
 
@@ -823,8 +838,9 @@  discard block
 block discarded – undo
823 838
 			return apply_filters( 'block_local_requests', false );
824 839
 		}
825 840
 
826
-		if ( !defined('WP_ACCESSIBLE_HOSTS') )
827
-			return true;
841
+		if ( !defined('WP_ACCESSIBLE_HOSTS') ) {
842
+					return true;
843
+		}
828 844
 
829 845
 		static $accessible_hosts = null;
830 846
 		static $wildcard_regex = array();
@@ -833,16 +849,19 @@  discard block
 block discarded – undo
833 849
 
834 850
 			if ( false !== strpos(WP_ACCESSIBLE_HOSTS, '*') ) {
835 851
 				$wildcard_regex = array();
836
-				foreach ( $accessible_hosts as $host )
837
-					$wildcard_regex[] = str_replace( '\*', '.+', preg_quote( $host, '/' ) );
852
+				foreach ( $accessible_hosts as $host ) {
853
+									$wildcard_regex[] = str_replace( '\*', '.+', preg_quote( $host, '/' ) );
854
+				}
838 855
 				$wildcard_regex = '/^(' . implode('|', $wildcard_regex) . ')$/i';
839 856
 			}
840 857
 		}
841 858
 
842
-		if ( !empty($wildcard_regex) )
843
-			return !preg_match($wildcard_regex, $check['host']);
844
-		else
845
-			return !in_array( $check['host'], $accessible_hosts ); //Inverse logic, If it's in the array, then we can't access it.
859
+		if ( !empty($wildcard_regex) ) {
860
+					return !preg_match($wildcard_regex, $check['host']);
861
+		} else {
862
+					return !in_array( $check['host'], $accessible_hosts );
863
+		}
864
+		//Inverse logic, If it's in the array, then we can't access it.
846 865
 
847 866
 	}
848 867
 
@@ -877,8 +896,9 @@  discard block
 block discarded – undo
877 896
 	 * @return string An Absolute URL, in a failure condition where the URL cannot be parsed, the relative URL will be returned.
878 897
 	 */
879 898
 	public static function make_absolute_url( $maybe_relative_path, $url ) {
880
-		if ( empty( $url ) )
881
-			return $maybe_relative_path;
899
+		if ( empty( $url ) ) {
900
+					return $maybe_relative_path;
901
+		}
882 902
 
883 903
 		if ( ! $url_parts = wp_parse_url( $url ) ) {
884 904
 			return $maybe_relative_path;
@@ -898,12 +918,14 @@  discard block
 block discarded – undo
898 918
 		// Schemeless URL's will make it this far, so we check for a host in the relative url and convert it to a protocol-url
899 919
 		if ( isset( $relative_url_parts['host'] ) ) {
900 920
 			$absolute_path .= $relative_url_parts['host'];
901
-			if ( isset( $relative_url_parts['port'] ) )
902
-				$absolute_path .= ':' . $relative_url_parts['port'];
921
+			if ( isset( $relative_url_parts['port'] ) ) {
922
+							$absolute_path .= ':' . $relative_url_parts['port'];
923
+			}
903 924
 		} else {
904 925
 			$absolute_path .= $url_parts['host'];
905
-			if ( isset( $url_parts['port'] ) )
906
-				$absolute_path .= ':' . $url_parts['port'];
926
+			if ( isset( $url_parts['port'] ) ) {
927
+							$absolute_path .= ':' . $url_parts['port'];
928
+			}
907 929
 		}
908 930
 
909 931
 		// Start off with the Absolute URL path.
@@ -931,8 +953,9 @@  discard block
 block discarded – undo
931 953
 		}
932 954
 
933 955
 		// Add the Query string.
934
-		if ( ! empty( $relative_url_parts['query'] ) )
935
-			$path .= '?' . $relative_url_parts['query'];
956
+		if ( ! empty( $relative_url_parts['query'] ) ) {
957
+					$path .= '?' . $relative_url_parts['query'];
958
+		}
936 959
 
937 960
 		return $absolute_path . '/' . ltrim( $path, '/' );
938 961
 	}
@@ -951,36 +974,42 @@  discard block
 block discarded – undo
951 974
 	 */
952 975
 	public static function handle_redirects( $url, $args, $response ) {
953 976
 		// If no redirects are present, or, redirects were not requested, perform no action.
954
-		if ( ! isset( $response['headers']['location'] ) || 0 === $args['_redirection'] )
955
-			return false;
977
+		if ( ! isset( $response['headers']['location'] ) || 0 === $args['_redirection'] ) {
978
+					return false;
979
+		}
956 980
 
957 981
 		// Only perform redirections on redirection http codes.
958
-		if ( $response['response']['code'] > 399 || $response['response']['code'] < 300 )
959
-			return false;
982
+		if ( $response['response']['code'] > 399 || $response['response']['code'] < 300 ) {
983
+					return false;
984
+		}
960 985
 
961 986
 		// Don't redirect if we've run out of redirects.
962
-		if ( $args['redirection']-- <= 0 )
963
-			return new WP_Error( 'http_request_failed', __('Too many redirects.') );
987
+		if ( $args['redirection']-- <= 0 ) {
988
+					return new WP_Error( 'http_request_failed', __('Too many redirects.') );
989
+		}
964 990
 
965 991
 		$redirect_location = $response['headers']['location'];
966 992
 
967 993
 		// If there were multiple Location headers, use the last header specified.
968
-		if ( is_array( $redirect_location ) )
969
-			$redirect_location = array_pop( $redirect_location );
994
+		if ( is_array( $redirect_location ) ) {
995
+					$redirect_location = array_pop( $redirect_location );
996
+		}
970 997
 
971 998
 		$redirect_location = WP_Http::make_absolute_url( $redirect_location, $url );
972 999
 
973 1000
 		// POST requests should not POST to a redirected location.
974 1001
 		if ( 'POST' == $args['method'] ) {
975
-			if ( in_array( $response['response']['code'], array( 302, 303 ) ) )
976
-				$args['method'] = 'GET';
1002
+			if ( in_array( $response['response']['code'], array( 302, 303 ) ) ) {
1003
+							$args['method'] = 'GET';
1004
+			}
977 1005
 		}
978 1006
 
979 1007
 		// Include valid cookies in the redirect process.
980 1008
 		if ( ! empty( $response['cookies'] ) ) {
981 1009
 			foreach ( $response['cookies'] as $cookie ) {
982
-				if ( $cookie->test( $redirect_location ) )
983
-					$args['cookies'][] = $cookie;
1010
+				if ( $cookie->test( $redirect_location ) ) {
1011
+									$args['cookies'][] = $cookie;
1012
+				}
984 1013
 			}
985 1014
 		}
986 1015
 
@@ -1004,11 +1033,13 @@  discard block
 block discarded – undo
1004 1033
 	 * @return integer|bool Upon success, '4' or '6' to represent a IPv4 or IPv6 address, false upon failure
1005 1034
 	 */
1006 1035
 	public static function is_ip_address( $maybe_ip ) {
1007
-		if ( preg_match( '/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $maybe_ip ) )
1008
-			return 4;
1036
+		if ( preg_match( '/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $maybe_ip ) ) {
1037
+					return 4;
1038
+		}
1009 1039
 
1010
-		if ( false !== strpos( $maybe_ip, ':' ) && preg_match( '/^(((?=.*(::))(?!.*\3.+\3))\3?|([\dA-F]{1,4}(\3|:\b|$)|\2))(?4){5}((?4){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i', trim( $maybe_ip, ' []' ) ) )
1011
-			return 6;
1040
+		if ( false !== strpos( $maybe_ip, ':' ) && preg_match( '/^(((?=.*(::))(?!.*\3.+\3))\3?|([\dA-F]{1,4}(\3|:\b|$)|\2))(?4){5}((?4){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i', trim( $maybe_ip, ' []' ) ) ) {
1041
+					return 6;
1042
+		}
1012 1043
 
1013 1044
 		return false;
1014 1045
 	}
Please login to merge, or discard this patch.
Spacing   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -7,11 +7,11 @@  discard block
 block discarded – undo
7 7
  * @since 2.7.0
8 8
  */
9 9
 
10
-if ( ! class_exists( 'Requests' ) ) {
11
-	require( ABSPATH . WPINC . '/class-requests.php' );
10
+if ( ! class_exists('Requests')) {
11
+	require(ABSPATH.WPINC.'/class-requests.php');
12 12
 
13 13
 	Requests::register_autoloader();
14
-	Requests::set_certificate_path( ABSPATH . WPINC . '/certificates/ca-bundle.crt' );
14
+	Requests::set_certificate_path(ABSPATH.WPINC.'/certificates/ca-bundle.crt');
15 15
 }
16 16
 
17 17
 /**
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'.
146 146
 	 *                        A WP_Error instance upon error.
147 147
 	 */
148
-	public function request( $url, $args = array() ) {
148
+	public function request($url, $args = array()) {
149 149
 		$defaults = array(
150 150
 			'method' => 'GET',
151 151
 			/**
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 			 * @param int $timeout_value Time in seconds until a request times out.
157 157
 			 *                           Default 5.
158 158
 			 */
159
-			'timeout' => apply_filters( 'http_request_timeout', 5 ),
159
+			'timeout' => apply_filters('http_request_timeout', 5),
160 160
 			/**
161 161
 			 * Filters the number of redirects allowed during an HTTP request.
162 162
 			 *
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 			 *
165 165
 			 * @param int $redirect_count Number of redirects allowed. Default 5.
166 166
 			 */
167
-			'redirection' => apply_filters( 'http_request_redirection_count', 5 ),
167
+			'redirection' => apply_filters('http_request_redirection_count', 5),
168 168
 			/**
169 169
 			 * Filters the version of the HTTP protocol used in a request.
170 170
 			 *
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 			 * @param string $version Version of HTTP used. Accepts '1.0' and '1.1'.
174 174
 			 *                        Default '1.0'.
175 175
 			 */
176
-			'httpversion' => apply_filters( 'http_request_version', '1.0' ),
176
+			'httpversion' => apply_filters('http_request_version', '1.0'),
177 177
 			/**
178 178
 			 * Filters the user agent value sent with an HTTP request.
179 179
 			 *
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 			 *
182 182
 			 * @param string $user_agent WordPress user agent string.
183 183
 			 */
184
-			'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . get_bloginfo( 'version' ) . '; ' . get_bloginfo( 'url' ) ),
184
+			'user-agent' => apply_filters('http_headers_useragent', 'WordPress/'.get_bloginfo('version').'; '.get_bloginfo('url')),
185 185
 			/**
186 186
 			 * Filters whether to pass URLs through wp_http_validate_url() in an HTTP request.
187 187
 			 *
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 			 * @param bool $pass_url Whether to pass URLs through wp_http_validate_url().
191 191
 			 *                       Default false.
192 192
 			 */
193
-			'reject_unsafe_urls' => apply_filters( 'http_request_reject_unsafe_urls', false ),
193
+			'reject_unsafe_urls' => apply_filters('http_request_reject_unsafe_urls', false),
194 194
 			'blocking' => true,
195 195
 			'headers' => array(),
196 196
 			'cookies' => array(),
@@ -198,20 +198,20 @@  discard block
 block discarded – undo
198 198
 			'compress' => false,
199 199
 			'decompress' => true,
200 200
 			'sslverify' => true,
201
-			'sslcertificates' => ABSPATH . WPINC . '/certificates/ca-bundle.crt',
201
+			'sslcertificates' => ABSPATH.WPINC.'/certificates/ca-bundle.crt',
202 202
 			'stream' => false,
203 203
 			'filename' => null,
204 204
 			'limit_response_size' => null,
205 205
 		);
206 206
 
207 207
 		// Pre-parse for the HEAD checks.
208
-		$args = wp_parse_args( $args );
208
+		$args = wp_parse_args($args);
209 209
 
210 210
 		// By default, Head requests do not cause redirections.
211
-		if ( isset($args['method']) && 'HEAD' == $args['method'] )
211
+		if (isset($args['method']) && 'HEAD' == $args['method'])
212 212
 			$defaults['redirection'] = 0;
213 213
 
214
-		$r = wp_parse_args( $args, $defaults );
214
+		$r = wp_parse_args($args, $defaults);
215 215
 		/**
216 216
 		 * Filters the arguments used in an HTTP request.
217 217
 		 *
@@ -220,10 +220,10 @@  discard block
 block discarded – undo
220 220
 		 * @param array  $r   An array of HTTP request arguments.
221 221
 		 * @param string $url The request URL.
222 222
 		 */
223
-		$r = apply_filters( 'http_request_args', $r, $url );
223
+		$r = apply_filters('http_request_args', $r, $url);
224 224
 
225 225
 		// The transports decrement this, store a copy of the original value for loop purposes.
226
-		if ( ! isset( $r['_redirection'] ) )
226
+		if ( ! isset($r['_redirection']))
227 227
 			$r['_redirection'] = $r['redirection'];
228 228
 
229 229
 		/**
@@ -244,51 +244,51 @@  discard block
 block discarded – undo
244 244
 		 * @param array               $r        HTTP request arguments.
245 245
 		 * @param string              $url      The request URL.
246 246
 		 */
247
-		$pre = apply_filters( 'pre_http_request', false, $r, $url );
247
+		$pre = apply_filters('pre_http_request', false, $r, $url);
248 248
 
249
-		if ( false !== $pre )
249
+		if (false !== $pre)
250 250
 			return $pre;
251 251
 
252
-		if ( function_exists( 'wp_kses_bad_protocol' ) ) {
253
-			if ( $r['reject_unsafe_urls'] ) {
254
-				$url = wp_http_validate_url( $url );
252
+		if (function_exists('wp_kses_bad_protocol')) {
253
+			if ($r['reject_unsafe_urls']) {
254
+				$url = wp_http_validate_url($url);
255 255
 			}
256
-			if ( $url ) {
257
-				$url = wp_kses_bad_protocol( $url, array( 'http', 'https', 'ssl' ) );
256
+			if ($url) {
257
+				$url = wp_kses_bad_protocol($url, array('http', 'https', 'ssl'));
258 258
 			}
259 259
 		}
260 260
 
261
-		$arrURL = @parse_url( $url );
261
+		$arrURL = @parse_url($url);
262 262
 
263
-		if ( empty( $url ) || empty( $arrURL['scheme'] ) ) {
263
+		if (empty($url) || empty($arrURL['scheme'])) {
264 264
 			return new WP_Error('http_request_failed', __('A valid URL was not provided.'));
265 265
 		}
266 266
 
267
-		if ( $this->block_request( $url ) ) {
268
-			return new WP_Error( 'http_request_failed', __( 'User has blocked requests through HTTP.' ) );
267
+		if ($this->block_request($url)) {
268
+			return new WP_Error('http_request_failed', __('User has blocked requests through HTTP.'));
269 269
 		}
270 270
 
271 271
 		// If we are streaming to a file but no filename was given drop it in the WP temp dir
272 272
 		// and pick its name using the basename of the $url
273
-		if ( $r['stream'] ) {
274
-			if ( empty( $r['filename'] ) ) {
275
-				$r['filename'] = get_temp_dir() . basename( $url );
273
+		if ($r['stream']) {
274
+			if (empty($r['filename'])) {
275
+				$r['filename'] = get_temp_dir().basename($url);
276 276
 			}
277 277
 
278 278
 			// Force some settings if we are streaming to a file and check for existence and perms of destination directory
279 279
 			$r['blocking'] = true;
280
-			if ( ! wp_is_writable( dirname( $r['filename'] ) ) ) {
281
-				return new WP_Error( 'http_request_failed', __( 'Destination directory for file streaming does not exist or is not writable.' ) );
280
+			if ( ! wp_is_writable(dirname($r['filename']))) {
281
+				return new WP_Error('http_request_failed', __('Destination directory for file streaming does not exist or is not writable.'));
282 282
 			}
283 283
 		}
284 284
 
285
-		if ( is_null( $r['headers'] ) ) {
285
+		if (is_null($r['headers'])) {
286 286
 			$r['headers'] = array();
287 287
 		}
288 288
 
289 289
 		// WP allows passing in headers as a string, weirdly.
290
-		if ( ! is_array( $r['headers'] ) ) {
291
-			$processedHeaders = WP_Http::processHeaders( $r['headers'] );
290
+		if ( ! is_array($r['headers'])) {
291
+			$processedHeaders = WP_Http::processHeaders($r['headers']);
292 292
 			$r['headers'] = $processedHeaders['headers'];
293 293
 		}
294 294
 
@@ -300,33 +300,33 @@  discard block
 block discarded – undo
300 300
 			'timeout' => $r['timeout'],
301 301
 			'useragent' => $r['user-agent'],
302 302
 			'blocking' => $r['blocking'],
303
-			'hooks' => new WP_HTTP_Requests_Hooks( $url, $r ),
303
+			'hooks' => new WP_HTTP_Requests_Hooks($url, $r),
304 304
 		);
305 305
 
306 306
 		// Ensure redirects follow browser behaviour.
307
-		$options['hooks']->register( 'requests.before_redirect', array( get_class(), 'browser_redirect_compatibility' ) );
307
+		$options['hooks']->register('requests.before_redirect', array(get_class(), 'browser_redirect_compatibility'));
308 308
 
309
-		if ( $r['stream'] ) {
309
+		if ($r['stream']) {
310 310
 			$options['filename'] = $r['filename'];
311 311
 		}
312
-		if ( empty( $r['redirection'] ) ) {
312
+		if (empty($r['redirection'])) {
313 313
 			$options['follow_redirects'] = false;
314 314
 		} else {
315 315
 			$options['redirects'] = $r['redirection'];
316 316
 		}
317 317
 
318 318
 		// Use byte limit, if we can
319
-		if ( isset( $r['limit_response_size'] ) ) {
319
+		if (isset($r['limit_response_size'])) {
320 320
 			$options['max_bytes'] = $r['limit_response_size'];
321 321
 		}
322 322
 
323 323
 		// If we've got cookies, use and convert them to Requests_Cookie.
324
-		if ( ! empty( $r['cookies'] ) ) {
325
-			$options['cookies'] = WP_Http::normalize_cookies( $r['cookies'] );
324
+		if ( ! empty($r['cookies'])) {
325
+			$options['cookies'] = WP_Http::normalize_cookies($r['cookies']);
326 326
 		}
327 327
 
328 328
 		// SSL certificate handling
329
-		if ( ! $r['sslverify'] ) {
329
+		if ( ! $r['sslverify']) {
330 330
 			$options['verify'] = false;
331 331
 			$options['verifyname'] = false;
332 332
 		} else {
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 		}
335 335
 
336 336
 		// All non-GET/HEAD requests should put the arguments in the form body.
337
-		if ( 'HEAD' !== $type && 'GET' !== $type ) {
337
+		if ('HEAD' !== $type && 'GET' !== $type) {
338 338
 			$options['data_format'] = 'body';
339 339
 		}
340 340
 
@@ -345,14 +345,14 @@  discard block
 block discarded – undo
345 345
 		 *
346 346
 		 * @param bool $ssl_verify Whether to verify the SSL connection. Default true.
347 347
 		 */
348
-		$options['verify'] = apply_filters( 'https_ssl_verify', $options['verify'] );
348
+		$options['verify'] = apply_filters('https_ssl_verify', $options['verify']);
349 349
 
350 350
 		// Check for proxies.
351 351
 		$proxy = new WP_HTTP_Proxy();
352
-		if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) {
353
-			$options['proxy'] = new Requests_Proxy_HTTP( $proxy->host() . ':' . $proxy->port() );
352
+		if ($proxy->is_enabled() && $proxy->send_through_proxy($url)) {
353
+			$options['proxy'] = new Requests_Proxy_HTTP($proxy->host().':'.$proxy->port());
354 354
 
355
-			if ( $proxy->use_authentication() ) {
355
+			if ($proxy->use_authentication()) {
356 356
 				$options['proxy']->use_authentication = true;
357 357
 				$options['proxy']->user = $proxy->username();
358 358
 				$options['proxy']->pass = $proxy->password();
@@ -363,17 +363,17 @@  discard block
 block discarded – undo
363 363
 		mbstring_binary_safe_encoding();
364 364
 
365 365
 		try {
366
-			$requests_response = Requests::request( $url, $headers, $data, $type, $options );
366
+			$requests_response = Requests::request($url, $headers, $data, $type, $options);
367 367
 
368 368
 			// Convert the response into an array
369
-			$http_response = new WP_HTTP_Requests_Response( $requests_response, $r['filename'] );
369
+			$http_response = new WP_HTTP_Requests_Response($requests_response, $r['filename']);
370 370
 			$response = $http_response->to_array();
371 371
 
372 372
 			// Add the original object to the array.
373 373
 			$response['http_response'] = $http_response;
374 374
 		}
375
-		catch ( Requests_Exception $e ) {
376
-			$response = new WP_Error( 'http_request_failed', $e->getMessage() );
375
+		catch (Requests_Exception $e) {
376
+			$response = new WP_Error('http_request_failed', $e->getMessage());
377 377
 		}
378 378
 
379 379
 		reset_mbstring_encoding();
@@ -389,12 +389,12 @@  discard block
 block discarded – undo
389 389
 		 * @param array          $args     HTTP request arguments.
390 390
 		 * @param string         $url      The request URL.
391 391
 		 */
392
-		do_action( 'http_api_debug', $response, 'response', 'Requests', $r, $url );
393
-		if ( is_wp_error( $response ) ) {
392
+		do_action('http_api_debug', $response, 'response', 'Requests', $r, $url);
393
+		if (is_wp_error($response)) {
394 394
 			return $response;
395 395
 		}
396 396
 
397
-		if ( ! $r['blocking'] ) {
397
+		if ( ! $r['blocking']) {
398 398
 			return array(
399 399
 				'headers' => array(),
400 400
 				'body' => '',
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
 		 * @param array  $r        HTTP request arguments.
417 417
 		 * @param string $url      The request URL.
418 418
 		 */
419
-		return apply_filters( 'http_response', $response, $r, $url );
419
+		return apply_filters('http_response', $response, $r, $url);
420 420
 	}
421 421
 
422 422
 	/**
@@ -429,14 +429,14 @@  discard block
 block discarded – undo
429 429
 	 * @param array $cookies List of cookies to send with the request.
430 430
 	 * @return Requests_Cookie_Jar Cookie holder object.
431 431
 	 */
432
-	public static function normalize_cookies( $cookies ) {
432
+	public static function normalize_cookies($cookies) {
433 433
 		$cookie_jar = new Requests_Cookie_Jar();
434 434
 
435
-		foreach ( $cookies as $name => $value ) {
436
-			if ( $value instanceof WP_Http_Cookie ) {
437
-				$cookie_jar[ $value->name ] = new Requests_Cookie( $value->name, $value->value, $value->get_attributes() );
438
-			} elseif ( is_scalar( $value ) ) {
439
-				$cookie_jar[ $name ] = new Requests_Cookie( $name, $value );
435
+		foreach ($cookies as $name => $value) {
436
+			if ($value instanceof WP_Http_Cookie) {
437
+				$cookie_jar[$value->name] = new Requests_Cookie($value->name, $value->value, $value->get_attributes());
438
+			} elseif (is_scalar($value)) {
439
+				$cookie_jar[$name] = new Requests_Cookie($name, $value);
440 440
 			}
441 441
 		}
442 442
 
@@ -459,9 +459,9 @@  discard block
 block discarded – undo
459 459
 	 * @param array             $options  Redirect request options.
460 460
 	 * @param Requests_Response $original Response object.
461 461
 	 */
462
-	public static function browser_redirect_compatibility( $location, $headers, $data, &$options, $original ) {
462
+	public static function browser_redirect_compatibility($location, $headers, $data, &$options, $original) {
463 463
 		// Browser compat
464
-		if ( $original->status_code === 302 ) {
464
+		if ($original->status_code === 302) {
465 465
 			$options['type'] = Requests::GET;
466 466
 		}
467 467
 	}
@@ -477,8 +477,8 @@  discard block
 block discarded – undo
477 477
 	 *
478 478
 	 * @return string|false Class name for the first transport that claims to support the request. False if no transport claims to support the request.
479 479
 	 */
480
-	public function _get_first_available_transport( $args, $url = null ) {
481
-		$transports = array( 'curl', 'streams' );
480
+	public function _get_first_available_transport($args, $url = null) {
481
+		$transports = array('curl', 'streams');
482 482
 
483 483
 		/**
484 484
 		 * Filters which HTTP transports are available and in what order.
@@ -490,17 +490,17 @@  discard block
 block discarded – undo
490 490
 		 * @param array  $args       HTTP request arguments.
491 491
 		 * @param string $url        The URL to request.
492 492
 		 */
493
-		$request_order = apply_filters( 'http_api_transports', $transports, $args, $url );
493
+		$request_order = apply_filters('http_api_transports', $transports, $args, $url);
494 494
 
495 495
 		// Loop over each transport on each HTTP request looking for one which will serve this request's needs.
496
-		foreach ( $request_order as $transport ) {
497
-			if ( in_array( $transport, $transports ) ) {
498
-				$transport = ucfirst( $transport );
496
+		foreach ($request_order as $transport) {
497
+			if (in_array($transport, $transports)) {
498
+				$transport = ucfirst($transport);
499 499
 			}
500
-			$class = 'WP_Http_' . $transport;
500
+			$class = 'WP_Http_'.$transport;
501 501
 
502 502
 			// Check to see if this transport is a possibility, calls the transport statically.
503
-			if ( !call_user_func( array( $class, 'test' ), $args, $url ) )
503
+			if ( ! call_user_func(array($class, 'test'), $args, $url))
504 504
 				continue;
505 505
 
506 506
 			return $class;
@@ -526,23 +526,23 @@  discard block
 block discarded – undo
526 526
 	 * @param array $args Request arguments
527 527
 	 * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error
528 528
 	 */
529
-	private function _dispatch_request( $url, $args ) {
529
+	private function _dispatch_request($url, $args) {
530 530
 		static $transports = array();
531 531
 
532
-		$class = $this->_get_first_available_transport( $args, $url );
533
-		if ( !$class )
534
-			return new WP_Error( 'http_failure', __( 'There are no HTTP transports available which can complete the requested request.' ) );
532
+		$class = $this->_get_first_available_transport($args, $url);
533
+		if ( ! $class)
534
+			return new WP_Error('http_failure', __('There are no HTTP transports available which can complete the requested request.'));
535 535
 
536 536
 		// Transport claims to support request, instantiate it and give it a whirl.
537
-		if ( empty( $transports[$class] ) )
537
+		if (empty($transports[$class]))
538 538
 			$transports[$class] = new $class;
539 539
 
540
-		$response = $transports[$class]->request( $url, $args );
540
+		$response = $transports[$class]->request($url, $args);
541 541
 
542 542
 		/** This action is documented in wp-includes/class-http.php */
543
-		do_action( 'http_api_debug', $response, 'response', $class, $args, $url );
543
+		do_action('http_api_debug', $response, 'response', $class, $args, $url);
544 544
 
545
-		if ( is_wp_error( $response ) )
545
+		if (is_wp_error($response))
546 546
 			return $response;
547 547
 
548 548
 		/**
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
 		 * @param array  $args     HTTP request arguments.
555 555
 		 * @param string $url      The request URL.
556 556
 		 */
557
-		return apply_filters( 'http_response', $response, $args, $url );
557
+		return apply_filters('http_response', $response, $args, $url);
558 558
 	}
559 559
 
560 560
 	/**
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
 	 */
572 572
 	public function post($url, $args = array()) {
573 573
 		$defaults = array('method' => 'POST');
574
-		$r = wp_parse_args( $args, $defaults );
574
+		$r = wp_parse_args($args, $defaults);
575 575
 		return $this->request($url, $r);
576 576
 	}
577 577
 
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
 	 */
590 590
 	public function get($url, $args = array()) {
591 591
 		$defaults = array('method' => 'GET');
592
-		$r = wp_parse_args( $args, $defaults );
592
+		$r = wp_parse_args($args, $defaults);
593 593
 		return $this->request($url, $r);
594 594
 	}
595 595
 
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 	 */
608 608
 	public function head($url, $args = array()) {
609 609
 		$defaults = array('method' => 'HEAD');
610
-		$r = wp_parse_args( $args, $defaults );
610
+		$r = wp_parse_args($args, $defaults);
611 611
 		return $this->request($url, $r);
612 612
 	}
613 613
 
@@ -642,9 +642,9 @@  discard block
 block discarded – undo
642 642
 	 * @return array Processed string headers. If duplicate headers are encountered,
643 643
 	 * 					Then a numbered array is returned as the value of that header-key.
644 644
 	 */
645
-	public static function processHeaders( $headers, $url = '' ) {
645
+	public static function processHeaders($headers, $url = '') {
646 646
 		// Split headers, one per array element.
647
-		if ( is_string($headers) ) {
647
+		if (is_string($headers)) {
648 648
 			// Tolerate line terminator: CRLF = LF (RFC 2616 19.3).
649 649
 			$headers = str_replace("\r\n", "\n", $headers);
650 650
 			/*
@@ -662,8 +662,8 @@  discard block
 block discarded – undo
662 662
 		 * If a redirection has taken place, The headers for each page request may have been passed.
663 663
 		 * In this case, determine the final HTTP header and parse from there.
664 664
 		 */
665
-		for ( $i = count($headers)-1; $i >= 0; $i-- ) {
666
-			if ( !empty($headers[$i]) && false === strpos($headers[$i], ':') ) {
665
+		for ($i = count($headers) - 1; $i >= 0; $i--) {
666
+			if ( ! empty($headers[$i]) && false === strpos($headers[$i], ':')) {
667 667
 				$headers = array_splice($headers, $i);
668 668
 				break;
669 669
 			}
@@ -671,35 +671,35 @@  discard block
 block discarded – undo
671 671
 
672 672
 		$cookies = array();
673 673
 		$newheaders = array();
674
-		foreach ( (array) $headers as $tempheader ) {
675
-			if ( empty($tempheader) )
674
+		foreach ((array) $headers as $tempheader) {
675
+			if (empty($tempheader))
676 676
 				continue;
677 677
 
678
-			if ( false === strpos($tempheader, ':') ) {
678
+			if (false === strpos($tempheader, ':')) {
679 679
 				$stack = explode(' ', $tempheader, 3);
680 680
 				$stack[] = '';
681
-				list( , $response['code'], $response['message']) = $stack;
681
+				list(, $response['code'], $response['message']) = $stack;
682 682
 				continue;
683 683
 			}
684 684
 
685 685
 			list($key, $value) = explode(':', $tempheader, 2);
686 686
 
687
-			$key = strtolower( $key );
688
-			$value = trim( $value );
687
+			$key = strtolower($key);
688
+			$value = trim($value);
689 689
 
690
-			if ( isset( $newheaders[ $key ] ) ) {
691
-				if ( ! is_array( $newheaders[ $key ] ) )
692
-					$newheaders[$key] = array( $newheaders[ $key ] );
693
-				$newheaders[ $key ][] = $value;
690
+			if (isset($newheaders[$key])) {
691
+				if ( ! is_array($newheaders[$key]))
692
+					$newheaders[$key] = array($newheaders[$key]);
693
+				$newheaders[$key][] = $value;
694 694
 			} else {
695
-				$newheaders[ $key ] = $value;
695
+				$newheaders[$key] = $value;
696 696
 			}
697
-			if ( 'set-cookie' == $key )
698
-				$cookies[] = new WP_Http_Cookie( $value, $url );
697
+			if ('set-cookie' == $key)
698
+				$cookies[] = new WP_Http_Cookie($value, $url);
699 699
 		}
700 700
 
701 701
 		// Cast the Response Code to an int
702
-		$response['code'] = intval( $response['code'] );
702
+		$response['code'] = intval($response['code']);
703 703
 
704 704
 		return array('response' => $response, 'headers' => $newheaders, 'cookies' => $cookies);
705 705
 	}
@@ -717,20 +717,20 @@  discard block
 block discarded – undo
717 717
 	 *
718 718
 	 * @param array $r Full array of args passed into ::request()
719 719
 	 */
720
-	public static function buildCookieHeader( &$r ) {
721
-		if ( ! empty($r['cookies']) ) {
720
+	public static function buildCookieHeader(&$r) {
721
+		if ( ! empty($r['cookies'])) {
722 722
 			// Upgrade any name => value cookie pairs to WP_HTTP_Cookie instances.
723
-			foreach ( $r['cookies'] as $name => $value ) {
724
-				if ( ! is_object( $value ) )
725
-					$r['cookies'][ $name ] = new WP_Http_Cookie( array( 'name' => $name, 'value' => $value ) );
723
+			foreach ($r['cookies'] as $name => $value) {
724
+				if ( ! is_object($value))
725
+					$r['cookies'][$name] = new WP_Http_Cookie(array('name' => $name, 'value' => $value));
726 726
 			}
727 727
 
728 728
 			$cookies_header = '';
729
-			foreach ( (array) $r['cookies'] as $cookie ) {
730
-				$cookies_header .= $cookie->getHeaderValue() . '; ';
729
+			foreach ((array) $r['cookies'] as $cookie) {
730
+				$cookies_header .= $cookie->getHeaderValue().'; ';
731 731
 			}
732 732
 
733
-			$cookies_header = substr( $cookies_header, 0, -2 );
733
+			$cookies_header = substr($cookies_header, 0, -2);
734 734
 			$r['headers']['cookie'] = $cookies_header;
735 735
 		}
736 736
 	}
@@ -749,9 +749,9 @@  discard block
 block discarded – undo
749 749
 	 * @param string $body Body content
750 750
 	 * @return string Chunked decoded body on success or raw body on failure.
751 751
 	 */
752
-	public static function chunkTransferDecode( $body ) {
752
+	public static function chunkTransferDecode($body) {
753 753
 		// The body is not chunked encoded or is malformed.
754
-		if ( ! preg_match( '/^([0-9a-f]+)[^\r\n]*\r\n/i', trim( $body ) ) )
754
+		if ( ! preg_match('/^([0-9a-f]+)[^\r\n]*\r\n/i', trim($body)))
755 755
 			return $body;
756 756
 
757 757
 		$parsed_body = '';
@@ -759,22 +759,22 @@  discard block
 block discarded – undo
759 759
 		// We'll be altering $body, so need a backup in case of error.
760 760
 		$body_original = $body;
761 761
 
762
-		while ( true ) {
763
-			$has_chunk = (bool) preg_match( '/^([0-9a-f]+)[^\r\n]*\r\n/i', $body, $match );
764
-			if ( ! $has_chunk || empty( $match[1] ) )
762
+		while (true) {
763
+			$has_chunk = (bool) preg_match('/^([0-9a-f]+)[^\r\n]*\r\n/i', $body, $match);
764
+			if ( ! $has_chunk || empty($match[1]))
765 765
 				return $body_original;
766 766
 
767
-			$length = hexdec( $match[1] );
768
-			$chunk_length = strlen( $match[0] );
767
+			$length = hexdec($match[1]);
768
+			$chunk_length = strlen($match[0]);
769 769
 
770 770
 			// Parse out the chunk of data.
771
-			$parsed_body .= substr( $body, $chunk_length, $length );
771
+			$parsed_body .= substr($body, $chunk_length, $length);
772 772
 
773 773
 			// Remove the chunk from the raw data.
774
-			$body = substr( $body, $length + $chunk_length );
774
+			$body = substr($body, $length + $chunk_length);
775 775
 
776 776
 			// End of the document.
777
-			if ( '0' === trim( $body ) )
777
+			if ('0' === trim($body))
778 778
 				return $parsed_body;
779 779
 		}
780 780
 	}
@@ -803,17 +803,17 @@  discard block
 block discarded – undo
803 803
 	 */
804 804
 	public function block_request($uri) {
805 805
 		// We don't need to block requests, because nothing is blocked.
806
-		if ( ! defined( 'WP_HTTP_BLOCK_EXTERNAL' ) || ! WP_HTTP_BLOCK_EXTERNAL )
806
+		if ( ! defined('WP_HTTP_BLOCK_EXTERNAL') || ! WP_HTTP_BLOCK_EXTERNAL)
807 807
 			return false;
808 808
 
809 809
 		$check = parse_url($uri);
810
-		if ( ! $check )
810
+		if ( ! $check)
811 811
 			return true;
812 812
 
813
-		$home = parse_url( get_option('siteurl') );
813
+		$home = parse_url(get_option('siteurl'));
814 814
 
815 815
 		// Don't block requests back to ourselves by default.
816
-		if ( 'localhost' == $check['host'] || ( isset( $home['host'] ) && $home['host'] == $check['host'] ) ) {
816
+		if ('localhost' == $check['host'] || (isset($home['host']) && $home['host'] == $check['host'])) {
817 817
 			/**
818 818
 			 * Filters whether to block local requests through the proxy.
819 819
 			 *
@@ -822,29 +822,29 @@  discard block
 block discarded – undo
822 822
 			 * @param bool $block Whether to block local requests through proxy.
823 823
 			 *                    Default false.
824 824
 			 */
825
-			return apply_filters( 'block_local_requests', false );
825
+			return apply_filters('block_local_requests', false);
826 826
 		}
827 827
 
828
-		if ( !defined('WP_ACCESSIBLE_HOSTS') )
828
+		if ( ! defined('WP_ACCESSIBLE_HOSTS'))
829 829
 			return true;
830 830
 
831 831
 		static $accessible_hosts = null;
832 832
 		static $wildcard_regex = array();
833
-		if ( null === $accessible_hosts ) {
833
+		if (null === $accessible_hosts) {
834 834
 			$accessible_hosts = preg_split('|,\s*|', WP_ACCESSIBLE_HOSTS);
835 835
 
836
-			if ( false !== strpos(WP_ACCESSIBLE_HOSTS, '*') ) {
836
+			if (false !== strpos(WP_ACCESSIBLE_HOSTS, '*')) {
837 837
 				$wildcard_regex = array();
838
-				foreach ( $accessible_hosts as $host )
839
-					$wildcard_regex[] = str_replace( '\*', '.+', preg_quote( $host, '/' ) );
840
-				$wildcard_regex = '/^(' . implode('|', $wildcard_regex) . ')$/i';
838
+				foreach ($accessible_hosts as $host)
839
+					$wildcard_regex[] = str_replace('\*', '.+', preg_quote($host, '/'));
840
+				$wildcard_regex = '/^('.implode('|', $wildcard_regex).')$/i';
841 841
 			}
842 842
 		}
843 843
 
844
-		if ( !empty($wildcard_regex) )
845
-			return !preg_match($wildcard_regex, $check['host']);
844
+		if ( ! empty($wildcard_regex))
845
+			return ! preg_match($wildcard_regex, $check['host']);
846 846
 		else
847
-			return !in_array( $check['host'], $accessible_hosts ); //Inverse logic, If it's in the array, then we can't access it.
847
+			return ! in_array($check['host'], $accessible_hosts); //Inverse logic, If it's in the array, then we can't access it.
848 848
 
849 849
 	}
850 850
 
@@ -859,9 +859,9 @@  discard block
 block discarded – undo
859 859
 	 * @return bool|array False on failure; Array of URL components on success;
860 860
 	 *                    See parse_url()'s return values.
861 861
 	 */
862
-	protected static function parse_url( $url ) {
863
-		_deprecated_function( __METHOD__, '4.4.0', 'wp_parse_url()' );
864
-		return wp_parse_url( $url );
862
+	protected static function parse_url($url) {
863
+		_deprecated_function(__METHOD__, '4.4.0', 'wp_parse_url()');
864
+		return wp_parse_url($url);
865 865
 	}
866 866
 
867 867
 	/**
@@ -878,65 +878,65 @@  discard block
 block discarded – undo
878 878
 	 * @param string $url                 The URL which $maybe_relative_path is relative to
879 879
 	 * @return string An Absolute URL, in a failure condition where the URL cannot be parsed, the relative URL will be returned.
880 880
 	 */
881
-	public static function make_absolute_url( $maybe_relative_path, $url ) {
882
-		if ( empty( $url ) )
881
+	public static function make_absolute_url($maybe_relative_path, $url) {
882
+		if (empty($url))
883 883
 			return $maybe_relative_path;
884 884
 
885
-		if ( ! $url_parts = wp_parse_url( $url ) ) {
885
+		if ( ! $url_parts = wp_parse_url($url)) {
886 886
 			return $maybe_relative_path;
887 887
 		}
888 888
 
889
-		if ( ! $relative_url_parts = wp_parse_url( $maybe_relative_path ) ) {
889
+		if ( ! $relative_url_parts = wp_parse_url($maybe_relative_path)) {
890 890
 			return $maybe_relative_path;
891 891
 		}
892 892
 
893 893
 		// Check for a scheme on the 'relative' url
894
-		if ( ! empty( $relative_url_parts['scheme'] ) ) {
894
+		if ( ! empty($relative_url_parts['scheme'])) {
895 895
 			return $maybe_relative_path;
896 896
 		}
897 897
 
898
-		$absolute_path = $url_parts['scheme'] . '://';
898
+		$absolute_path = $url_parts['scheme'].'://';
899 899
 
900 900
 		// Schemeless URL's will make it this far, so we check for a host in the relative url and convert it to a protocol-url
901
-		if ( isset( $relative_url_parts['host'] ) ) {
901
+		if (isset($relative_url_parts['host'])) {
902 902
 			$absolute_path .= $relative_url_parts['host'];
903
-			if ( isset( $relative_url_parts['port'] ) )
904
-				$absolute_path .= ':' . $relative_url_parts['port'];
903
+			if (isset($relative_url_parts['port']))
904
+				$absolute_path .= ':'.$relative_url_parts['port'];
905 905
 		} else {
906 906
 			$absolute_path .= $url_parts['host'];
907
-			if ( isset( $url_parts['port'] ) )
908
-				$absolute_path .= ':' . $url_parts['port'];
907
+			if (isset($url_parts['port']))
908
+				$absolute_path .= ':'.$url_parts['port'];
909 909
 		}
910 910
 
911 911
 		// Start off with the Absolute URL path.
912
-		$path = ! empty( $url_parts['path'] ) ? $url_parts['path'] : '/';
912
+		$path = ! empty($url_parts['path']) ? $url_parts['path'] : '/';
913 913
 
914 914
 		// If it's a root-relative path, then great.
915
-		if ( ! empty( $relative_url_parts['path'] ) && '/' == $relative_url_parts['path'][0] ) {
915
+		if ( ! empty($relative_url_parts['path']) && '/' == $relative_url_parts['path'][0]) {
916 916
 			$path = $relative_url_parts['path'];
917 917
 
918 918
 		// Else it's a relative path.
919
-		} elseif ( ! empty( $relative_url_parts['path'] ) ) {
919
+		} elseif ( ! empty($relative_url_parts['path'])) {
920 920
 			// Strip off any file components from the absolute path.
921
-			$path = substr( $path, 0, strrpos( $path, '/' ) + 1 );
921
+			$path = substr($path, 0, strrpos($path, '/') + 1);
922 922
 
923 923
 			// Build the new path.
924 924
 			$path .= $relative_url_parts['path'];
925 925
 
926 926
 			// Strip all /path/../ out of the path.
927
-			while ( strpos( $path, '../' ) > 1 ) {
928
-				$path = preg_replace( '![^/]+/\.\./!', '', $path );
927
+			while (strpos($path, '../') > 1) {
928
+				$path = preg_replace('![^/]+/\.\./!', '', $path);
929 929
 			}
930 930
 
931 931
 			// Strip any final leading ../ from the path.
932
-			$path = preg_replace( '!^/(\.\./)+!', '', $path );
932
+			$path = preg_replace('!^/(\.\./)+!', '', $path);
933 933
 		}
934 934
 
935 935
 		// Add the Query string.
936
-		if ( ! empty( $relative_url_parts['query'] ) )
937
-			$path .= '?' . $relative_url_parts['query'];
936
+		if ( ! empty($relative_url_parts['query']))
937
+			$path .= '?'.$relative_url_parts['query'];
938 938
 
939
-		return $absolute_path . '/' . ltrim( $path, '/' );
939
+		return $absolute_path.'/'.ltrim($path, '/');
940 940
 	}
941 941
 
942 942
 	/**
@@ -951,42 +951,42 @@  discard block
 block discarded – undo
951 951
 	 * @param array $response The Response of the HTTP request.
952 952
 	 * @return false|object False if no redirect is present, a WP_HTTP or WP_Error result otherwise.
953 953
 	 */
954
-	public static function handle_redirects( $url, $args, $response ) {
954
+	public static function handle_redirects($url, $args, $response) {
955 955
 		// If no redirects are present, or, redirects were not requested, perform no action.
956
-		if ( ! isset( $response['headers']['location'] ) || 0 === $args['_redirection'] )
956
+		if ( ! isset($response['headers']['location']) || 0 === $args['_redirection'])
957 957
 			return false;
958 958
 
959 959
 		// Only perform redirections on redirection http codes.
960
-		if ( $response['response']['code'] > 399 || $response['response']['code'] < 300 )
960
+		if ($response['response']['code'] > 399 || $response['response']['code'] < 300)
961 961
 			return false;
962 962
 
963 963
 		// Don't redirect if we've run out of redirects.
964
-		if ( $args['redirection']-- <= 0 )
965
-			return new WP_Error( 'http_request_failed', __('Too many redirects.') );
964
+		if ($args['redirection']-- <= 0)
965
+			return new WP_Error('http_request_failed', __('Too many redirects.'));
966 966
 
967 967
 		$redirect_location = $response['headers']['location'];
968 968
 
969 969
 		// If there were multiple Location headers, use the last header specified.
970
-		if ( is_array( $redirect_location ) )
971
-			$redirect_location = array_pop( $redirect_location );
970
+		if (is_array($redirect_location))
971
+			$redirect_location = array_pop($redirect_location);
972 972
 
973
-		$redirect_location = WP_Http::make_absolute_url( $redirect_location, $url );
973
+		$redirect_location = WP_Http::make_absolute_url($redirect_location, $url);
974 974
 
975 975
 		// POST requests should not POST to a redirected location.
976
-		if ( 'POST' == $args['method'] ) {
977
-			if ( in_array( $response['response']['code'], array( 302, 303 ) ) )
976
+		if ('POST' == $args['method']) {
977
+			if (in_array($response['response']['code'], array(302, 303)))
978 978
 				$args['method'] = 'GET';
979 979
 		}
980 980
 
981 981
 		// Include valid cookies in the redirect process.
982
-		if ( ! empty( $response['cookies'] ) ) {
983
-			foreach ( $response['cookies'] as $cookie ) {
984
-				if ( $cookie->test( $redirect_location ) )
982
+		if ( ! empty($response['cookies'])) {
983
+			foreach ($response['cookies'] as $cookie) {
984
+				if ($cookie->test($redirect_location))
985 985
 					$args['cookies'][] = $cookie;
986 986
 			}
987 987
 		}
988 988
 
989
-		return wp_remote_request( $redirect_location, $args );
989
+		return wp_remote_request($redirect_location, $args);
990 990
 	}
991 991
 
992 992
 	/**
@@ -1005,11 +1005,11 @@  discard block
 block discarded – undo
1005 1005
 	 * @param string $maybe_ip A suspected IP address
1006 1006
 	 * @return integer|bool Upon success, '4' or '6' to represent a IPv4 or IPv6 address, false upon failure
1007 1007
 	 */
1008
-	public static function is_ip_address( $maybe_ip ) {
1009
-		if ( preg_match( '/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $maybe_ip ) )
1008
+	public static function is_ip_address($maybe_ip) {
1009
+		if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $maybe_ip))
1010 1010
 			return 4;
1011 1011
 
1012
-		if ( false !== strpos( $maybe_ip, ':' ) && preg_match( '/^(((?=.*(::))(?!.*\3.+\3))\3?|([\dA-F]{1,4}(\3|:\b|$)|\2))(?4){5}((?4){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i', trim( $maybe_ip, ' []' ) ) )
1012
+		if (false !== strpos($maybe_ip, ':') && preg_match('/^(((?=.*(::))(?!.*\3.+\3))\3?|([\dA-F]{1,4}(\3|:\b|$)|\2))(?4){5}((?4){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i', trim($maybe_ip, ' []')))
1013 1013
 			return 6;
1014 1014
 
1015 1015
 		return false;
Please login to merge, or discard this patch.
src/wp-includes/class-wp-comment-query.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1004,7 +1004,7 @@
 block discarded – undo
1004 1004
 	 * @global wpdb $wpdb WordPress database abstraction object.
1005 1005
 	 *
1006 1006
 	 * @param string $string
1007
-	 * @param array $cols
1007
+	 * @param string[] $cols
1008 1008
 	 * @return string
1009 1009
 	 */
1010 1010
 	protected function get_search_sql( $string, $cols ) {
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -251,7 +251,7 @@
 block discarded – undo
251 251
 	 *                                                   The parameter is ignored (forced to `false`) when
252 252
 	 *                                                   `$fields` is 'ids' or 'counts'. Accepts 'threaded',
253 253
 	 *                                                   'flat', or false. Default: false.
254
- 	 *     @type string       $cache_domain              Unique cache key to be produced when this query is stored in
254
+	 *     @type string       $cache_domain              Unique cache key to be produced when this query is stored in
255 255
 	 *                                                   an object cache. Default is 'core'.
256 256
 	 *     @type bool         $update_comment_meta_cache Whether to prime the metadata cache for found comments.
257 257
 	 *                                                   Default true.
Please login to merge, or discard this patch.
Spacing   +236 added lines, -237 removed lines patch added patch discarded remove patch
@@ -134,9 +134,9 @@  discard block
 block discarded – undo
134 134
 	 * @param array    $arguments Arguments to pass when calling.
135 135
 	 * @return mixed|false Return value of the callback, false otherwise.
136 136
 	 */
137
-	public function __call( $name, $arguments ) {
138
-		if ( 'get_search_sql' === $name ) {
139
-			return call_user_func_array( array( $this, $name ), $arguments );
137
+	public function __call($name, $arguments) {
138
+		if ('get_search_sql' === $name) {
139
+			return call_user_func_array(array($this, $name), $arguments);
140 140
 		}
141 141
 		return false;
142 142
 	}
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 	 *                                                   Default false.
260 260
 	 * }
261 261
 	 */
262
-	public function __construct( $query = '' ) {
262
+	public function __construct($query = '') {
263 263
 		$this->query_var_defaults = array(
264 264
 			'author_email' => '',
265 265
 			'author_url' => '',
@@ -307,8 +307,8 @@  discard block
 block discarded – undo
307 307
 			'update_comment_post_cache' => false,
308 308
 		);
309 309
 
310
-		if ( ! empty( $query ) ) {
311
-			$this->query( $query );
310
+		if ( ! empty($query)) {
311
+			$this->query($query);
312 312
 		}
313 313
 	}
314 314
 
@@ -321,12 +321,12 @@  discard block
 block discarded – undo
321 321
 	 *
322 322
 	 * @param string|array $query WP_Comment_Query arguments. See WP_Comment_Query::__construct()
323 323
 	 */
324
-	public function parse_query( $query = '' ) {
325
-		if ( empty( $query ) ) {
324
+	public function parse_query($query = '') {
325
+		if (empty($query)) {
326 326
 			$query = $this->query_vars;
327 327
 		}
328 328
 
329
-		$this->query_vars = wp_parse_args( $query, $this->query_var_defaults );
329
+		$this->query_vars = wp_parse_args($query, $this->query_var_defaults);
330 330
 
331 331
 		/**
332 332
 		 * Fires after the comment query vars have been parsed.
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 		 *
336 336
 		 * @param WP_Comment_Query &$this The WP_Comment_Query instance (passed by reference).
337 337
 		 */
338
-		do_action_ref_array( 'parse_comment_query', array( &$this ) );
338
+		do_action_ref_array('parse_comment_query', array(&$this));
339 339
 	}
340 340
 
341 341
 	/**
@@ -352,8 +352,8 @@  discard block
 block discarded – undo
352 352
 	 * @param string|array $query Array or URL query string of parameters.
353 353
 	 * @return array|int List of comments, or number of comments when 'count' is passed as a query var.
354 354
 	 */
355
-	public function query( $query ) {
356
-		$this->query_vars = wp_parse_args( $query );
355
+	public function query($query) {
356
+		$this->query_vars = wp_parse_args($query);
357 357
 		return $this->get_comments();
358 358
 	}
359 359
 
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 
375 375
 		// Parse meta query
376 376
 		$this->meta_query = new WP_Meta_Query();
377
-		$this->meta_query->parse_query_vars( $this->query_vars );
377
+		$this->meta_query->parse_query_vars($this->query_vars);
378 378
 
379 379
 		/**
380 380
 		 * Fires before comments are retrieved.
@@ -383,24 +383,24 @@  discard block
 block discarded – undo
383 383
 		 *
384 384
 		 * @param WP_Comment_Query &$this Current instance of WP_Comment_Query, passed by reference.
385 385
 		 */
386
-		do_action_ref_array( 'pre_get_comments', array( &$this ) );
386
+		do_action_ref_array('pre_get_comments', array(&$this));
387 387
 
388 388
 		// Reparse query vars, in case they were modified in a 'pre_get_comments' callback.
389
-		$this->meta_query->parse_query_vars( $this->query_vars );
390
-		if ( ! empty( $this->meta_query->queries ) ) {
391
-			$this->meta_query_clauses = $this->meta_query->get_sql( 'comment', $wpdb->comments, 'comment_ID', $this );
389
+		$this->meta_query->parse_query_vars($this->query_vars);
390
+		if ( ! empty($this->meta_query->queries)) {
391
+			$this->meta_query_clauses = $this->meta_query->get_sql('comment', $wpdb->comments, 'comment_ID', $this);
392 392
 		}
393 393
 
394 394
 		// $args can include anything. Only use the args defined in the query_var_defaults to compute the key.
395
-		$key = md5( serialize( wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) ) ) );
396
-		$last_changed = wp_cache_get_last_changed( 'comment' );
395
+		$key = md5(serialize(wp_array_slice_assoc($this->query_vars, array_keys($this->query_var_defaults))));
396
+		$last_changed = wp_cache_get_last_changed('comment');
397 397
 
398 398
 
399 399
 		$cache_key   = "get_comments:$key:$last_changed";
400
-		$cache_value = wp_cache_get( $cache_key, 'comment' );
401
-		if ( false === $cache_value ) {
400
+		$cache_value = wp_cache_get($cache_key, 'comment');
401
+		if (false === $cache_value) {
402 402
 			$comment_ids = $this->get_comment_ids();
403
-			if ( $comment_ids ) {
403
+			if ($comment_ids) {
404 404
 				$this->set_found_comments();
405 405
 			}
406 406
 
@@ -408,47 +408,47 @@  discard block
 block discarded – undo
408 408
 				'comment_ids'    => $comment_ids,
409 409
 				'found_comments' => $this->found_comments,
410 410
 			);
411
-			wp_cache_add( $cache_key, $cache_value, 'comment' );
411
+			wp_cache_add($cache_key, $cache_value, 'comment');
412 412
 		} else {
413 413
 			$comment_ids          = $cache_value['comment_ids'];
414 414
 			$this->found_comments = $cache_value['found_comments'];
415 415
 		}
416 416
 
417
-		if ( $this->found_comments && $this->query_vars['number'] ) {
418
-			$this->max_num_pages = ceil( $this->found_comments / $this->query_vars['number'] );
417
+		if ($this->found_comments && $this->query_vars['number']) {
418
+			$this->max_num_pages = ceil($this->found_comments / $this->query_vars['number']);
419 419
 		}
420 420
 
421 421
 		// If querying for a count only, there's nothing more to do.
422
-		if ( $this->query_vars['count'] ) {
422
+		if ($this->query_vars['count']) {
423 423
 			// $comment_ids is actually a count in this case.
424
-			return intval( $comment_ids );
424
+			return intval($comment_ids);
425 425
 		}
426 426
 
427
-		$comment_ids = array_map( 'intval', $comment_ids );
427
+		$comment_ids = array_map('intval', $comment_ids);
428 428
 
429
-		if ( 'ids' == $this->query_vars['fields'] ) {
429
+		if ('ids' == $this->query_vars['fields']) {
430 430
 			$this->comments = $comment_ids;
431 431
 			return $this->comments;
432 432
 		}
433 433
 
434
-		_prime_comment_caches( $comment_ids, $this->query_vars['update_comment_meta_cache'] );
434
+		_prime_comment_caches($comment_ids, $this->query_vars['update_comment_meta_cache']);
435 435
 
436 436
 		// Fetch full comment objects from the primed cache.
437 437
 		$_comments = array();
438
-		foreach ( $comment_ids as $comment_id ) {
439
-			if ( $_comment = get_comment( $comment_id ) ) {
438
+		foreach ($comment_ids as $comment_id) {
439
+			if ($_comment = get_comment($comment_id)) {
440 440
 				$_comments[] = $_comment;
441 441
 			}
442 442
 		}
443 443
 
444 444
 		// Prime comment post caches.
445
-		if ( $this->query_vars['update_comment_post_cache'] ) {
445
+		if ($this->query_vars['update_comment_post_cache']) {
446 446
 			$comment_post_ids = array();
447
-			foreach ( $_comments as $_comment ) {
447
+			foreach ($_comments as $_comment) {
448 448
 				$comment_post_ids[] = $_comment->comment_post_ID;
449 449
 			}
450 450
 
451
-			_prime_post_caches( $comment_post_ids, false, false );
451
+			_prime_post_caches($comment_post_ids, false, false);
452 452
 		}
453 453
 
454 454
 		/**
@@ -459,13 +459,13 @@  discard block
 block discarded – undo
459 459
 		 * @param array            $results  An array of comments.
460 460
 		 * @param WP_Comment_Query &$this    Current instance of WP_Comment_Query, passed by reference.
461 461
 		 */
462
-		$_comments = apply_filters_ref_array( 'the_comments', array( $_comments, &$this ) );
462
+		$_comments = apply_filters_ref_array('the_comments', array($_comments, &$this));
463 463
 
464 464
 		// Convert to WP_Comment instances
465
-		$comments = array_map( 'get_comment', $_comments );
465
+		$comments = array_map('get_comment', $_comments);
466 466
 
467
-		if ( $this->query_vars['hierarchical'] ) {
468
-			$comments = $this->fill_descendants( $comments );
467
+		if ($this->query_vars['hierarchical']) {
468
+			$comments = $this->fill_descendants($comments);
469 469
 		}
470 470
 
471 471
 		$this->comments = $comments;
@@ -489,14 +489,14 @@  discard block
 block discarded – undo
489 489
 		// 'status' accepts an array or a comma-separated string.
490 490
 		$status_clauses = array();
491 491
 		$statuses = $this->query_vars['status'];
492
-		if ( ! is_array( $statuses ) ) {
493
-			$statuses = preg_split( '/[\s,]+/', $statuses );
492
+		if ( ! is_array($statuses)) {
493
+			$statuses = preg_split('/[\s,]+/', $statuses);
494 494
 		}
495 495
 
496 496
 		// 'any' overrides other statuses.
497
-		if ( ! in_array( 'any', $statuses ) ) {
498
-			foreach ( $statuses as $status ) {
499
-				switch ( $status ) {
497
+		if ( ! in_array('any', $statuses)) {
498
+			foreach ($statuses as $status) {
499
+				switch ($status) {
500 500
 					case 'hold' :
501 501
 						$status_clauses[] = "comment_approved = '0'";
502 502
 						break;
@@ -511,65 +511,64 @@  discard block
 block discarded – undo
511 511
 						break;
512 512
 
513 513
 					default :
514
-						$status_clauses[] = $wpdb->prepare( "comment_approved = %s", $status );
514
+						$status_clauses[] = $wpdb->prepare("comment_approved = %s", $status);
515 515
 						break;
516 516
 				}
517 517
 			}
518 518
 
519
-			if ( ! empty( $status_clauses ) ) {
520
-				$approved_clauses[] = '( ' . implode( ' OR ', $status_clauses ) . ' )';
519
+			if ( ! empty($status_clauses)) {
520
+				$approved_clauses[] = '( '.implode(' OR ', $status_clauses).' )';
521 521
 			}
522 522
 		}
523 523
 
524 524
 		// User IDs or emails whose unapproved comments are included, regardless of $status.
525
-		if ( ! empty( $this->query_vars['include_unapproved'] ) ) {
525
+		if ( ! empty($this->query_vars['include_unapproved'])) {
526 526
 			$include_unapproved = $this->query_vars['include_unapproved'];
527 527
 
528 528
 			// Accepts arrays or comma-separated strings.
529
-			if ( ! is_array( $include_unapproved ) ) {
530
-				$include_unapproved = preg_split( '/[\s,]+/', $include_unapproved );
529
+			if ( ! is_array($include_unapproved)) {
530
+				$include_unapproved = preg_split('/[\s,]+/', $include_unapproved);
531 531
 			}
532 532
 
533 533
 			$unapproved_ids = $unapproved_emails = array();
534
-			foreach ( $include_unapproved as $unapproved_identifier ) {
534
+			foreach ($include_unapproved as $unapproved_identifier) {
535 535
 				// Numeric values are assumed to be user ids.
536
-				if ( is_numeric( $unapproved_identifier ) ) {
537
-					$approved_clauses[] = $wpdb->prepare( "( user_id = %d AND comment_approved = '0' )", $unapproved_identifier );
536
+				if (is_numeric($unapproved_identifier)) {
537
+					$approved_clauses[] = $wpdb->prepare("( user_id = %d AND comment_approved = '0' )", $unapproved_identifier);
538 538
 
539 539
 				// Otherwise we match against email addresses.
540 540
 				} else {
541
-					$approved_clauses[] = $wpdb->prepare( "( comment_author_email = %s AND comment_approved = '0' )", $unapproved_identifier );
541
+					$approved_clauses[] = $wpdb->prepare("( comment_author_email = %s AND comment_approved = '0' )", $unapproved_identifier);
542 542
 				}
543 543
 			}
544 544
 		}
545 545
 
546 546
 		// Collapse comment_approved clauses into a single OR-separated clause.
547
-		if ( ! empty( $approved_clauses ) ) {
548
-			if ( 1 === count( $approved_clauses ) ) {
547
+		if ( ! empty($approved_clauses)) {
548
+			if (1 === count($approved_clauses)) {
549 549
 				$this->sql_clauses['where']['approved'] = $approved_clauses[0];
550 550
 			} else {
551
-				$this->sql_clauses['where']['approved'] = '( ' . implode( ' OR ', $approved_clauses ) . ' )';
551
+				$this->sql_clauses['where']['approved'] = '( '.implode(' OR ', $approved_clauses).' )';
552 552
 			}
553 553
 		}
554 554
 
555
-		$order = ( 'ASC' == strtoupper( $this->query_vars['order'] ) ) ? 'ASC' : 'DESC';
555
+		$order = ('ASC' == strtoupper($this->query_vars['order'])) ? 'ASC' : 'DESC';
556 556
 
557 557
 		// Disable ORDER BY with 'none', an empty array, or boolean false.
558
-		if ( in_array( $this->query_vars['orderby'], array( 'none', array(), false ), true ) ) {
558
+		if (in_array($this->query_vars['orderby'], array('none', array(), false), true)) {
559 559
 			$orderby = '';
560
-		} elseif ( ! empty( $this->query_vars['orderby'] ) ) {
561
-			$ordersby = is_array( $this->query_vars['orderby'] ) ?
562
-				$this->query_vars['orderby'] :
563
-				preg_split( '/[,\s]/', $this->query_vars['orderby'] );
560
+		} elseif ( ! empty($this->query_vars['orderby'])) {
561
+			$ordersby = is_array($this->query_vars['orderby']) ?
562
+				$this->query_vars['orderby'] : preg_split('/[,\s]/', $this->query_vars['orderby']);
564 563
 
565 564
 			$orderby_array = array();
566 565
 			$found_orderby_comment_ID = false;
567
-			foreach ( $ordersby as $_key => $_value ) {
568
-				if ( ! $_value ) {
566
+			foreach ($ordersby as $_key => $_value) {
567
+				if ( ! $_value) {
569 568
 					continue;
570 569
 				}
571 570
 
572
-				if ( is_int( $_key ) ) {
571
+				if (is_int($_key)) {
573 572
 					$_orderby = $_value;
574 573
 					$_order = $order;
575 574
 				} else {
@@ -577,45 +576,45 @@  discard block
 block discarded – undo
577 576
 					$_order = $_value;
578 577
 				}
579 578
 
580
-				if ( ! $found_orderby_comment_ID && in_array( $_orderby, array( 'comment_ID', 'comment__in' ) ) ) {
579
+				if ( ! $found_orderby_comment_ID && in_array($_orderby, array('comment_ID', 'comment__in'))) {
581 580
 					$found_orderby_comment_ID = true;
582 581
 				}
583 582
 
584
-				$parsed = $this->parse_orderby( $_orderby );
583
+				$parsed = $this->parse_orderby($_orderby);
585 584
 
586
-				if ( ! $parsed ) {
585
+				if ( ! $parsed) {
587 586
 					continue;
588 587
 				}
589 588
 
590
-				if ( 'comment__in' === $_orderby ) {
589
+				if ('comment__in' === $_orderby) {
591 590
 					$orderby_array[] = $parsed;
592 591
 					continue;
593 592
 				}
594 593
 
595
-				$orderby_array[] = $parsed . ' ' . $this->parse_order( $_order );
594
+				$orderby_array[] = $parsed.' '.$this->parse_order($_order);
596 595
 			}
597 596
 
598 597
 			// If no valid clauses were found, order by comment_date_gmt.
599
-			if ( empty( $orderby_array ) ) {
598
+			if (empty($orderby_array)) {
600 599
 				$orderby_array[] = "$wpdb->comments.comment_date_gmt $order";
601 600
 			}
602 601
 
603 602
 			// To ensure determinate sorting, always include a comment_ID clause.
604
-			if ( ! $found_orderby_comment_ID ) {
603
+			if ( ! $found_orderby_comment_ID) {
605 604
 				$comment_ID_order = '';
606 605
 
607 606
 				// Inherit order from comment_date or comment_date_gmt, if available.
608
-				foreach ( $orderby_array as $orderby_clause ) {
609
-					if ( preg_match( '/comment_date(?:_gmt)*\ (ASC|DESC)/', $orderby_clause, $match ) ) {
607
+				foreach ($orderby_array as $orderby_clause) {
608
+					if (preg_match('/comment_date(?:_gmt)*\ (ASC|DESC)/', $orderby_clause, $match)) {
610 609
 						$comment_ID_order = $match[1];
611 610
 						break;
612 611
 					}
613 612
 				}
614 613
 
615 614
 				// If no date-related order is available, use the date from the first available clause.
616
-				if ( ! $comment_ID_order ) {
617
-					foreach ( $orderby_array as $orderby_clause ) {
618
-						if ( false !== strpos( 'ASC', $orderby_clause ) ) {
615
+				if ( ! $comment_ID_order) {
616
+					foreach ($orderby_array as $orderby_clause) {
617
+						if (false !== strpos('ASC', $orderby_clause)) {
619 618
 							$comment_ID_order = 'ASC';
620 619
 						} else {
621 620
 							$comment_ID_order = 'DESC';
@@ -626,94 +625,94 @@  discard block
 block discarded – undo
626 625
 				}
627 626
 
628 627
 				// Default to DESC.
629
-				if ( ! $comment_ID_order ) {
628
+				if ( ! $comment_ID_order) {
630 629
 					$comment_ID_order = 'DESC';
631 630
 				}
632 631
 
633 632
 				$orderby_array[] = "$wpdb->comments.comment_ID $comment_ID_order";
634 633
 			}
635 634
 
636
-			$orderby = implode( ', ', $orderby_array );
635
+			$orderby = implode(', ', $orderby_array);
637 636
 		} else {
638 637
 			$orderby = "$wpdb->comments.comment_date_gmt $order";
639 638
 		}
640 639
 
641
-		$number = absint( $this->query_vars['number'] );
642
-		$offset = absint( $this->query_vars['offset'] );
640
+		$number = absint($this->query_vars['number']);
641
+		$offset = absint($this->query_vars['offset']);
643 642
 
644
-		if ( ! empty( $number ) ) {
645
-			if ( $offset ) {
646
-				$limits = 'LIMIT ' . $offset . ',' . $number;
643
+		if ( ! empty($number)) {
644
+			if ($offset) {
645
+				$limits = 'LIMIT '.$offset.','.$number;
647 646
 			} else {
648
-				$limits = 'LIMIT ' . $number;
647
+				$limits = 'LIMIT '.$number;
649 648
 			}
650 649
 		}
651 650
 
652
-		if ( $this->query_vars['count'] ) {
651
+		if ($this->query_vars['count']) {
653 652
 			$fields = 'COUNT(*)';
654 653
 		} else {
655 654
 			$fields = "$wpdb->comments.comment_ID";
656 655
 		}
657 656
 
658
-		$post_id = absint( $this->query_vars['post_id'] );
659
-		if ( ! empty( $post_id ) ) {
660
-			$this->sql_clauses['where']['post_id'] = $wpdb->prepare( 'comment_post_ID = %d', $post_id );
657
+		$post_id = absint($this->query_vars['post_id']);
658
+		if ( ! empty($post_id)) {
659
+			$this->sql_clauses['where']['post_id'] = $wpdb->prepare('comment_post_ID = %d', $post_id);
661 660
 		}
662 661
 
663 662
 		// Parse comment IDs for an IN clause.
664
-		if ( ! empty( $this->query_vars['comment__in'] ) ) {
665
-			$this->sql_clauses['where']['comment__in'] = "$wpdb->comments.comment_ID IN ( " . implode( ',', wp_parse_id_list( $this->query_vars['comment__in'] ) ) . ' )';
663
+		if ( ! empty($this->query_vars['comment__in'])) {
664
+			$this->sql_clauses['where']['comment__in'] = "$wpdb->comments.comment_ID IN ( ".implode(',', wp_parse_id_list($this->query_vars['comment__in'])).' )';
666 665
 		}
667 666
 
668 667
 		// Parse comment IDs for a NOT IN clause.
669
-		if ( ! empty( $this->query_vars['comment__not_in'] ) ) {
670
-			$this->sql_clauses['where']['comment__not_in'] = "$wpdb->comments.comment_ID NOT IN ( " . implode( ',', wp_parse_id_list( $this->query_vars['comment__not_in'] ) ) . ' )';
668
+		if ( ! empty($this->query_vars['comment__not_in'])) {
669
+			$this->sql_clauses['where']['comment__not_in'] = "$wpdb->comments.comment_ID NOT IN ( ".implode(',', wp_parse_id_list($this->query_vars['comment__not_in'])).' )';
671 670
 		}
672 671
 
673 672
 		// Parse comment parent IDs for an IN clause.
674
-		if ( ! empty( $this->query_vars['parent__in'] ) ) {
675
-			$this->sql_clauses['where']['parent__in'] = 'comment_parent IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['parent__in'] ) ) . ' )';
673
+		if ( ! empty($this->query_vars['parent__in'])) {
674
+			$this->sql_clauses['where']['parent__in'] = 'comment_parent IN ( '.implode(',', wp_parse_id_list($this->query_vars['parent__in'])).' )';
676 675
 		}
677 676
 
678 677
 		// Parse comment parent IDs for a NOT IN clause.
679
-		if ( ! empty( $this->query_vars['parent__not_in'] ) ) {
680
-			$this->sql_clauses['where']['parent__not_in'] = 'comment_parent NOT IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['parent__not_in'] ) ) . ' )';
678
+		if ( ! empty($this->query_vars['parent__not_in'])) {
679
+			$this->sql_clauses['where']['parent__not_in'] = 'comment_parent NOT IN ( '.implode(',', wp_parse_id_list($this->query_vars['parent__not_in'])).' )';
681 680
 		}
682 681
 
683 682
 		// Parse comment post IDs for an IN clause.
684
-		if ( ! empty( $this->query_vars['post__in'] ) ) {
685
-			$this->sql_clauses['where']['post__in'] = 'comment_post_ID IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['post__in'] ) ) . ' )';
683
+		if ( ! empty($this->query_vars['post__in'])) {
684
+			$this->sql_clauses['where']['post__in'] = 'comment_post_ID IN ( '.implode(',', wp_parse_id_list($this->query_vars['post__in'])).' )';
686 685
 		}
687 686
 
688 687
 		// Parse comment post IDs for a NOT IN clause.
689
-		if ( ! empty( $this->query_vars['post__not_in'] ) ) {
690
-			$this->sql_clauses['where']['post__not_in'] = 'comment_post_ID NOT IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['post__not_in'] ) ) . ' )';
688
+		if ( ! empty($this->query_vars['post__not_in'])) {
689
+			$this->sql_clauses['where']['post__not_in'] = 'comment_post_ID NOT IN ( '.implode(',', wp_parse_id_list($this->query_vars['post__not_in'])).' )';
691 690
 		}
692 691
 
693
-		if ( '' !== $this->query_vars['author_email'] ) {
694
-			$this->sql_clauses['where']['author_email'] = $wpdb->prepare( 'comment_author_email = %s', $this->query_vars['author_email'] );
692
+		if ('' !== $this->query_vars['author_email']) {
693
+			$this->sql_clauses['where']['author_email'] = $wpdb->prepare('comment_author_email = %s', $this->query_vars['author_email']);
695 694
 		}
696 695
 
697
-		if ( '' !== $this->query_vars['author_url'] ) {
698
-			$this->sql_clauses['where']['author_url'] = $wpdb->prepare( 'comment_author_url = %s', $this->query_vars['author_url'] );
696
+		if ('' !== $this->query_vars['author_url']) {
697
+			$this->sql_clauses['where']['author_url'] = $wpdb->prepare('comment_author_url = %s', $this->query_vars['author_url']);
699 698
 		}
700 699
 
701
-		if ( '' !== $this->query_vars['karma'] ) {
702
-			$this->sql_clauses['where']['karma'] = $wpdb->prepare( 'comment_karma = %d', $this->query_vars['karma'] );
700
+		if ('' !== $this->query_vars['karma']) {
701
+			$this->sql_clauses['where']['karma'] = $wpdb->prepare('comment_karma = %d', $this->query_vars['karma']);
703 702
 		}
704 703
 
705 704
 		// Filtering by comment_type: 'type', 'type__in', 'type__not_in'.
706 705
 		$raw_types = array(
707
-			'IN' => array_merge( (array) $this->query_vars['type'], (array) $this->query_vars['type__in'] ),
706
+			'IN' => array_merge((array) $this->query_vars['type'], (array) $this->query_vars['type__in']),
708 707
 			'NOT IN' => (array) $this->query_vars['type__not_in'],
709 708
 		);
710 709
 
711 710
 		$comment_types = array();
712
-		foreach ( $raw_types as $operator => $_raw_types ) {
713
-			$_raw_types = array_unique( $_raw_types );
711
+		foreach ($raw_types as $operator => $_raw_types) {
712
+			$_raw_types = array_unique($_raw_types);
714 713
 
715
-			foreach ( $_raw_types as $type ) {
716
-				switch ( $type ) {
714
+			foreach ($_raw_types as $type) {
715
+				switch ($type) {
717 716
 					// An empty translates to 'all', for backward compatibility
718 717
 					case '':
719 718
 					case 'all' :
@@ -721,134 +720,134 @@  discard block
 block discarded – undo
721 720
 
722 721
 					case 'comment':
723 722
 					case 'comments':
724
-						$comment_types[ $operator ][] = "''";
723
+						$comment_types[$operator][] = "''";
725 724
 						break;
726 725
 
727 726
 					case 'pings':
728
-						$comment_types[ $operator ][] = "'pingback'";
729
-						$comment_types[ $operator ][] = "'trackback'";
727
+						$comment_types[$operator][] = "'pingback'";
728
+						$comment_types[$operator][] = "'trackback'";
730 729
 						break;
731 730
 
732 731
 					default:
733
-						$comment_types[ $operator ][] = $wpdb->prepare( '%s', $type );
732
+						$comment_types[$operator][] = $wpdb->prepare('%s', $type);
734 733
 						break;
735 734
 				}
736 735
 			}
737 736
 
738
-			if ( ! empty( $comment_types[ $operator ] ) ) {
739
-				$types_sql = implode( ', ', $comment_types[ $operator ] );
740
-				$this->sql_clauses['where']['comment_type__' . strtolower( str_replace( ' ', '_', $operator ) ) ] = "comment_type $operator ($types_sql)";
737
+			if ( ! empty($comment_types[$operator])) {
738
+				$types_sql = implode(', ', $comment_types[$operator]);
739
+				$this->sql_clauses['where']['comment_type__'.strtolower(str_replace(' ', '_', $operator))] = "comment_type $operator ($types_sql)";
741 740
 			}
742 741
 		}
743 742
 
744 743
 		$parent = $this->query_vars['parent'];
745
-		if ( $this->query_vars['hierarchical'] && ! $parent ) {
744
+		if ($this->query_vars['hierarchical'] && ! $parent) {
746 745
 			$parent = 0;
747 746
 		}
748 747
 
749
-		if ( '' !== $parent ) {
750
-			$this->sql_clauses['where']['parent'] = $wpdb->prepare( 'comment_parent = %d', $parent );
748
+		if ('' !== $parent) {
749
+			$this->sql_clauses['where']['parent'] = $wpdb->prepare('comment_parent = %d', $parent);
751 750
 		}
752 751
 
753
-		if ( is_array( $this->query_vars['user_id'] ) ) {
754
-			$this->sql_clauses['where']['user_id'] = 'user_id IN (' . implode( ',', array_map( 'absint', $this->query_vars['user_id'] ) ) . ')';
755
-		} elseif ( '' !== $this->query_vars['user_id'] ) {
756
-			$this->sql_clauses['where']['user_id'] = $wpdb->prepare( 'user_id = %d', $this->query_vars['user_id'] );
752
+		if (is_array($this->query_vars['user_id'])) {
753
+			$this->sql_clauses['where']['user_id'] = 'user_id IN ('.implode(',', array_map('absint', $this->query_vars['user_id'])).')';
754
+		} elseif ('' !== $this->query_vars['user_id']) {
755
+			$this->sql_clauses['where']['user_id'] = $wpdb->prepare('user_id = %d', $this->query_vars['user_id']);
757 756
 		}
758 757
 
759 758
 		// Falsy search strings are ignored.
760
-		if ( strlen( $this->query_vars['search'] ) ) {
759
+		if (strlen($this->query_vars['search'])) {
761 760
 			$search_sql = $this->get_search_sql(
762 761
 				$this->query_vars['search'],
763
-				array( 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_content' )
762
+				array('comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_content')
764 763
 			);
765 764
 
766 765
 			// Strip leading 'AND'.
767
-			$this->sql_clauses['where']['search'] = preg_replace( '/^\s*AND\s*/', '', $search_sql );
766
+			$this->sql_clauses['where']['search'] = preg_replace('/^\s*AND\s*/', '', $search_sql);
768 767
 		}
769 768
 
770 769
 		// If any post-related query vars are passed, join the posts table.
771 770
 		$join_posts_table = false;
772
-		$plucked = wp_array_slice_assoc( $this->query_vars, array( 'post_author', 'post_name', 'post_parent' ) );
773
-		$post_fields = array_filter( $plucked );
771
+		$plucked = wp_array_slice_assoc($this->query_vars, array('post_author', 'post_name', 'post_parent'));
772
+		$post_fields = array_filter($plucked);
774 773
 
775
-		if ( ! empty( $post_fields ) ) {
774
+		if ( ! empty($post_fields)) {
776 775
 			$join_posts_table = true;
777
-			foreach ( $post_fields as $field_name => $field_value ) {
776
+			foreach ($post_fields as $field_name => $field_value) {
778 777
 				// $field_value may be an array.
779
-				$esses = array_fill( 0, count( (array) $field_value ), '%s' );
780
-				$this->sql_clauses['where'][ $field_name ] = $wpdb->prepare( " {$wpdb->posts}.{$field_name} IN (" . implode( ',', $esses ) . ')', $field_value );
778
+				$esses = array_fill(0, count((array) $field_value), '%s');
779
+				$this->sql_clauses['where'][$field_name] = $wpdb->prepare(" {$wpdb->posts}.{$field_name} IN (".implode(',', $esses).')', $field_value);
781 780
 			}
782 781
 		}
783 782
 
784 783
 		// 'post_status' and 'post_type' are handled separately, due to the specialized behavior of 'any'.
785
-		foreach ( array( 'post_status', 'post_type' ) as $field_name ) {
784
+		foreach (array('post_status', 'post_type') as $field_name) {
786 785
 			$q_values = array();
787
-			if ( ! empty( $this->query_vars[ $field_name ] ) ) {
788
-				$q_values = $this->query_vars[ $field_name ];
789
-				if ( ! is_array( $q_values ) ) {
790
-					$q_values = explode( ',', $q_values );
786
+			if ( ! empty($this->query_vars[$field_name])) {
787
+				$q_values = $this->query_vars[$field_name];
788
+				if ( ! is_array($q_values)) {
789
+					$q_values = explode(',', $q_values);
791 790
 				}
792 791
 
793 792
 				// 'any' will cause the query var to be ignored.
794
-				if ( in_array( 'any', $q_values, true ) || empty( $q_values ) ) {
793
+				if (in_array('any', $q_values, true) || empty($q_values)) {
795 794
 					continue;
796 795
 				}
797 796
 
798 797
 				$join_posts_table = true;
799 798
 
800
-				$esses = array_fill( 0, count( $q_values ), '%s' );
801
-				$this->sql_clauses['where'][ $field_name ] = $wpdb->prepare( " {$wpdb->posts}.{$field_name} IN (" . implode( ',', $esses ) . ")", $q_values );
799
+				$esses = array_fill(0, count($q_values), '%s');
800
+				$this->sql_clauses['where'][$field_name] = $wpdb->prepare(" {$wpdb->posts}.{$field_name} IN (".implode(',', $esses).")", $q_values);
802 801
 			}
803 802
 		}
804 803
 
805 804
 		// Comment author IDs for an IN clause.
806
-		if ( ! empty( $this->query_vars['author__in'] ) ) {
807
-			$this->sql_clauses['where']['author__in'] = 'user_id IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['author__in'] ) ) . ' )';
805
+		if ( ! empty($this->query_vars['author__in'])) {
806
+			$this->sql_clauses['where']['author__in'] = 'user_id IN ( '.implode(',', wp_parse_id_list($this->query_vars['author__in'])).' )';
808 807
 		}
809 808
 
810 809
 		// Comment author IDs for a NOT IN clause.
811
-		if ( ! empty( $this->query_vars['author__not_in'] ) ) {
812
-			$this->sql_clauses['where']['author__not_in'] = 'user_id NOT IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['author__not_in'] ) ) . ' )';
810
+		if ( ! empty($this->query_vars['author__not_in'])) {
811
+			$this->sql_clauses['where']['author__not_in'] = 'user_id NOT IN ( '.implode(',', wp_parse_id_list($this->query_vars['author__not_in'])).' )';
813 812
 		}
814 813
 
815 814
 		// Post author IDs for an IN clause.
816
-		if ( ! empty( $this->query_vars['post_author__in'] ) ) {
815
+		if ( ! empty($this->query_vars['post_author__in'])) {
817 816
 			$join_posts_table = true;
818
-			$this->sql_clauses['where']['post_author__in'] = 'post_author IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['post_author__in'] ) ) . ' )';
817
+			$this->sql_clauses['where']['post_author__in'] = 'post_author IN ( '.implode(',', wp_parse_id_list($this->query_vars['post_author__in'])).' )';
819 818
 		}
820 819
 
821 820
 		// Post author IDs for a NOT IN clause.
822
-		if ( ! empty( $this->query_vars['post_author__not_in'] ) ) {
821
+		if ( ! empty($this->query_vars['post_author__not_in'])) {
823 822
 			$join_posts_table = true;
824
-			$this->sql_clauses['where']['post_author__not_in'] = 'post_author NOT IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['post_author__not_in'] ) ) . ' )';
823
+			$this->sql_clauses['where']['post_author__not_in'] = 'post_author NOT IN ( '.implode(',', wp_parse_id_list($this->query_vars['post_author__not_in'])).' )';
825 824
 		}
826 825
 
827 826
 		$join = '';
828 827
 
829
-		if ( $join_posts_table ) {
828
+		if ($join_posts_table) {
830 829
 			$join .= "JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID";
831 830
 		}
832 831
 
833
-		if ( ! empty( $this->meta_query_clauses ) ) {
832
+		if ( ! empty($this->meta_query_clauses)) {
834 833
 			$join .= $this->meta_query_clauses['join'];
835 834
 
836 835
 			// Strip leading 'AND'.
837
-			$this->sql_clauses['where']['meta_query'] = preg_replace( '/^\s*AND\s*/', '', $this->meta_query_clauses['where'] );
836
+			$this->sql_clauses['where']['meta_query'] = preg_replace('/^\s*AND\s*/', '', $this->meta_query_clauses['where']);
838 837
 
839
-			if ( ! $this->query_vars['count'] ) {
838
+			if ( ! $this->query_vars['count']) {
840 839
 				$groupby = "{$wpdb->comments}.comment_ID";
841 840
 			}
842 841
 		}
843 842
 
844
-		if ( ! empty( $this->query_vars['date_query'] ) && is_array( $this->query_vars['date_query'] ) ) {
845
-			$this->date_query = new WP_Date_Query( $this->query_vars['date_query'], 'comment_date' );
846
-			$this->sql_clauses['where']['date_query'] = preg_replace( '/^\s*AND\s*/', '', $this->date_query->get_sql() );
843
+		if ( ! empty($this->query_vars['date_query']) && is_array($this->query_vars['date_query'])) {
844
+			$this->date_query = new WP_Date_Query($this->query_vars['date_query'], 'comment_date');
845
+			$this->sql_clauses['where']['date_query'] = preg_replace('/^\s*AND\s*/', '', $this->date_query->get_sql());
847 846
 		}
848 847
 
849
-		$where = implode( ' AND ', $this->sql_clauses['where'] );
848
+		$where = implode(' AND ', $this->sql_clauses['where']);
850 849
 
851
-		$pieces = array( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' );
850
+		$pieces = array('fields', 'join', 'where', 'orderby', 'limits', 'groupby');
852 851
 		/**
853 852
 		 * Filters the comment query clauses.
854 853
 		 *
@@ -857,31 +856,31 @@  discard block
 block discarded – undo
857 856
 		 * @param array            $pieces A compacted array of comment query clauses.
858 857
 		 * @param WP_Comment_Query &$this  Current instance of WP_Comment_Query, passed by reference.
859 858
 		 */
860
-		$clauses = apply_filters_ref_array( 'comments_clauses', array( compact( $pieces ), &$this ) );
859
+		$clauses = apply_filters_ref_array('comments_clauses', array(compact($pieces), &$this));
861 860
 
862
-		$fields = isset( $clauses[ 'fields' ] ) ? $clauses[ 'fields' ] : '';
863
-		$join = isset( $clauses[ 'join' ] ) ? $clauses[ 'join' ] : '';
864
-		$where = isset( $clauses[ 'where' ] ) ? $clauses[ 'where' ] : '';
865
-		$orderby = isset( $clauses[ 'orderby' ] ) ? $clauses[ 'orderby' ] : '';
866
-		$limits = isset( $clauses[ 'limits' ] ) ? $clauses[ 'limits' ] : '';
867
-		$groupby = isset( $clauses[ 'groupby' ] ) ? $clauses[ 'groupby' ] : '';
861
+		$fields = isset($clauses['fields']) ? $clauses['fields'] : '';
862
+		$join = isset($clauses['join']) ? $clauses['join'] : '';
863
+		$where = isset($clauses['where']) ? $clauses['where'] : '';
864
+		$orderby = isset($clauses['orderby']) ? $clauses['orderby'] : '';
865
+		$limits = isset($clauses['limits']) ? $clauses['limits'] : '';
866
+		$groupby = isset($clauses['groupby']) ? $clauses['groupby'] : '';
868 867
 
869 868
 		$this->filtered_where_clause = $where;
870 869
 
871
-		if ( $where ) {
872
-			$where = 'WHERE ' . $where;
870
+		if ($where) {
871
+			$where = 'WHERE '.$where;
873 872
 		}
874 873
 
875
-		if ( $groupby ) {
876
-			$groupby = 'GROUP BY ' . $groupby;
874
+		if ($groupby) {
875
+			$groupby = 'GROUP BY '.$groupby;
877 876
 		}
878 877
 
879
-		if ( $orderby ) {
878
+		if ($orderby) {
880 879
 			$orderby = "ORDER BY $orderby";
881 880
 		}
882 881
 
883 882
 		$found_rows = '';
884
-		if ( ! $this->query_vars['no_found_rows'] ) {
883
+		if ( ! $this->query_vars['no_found_rows']) {
885 884
 			$found_rows = 'SQL_CALC_FOUND_ROWS';
886 885
 		}
887 886
 
@@ -893,11 +892,11 @@  discard block
 block discarded – undo
893 892
 
894 893
 		$this->request = "{$this->sql_clauses['select']} {$this->sql_clauses['from']} {$where} {$this->sql_clauses['groupby']} {$this->sql_clauses['orderby']} {$this->sql_clauses['limits']}";
895 894
 
896
-		if ( $this->query_vars['count'] ) {
897
-			return intval( $wpdb->get_var( $this->request ) );
895
+		if ($this->query_vars['count']) {
896
+			return intval($wpdb->get_var($this->request));
898 897
 		} else {
899
-			$comment_ids = $wpdb->get_col( $this->request );
900
-			return array_map( 'intval', $comment_ids );
898
+			$comment_ids = $wpdb->get_col($this->request);
899
+			return array_map('intval', $comment_ids);
901 900
 		}
902 901
 	}
903 902
 
@@ -913,7 +912,7 @@  discard block
 block discarded – undo
913 912
 	private function set_found_comments() {
914 913
 		global $wpdb;
915 914
 
916
-		if ( $this->query_vars['number'] && ! $this->query_vars['no_found_rows'] ) {
915
+		if ($this->query_vars['number'] && ! $this->query_vars['no_found_rows']) {
917 916
 			/**
918 917
 			 * Filters the query used to retrieve found comment count.
919 918
 			 *
@@ -922,9 +921,9 @@  discard block
 block discarded – undo
922 921
 			 * @param string           $found_comments_query SQL query. Default 'SELECT FOUND_ROWS()'.
923 922
 			 * @param WP_Comment_Query $comment_query        The `WP_Comment_Query` instance.
924 923
 			 */
925
-			$found_comments_query = apply_filters( 'found_comments_query', 'SELECT FOUND_ROWS()', $this );
924
+			$found_comments_query = apply_filters('found_comments_query', 'SELECT FOUND_ROWS()', $this);
926 925
 
927
-			$this->found_comments = (int) $wpdb->get_var( $found_comments_query );
926
+			$this->found_comments = (int) $wpdb->get_var($found_comments_query);
928 927
 		}
929 928
 	}
930 929
 
@@ -939,38 +938,38 @@  discard block
 block discarded – undo
939 938
 	 * @param array $comments Array of top-level comments whose descendants should be filled in.
940 939
 	 * @return array
941 940
 	 */
942
-	protected function fill_descendants( $comments ) {
941
+	protected function fill_descendants($comments) {
943 942
 		global $wpdb;
944 943
 
945 944
 		$levels = array(
946
-			0 => wp_list_pluck( $comments, 'comment_ID' ),
945
+			0 => wp_list_pluck($comments, 'comment_ID'),
947 946
 		);
948 947
 
949
-		$key = md5( serialize( wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) ) ) );
950
-		$last_changed = wp_cache_get_last_changed( 'comment' );
948
+		$key = md5(serialize(wp_array_slice_assoc($this->query_vars, array_keys($this->query_var_defaults))));
949
+		$last_changed = wp_cache_get_last_changed('comment');
951 950
 
952 951
 		// Fetch an entire level of the descendant tree at a time.
953 952
 		$level = 0;
954
-		$exclude_keys = array( 'parent', 'parent__in', 'parent__not_in' );
953
+		$exclude_keys = array('parent', 'parent__in', 'parent__not_in');
955 954
 		do {
956 955
 			// Parent-child relationships may be cached. Only query for those that are not.
957 956
 			$child_ids = $uncached_parent_ids = array();
958
-			$_parent_ids = $levels[ $level ];
959
-			foreach ( $_parent_ids as $parent_id ) {
957
+			$_parent_ids = $levels[$level];
958
+			foreach ($_parent_ids as $parent_id) {
960 959
 				$cache_key = "get_comment_child_ids:$parent_id:$key:$last_changed";
961
-				$parent_child_ids = wp_cache_get( $cache_key, 'comment' );
962
-				if ( false !== $parent_child_ids ) {
963
-					$child_ids = array_merge( $child_ids, $parent_child_ids );
960
+				$parent_child_ids = wp_cache_get($cache_key, 'comment');
961
+				if (false !== $parent_child_ids) {
962
+					$child_ids = array_merge($child_ids, $parent_child_ids);
964 963
 				} else {
965 964
 					$uncached_parent_ids[] = $parent_id;
966 965
 				}
967 966
 			}
968 967
 
969
-			if ( $uncached_parent_ids ) {
968
+			if ($uncached_parent_ids) {
970 969
 				// Fetch this level of comments.
971 970
 				$parent_query_args = $this->query_vars;
972
-				foreach ( $exclude_keys as $exclude_key ) {
973
-					$parent_query_args[ $exclude_key ] = '';
971
+				foreach ($exclude_keys as $exclude_key) {
972
+					$parent_query_args[$exclude_key] = '';
974 973
 				}
975 974
 				$parent_query_args['parent__in']    = $uncached_parent_ids;
976 975
 				$parent_query_args['no_found_rows'] = true;
@@ -978,61 +977,61 @@  discard block
 block discarded – undo
978 977
 				$parent_query_args['offset']        = 0;
979 978
 				$parent_query_args['number']        = 0;
980 979
 
981
-				$level_comments = get_comments( $parent_query_args );
980
+				$level_comments = get_comments($parent_query_args);
982 981
 
983 982
 				// Cache parent-child relationships.
984
-				$parent_map = array_fill_keys( $uncached_parent_ids, array() );
985
-				foreach ( $level_comments as $level_comment ) {
986
-					$parent_map[ $level_comment->comment_parent ][] = $level_comment->comment_ID;
983
+				$parent_map = array_fill_keys($uncached_parent_ids, array());
984
+				foreach ($level_comments as $level_comment) {
985
+					$parent_map[$level_comment->comment_parent][] = $level_comment->comment_ID;
987 986
 					$child_ids[] = $level_comment->comment_ID;
988 987
 				}
989 988
 
990
-				foreach ( $parent_map as $parent_id => $children ) {
989
+				foreach ($parent_map as $parent_id => $children) {
991 990
 					$cache_key = "get_comment_child_ids:$parent_id:$key:$last_changed";
992
-					wp_cache_set( $cache_key, $children, 'comment' );
991
+					wp_cache_set($cache_key, $children, 'comment');
993 992
 				}
994 993
 			}
995 994
 
996 995
 			$level++;
997
-			$levels[ $level ] = $child_ids;
998
-		} while ( $child_ids );
996
+			$levels[$level] = $child_ids;
997
+		} while ($child_ids);
999 998
 
1000 999
 		// Prime comment caches for non-top-level comments.
1001 1000
 		$descendant_ids = array();
1002
-		for ( $i = 1, $c = count( $levels ); $i < $c; $i++ ) {
1003
-			$descendant_ids = array_merge( $descendant_ids, $levels[ $i ] );
1001
+		for ($i = 1, $c = count($levels); $i < $c; $i++) {
1002
+			$descendant_ids = array_merge($descendant_ids, $levels[$i]);
1004 1003
 		}
1005 1004
 
1006
-		_prime_comment_caches( $descendant_ids, $this->query_vars['update_comment_meta_cache'] );
1005
+		_prime_comment_caches($descendant_ids, $this->query_vars['update_comment_meta_cache']);
1007 1006
 
1008 1007
 		// Assemble a flat array of all comments + descendants.
1009 1008
 		$all_comments = $comments;
1010
-		foreach ( $descendant_ids as $descendant_id ) {
1011
-			$all_comments[] = get_comment( $descendant_id );
1009
+		foreach ($descendant_ids as $descendant_id) {
1010
+			$all_comments[] = get_comment($descendant_id);
1012 1011
 		}
1013 1012
 
1014 1013
 		// If a threaded representation was requested, build the tree.
1015
-		if ( 'threaded' === $this->query_vars['hierarchical'] ) {
1014
+		if ('threaded' === $this->query_vars['hierarchical']) {
1016 1015
 			$threaded_comments = $ref = array();
1017
-			foreach ( $all_comments as $k => $c ) {
1018
-				$_c = get_comment( $c->comment_ID );
1016
+			foreach ($all_comments as $k => $c) {
1017
+				$_c = get_comment($c->comment_ID);
1019 1018
 
1020 1019
 				// If the comment isn't in the reference array, it goes in the top level of the thread.
1021
-				if ( ! isset( $ref[ $c->comment_parent ] ) ) {
1022
-					$threaded_comments[ $_c->comment_ID ] = $_c;
1023
-					$ref[ $_c->comment_ID ] = $threaded_comments[ $_c->comment_ID ];
1020
+				if ( ! isset($ref[$c->comment_parent])) {
1021
+					$threaded_comments[$_c->comment_ID] = $_c;
1022
+					$ref[$_c->comment_ID] = $threaded_comments[$_c->comment_ID];
1024 1023
 
1025 1024
 				// Otherwise, set it as a child of its parent.
1026 1025
 				} else {
1027 1026
 
1028
-					$ref[ $_c->comment_parent ]->add_child( $_c );
1029
-					$ref[ $_c->comment_ID ] = $ref[ $_c->comment_parent ]->get_child( $_c->comment_ID );
1027
+					$ref[$_c->comment_parent]->add_child($_c);
1028
+					$ref[$_c->comment_ID] = $ref[$_c->comment_parent]->get_child($_c->comment_ID);
1030 1029
 				}
1031 1030
 			}
1032 1031
 
1033 1032
 			// Set the 'populated_children' flag, to ensure additional database queries aren't run.
1034
-			foreach ( $ref as $_ref ) {
1035
-				$_ref->populated_children( true );
1033
+			foreach ($ref as $_ref) {
1034
+				$_ref->populated_children(true);
1036 1035
 			}
1037 1036
 
1038 1037
 			$comments = $threaded_comments;
@@ -1055,17 +1054,17 @@  discard block
 block discarded – undo
1055 1054
 	 * @param array $cols
1056 1055
 	 * @return string
1057 1056
 	 */
1058
-	protected function get_search_sql( $string, $cols ) {
1057
+	protected function get_search_sql($string, $cols) {
1059 1058
 		global $wpdb;
1060 1059
 
1061
-		$like = '%' . $wpdb->esc_like( $string ) . '%';
1060
+		$like = '%'.$wpdb->esc_like($string).'%';
1062 1061
 
1063 1062
 		$searches = array();
1064
-		foreach ( $cols as $col ) {
1065
-			$searches[] = $wpdb->prepare( "$col LIKE %s", $like );
1063
+		foreach ($cols as $col) {
1064
+			$searches[] = $wpdb->prepare("$col LIKE %s", $like);
1066 1065
 		}
1067 1066
 
1068
-		return ' AND (' . implode(' OR ', $searches) . ')';
1067
+		return ' AND ('.implode(' OR ', $searches).')';
1069 1068
 	}
1070 1069
 
1071 1070
 	/**
@@ -1079,7 +1078,7 @@  discard block
 block discarded – undo
1079 1078
 	 * @param string $orderby Alias for the field to order by.
1080 1079
 	 * @return string|false Value to used in the ORDER clause. False otherwise.
1081 1080
 	 */
1082
-	protected function parse_orderby( $orderby ) {
1081
+	protected function parse_orderby($orderby) {
1083 1082
 		global $wpdb;
1084 1083
 
1085 1084
 		$allowed_keys = array(
@@ -1100,30 +1099,30 @@  discard block
 block discarded – undo
1100 1099
 			'user_id',
1101 1100
 		);
1102 1101
 
1103
-		if ( ! empty( $this->query_vars['meta_key'] ) ) {
1102
+		if ( ! empty($this->query_vars['meta_key'])) {
1104 1103
 			$allowed_keys[] = $this->query_vars['meta_key'];
1105 1104
 			$allowed_keys[] = 'meta_value';
1106 1105
 			$allowed_keys[] = 'meta_value_num';
1107 1106
 		}
1108 1107
 
1109 1108
 		$meta_query_clauses = $this->meta_query->get_clauses();
1110
-		if ( $meta_query_clauses ) {
1111
-			$allowed_keys = array_merge( $allowed_keys, array_keys( $meta_query_clauses ) );
1109
+		if ($meta_query_clauses) {
1110
+			$allowed_keys = array_merge($allowed_keys, array_keys($meta_query_clauses));
1112 1111
 		}
1113 1112
 
1114 1113
 		$parsed = false;
1115
-		if ( $orderby == $this->query_vars['meta_key'] || $orderby == 'meta_value' ) {
1114
+		if ($orderby == $this->query_vars['meta_key'] || $orderby == 'meta_value') {
1116 1115
 			$parsed = "$wpdb->commentmeta.meta_value";
1117
-		} elseif ( $orderby == 'meta_value_num' ) {
1116
+		} elseif ($orderby == 'meta_value_num') {
1118 1117
 			$parsed = "$wpdb->commentmeta.meta_value+0";
1119
-		} elseif ( $orderby == 'comment__in' ) {
1120
-			$comment__in = implode( ',', array_map( 'absint', $this->query_vars['comment__in'] ) );
1118
+		} elseif ($orderby == 'comment__in') {
1119
+			$comment__in = implode(',', array_map('absint', $this->query_vars['comment__in']));
1121 1120
 			$parsed = "FIELD( {$wpdb->comments}.comment_ID, $comment__in )";
1122
-		} elseif ( in_array( $orderby, $allowed_keys ) ) {
1121
+		} elseif (in_array($orderby, $allowed_keys)) {
1123 1122
 
1124
-			if ( isset( $meta_query_clauses[ $orderby ] ) ) {
1125
-				$meta_clause = $meta_query_clauses[ $orderby ];
1126
-				$parsed = sprintf( "CAST(%s.meta_value AS %s)", esc_sql( $meta_clause['alias'] ), esc_sql( $meta_clause['cast'] ) );
1123
+			if (isset($meta_query_clauses[$orderby])) {
1124
+				$meta_clause = $meta_query_clauses[$orderby];
1125
+				$parsed = sprintf("CAST(%s.meta_value AS %s)", esc_sql($meta_clause['alias']), esc_sql($meta_clause['cast']));
1127 1126
 			} else {
1128 1127
 				$parsed = "$wpdb->comments.$orderby";
1129 1128
 			}
@@ -1141,12 +1140,12 @@  discard block
 block discarded – undo
1141 1140
 	 * @param string $order The 'order' query variable.
1142 1141
 	 * @return string The sanitized 'order' query variable.
1143 1142
 	 */
1144
-	protected function parse_order( $order ) {
1145
-		if ( ! is_string( $order ) || empty( $order ) ) {
1143
+	protected function parse_order($order) {
1144
+		if ( ! is_string($order) || empty($order)) {
1146 1145
 			return 'DESC';
1147 1146
 		}
1148 1147
 
1149
-		if ( 'ASC' === strtoupper( $order ) ) {
1148
+		if ('ASC' === strtoupper($order)) {
1150 1149
 			return 'ASC';
1151 1150
 		} else {
1152 1151
 			return 'DESC';
Please login to merge, or discard this patch.
src/wp-includes/class-wp-comment.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -366,7 +366,7 @@
 block discarded – undo
366 366
 	 * @access public
367 367
 	 *
368 368
 	 * @param string $name Property name.
369
-	 * @return bool
369
+	 * @return boolean|null
370 370
 	 */
371 371
 	public function __isset( $name ) {
372 372
 		if ( in_array( $name, $this->post_fields ) && 0 !== (int) $this->comment_post_ID ) {
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	 * @access protected
175 175
 	 * @var array
176 176
 	 */
177
-	protected $post_fields = array( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'comment_status', 'ping_status', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_content_filtered', 'post_parent', 'guid', 'menu_order', 'post_type', 'post_mime_type', 'comment_count' );
177
+	protected $post_fields = array('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'comment_status', 'ping_status', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_content_filtered', 'post_parent', 'guid', 'menu_order', 'post_type', 'post_mime_type', 'comment_count');
178 178
 
179 179
 	/**
180 180
 	 * Retrieves a WP_Comment instance.
@@ -188,28 +188,28 @@  discard block
 block discarded – undo
188 188
 	 * @param int $id Comment ID.
189 189
 	 * @return WP_Comment|false Comment object, otherwise false.
190 190
 	 */
191
-	public static function get_instance( $id ) {
191
+	public static function get_instance($id) {
192 192
 		global $wpdb;
193 193
 
194
-		if ( ! is_numeric( $id ) || $id != floor( $id ) || ! $id ) {
194
+		if ( ! is_numeric($id) || $id != floor($id) || ! $id) {
195 195
 			return false;
196 196
 		}
197 197
 
198 198
 		$comment_id = (int) $id;
199 199
 
200
-		$_comment = wp_cache_get( $comment_id, 'comment' );
200
+		$_comment = wp_cache_get($comment_id, 'comment');
201 201
 
202
-		if ( ! $_comment ) {
203
-			$_comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment_id ) );
202
+		if ( ! $_comment) {
203
+			$_comment = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment_id));
204 204
 
205
-			if ( ! $_comment ) {
205
+			if ( ! $_comment) {
206 206
 				return false;
207 207
 			}
208 208
 
209
-			wp_cache_add( $_comment->comment_ID, $_comment, 'comment' );
209
+			wp_cache_add($_comment->comment_ID, $_comment, 'comment');
210 210
 		}
211 211
 
212
-		return new WP_Comment( $_comment );
212
+		return new WP_Comment($_comment);
213 213
 	}
214 214
 
215 215
 	/**
@@ -222,8 +222,8 @@  discard block
 block discarded – undo
222 222
 	 *
223 223
 	 * @param WP_Comment $comment Comment object.
224 224
 	 */
225
-	public function __construct( $comment ) {
226
-		foreach ( get_object_vars( $comment ) as $key => $value ) {
225
+	public function __construct($comment) {
226
+		foreach (get_object_vars($comment) as $key => $value) {
227 227
 			$this->$key = $value;
228 228
 		}
229 229
 	}
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 	 * @return array Object as array.
238 238
 	 */
239 239
 	public function to_array() {
240
-		return get_object_vars( $this );
240
+		return get_object_vars($this);
241 241
 	}
242 242
 
243 243
 	/**
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 	 * }
278 278
 	 * @return array Array of `WP_Comment` objects.
279 279
 	 */
280
-	public function get_children( $args = array() ) {
280
+	public function get_children($args = array()) {
281 281
 		$defaults = array(
282 282
 			'format' => 'tree',
283 283
 			'status' => 'all',
@@ -285,26 +285,26 @@  discard block
 block discarded – undo
285 285
 			'orderby' => '',
286 286
 		);
287 287
 
288
-		$_args = wp_parse_args( $args, $defaults );
288
+		$_args = wp_parse_args($args, $defaults);
289 289
 		$_args['parent'] = $this->comment_ID;
290 290
 
291
-		if ( is_null( $this->children ) ) {
292
-			if ( $this->populated_children ) {
291
+		if (is_null($this->children)) {
292
+			if ($this->populated_children) {
293 293
 				$this->children = array();
294 294
 			} else {
295
-				$this->children = get_comments( $_args );
295
+				$this->children = get_comments($_args);
296 296
 			}
297 297
 		}
298 298
 
299
-		if ( 'flat' === $_args['format'] ) {
299
+		if ('flat' === $_args['format']) {
300 300
 			$children = array();
301
-			foreach ( $this->children as $child ) {
301
+			foreach ($this->children as $child) {
302 302
 				$child_args = $_args;
303 303
 				$child_args['format'] = 'flat';
304 304
 				// get_children() resets this value automatically.
305
-				unset( $child_args['parent'] );
305
+				unset($child_args['parent']);
306 306
 
307
-				$children = array_merge( $children, array( $child ), $child->get_children( $child_args ) );
307
+				$children = array_merge($children, array($child), $child->get_children($child_args));
308 308
 			}
309 309
 		} else {
310 310
 			$children = $this->children;
@@ -323,8 +323,8 @@  discard block
 block discarded – undo
323 323
 	 *
324 324
 	 * @param WP_Comment $child Child comment.
325 325
 	 */
326
-	public function add_child( WP_Comment $child ) {
327
-		$this->children[ $child->comment_ID ] = $child;
326
+	public function add_child(WP_Comment $child) {
327
+		$this->children[$child->comment_ID] = $child;
328 328
 	}
329 329
 
330 330
 	/**
@@ -336,9 +336,9 @@  discard block
 block discarded – undo
336 336
 	 * @param int $child_id ID of the child.
337 337
 	 * @return WP_Comment|bool Returns the comment object if found, otherwise false.
338 338
 	 */
339
-	public function get_child( $child_id ) {
340
-		if ( isset( $this->children[ $child_id ] ) ) {
341
-			return $this->children[ $child_id ];
339
+	public function get_child($child_id) {
340
+		if (isset($this->children[$child_id])) {
341
+			return $this->children[$child_id];
342 342
 		}
343 343
 
344 344
 		return false;
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 	 *
355 355
 	 * @param bool $set Whether the comment's children have already been populated.
356 356
 	 */
357
-	public function populated_children( $set ) {
357
+	public function populated_children($set) {
358 358
 		$this->populated_children = (bool) $set;
359 359
 	}
360 360
 
@@ -369,10 +369,10 @@  discard block
 block discarded – undo
369 369
 	 * @param string $name Property name.
370 370
 	 * @return bool
371 371
 	 */
372
-	public function __isset( $name ) {
373
-		if ( in_array( $name, $this->post_fields ) && 0 !== (int) $this->comment_post_ID ) {
374
-			$post = get_post( $this->comment_post_ID );
375
-			return property_exists( $post, $name );
372
+	public function __isset($name) {
373
+		if (in_array($name, $this->post_fields) && 0 !== (int) $this->comment_post_ID) {
374
+			$post = get_post($this->comment_post_ID);
375
+			return property_exists($post, $name);
376 376
 		}
377 377
 	}
378 378
 
@@ -387,9 +387,9 @@  discard block
 block discarded – undo
387 387
 	 * @param string $name
388 388
 	 * @return mixed
389 389
 	 */
390
-	public function __get( $name ) {
391
-		if ( in_array( $name, $this->post_fields ) ) {
392
-			$post = get_post( $this->comment_post_ID );
390
+	public function __get($name) {
391
+		if (in_array($name, $this->post_fields)) {
392
+			$post = get_post($this->comment_post_ID);
393 393
 			return $post->$name;
394 394
 		}
395 395
 	}
Please login to merge, or discard this patch.
src/wp-includes/class-wp-customize-control.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -209,7 +209,7 @@
 block discarded – undo
209 209
 	 * @since 4.1.0
210 210
 	 * @access public
211 211
 	 *
212
-	 * @return true Always true.
212
+	 * @return boolean Always true.
213 213
 	 */
214 214
 	public function active_callback() {
215 215
 		return true;
Please login to merge, or discard this patch.
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -361,8 +361,9 @@  discard block
 block discarded – undo
361 361
 	 * @uses WP_Customize_Control::render()
362 362
 	 */
363 363
 	final public function maybe_render() {
364
-		if ( ! $this->check_capabilities() )
365
-			return;
364
+		if ( ! $this->check_capabilities() ) {
365
+					return;
366
+		}
366 367
 
367 368
 		/**
368 369
 		 * Fires just before the current Customizer control is rendered.
@@ -411,8 +412,9 @@  discard block
 block discarded – undo
411 412
 	 * @return string Data link parameter, if $setting_key is a valid setting, empty string otherwise.
412 413
 	 */
413 414
 	public function get_link( $setting_key = 'default' ) {
414
-		if ( ! isset( $this->settings[ $setting_key ] ) )
415
-			return '';
415
+		if ( ! isset( $this->settings[ $setting_key ] ) ) {
416
+					return '';
417
+		}
416 418
 
417 419
 		return 'data-customize-setting-link="' . esc_attr( $this->settings[ $setting_key ]->id ) . '"';
418 420
 	}
@@ -467,8 +469,9 @@  discard block
 block discarded – undo
467 469
 				<?php
468 470
 				break;
469 471
 			case 'radio':
470
-				if ( empty( $this->choices ) )
471
-					return;
472
+				if ( empty( $this->choices ) ) {
473
+									return;
474
+				}
472 475
 
473 476
 				$name = '_customize-radio-' . $this->id;
474 477
 
@@ -489,8 +492,9 @@  discard block
 block discarded – undo
489 492
 				endforeach;
490 493
 				break;
491 494
 			case 'select':
492
-				if ( empty( $this->choices ) )
493
-					return;
495
+				if ( empty( $this->choices ) ) {
496
+									return;
497
+				}
494 498
 
495 499
 				?>
496 500
 				<label>
@@ -503,8 +507,9 @@  discard block
 block discarded – undo
503 507
 
504 508
 					<select <?php $this->link(); ?>>
505 509
 						<?php
506
-						foreach ( $this->choices as $value => $label )
507
-							echo '<option value="' . esc_attr( $value ) . '"' . selected( $this->value(), $value, false ) . '>' . $label . '</option>';
510
+						foreach ( $this->choices as $value => $label ) {
511
+													echo '<option value="' . esc_attr( $value ) . '"' . selected( $this->value(), $value, false ) . '>' . $label . '</option>';
512
+						}
508 513
 						?>
509 514
 					</select>
510 515
 				</label>
Please login to merge, or discard this patch.
Spacing   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -191,34 +191,34 @@  discard block
 block discarded – undo
191 191
 	 *                                                 'date' are supported implicitly. Default 'text'.
192 192
 	 * }
193 193
 	 */
194
-	public function __construct( $manager, $id, $args = array() ) {
195
-		$keys = array_keys( get_object_vars( $this ) );
196
-		foreach ( $keys as $key ) {
197
-			if ( isset( $args[ $key ] ) ) {
198
-				$this->$key = $args[ $key ];
194
+	public function __construct($manager, $id, $args = array()) {
195
+		$keys = array_keys(get_object_vars($this));
196
+		foreach ($keys as $key) {
197
+			if (isset($args[$key])) {
198
+				$this->$key = $args[$key];
199 199
 			}
200 200
 		}
201 201
 
202 202
 		$this->manager = $manager;
203 203
 		$this->id = $id;
204
-		if ( empty( $this->active_callback ) ) {
205
-			$this->active_callback = array( $this, 'active_callback' );
204
+		if (empty($this->active_callback)) {
205
+			$this->active_callback = array($this, 'active_callback');
206 206
 		}
207 207
 		self::$instance_count += 1;
208 208
 		$this->instance_number = self::$instance_count;
209 209
 
210 210
 		// Process settings.
211
-		if ( ! isset( $this->settings ) ) {
211
+		if ( ! isset($this->settings)) {
212 212
 			$this->settings = $id;
213 213
 		}
214 214
 
215 215
 		$settings = array();
216
-		if ( is_array( $this->settings ) ) {
217
-			foreach ( $this->settings as $key => $setting ) {
218
-				$settings[ $key ] = $this->manager->get_setting( $setting );
216
+		if (is_array($this->settings)) {
217
+			foreach ($this->settings as $key => $setting) {
218
+				$settings[$key] = $this->manager->get_setting($setting);
219 219
 			}
220
-		} else if ( is_string( $this->settings ) ) {
221
-			$this->setting = $this->manager->get_setting( $this->settings );
220
+		} else if (is_string($this->settings)) {
221
+			$this->setting = $this->manager->get_setting($this->settings);
222 222
 			$settings['default'] = $this->setting;
223 223
 		}
224 224
 		$this->settings = $settings;
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	 */
242 242
 	final public function active() {
243 243
 		$control = $this;
244
-		$active = call_user_func( $this->active_callback, $this );
244
+		$active = call_user_func($this->active_callback, $this);
245 245
 
246 246
 		/**
247 247
 		 * Filters response of WP_Customize_Control::active().
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 		 * @param bool                 $active  Whether the Customizer control is active.
252 252
 		 * @param WP_Customize_Control $control WP_Customize_Control instance.
253 253
 		 */
254
-		$active = apply_filters( 'customize_control_active', $active, $control );
254
+		$active = apply_filters('customize_control_active', $active, $control);
255 255
 
256 256
 		return $active;
257 257
 	}
@@ -280,9 +280,9 @@  discard block
 block discarded – undo
280 280
 	 * @param string $setting_key
281 281
 	 * @return mixed The requested setting's value, if the setting exists.
282 282
 	 */
283
-	final public function value( $setting_key = 'default' ) {
284
-		if ( isset( $this->settings[ $setting_key ] ) ) {
285
-			return $this->settings[ $setting_key ]->value();
283
+	final public function value($setting_key = 'default') {
284
+		if (isset($this->settings[$setting_key])) {
285
+			return $this->settings[$setting_key]->value();
286 286
 		}
287 287
 	}
288 288
 
@@ -293,8 +293,8 @@  discard block
 block discarded – undo
293 293
 	 */
294 294
 	public function to_json() {
295 295
 		$this->json['settings'] = array();
296
-		foreach ( $this->settings as $key => $setting ) {
297
-			$this->json['settings'][ $key ] = $setting->id;
296
+		foreach ($this->settings as $key => $setting) {
297
+			$this->json['settings'][$key] = $setting->id;
298 298
 		}
299 299
 
300 300
 		$this->json['type'] = $this->type;
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 		$this->json['description'] = $this->description;
307 307
 		$this->json['instanceNumber'] = $this->instance_number;
308 308
 
309
-		if ( 'dropdown-pages' === $this->type ) {
309
+		if ('dropdown-pages' === $this->type) {
310 310
 			$this->json['allow_addition'] = $this->allow_addition;
311 311
 		}
312 312
 	}
@@ -336,18 +336,18 @@  discard block
 block discarded – undo
336 336
 	 * @return bool False if theme doesn't support the control or user doesn't have the required permissions, otherwise true.
337 337
 	 */
338 338
 	final public function check_capabilities() {
339
-		if ( ! empty( $this->capability ) && ! current_user_can( $this->capability ) ) {
339
+		if ( ! empty($this->capability) && ! current_user_can($this->capability)) {
340 340
 			return false;
341 341
 		}
342 342
 
343
-		foreach ( $this->settings as $setting ) {
344
-			if ( ! $setting || ! $setting->check_capabilities() ) {
343
+		foreach ($this->settings as $setting) {
344
+			if ( ! $setting || ! $setting->check_capabilities()) {
345 345
 				return false;
346 346
 			}
347 347
 		}
348 348
 
349
-		$section = $this->manager->get_section( $this->section );
350
-		if ( isset( $section ) && ! $section->check_capabilities() ) {
349
+		$section = $this->manager->get_section($this->section);
350
+		if (isset($section) && ! $section->check_capabilities()) {
351 351
 			return false;
352 352
 		}
353 353
 
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 	final public function get_content() {
365 365
 		ob_start();
366 366
 		$this->maybe_render();
367
-		return trim( ob_get_clean() );
367
+		return trim(ob_get_clean());
368 368
 	}
369 369
 
370 370
 	/**
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 	 * @uses WP_Customize_Control::render()
375 375
 	 */
376 376
 	final public function maybe_render() {
377
-		if ( ! $this->check_capabilities() )
377
+		if ( ! $this->check_capabilities())
378 378
 			return;
379 379
 
380 380
 		/**
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 		 *
385 385
 		 * @param WP_Customize_Control $this WP_Customize_Control instance.
386 386
 		 */
387
-		do_action( 'customize_render_control', $this );
387
+		do_action('customize_render_control', $this);
388 388
 
389 389
 		/**
390 390
 		 * Fires just before a specific Customizer control is rendered.
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 		 *
397 397
 		 * @param WP_Customize_Control $this WP_Customize_Control instance.
398 398
 		 */
399
-		do_action( "customize_render_control_{$this->id}", $this );
399
+		do_action("customize_render_control_{$this->id}", $this);
400 400
 
401 401
 		$this->render();
402 402
 	}
@@ -407,10 +407,10 @@  discard block
 block discarded – undo
407 407
 	 * @since 3.4.0
408 408
 	 */
409 409
 	protected function render() {
410
-		$id    = 'customize-control-' . str_replace( array( '[', ']' ), array( '-', '' ), $this->id );
411
-		$class = 'customize-control customize-control-' . $this->type;
410
+		$id    = 'customize-control-'.str_replace(array('[', ']'), array('-', ''), $this->id);
411
+		$class = 'customize-control customize-control-'.$this->type;
412 412
 
413
-		?><li id="<?php echo esc_attr( $id ); ?>" class="<?php echo esc_attr( $class ); ?>">
413
+		?><li id="<?php echo esc_attr($id); ?>" class="<?php echo esc_attr($class); ?>">
414 414
 			<?php $this->render_content(); ?>
415 415
 		</li><?php
416 416
 	}
@@ -423,11 +423,11 @@  discard block
 block discarded – undo
423 423
 	 * @param string $setting_key
424 424
 	 * @return string Data link parameter, if $setting_key is a valid setting, empty string otherwise.
425 425
 	 */
426
-	public function get_link( $setting_key = 'default' ) {
427
-		if ( ! isset( $this->settings[ $setting_key ] ) )
426
+	public function get_link($setting_key = 'default') {
427
+		if ( ! isset($this->settings[$setting_key]))
428 428
 			return '';
429 429
 
430
-		return 'data-customize-setting-link="' . esc_attr( $this->settings[ $setting_key ]->id ) . '"';
430
+		return 'data-customize-setting-link="'.esc_attr($this->settings[$setting_key]->id).'"';
431 431
 	}
432 432
 
433 433
 	/**
@@ -438,8 +438,8 @@  discard block
 block discarded – undo
438 438
 	 *
439 439
 	 * @param string $setting_key
440 440
 	 */
441
-	public function link( $setting_key = 'default' ) {
442
-		echo $this->get_link( $setting_key );
441
+	public function link($setting_key = 'default') {
442
+		echo $this->get_link($setting_key);
443 443
 	}
444 444
 
445 445
 	/**
@@ -449,8 +449,8 @@  discard block
 block discarded – undo
449 449
 	 * @access public
450 450
 	 */
451 451
 	public function input_attrs() {
452
-		foreach ( $this->input_attrs as $attr => $value ) {
453
-			echo $attr . '="' . esc_attr( $value ) . '" ';
452
+		foreach ($this->input_attrs as $attr => $value) {
453
+			echo $attr.'="'.esc_attr($value).'" ';
454 454
 		}
455 455
 	}
456 456
 
@@ -467,57 +467,57 @@  discard block
 block discarded – undo
467 467
 	 * @since 3.4.0
468 468
 	 */
469 469
 	protected function render_content() {
470
-		switch( $this->type ) {
470
+		switch ($this->type) {
471 471
 			case 'checkbox':
472 472
 				?>
473 473
 				<label>
474
-					<input type="checkbox" value="<?php echo esc_attr( $this->value() ); ?>" <?php $this->link(); checked( $this->value() ); ?> />
475
-					<?php echo esc_html( $this->label ); ?>
476
-					<?php if ( ! empty( $this->description ) ) : ?>
474
+					<input type="checkbox" value="<?php echo esc_attr($this->value()); ?>" <?php $this->link(); checked($this->value()); ?> />
475
+					<?php echo esc_html($this->label); ?>
476
+					<?php if ( ! empty($this->description)) : ?>
477 477
 						<span class="description customize-control-description"><?php echo $this->description; ?></span>
478 478
 					<?php endif; ?>
479 479
 				</label>
480 480
 				<?php
481 481
 				break;
482 482
 			case 'radio':
483
-				if ( empty( $this->choices ) )
483
+				if (empty($this->choices))
484 484
 					return;
485 485
 
486
-				$name = '_customize-radio-' . $this->id;
486
+				$name = '_customize-radio-'.$this->id;
487 487
 
488
-				if ( ! empty( $this->label ) ) : ?>
489
-					<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
488
+				if ( ! empty($this->label)) : ?>
489
+					<span class="customize-control-title"><?php echo esc_html($this->label); ?></span>
490 490
 				<?php endif;
491
-				if ( ! empty( $this->description ) ) : ?>
492
-					<span class="description customize-control-description"><?php echo $this->description ; ?></span>
491
+				if ( ! empty($this->description)) : ?>
492
+					<span class="description customize-control-description"><?php echo $this->description; ?></span>
493 493
 				<?php endif;
494 494
 
495
-				foreach ( $this->choices as $value => $label ) :
495
+				foreach ($this->choices as $value => $label) :
496 496
 					?>
497 497
 					<label>
498
-						<input type="radio" value="<?php echo esc_attr( $value ); ?>" name="<?php echo esc_attr( $name ); ?>" <?php $this->link(); checked( $this->value(), $value ); ?> />
499
-						<?php echo esc_html( $label ); ?><br/>
498
+						<input type="radio" value="<?php echo esc_attr($value); ?>" name="<?php echo esc_attr($name); ?>" <?php $this->link(); checked($this->value(), $value); ?> />
499
+						<?php echo esc_html($label); ?><br/>
500 500
 					</label>
501 501
 					<?php
502 502
 				endforeach;
503 503
 				break;
504 504
 			case 'select':
505
-				if ( empty( $this->choices ) )
505
+				if (empty($this->choices))
506 506
 					return;
507 507
 
508 508
 				?>
509 509
 				<label>
510
-					<?php if ( ! empty( $this->label ) ) : ?>
511
-						<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
510
+					<?php if ( ! empty($this->label)) : ?>
511
+						<span class="customize-control-title"><?php echo esc_html($this->label); ?></span>
512 512
 					<?php endif;
513
-					if ( ! empty( $this->description ) ) : ?>
513
+					if ( ! empty($this->description)) : ?>
514 514
 						<span class="description customize-control-description"><?php echo $this->description; ?></span>
515 515
 					<?php endif; ?>
516 516
 
517 517
 					<select <?php $this->link(); ?>>
518 518
 						<?php
519
-						foreach ( $this->choices as $value => $label )
520
-							echo '<option value="' . esc_attr( $value ) . '"' . selected( $this->value(), $value, false ) . '>' . $label . '</option>';
519
+						foreach ($this->choices as $value => $label)
520
+							echo '<option value="'.esc_attr($value).'"'.selected($this->value(), $value, false).'>'.$label.'</option>';
521 521
 						?>
522 522
 					</select>
523 523
 				</label>
@@ -526,29 +526,29 @@  discard block
 block discarded – undo
526 526
 			case 'textarea':
527 527
 				?>
528 528
 				<label>
529
-					<?php if ( ! empty( $this->label ) ) : ?>
530
-						<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
529
+					<?php if ( ! empty($this->label)) : ?>
530
+						<span class="customize-control-title"><?php echo esc_html($this->label); ?></span>
531 531
 					<?php endif;
532
-					if ( ! empty( $this->description ) ) : ?>
532
+					if ( ! empty($this->description)) : ?>
533 533
 						<span class="description customize-control-description"><?php echo $this->description; ?></span>
534 534
 					<?php endif; ?>
535
-					<textarea rows="5" <?php $this->input_attrs(); ?> <?php $this->link(); ?>><?php echo esc_textarea( $this->value() ); ?></textarea>
535
+					<textarea rows="5" <?php $this->input_attrs(); ?> <?php $this->link(); ?>><?php echo esc_textarea($this->value()); ?></textarea>
536 536
 				</label>
537 537
 				<?php
538 538
 				break;
539 539
 			case 'dropdown-pages':
540 540
 				?>
541 541
 				<label>
542
-				<?php if ( ! empty( $this->label ) ) : ?>
543
-					<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
542
+				<?php if ( ! empty($this->label)) : ?>
543
+					<span class="customize-control-title"><?php echo esc_html($this->label); ?></span>
544 544
 				<?php endif;
545
-				if ( ! empty( $this->description ) ) : ?>
545
+				if ( ! empty($this->description)) : ?>
546 546
 					<span class="description customize-control-description"><?php echo $this->description; ?></span>
547 547
 				<?php endif; ?>
548 548
 
549 549
 				<?php
550
-				$dropdown_name = '_customize-dropdown-pages-' . $this->id;
551
-				$show_option_none = __( '&mdash; Select &mdash;' );
550
+				$dropdown_name = '_customize-dropdown-pages-'.$this->id;
551
+				$show_option_none = __('&mdash; Select &mdash;');
552 552
 				$option_none_value = '0';
553 553
 				$dropdown = wp_dropdown_pages(
554 554
 					array(
@@ -559,56 +559,56 @@  discard block
 block discarded – undo
559 559
 						'selected'          => $this->value(),
560 560
 					)
561 561
 				);
562
-				if ( empty( $dropdown ) ) {
563
-					$dropdown = sprintf( '<select id="%1$s" name="%1$s">', esc_attr( $dropdown_name ) );
564
-					$dropdown .= sprintf( '<option value="%1$s">%2$s</option>', esc_attr( $option_none_value ), esc_html( $show_option_none ) );
562
+				if (empty($dropdown)) {
563
+					$dropdown = sprintf('<select id="%1$s" name="%1$s">', esc_attr($dropdown_name));
564
+					$dropdown .= sprintf('<option value="%1$s">%2$s</option>', esc_attr($option_none_value), esc_html($show_option_none));
565 565
 					$dropdown .= '</select>';
566 566
 				}
567 567
 
568 568
 				// Hackily add in the data link parameter.
569
-				$dropdown = str_replace( '<select', '<select ' . $this->get_link(), $dropdown );
569
+				$dropdown = str_replace('<select', '<select '.$this->get_link(), $dropdown);
570 570
 
571 571
 				// Even more hacikly add auto-draft page stubs.
572 572
 				// @todo Eventually this should be removed in favor of the pages being injected into the underlying get_pages() call. See <https://github.com/xwp/wp-customize-posts/pull/250>.
573
-				$nav_menus_created_posts_setting = $this->manager->get_setting( 'nav_menus_created_posts' );
574
-				if ( $nav_menus_created_posts_setting && current_user_can( 'publish_pages' ) ) {
573
+				$nav_menus_created_posts_setting = $this->manager->get_setting('nav_menus_created_posts');
574
+				if ($nav_menus_created_posts_setting && current_user_can('publish_pages')) {
575 575
 					$auto_draft_page_options = '';
576
-					foreach ( $nav_menus_created_posts_setting->value() as $auto_draft_page_id ) {
577
-						$post = get_post( $auto_draft_page_id );
578
-						if ( $post && 'page' === $post->post_type ) {
579
-							$auto_draft_page_options .= sprintf( '<option value="%1$s">%2$s</option>', esc_attr( $post->ID ), esc_html( $post->post_title ) );
576
+					foreach ($nav_menus_created_posts_setting->value() as $auto_draft_page_id) {
577
+						$post = get_post($auto_draft_page_id);
578
+						if ($post && 'page' === $post->post_type) {
579
+							$auto_draft_page_options .= sprintf('<option value="%1$s">%2$s</option>', esc_attr($post->ID), esc_html($post->post_title));
580 580
 						}
581 581
 					}
582
-					if ( $auto_draft_page_options ) {
583
-						$dropdown = str_replace( '</select>', $auto_draft_page_options . '</select>', $dropdown );
582
+					if ($auto_draft_page_options) {
583
+						$dropdown = str_replace('</select>', $auto_draft_page_options.'</select>', $dropdown);
584 584
 					}
585 585
 				}
586 586
 
587 587
 				echo $dropdown;
588 588
 				?>
589 589
 				</label>
590
-				<?php if ( $this->allow_addition && current_user_can( 'publish_pages' ) && current_user_can( 'edit_theme_options' ) ) : // Currently tied to menus functionality. ?>
590
+				<?php if ($this->allow_addition && current_user_can('publish_pages') && current_user_can('edit_theme_options')) : // Currently tied to menus functionality. ?>
591 591
 					<button type="button" class="button-link add-new-toggle"><?php
592 592
 						/* translators: %s: add new page label */
593
-						printf( __( '+ %s' ), get_post_type_object( 'page' )->labels->add_new_item );
593
+						printf(__('+ %s'), get_post_type_object('page')->labels->add_new_item);
594 594
 					?></button>
595 595
 					<div class="new-content-item">
596
-						<label for="create-input-<?php echo $this->id; ?>"><span class="screen-reader-text"><?php _e( 'New page title' ); ?></span></label>
597
-						<input type="text" id="create-input-<?php echo $this->id; ?>" class="create-item-input" placeholder="<?php esc_attr_e( 'New page title&hellip;' ); ?>">
598
-						<button type="button" class="button add-content"><?php _e( 'Add' ); ?></button>
596
+						<label for="create-input-<?php echo $this->id; ?>"><span class="screen-reader-text"><?php _e('New page title'); ?></span></label>
597
+						<input type="text" id="create-input-<?php echo $this->id; ?>" class="create-item-input" placeholder="<?php esc_attr_e('New page title&hellip;'); ?>">
598
+						<button type="button" class="button add-content"><?php _e('Add'); ?></button>
599 599
 					</div>
600 600
 				<?php endif;
601 601
 				break;
602 602
 			default:
603 603
 				?>
604 604
 				<label>
605
-					<?php if ( ! empty( $this->label ) ) : ?>
606
-						<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
605
+					<?php if ( ! empty($this->label)) : ?>
606
+						<span class="customize-control-title"><?php echo esc_html($this->label); ?></span>
607 607
 					<?php endif;
608
-					if ( ! empty( $this->description ) ) : ?>
608
+					if ( ! empty($this->description)) : ?>
609 609
 						<span class="description customize-control-description"><?php echo $this->description; ?></span>
610 610
 					<?php endif; ?>
611
-					<input type="<?php echo esc_attr( $this->type ); ?>" <?php $this->input_attrs(); ?> value="<?php echo esc_attr( $this->value() ); ?>" <?php $this->link(); ?> />
611
+					<input type="<?php echo esc_attr($this->type); ?>" <?php $this->input_attrs(); ?> value="<?php echo esc_attr($this->value()); ?>" <?php $this->link(); ?> />
612 612
 				</label>
613 613
 				<?php
614 614
 				break;
@@ -649,55 +649,55 @@  discard block
 block discarded – undo
649 649
 }
650 650
 
651 651
 /** WP_Customize_Color_Control class */
652
-require_once( ABSPATH . WPINC . '/customize/class-wp-customize-color-control.php' );
652
+require_once(ABSPATH.WPINC.'/customize/class-wp-customize-color-control.php');
653 653
 
654 654
 /** WP_Customize_Media_Control class */
655
-require_once( ABSPATH . WPINC . '/customize/class-wp-customize-media-control.php' );
655
+require_once(ABSPATH.WPINC.'/customize/class-wp-customize-media-control.php');
656 656
 
657 657
 /** WP_Customize_Upload_Control class */
658
-require_once( ABSPATH . WPINC . '/customize/class-wp-customize-upload-control.php' );
658
+require_once(ABSPATH.WPINC.'/customize/class-wp-customize-upload-control.php');
659 659
 
660 660
 /** WP_Customize_Image_Control class */
661
-require_once( ABSPATH . WPINC . '/customize/class-wp-customize-image-control.php' );
661
+require_once(ABSPATH.WPINC.'/customize/class-wp-customize-image-control.php');
662 662
 
663 663
 /** WP_Customize_Background_Image_Control class */
664
-require_once( ABSPATH . WPINC . '/customize/class-wp-customize-background-image-control.php' );
664
+require_once(ABSPATH.WPINC.'/customize/class-wp-customize-background-image-control.php');
665 665
 
666 666
 /** WP_Customize_Background_Position_Control class */
667
-require_once( ABSPATH . WPINC . '/customize/class-wp-customize-background-position-control.php' );
667
+require_once(ABSPATH.WPINC.'/customize/class-wp-customize-background-position-control.php');
668 668
 
669 669
 /** WP_Customize_Cropped_Image_Control class */
670
-require_once( ABSPATH . WPINC . '/customize/class-wp-customize-cropped-image-control.php' );
670
+require_once(ABSPATH.WPINC.'/customize/class-wp-customize-cropped-image-control.php');
671 671
 
672 672
 /** WP_Customize_Site_Icon_Control class */
673
-require_once( ABSPATH . WPINC . '/customize/class-wp-customize-site-icon-control.php' );
673
+require_once(ABSPATH.WPINC.'/customize/class-wp-customize-site-icon-control.php');
674 674
 
675 675
 /** WP_Customize_Header_Image_Control class */
676
-require_once( ABSPATH . WPINC . '/customize/class-wp-customize-header-image-control.php' );
676
+require_once(ABSPATH.WPINC.'/customize/class-wp-customize-header-image-control.php');
677 677
 
678 678
 /** WP_Customize_Theme_Control class */
679
-require_once( ABSPATH . WPINC . '/customize/class-wp-customize-theme-control.php' );
679
+require_once(ABSPATH.WPINC.'/customize/class-wp-customize-theme-control.php');
680 680
 
681 681
 /** WP_Widget_Area_Customize_Control class */
682
-require_once( ABSPATH . WPINC . '/customize/class-wp-widget-area-customize-control.php' );
682
+require_once(ABSPATH.WPINC.'/customize/class-wp-widget-area-customize-control.php');
683 683
 
684 684
 /** WP_Widget_Form_Customize_Control class */
685
-require_once( ABSPATH . WPINC . '/customize/class-wp-widget-form-customize-control.php' );
685
+require_once(ABSPATH.WPINC.'/customize/class-wp-widget-form-customize-control.php');
686 686
 
687 687
 /** WP_Customize_Nav_Menu_Control class */
688
-require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-control.php' );
688
+require_once(ABSPATH.WPINC.'/customize/class-wp-customize-nav-menu-control.php');
689 689
 
690 690
 /** WP_Customize_Nav_Menu_Item_Control class */
691
-require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-item-control.php' );
691
+require_once(ABSPATH.WPINC.'/customize/class-wp-customize-nav-menu-item-control.php');
692 692
 
693 693
 /** WP_Customize_Nav_Menu_Location_Control class */
694
-require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-location-control.php' );
694
+require_once(ABSPATH.WPINC.'/customize/class-wp-customize-nav-menu-location-control.php');
695 695
 
696 696
 /** WP_Customize_Nav_Menu_Name_Control class */
697
-require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-name-control.php' );
697
+require_once(ABSPATH.WPINC.'/customize/class-wp-customize-nav-menu-name-control.php');
698 698
 
699 699
 /** WP_Customize_Nav_Menu_Auto_Add_Control class */
700
-require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-auto-add-control.php' );
700
+require_once(ABSPATH.WPINC.'/customize/class-wp-customize-nav-menu-auto-add-control.php');
701 701
 
702 702
 /** WP_Customize_New_Menu_Control class */
703
-require_once( ABSPATH . WPINC . '/customize/class-wp-customize-new-menu-control.php' );
703
+require_once(ABSPATH.WPINC.'/customize/class-wp-customize-new-menu-control.php');
Please login to merge, or discard this patch.