Completed
Push — master ( a7cd2a...eabd6c )
by Stephen
38:42
created
src/wp-includes/post.php 5 patches
Switch Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -5208,18 +5208,18 @@
 block discarded – undo
5208 5208
 	}
5209 5209
 
5210 5210
 	switch ( $type ) {
5211
-	case 'image':
5212
-		$image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' );
5213
-		return in_array( $ext, $image_exts );
5211
+		case 'image':
5212
+			$image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' );
5213
+			return in_array( $ext, $image_exts );
5214 5214
 
5215
-	case 'audio':
5216
-		return in_array( $ext, wp_get_audio_extensions() );
5215
+		case 'audio':
5216
+			return in_array( $ext, wp_get_audio_extensions() );
5217 5217
 
5218
-	case 'video':
5219
-		return in_array( $ext, wp_get_video_extensions() );
5218
+		case 'video':
5219
+			return in_array( $ext, wp_get_video_extensions() );
5220 5220
 
5221
-	default:
5222
-		return $type === $ext;
5221
+		default:
5222
+			return $type === $ext;
5223 5223
 	}
5224 5224
 }
5225 5225
 
Please login to merge, or discard this patch.
Doc Comments   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
  * @since 1.0.0
389 389
  *
390 390
  * @param string $post Post content.
391
- * @return array Post before ('main'), after ('extended'), and custom read more ('more_text').
391
+ * @return integer Post before ('main'), after ('extended'), and custom read more ('more_text').
392 392
  */
393 393
 function get_extended( $post ) {
394 394
 	//Match the new style more links.
@@ -1801,7 +1801,7 @@  discard block
 block discarded – undo
1801 1801
  *
1802 1802
  * @param int    $post_id    Post ID.
1803 1803
  * @param string $meta_key   Metadata name.
1804
- * @param mixed  $meta_value Optional. Metadata value. Must be serializable if
1804
+ * @param string  $meta_value Optional. Metadata value. Must be serializable if
1805 1805
  *                           non-scalar. Default empty.
1806 1806
  * @return bool True on success, false on failure.
1807 1807
  */
@@ -2729,7 +2729,7 @@  discard block
 block discarded – undo
2729 2729
  *
2730 2730
  * @global wpdb $wpdb WordPress database abstraction object.
2731 2731
  *
2732
- * @param int|WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
2732
+ * @param integer $post Optional. Post ID or post object. Defaults to global $post.
2733 2733
  * @return mixed|void False on failure.
2734 2734
  */
2735 2735
 function wp_trash_post_comments( $post = null ) {
@@ -2785,8 +2785,8 @@  discard block
 block discarded – undo
2785 2785
  *
2786 2786
  * @global wpdb $wpdb WordPress database abstraction object.
2787 2787
  *
2788
- * @param int|WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
2789
- * @return true|void
2788
+ * @param integer $post Optional. Post ID or post object. Defaults to global $post.
2789
+ * @return null|boolean
2790 2790
  */
2791 2791
 function wp_untrash_post_comments( $post = null ) {
2792 2792
 	global $wpdb;
@@ -5130,7 +5130,7 @@  discard block
 block discarded – undo
5130 5130
  * @since 4.2.0
5131 5131
  *
5132 5132
  * @param string      $type    Attachment type. Accepts 'image', 'audio', or 'video'.
5133
- * @param int|WP_Post $post_id Optional. Attachment ID. Default 0.
5133
+ * @param integer $post_id Optional. Attachment ID. Default 0.
5134 5134
  * @return bool True if one of the accepted types, false otherwise.
5135 5135
  */
5136 5136
 function wp_attachment_is( $type, $post_id = 0 ) {
@@ -5180,7 +5180,7 @@  discard block
 block discarded – undo
5180 5180
  * @since 4.2.0 Modified into wrapper for wp_attachment_is() and
5181 5181
  *              allowed WP_Post object to be passed.
5182 5182
  *
5183
- * @param int|WP_Post $post Optional. Attachment ID. Default 0.
5183
+ * @param integer $post Optional. Attachment ID. Default 0.
5184 5184
  * @return bool Whether the attachment is an image.
5185 5185
  */
5186 5186
 function wp_attachment_is_image( $post = 0 ) {
@@ -5192,7 +5192,7 @@  discard block
 block discarded – undo
5192 5192
  *
5193 5193
  * @since 2.1.0
5194 5194
  *
5195
- * @param string|int $mime MIME type or attachment ID.
5195
+ * @param integer $mime MIME type or attachment ID.
5196 5196
  * @return string|false Icon, false otherwise.
5197 5197
  */
5198 5198
 function wp_mime_type_icon( $mime = 0 ) {
@@ -5967,7 +5967,7 @@  discard block
 block discarded – undo
5967 5967
  *
5968 5968
  * @since 3.3.0
5969 5969
  *
5970
- * @param int|WP_Post $post Post ID or post object where thumbnail should be removed from.
5970
+ * @param integer $post Post ID or post object where thumbnail should be removed from.
5971 5971
  * @return bool True on success, false on failure.
5972 5972
  */
5973 5973
 function delete_post_thumbnail( $post ) {
@@ -6090,7 +6090,7 @@  discard block
 block discarded – undo
6090 6090
  * @access private
6091 6091
  *
6092 6092
  * @param string $post_name Slug.
6093
- * @param string $post_ID   Optional. Post ID that should be ignored. Default 0.
6093
+ * @param integer $post_ID   Optional. Post ID that should be ignored. Default 0.
6094 6094
  */
6095 6095
 function wp_add_trashed_suffix_to_post_name_for_trashed_posts( $post_name, $post_ID = 0 ) {
6096 6096
 	$trashed_posts_with_desired_slug = get_posts( array(
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Core Post API
4
- *
5
- * @package WordPress
6
- * @subpackage Post
7
- */
3
+	 * Core Post API
4
+	 *
5
+	 * @package WordPress
6
+	 * @subpackage Post
7
+	 */
8 8
 
9 9
 //
10 10
 // Post Type Registration
Please login to merge, or discard this patch.
Spacing   +1269 added lines, -1269 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@  discard block
 block discarded – undo
16 16
  * @since 2.9.0
17 17
  */
18 18
 function create_initial_post_types() {
19
-	register_post_type( 'post', array(
19
+	register_post_type('post', array(
20 20
 		'labels' => array(
21
-			'name_admin_bar' => _x( 'Post', 'add new on admin bar' ),
21
+			'name_admin_bar' => _x('Post', 'add new on admin bar'),
22 22
 		),
23 23
 		'public'  => true,
24 24
 		'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
@@ -30,12 +30,12 @@  discard block
 block discarded – undo
30 30
 		'rewrite' => false,
31 31
 		'query_var' => false,
32 32
 		'delete_with_user' => true,
33
-		'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'post-formats' ),
34
-	) );
33
+		'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'post-formats'),
34
+	));
35 35
 
36
-	register_post_type( 'page', array(
36
+	register_post_type('page', array(
37 37
 		'labels' => array(
38
-			'name_admin_bar' => _x( 'Page', 'add new on admin bar' ),
38
+			'name_admin_bar' => _x('Page', 'add new on admin bar'),
39 39
 		),
40 40
 		'public' => true,
41 41
 		'publicly_queryable' => false,
@@ -48,16 +48,16 @@  discard block
 block discarded – undo
48 48
 		'rewrite' => false,
49 49
 		'query_var' => false,
50 50
 		'delete_with_user' => true,
51
-		'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes', 'custom-fields', 'comments', 'revisions' ),
52
-	) );
51
+		'supports' => array('title', 'editor', 'author', 'thumbnail', 'page-attributes', 'custom-fields', 'comments', 'revisions'),
52
+	));
53 53
 
54
-	register_post_type( 'attachment', array(
54
+	register_post_type('attachment', array(
55 55
 		'labels' => array(
56 56
 			'name' => _x('Media', 'post type general name'),
57
-			'name_admin_bar' => _x( 'Media', 'add new from admin bar' ),
58
-			'add_new' => _x( 'Add New', 'add new media' ),
59
- 			'edit_item' => __( 'Edit Media' ),
60
- 			'view_item' => __( 'View Attachment Page' ),
57
+			'name_admin_bar' => _x('Media', 'add new from admin bar'),
58
+			'add_new' => _x('Add New', 'add new media'),
59
+ 			'edit_item' => __('Edit Media'),
60
+ 			'view_item' => __('View Attachment Page'),
61 61
 		),
62 62
 		'public' => true,
63 63
 		'show_ui' => true,
@@ -73,15 +73,15 @@  discard block
 block discarded – undo
73 73
 		'query_var' => false,
74 74
 		'show_in_nav_menus' => false,
75 75
 		'delete_with_user' => true,
76
-		'supports' => array( 'title', 'author', 'comments' ),
77
-	) );
78
-	add_post_type_support( 'attachment:audio', 'thumbnail' );
79
-	add_post_type_support( 'attachment:video', 'thumbnail' );
76
+		'supports' => array('title', 'author', 'comments'),
77
+	));
78
+	add_post_type_support('attachment:audio', 'thumbnail');
79
+	add_post_type_support('attachment:video', 'thumbnail');
80 80
 
81
-	register_post_type( 'revision', array(
81
+	register_post_type('revision', array(
82 82
 		'labels' => array(
83
-			'name' => __( 'Revisions' ),
84
-			'singular_name' => __( 'Revision' ),
83
+			'name' => __('Revisions'),
84
+			'singular_name' => __('Revision'),
85 85
 		),
86 86
 		'public' => false,
87 87
 		'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
@@ -93,13 +93,13 @@  discard block
 block discarded – undo
93 93
 		'query_var' => false,
94 94
 		'can_export' => false,
95 95
 		'delete_with_user' => true,
96
-		'supports' => array( 'author' ),
97
-	) );
96
+		'supports' => array('author'),
97
+	));
98 98
 
99
-	register_post_type( 'nav_menu_item', array(
99
+	register_post_type('nav_menu_item', array(
100 100
 		'labels' => array(
101
-			'name' => __( 'Navigation Menu Items' ),
102
-			'singular_name' => __( 'Navigation Menu Item' ),
101
+			'name' => __('Navigation Menu Items'),
102
+			'singular_name' => __('Navigation Menu Item'),
103 103
 		),
104 104
 		'public' => false,
105 105
 		'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
@@ -107,63 +107,63 @@  discard block
 block discarded – undo
107 107
 		'rewrite' => false,
108 108
 		'delete_with_user' => false,
109 109
 		'query_var' => false,
110
-	) );
110
+	));
111 111
 
112
-	register_post_status( 'publish', array(
113
-		'label'       => _x( 'Published', 'post status' ),
112
+	register_post_status('publish', array(
113
+		'label'       => _x('Published', 'post status'),
114 114
 		'public'      => true,
115 115
 		'_builtin'    => true, /* internal use only. */
116
-		'label_count' => _n_noop( 'Published <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>' ),
117
-	) );
116
+		'label_count' => _n_noop('Published <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>'),
117
+	));
118 118
 
119
-	register_post_status( 'future', array(
120
-		'label'       => _x( 'Scheduled', 'post status' ),
119
+	register_post_status('future', array(
120
+		'label'       => _x('Scheduled', 'post status'),
121 121
 		'protected'   => true,
122 122
 		'_builtin'    => true, /* internal use only. */
123
-		'label_count' => _n_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>' ),
124
-	) );
123
+		'label_count' => _n_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>'),
124
+	));
125 125
 
126
-	register_post_status( 'draft', array(
127
-		'label'       => _x( 'Draft', 'post status' ),
126
+	register_post_status('draft', array(
127
+		'label'       => _x('Draft', 'post status'),
128 128
 		'protected'   => true,
129 129
 		'_builtin'    => true, /* internal use only. */
130
-		'label_count' => _n_noop( 'Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>' ),
131
-	) );
130
+		'label_count' => _n_noop('Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>'),
131
+	));
132 132
 
133
-	register_post_status( 'pending', array(
134
-		'label'       => _x( 'Pending', 'post status' ),
133
+	register_post_status('pending', array(
134
+		'label'       => _x('Pending', 'post status'),
135 135
 		'protected'   => true,
136 136
 		'_builtin'    => true, /* internal use only. */
137
-		'label_count' => _n_noop( 'Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>' ),
138
-	) );
137
+		'label_count' => _n_noop('Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>'),
138
+	));
139 139
 
140
-	register_post_status( 'private', array(
141
-		'label'       => _x( 'Private', 'post status' ),
140
+	register_post_status('private', array(
141
+		'label'       => _x('Private', 'post status'),
142 142
 		'private'     => true,
143 143
 		'_builtin'    => true, /* internal use only. */
144
-		'label_count' => _n_noop( 'Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>' ),
145
-	) );
144
+		'label_count' => _n_noop('Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>'),
145
+	));
146 146
 
147
-	register_post_status( 'trash', array(
148
-		'label'       => _x( 'Trash', 'post status' ),
147
+	register_post_status('trash', array(
148
+		'label'       => _x('Trash', 'post status'),
149 149
 		'internal'    => true,
150 150
 		'_builtin'    => true, /* internal use only. */
151
-		'label_count' => _n_noop( 'Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>' ),
151
+		'label_count' => _n_noop('Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>'),
152 152
 		'show_in_admin_status_list' => true,
153
-	) );
153
+	));
154 154
 
155
-	register_post_status( 'auto-draft', array(
155
+	register_post_status('auto-draft', array(
156 156
 		'label'    => 'auto-draft',
157 157
 		'internal' => true,
158 158
 		'_builtin' => true, /* internal use only. */
159
-	) );
159
+	));
160 160
 
161
-	register_post_status( 'inherit', array(
161
+	register_post_status('inherit', array(
162 162
 		'label'    => 'inherit',
163 163
 		'internal' => true,
164 164
 		'_builtin' => true, /* internal use only. */
165 165
 		'exclude_from_search' => false,
166
-	) );
166
+	));
167 167
 }
168 168
 
169 169
 /**
@@ -184,15 +184,15 @@  discard block
 block discarded – undo
184 184
  * @param bool $unfiltered    Optional. Whether to apply filters. Default false.
185 185
  * @return string|false The file path to where the attached file should be, false otherwise.
186 186
  */
187
-function get_attached_file( $attachment_id, $unfiltered = false ) {
188
-	$file = get_post_meta( $attachment_id, '_wp_attached_file', true );
187
+function get_attached_file($attachment_id, $unfiltered = false) {
188
+	$file = get_post_meta($attachment_id, '_wp_attached_file', true);
189 189
 
190 190
 	// If the file is relative, prepend upload dir.
191
-	if ( $file && 0 !== strpos( $file, '/' ) && ! preg_match( '|^.:\\\|', $file ) && ( ( $uploads = wp_get_upload_dir() ) && false === $uploads['error'] ) ) {
192
-		$file = $uploads['basedir'] . "/$file";
191
+	if ($file && 0 !== strpos($file, '/') && ! preg_match('|^.:\\\|', $file) && (($uploads = wp_get_upload_dir()) && false === $uploads['error'])) {
192
+		$file = $uploads['basedir']."/$file";
193 193
 	}
194 194
 
195
-	if ( $unfiltered ) {
195
+	if ($unfiltered) {
196 196
 		return $file;
197 197
 	}
198 198
 
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 	 * @param string $file          Path to attached file.
205 205
 	 * @param int    $attachment_id Attachment ID.
206 206
 	 */
207
-	return apply_filters( 'get_attached_file', $file, $attachment_id );
207
+	return apply_filters('get_attached_file', $file, $attachment_id);
208 208
 }
209 209
 
210 210
 /**
@@ -219,8 +219,8 @@  discard block
 block discarded – undo
219 219
  * @param string $file          File path for the attachment.
220 220
  * @return bool True on success, false on failure.
221 221
  */
222
-function update_attached_file( $attachment_id, $file ) {
223
-	if ( !get_post( $attachment_id ) )
222
+function update_attached_file($attachment_id, $file) {
223
+	if ( ! get_post($attachment_id))
224 224
 		return false;
225 225
 
226 226
 	/**
@@ -231,12 +231,12 @@  discard block
 block discarded – undo
231 231
 	 * @param string $file          Path to the attached file to update.
232 232
 	 * @param int    $attachment_id Attachment ID.
233 233
 	 */
234
-	$file = apply_filters( 'update_attached_file', $file, $attachment_id );
234
+	$file = apply_filters('update_attached_file', $file, $attachment_id);
235 235
 
236
-	if ( $file = _wp_relative_upload_path( $file ) )
237
-		return update_post_meta( $attachment_id, '_wp_attached_file', $file );
236
+	if ($file = _wp_relative_upload_path($file))
237
+		return update_post_meta($attachment_id, '_wp_attached_file', $file);
238 238
 	else
239
-		return delete_post_meta( $attachment_id, '_wp_attached_file' );
239
+		return delete_post_meta($attachment_id, '_wp_attached_file');
240 240
 }
241 241
 
242 242
 /**
@@ -249,13 +249,13 @@  discard block
 block discarded – undo
249 249
  * @param string $path Full path to the file.
250 250
  * @return string Relative path on success, unchanged path on failure.
251 251
  */
252
-function _wp_relative_upload_path( $path ) {
252
+function _wp_relative_upload_path($path) {
253 253
 	$new_path = $path;
254 254
 
255 255
 	$uploads = wp_get_upload_dir();
256
-	if ( 0 === strpos( $new_path, $uploads['basedir'] ) ) {
257
-			$new_path = str_replace( $uploads['basedir'], '', $new_path );
258
-			$new_path = ltrim( $new_path, '/' );
256
+	if (0 === strpos($new_path, $uploads['basedir'])) {
257
+			$new_path = str_replace($uploads['basedir'], '', $new_path);
258
+			$new_path = ltrim($new_path, '/');
259 259
 	}
260 260
 
261 261
 	/**
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 	 * @param string $new_path Relative path to the file.
267 267
 	 * @param string $path     Full path to the file.
268 268
 	 */
269
-	return apply_filters( '_wp_relative_upload_path', $new_path, $path );
269
+	return apply_filters('_wp_relative_upload_path', $new_path, $path);
270 270
 }
271 271
 
272 272
 /**
@@ -321,17 +321,17 @@  discard block
 block discarded – undo
321 321
  * @return array Array of children, where the type of each element is determined by $output parameter.
322 322
  *               Empty array on failure.
323 323
  */
324
-function get_children( $args = '', $output = OBJECT ) {
324
+function get_children($args = '', $output = OBJECT) {
325 325
 	$kids = array();
326
-	if ( empty( $args ) ) {
327
-		if ( isset( $GLOBALS['post'] ) ) {
328
-			$args = array('post_parent' => (int) $GLOBALS['post']->post_parent );
326
+	if (empty($args)) {
327
+		if (isset($GLOBALS['post'])) {
328
+			$args = array('post_parent' => (int) $GLOBALS['post']->post_parent);
329 329
 		} else {
330 330
 			return $kids;
331 331
 		}
332
-	} elseif ( is_object( $args ) ) {
333
-		$args = array('post_parent' => (int) $args->post_parent );
334
-	} elseif ( is_numeric( $args ) ) {
332
+	} elseif (is_object($args)) {
333
+		$args = array('post_parent' => (int) $args->post_parent);
334
+	} elseif (is_numeric($args)) {
335 335
 		$args = array('post_parent' => (int) $args);
336 336
 	}
337 337
 
@@ -340,32 +340,32 @@  discard block
 block discarded – undo
340 340
 		'post_status' => 'any', 'post_parent' => 0,
341 341
 	);
342 342
 
343
-	$r = wp_parse_args( $args, $defaults );
343
+	$r = wp_parse_args($args, $defaults);
344 344
 
345
-	$children = get_posts( $r );
345
+	$children = get_posts($r);
346 346
 
347
-	if ( ! $children )
347
+	if ( ! $children)
348 348
 		return $kids;
349 349
 
350
-	if ( ! empty( $r['fields'] ) )
350
+	if ( ! empty($r['fields']))
351 351
 		return $children;
352 352
 
353 353
 	update_post_cache($children);
354 354
 
355
-	foreach ( $children as $key => $child )
355
+	foreach ($children as $key => $child)
356 356
 		$kids[$child->ID] = $children[$key];
357 357
 
358
-	if ( $output == OBJECT ) {
358
+	if ($output == OBJECT) {
359 359
 		return $kids;
360
-	} elseif ( $output == ARRAY_A ) {
360
+	} elseif ($output == ARRAY_A) {
361 361
 		$weeuns = array();
362
-		foreach ( (array) $kids as $kid ) {
362
+		foreach ((array) $kids as $kid) {
363 363
 			$weeuns[$kid->ID] = get_object_vars($kids[$kid->ID]);
364 364
 		}
365 365
 		return $weeuns;
366
-	} elseif ( $output == ARRAY_N ) {
366
+	} elseif ($output == ARRAY_N) {
367 367
 		$babes = array();
368
-		foreach ( (array) $kids as $kid ) {
368
+		foreach ((array) $kids as $kid) {
369 369
 			$babes[$kid->ID] = array_values(get_object_vars($kids[$kid->ID]));
370 370
 		}
371 371
 		return $babes;
@@ -390,9 +390,9 @@  discard block
 block discarded – undo
390 390
  * @param string $post Post content.
391 391
  * @return array Post before ('main'), after ('extended'), and custom read more ('more_text').
392 392
  */
393
-function get_extended( $post ) {
393
+function get_extended($post) {
394 394
 	//Match the new style more links.
395
-	if ( preg_match('/<!--more(.*?)?-->/', $post, $matches) ) {
395
+	if (preg_match('/<!--more(.*?)?-->/', $post, $matches)) {
396 396
 		list($main, $extended) = explode($matches[0], $post, 2);
397 397
 		$more_text = $matches[1];
398 398
 	} else {
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 	$extended = preg_replace('/^[\s]*(.*)[\s]*$/', '\\1', $extended);
407 407
 	$more_text = preg_replace('/^[\s]*(.*)[\s]*$/', '\\1', $more_text);
408 408
 
409
-	return array( 'main' => $main, 'extended' => $extended, 'more_text' => $more_text );
409
+	return array('main' => $main, 'extended' => $extended, 'more_text' => $more_text);
410 410
 }
411 411
 
412 412
 /**
@@ -427,34 +427,34 @@  discard block
 block discarded – undo
427 427
  * @return WP_Post|array|null Type corresponding to $output on success or null on failure.
428 428
  *                            When $output is OBJECT, a `WP_Post` instance is returned.
429 429
  */
430
-function get_post( $post = null, $output = OBJECT, $filter = 'raw' ) {
431
-	if ( empty( $post ) && isset( $GLOBALS['post'] ) )
430
+function get_post($post = null, $output = OBJECT, $filter = 'raw') {
431
+	if (empty($post) && isset($GLOBALS['post']))
432 432
 		$post = $GLOBALS['post'];
433 433
 
434
-	if ( $post instanceof WP_Post ) {
434
+	if ($post instanceof WP_Post) {
435 435
 		$_post = $post;
436
-	} elseif ( is_object( $post ) ) {
437
-		if ( empty( $post->filter ) ) {
438
-			$_post = sanitize_post( $post, 'raw' );
439
-			$_post = new WP_Post( $_post );
440
-		} elseif ( 'raw' == $post->filter ) {
441
-			$_post = new WP_Post( $post );
436
+	} elseif (is_object($post)) {
437
+		if (empty($post->filter)) {
438
+			$_post = sanitize_post($post, 'raw');
439
+			$_post = new WP_Post($_post);
440
+		} elseif ('raw' == $post->filter) {
441
+			$_post = new WP_Post($post);
442 442
 		} else {
443
-			$_post = WP_Post::get_instance( $post->ID );
443
+			$_post = WP_Post::get_instance($post->ID);
444 444
 		}
445 445
 	} else {
446
-		$_post = WP_Post::get_instance( $post );
446
+		$_post = WP_Post::get_instance($post);
447 447
 	}
448 448
 
449
-	if ( ! $_post )
449
+	if ( ! $_post)
450 450
 		return null;
451 451
 
452
-	$_post = $_post->filter( $filter );
452
+	$_post = $_post->filter($filter);
453 453
 
454
-	if ( $output == ARRAY_A )
454
+	if ($output == ARRAY_A)
455 455
 		return $_post->to_array();
456
-	elseif ( $output == ARRAY_N )
457
-		return array_values( $_post->to_array() );
456
+	elseif ($output == ARRAY_N)
457
+		return array_values($_post->to_array());
458 458
 
459 459
 	return $_post;
460 460
 }
@@ -467,19 +467,19 @@  discard block
 block discarded – undo
467 467
  * @param int|WP_Post $post Post ID or post object.
468 468
  * @return array Ancestor IDs or empty array if none are found.
469 469
  */
470
-function get_post_ancestors( $post ) {
471
-	$post = get_post( $post );
470
+function get_post_ancestors($post) {
471
+	$post = get_post($post);
472 472
 
473
-	if ( ! $post || empty( $post->post_parent ) || $post->post_parent == $post->ID )
473
+	if ( ! $post || empty($post->post_parent) || $post->post_parent == $post->ID)
474 474
 		return array();
475 475
 
476 476
 	$ancestors = array();
477 477
 
478 478
 	$id = $ancestors[] = $post->post_parent;
479 479
 
480
-	while ( $ancestor = get_post( $id ) ) {
480
+	while ($ancestor = get_post($id)) {
481 481
 		// Loop detection: If the ancestor has been seen before, break.
482
-		if ( empty( $ancestor->post_parent ) || ( $ancestor->post_parent == $post->ID ) || in_array( $ancestor->post_parent, $ancestors ) )
482
+		if (empty($ancestor->post_parent) || ($ancestor->post_parent == $post->ID) || in_array($ancestor->post_parent, $ancestors))
483 483
 			break;
484 484
 
485 485
 		$id = $ancestors[] = $ancestor->post_parent;
@@ -508,13 +508,13 @@  discard block
 block discarded – undo
508 508
  *                             or 'display'. Default 'display'.
509 509
  * @return string The value of the post field on success, empty string on failure.
510 510
  */
511
-function get_post_field( $field, $post = null, $context = 'display' ) {
512
-	$post = get_post( $post );
511
+function get_post_field($field, $post = null, $context = 'display') {
512
+	$post = get_post($post);
513 513
 
514
-	if ( !$post )
514
+	if ( ! $post)
515 515
 		return '';
516 516
 
517
-	if ( !isset($post->$field) )
517
+	if ( ! isset($post->$field))
518 518
 		return '';
519 519
 
520 520
 	return sanitize_post_field($field, $post->$field, $post->ID, $context);
@@ -531,10 +531,10 @@  discard block
 block discarded – undo
531 531
  * @param int|WP_Post $ID Optional. Post ID or post object. Default empty.
532 532
  * @return string|false The mime type on success, false on failure.
533 533
  */
534
-function get_post_mime_type( $ID = '' ) {
534
+function get_post_mime_type($ID = '') {
535 535
 	$post = get_post($ID);
536 536
 
537
-	if ( is_object($post) )
537
+	if (is_object($post))
538 538
 		return $post->post_mime_type;
539 539
 
540 540
 	return false;
@@ -551,25 +551,25 @@  discard block
 block discarded – undo
551 551
  * @param int|WP_Post $ID Optional. Post ID or post object. Default empty.
552 552
  * @return string|false Post status on success, false on failure.
553 553
  */
554
-function get_post_status( $ID = '' ) {
554
+function get_post_status($ID = '') {
555 555
 	$post = get_post($ID);
556 556
 
557
-	if ( !is_object($post) )
557
+	if ( ! is_object($post))
558 558
 		return false;
559 559
 
560
-	if ( 'attachment' == $post->post_type ) {
561
-		if ( 'private' == $post->post_status )
560
+	if ('attachment' == $post->post_type) {
561
+		if ('private' == $post->post_status)
562 562
 			return 'private';
563 563
 
564 564
 		// Unattached attachments are assumed to be published.
565
-		if ( ( 'inherit' == $post->post_status ) && ( 0 == $post->post_parent) )
565
+		if (('inherit' == $post->post_status) && (0 == $post->post_parent))
566 566
 			return 'publish';
567 567
 
568 568
 		// Inherit status from the parent.
569
-		if ( $post->post_parent && ( $post->ID != $post->post_parent ) ) {
570
-			$parent_post_status = get_post_status( $post->post_parent );
571
-			if ( 'trash' == $parent_post_status ) {
572
-				return get_post_meta( $post->post_parent, '_wp_trash_meta_status', true );
569
+		if ($post->post_parent && ($post->ID != $post->post_parent)) {
570
+			$parent_post_status = get_post_status($post->post_parent);
571
+			if ('trash' == $parent_post_status) {
572
+				return get_post_meta($post->post_parent, '_wp_trash_meta_status', true);
573 573
 			} else {
574 574
 				return $parent_post_status;
575 575
 			}
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
 	 * @param string  $post_status The post status.
586 586
 	 * @param WP_Post $post        The post object.
587 587
 	 */
588
-	return apply_filters( 'get_post_status', $post->post_status, $post );
588
+	return apply_filters('get_post_status', $post->post_status, $post);
589 589
 }
590 590
 
591 591
 /**
@@ -600,10 +600,10 @@  discard block
 block discarded – undo
600 600
  */
601 601
 function get_post_statuses() {
602 602
 	$status = array(
603
-		'draft'   => __( 'Draft' ),
604
-		'pending' => __( 'Pending Review' ),
605
-		'private' => __( 'Private' ),
606
-		'publish' => __( 'Published' )
603
+		'draft'   => __('Draft'),
604
+		'pending' => __('Pending Review'),
605
+		'private' => __('Private'),
606
+		'publish' => __('Published')
607 607
 	);
608 608
 
609 609
 	return $status;
@@ -621,9 +621,9 @@  discard block
 block discarded – undo
621 621
  */
622 622
 function get_page_statuses() {
623 623
 	$status = array(
624
-		'draft'   => __( 'Draft' ),
625
-		'private' => __( 'Private' ),
626
-		'publish' => __( 'Published' )
624
+		'draft'   => __('Draft'),
625
+		'private' => __('Private'),
626
+		'publish' => __('Published')
627 627
 	);
628 628
 
629 629
 	return $status;
@@ -672,10 +672,10 @@  discard block
 block discarded – undo
672 672
  * }
673 673
  * @return object
674 674
  */
675
-function register_post_status( $post_status, $args = array() ) {
675
+function register_post_status($post_status, $args = array()) {
676 676
 	global $wp_post_statuses;
677 677
 
678
-	if (!is_array($wp_post_statuses))
678
+	if ( ! is_array($wp_post_statuses))
679 679
 		$wp_post_statuses = array();
680 680
 
681 681
 	// Args prefixed with an underscore are reserved for internal use.
@@ -699,38 +699,38 @@  discard block
 block discarded – undo
699 699
 	$args->name = $post_status;
700 700
 
701 701
 	// Set various defaults.
702
-	if ( null === $args->public && null === $args->internal && null === $args->protected && null === $args->private )
702
+	if (null === $args->public && null === $args->internal && null === $args->protected && null === $args->private)
703 703
 		$args->internal = true;
704 704
 
705
-	if ( null === $args->public  )
705
+	if (null === $args->public)
706 706
 		$args->public = false;
707 707
 
708
-	if ( null === $args->private  )
708
+	if (null === $args->private)
709 709
 		$args->private = false;
710 710
 
711
-	if ( null === $args->protected  )
711
+	if (null === $args->protected)
712 712
 		$args->protected = false;
713 713
 
714
-	if ( null === $args->internal  )
714
+	if (null === $args->internal)
715 715
 		$args->internal = false;
716 716
 
717
-	if ( null === $args->publicly_queryable )
717
+	if (null === $args->publicly_queryable)
718 718
 		$args->publicly_queryable = $args->public;
719 719
 
720
-	if ( null === $args->exclude_from_search )
720
+	if (null === $args->exclude_from_search)
721 721
 		$args->exclude_from_search = $args->internal;
722 722
 
723
-	if ( null === $args->show_in_admin_all_list )
724
-		$args->show_in_admin_all_list = !$args->internal;
723
+	if (null === $args->show_in_admin_all_list)
724
+		$args->show_in_admin_all_list = ! $args->internal;
725 725
 
726
-	if ( null === $args->show_in_admin_status_list )
727
-		$args->show_in_admin_status_list = !$args->internal;
726
+	if (null === $args->show_in_admin_status_list)
727
+		$args->show_in_admin_status_list = ! $args->internal;
728 728
 
729
-	if ( false === $args->label )
729
+	if (false === $args->label)
730 730
 		$args->label = $post_status;
731 731
 
732
-	if ( false === $args->label_count )
733
-		$args->label_count = array( $args->label, $args->label );
732
+	if (false === $args->label_count)
733
+		$args->label_count = array($args->label, $args->label);
734 734
 
735 735
 	$wp_post_statuses[$post_status] = $args;
736 736
 
@@ -749,10 +749,10 @@  discard block
 block discarded – undo
749 749
  * @param string $post_status The name of a registered post status.
750 750
  * @return object|null A post status object.
751 751
  */
752
-function get_post_status_object( $post_status ) {
752
+function get_post_status_object($post_status) {
753 753
 	global $wp_post_statuses;
754 754
 
755
-	if ( empty($wp_post_statuses[$post_status]) )
755
+	if (empty($wp_post_statuses[$post_status]))
756 756
 		return null;
757 757
 
758 758
 	return $wp_post_statuses[$post_status];
@@ -775,7 +775,7 @@  discard block
 block discarded – undo
775 775
  *                               Default 'and'.
776 776
  * @return array A list of post status names or objects.
777 777
  */
778
-function get_post_stati( $args = array(), $output = 'names', $operator = 'and' ) {
778
+function get_post_stati($args = array(), $output = 'names', $operator = 'and') {
779 779
 	global $wp_post_statuses;
780 780
 
781 781
 	$field = ('names' == $output) ? 'name' : false;
@@ -795,11 +795,11 @@  discard block
 block discarded – undo
795 795
  * @param string $post_type Post type name
796 796
  * @return bool Whether post type is hierarchical.
797 797
  */
798
-function is_post_type_hierarchical( $post_type ) {
799
-	if ( ! post_type_exists( $post_type ) )
798
+function is_post_type_hierarchical($post_type) {
799
+	if ( ! post_type_exists($post_type))
800 800
 		return false;
801 801
 
802
-	$post_type = get_post_type_object( $post_type );
802
+	$post_type = get_post_type_object($post_type);
803 803
 	return $post_type->hierarchical;
804 804
 }
805 805
 
@@ -813,8 +813,8 @@  discard block
 block discarded – undo
813 813
  * @param string $post_type Post type name.
814 814
  * @return bool Whether post type is registered.
815 815
  */
816
-function post_type_exists( $post_type ) {
817
-	return (bool) get_post_type_object( $post_type );
816
+function post_type_exists($post_type) {
817
+	return (bool) get_post_type_object($post_type);
818 818
 }
819 819
 
820 820
 /**
@@ -825,8 +825,8 @@  discard block
 block discarded – undo
825 825
  * @param int|WP_Post|null $post Optional. Post ID or post object. Default is global $post.
826 826
  * @return string|false          Post type on success, false on failure.
827 827
  */
828
-function get_post_type( $post = null ) {
829
-	if ( $post = get_post( $post ) )
828
+function get_post_type($post = null) {
829
+	if ($post = get_post($post))
830 830
 		return $post->post_type;
831 831
 
832 832
 	return false;
@@ -844,14 +844,14 @@  discard block
 block discarded – undo
844 844
  * @param string $post_type The name of a registered post type.
845 845
  * @return object|null A post type object.
846 846
  */
847
-function get_post_type_object( $post_type ) {
847
+function get_post_type_object($post_type) {
848 848
 	global $wp_post_types;
849 849
 
850
-	if ( ! is_scalar( $post_type ) || empty( $wp_post_types[ $post_type ] ) ) {
850
+	if ( ! is_scalar($post_type) || empty($wp_post_types[$post_type])) {
851 851
 		return null;
852 852
 	}
853 853
 
854
-	return $wp_post_types[ $post_type ];
854
+	return $wp_post_types[$post_type];
855 855
 }
856 856
 
857 857
 /**
@@ -872,7 +872,7 @@  discard block
 block discarded – undo
872 872
  *                               must match; 'not' means no elements may match. Default 'and'.
873 873
  * @return array A list of post type names or objects.
874 874
  */
875
-function get_post_types( $args = array(), $output = 'names', $operator = 'and' ) {
875
+function get_post_types($args = array(), $output = 'names', $operator = 'and') {
876 876
 	global $wp_post_types;
877 877
 
878 878
 	$field = ('names' == $output) ? 'name' : false;
@@ -995,16 +995,16 @@  discard block
 block discarded – undo
995 995
  * }
996 996
  * @return object|WP_Error The registered post type object, or an error object.
997 997
  */
998
-function register_post_type( $post_type, $args = array() ) {
998
+function register_post_type($post_type, $args = array()) {
999 999
 	global $wp_post_types, $wp_rewrite, $wp;
1000 1000
 
1001
-	if ( ! is_array( $wp_post_types ) ) {
1001
+	if ( ! is_array($wp_post_types)) {
1002 1002
 		$wp_post_types = array();
1003 1003
 	}
1004 1004
 
1005 1005
 	// Sanitize post type name
1006
-	$post_type = sanitize_key( $post_type );
1007
-	$args      = wp_parse_args( $args );
1006
+	$post_type = sanitize_key($post_type);
1007
+	$args      = wp_parse_args($args);
1008 1008
 
1009 1009
 	/**
1010 1010
 	 * Filter the arguments for registering a post type.
@@ -1014,9 +1014,9 @@  discard block
 block discarded – undo
1014 1014
 	 * @param array  $args      Array of arguments for registering a post type.
1015 1015
 	 * @param string $post_type Post type key.
1016 1016
 	 */
1017
-	$args = apply_filters( 'register_post_type_args', $args, $post_type );
1017
+	$args = apply_filters('register_post_type_args', $args, $post_type);
1018 1018
 
1019
-	$has_edit_link = ! empty( $args['_edit_link'] );
1019
+	$has_edit_link = ! empty($args['_edit_link']);
1020 1020
 
1021 1021
 	// Args prefixed with an underscore are reserved for internal use.
1022 1022
 	$defaults = array(
@@ -1046,136 +1046,136 @@  discard block
 block discarded – undo
1046 1046
 		'_builtin'             => false,
1047 1047
 		'_edit_link'           => 'post.php?post=%d',
1048 1048
 	);
1049
-	$args = array_merge( $defaults, $args );
1049
+	$args = array_merge($defaults, $args);
1050 1050
 	$args = (object) $args;
1051 1051
 
1052 1052
 	$args->name = $post_type;
1053 1053
 
1054
-	if ( empty( $post_type ) || strlen( $post_type ) > 20 ) {
1055
-		_doing_it_wrong( __FUNCTION__, __( 'Post type names must be between 1 and 20 characters in length.' ), '4.2' );
1056
-		return new WP_Error( 'post_type_length_invalid', __( 'Post type names must be between 1 and 20 characters in length.' ) );
1054
+	if (empty($post_type) || strlen($post_type) > 20) {
1055
+		_doing_it_wrong(__FUNCTION__, __('Post type names must be between 1 and 20 characters in length.'), '4.2');
1056
+		return new WP_Error('post_type_length_invalid', __('Post type names must be between 1 and 20 characters in length.'));
1057 1057
 	}
1058 1058
 
1059 1059
 	// If not set, default to the setting for public.
1060
-	if ( null === $args->publicly_queryable )
1060
+	if (null === $args->publicly_queryable)
1061 1061
 		$args->publicly_queryable = $args->public;
1062 1062
 
1063 1063
 	// If not set, default to the setting for public.
1064
-	if ( null === $args->show_ui )
1064
+	if (null === $args->show_ui)
1065 1065
 		$args->show_ui = $args->public;
1066 1066
 
1067 1067
 	// If not set, default to the setting for show_ui.
1068
-	if ( null === $args->show_in_menu || ! $args->show_ui )
1068
+	if (null === $args->show_in_menu || ! $args->show_ui)
1069 1069
 		$args->show_in_menu = $args->show_ui;
1070 1070
 
1071 1071
 	// If not set, default to the whether the full UI is shown.
1072
-	if ( null === $args->show_in_admin_bar )
1072
+	if (null === $args->show_in_admin_bar)
1073 1073
 		$args->show_in_admin_bar = (bool) $args->show_in_menu;
1074 1074
 
1075 1075
 	// If not set, default to the setting for public.
1076
-	if ( null === $args->show_in_nav_menus )
1076
+	if (null === $args->show_in_nav_menus)
1077 1077
 		$args->show_in_nav_menus = $args->public;
1078 1078
 
1079 1079
 	// If not set, default to true if not public, false if public.
1080
-	if ( null === $args->exclude_from_search )
1081
-		$args->exclude_from_search = !$args->public;
1080
+	if (null === $args->exclude_from_search)
1081
+		$args->exclude_from_search = ! $args->public;
1082 1082
 
1083 1083
 	// Back compat with quirky handling in version 3.0. #14122.
1084
-	if ( empty( $args->capabilities ) && null === $args->map_meta_cap && in_array( $args->capability_type, array( 'post', 'page' ) ) )
1084
+	if (empty($args->capabilities) && null === $args->map_meta_cap && in_array($args->capability_type, array('post', 'page')))
1085 1085
 		$args->map_meta_cap = true;
1086 1086
 
1087 1087
 	// If not set, default to false.
1088
-	if ( null === $args->map_meta_cap )
1088
+	if (null === $args->map_meta_cap)
1089 1089
 		$args->map_meta_cap = false;
1090 1090
 
1091 1091
 	// If there's no specified edit link and no UI, remove the edit link.
1092
-	if ( ! $args->show_ui && ! $has_edit_link ) {
1092
+	if ( ! $args->show_ui && ! $has_edit_link) {
1093 1093
 		$args->_edit_link = '';
1094 1094
 	}
1095 1095
 
1096
-	$args->cap = get_post_type_capabilities( $args );
1097
-	unset( $args->capabilities );
1096
+	$args->cap = get_post_type_capabilities($args);
1097
+	unset($args->capabilities);
1098 1098
 
1099
-	if ( is_array( $args->capability_type ) )
1099
+	if (is_array($args->capability_type))
1100 1100
 		$args->capability_type = $args->capability_type[0];
1101 1101
 
1102
-	if ( ! empty( $args->supports ) ) {
1103
-		add_post_type_support( $post_type, $args->supports );
1104
-		unset( $args->supports );
1105
-	} elseif ( false !== $args->supports ) {
1102
+	if ( ! empty($args->supports)) {
1103
+		add_post_type_support($post_type, $args->supports);
1104
+		unset($args->supports);
1105
+	} elseif (false !== $args->supports) {
1106 1106
 		// Add default features
1107
-		add_post_type_support( $post_type, array( 'title', 'editor' ) );
1107
+		add_post_type_support($post_type, array('title', 'editor'));
1108 1108
 	}
1109 1109
 
1110
-	if ( false !== $args->query_var ) {
1111
-		if ( true === $args->query_var )
1110
+	if (false !== $args->query_var) {
1111
+		if (true === $args->query_var)
1112 1112
 			$args->query_var = $post_type;
1113 1113
 		else
1114
-			$args->query_var = sanitize_title_with_dashes( $args->query_var );
1114
+			$args->query_var = sanitize_title_with_dashes($args->query_var);
1115 1115
 
1116
-		if ( $wp && is_post_type_viewable( $args ) ) {
1117
-			$wp->add_query_var( $args->query_var );
1116
+		if ($wp && is_post_type_viewable($args)) {
1117
+			$wp->add_query_var($args->query_var);
1118 1118
 		}
1119 1119
 	}
1120 1120
 
1121
-	if ( false !== $args->rewrite && ( is_admin() || '' != get_option( 'permalink_structure' ) ) ) {
1122
-		if ( ! is_array( $args->rewrite ) )
1121
+	if (false !== $args->rewrite && (is_admin() || '' != get_option('permalink_structure'))) {
1122
+		if ( ! is_array($args->rewrite))
1123 1123
 			$args->rewrite = array();
1124
-		if ( empty( $args->rewrite['slug'] ) )
1124
+		if (empty($args->rewrite['slug']))
1125 1125
 			$args->rewrite['slug'] = $post_type;
1126
-		if ( ! isset( $args->rewrite['with_front'] ) )
1126
+		if ( ! isset($args->rewrite['with_front']))
1127 1127
 			$args->rewrite['with_front'] = true;
1128
-		if ( ! isset( $args->rewrite['pages'] ) )
1128
+		if ( ! isset($args->rewrite['pages']))
1129 1129
 			$args->rewrite['pages'] = true;
1130
-		if ( ! isset( $args->rewrite['feeds'] ) || ! $args->has_archive )
1130
+		if ( ! isset($args->rewrite['feeds']) || ! $args->has_archive)
1131 1131
 			$args->rewrite['feeds'] = (bool) $args->has_archive;
1132
-		if ( ! isset( $args->rewrite['ep_mask'] ) ) {
1133
-			if ( isset( $args->permalink_epmask ) )
1132
+		if ( ! isset($args->rewrite['ep_mask'])) {
1133
+			if (isset($args->permalink_epmask))
1134 1134
 				$args->rewrite['ep_mask'] = $args->permalink_epmask;
1135 1135
 			else
1136 1136
 				$args->rewrite['ep_mask'] = EP_PERMALINK;
1137 1137
 		}
1138 1138
 
1139
-		if ( $args->hierarchical )
1140
-			add_rewrite_tag( "%$post_type%", '(.+?)', $args->query_var ? "{$args->query_var}=" : "post_type=$post_type&pagename=" );
1139
+		if ($args->hierarchical)
1140
+			add_rewrite_tag("%$post_type%", '(.+?)', $args->query_var ? "{$args->query_var}=" : "post_type=$post_type&pagename=");
1141 1141
 		else
1142
-			add_rewrite_tag( "%$post_type%", '([^/]+)', $args->query_var ? "{$args->query_var}=" : "post_type=$post_type&name=" );
1142
+			add_rewrite_tag("%$post_type%", '([^/]+)', $args->query_var ? "{$args->query_var}=" : "post_type=$post_type&name=");
1143 1143
 
1144
-		if ( $args->has_archive ) {
1144
+		if ($args->has_archive) {
1145 1145
 			$archive_slug = $args->has_archive === true ? $args->rewrite['slug'] : $args->has_archive;
1146
-			if ( $args->rewrite['with_front'] )
1147
-				$archive_slug = substr( $wp_rewrite->front, 1 ) . $archive_slug;
1146
+			if ($args->rewrite['with_front'])
1147
+				$archive_slug = substr($wp_rewrite->front, 1).$archive_slug;
1148 1148
 			else
1149
-				$archive_slug = $wp_rewrite->root . $archive_slug;
1149
+				$archive_slug = $wp_rewrite->root.$archive_slug;
1150 1150
 
1151
-			add_rewrite_rule( "{$archive_slug}/?$", "index.php?post_type=$post_type", 'top' );
1152
-			if ( $args->rewrite['feeds'] && $wp_rewrite->feeds ) {
1153
-				$feeds = '(' . trim( implode( '|', $wp_rewrite->feeds ) ) . ')';
1154
-				add_rewrite_rule( "{$archive_slug}/feed/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' );
1155
-				add_rewrite_rule( "{$archive_slug}/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' );
1151
+			add_rewrite_rule("{$archive_slug}/?$", "index.php?post_type=$post_type", 'top');
1152
+			if ($args->rewrite['feeds'] && $wp_rewrite->feeds) {
1153
+				$feeds = '('.trim(implode('|', $wp_rewrite->feeds)).')';
1154
+				add_rewrite_rule("{$archive_slug}/feed/$feeds/?$", "index.php?post_type=$post_type".'&feed=$matches[1]', 'top');
1155
+				add_rewrite_rule("{$archive_slug}/$feeds/?$", "index.php?post_type=$post_type".'&feed=$matches[1]', 'top');
1156 1156
 			}
1157
-			if ( $args->rewrite['pages'] )
1158
-				add_rewrite_rule( "{$archive_slug}/{$wp_rewrite->pagination_base}/([0-9]{1,})/?$", "index.php?post_type=$post_type" . '&paged=$matches[1]', 'top' );
1157
+			if ($args->rewrite['pages'])
1158
+				add_rewrite_rule("{$archive_slug}/{$wp_rewrite->pagination_base}/([0-9]{1,})/?$", "index.php?post_type=$post_type".'&paged=$matches[1]', 'top');
1159 1159
 		}
1160 1160
 
1161 1161
 		$permastruct_args = $args->rewrite;
1162 1162
 		$permastruct_args['feed'] = $permastruct_args['feeds'];
1163
-		add_permastruct( $post_type, "{$args->rewrite['slug']}/%$post_type%", $permastruct_args );
1163
+		add_permastruct($post_type, "{$args->rewrite['slug']}/%$post_type%", $permastruct_args);
1164 1164
 	}
1165 1165
 
1166 1166
 	// Register the post type meta box if a custom callback was specified.
1167
-	if ( $args->register_meta_box_cb )
1168
-		add_action( 'add_meta_boxes_' . $post_type, $args->register_meta_box_cb, 10, 1 );
1167
+	if ($args->register_meta_box_cb)
1168
+		add_action('add_meta_boxes_'.$post_type, $args->register_meta_box_cb, 10, 1);
1169 1169
 
1170
-	$args->labels = get_post_type_labels( $args );
1170
+	$args->labels = get_post_type_labels($args);
1171 1171
 	$args->label = $args->labels->name;
1172 1172
 
1173
-	$wp_post_types[ $post_type ] = $args;
1173
+	$wp_post_types[$post_type] = $args;
1174 1174
 
1175
-	add_action( 'future_' . $post_type, '_future_post_hook', 5, 2 );
1175
+	add_action('future_'.$post_type, '_future_post_hook', 5, 2);
1176 1176
 
1177
-	foreach ( $args->taxonomies as $taxonomy ) {
1178
-		register_taxonomy_for_object_type( $taxonomy, $post_type );
1177
+	foreach ($args->taxonomies as $taxonomy) {
1178
+		register_taxonomy_for_object_type($taxonomy, $post_type);
1179 1179
 	}
1180 1180
 
1181 1181
 	/**
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 	 * @param string $post_type Post type.
1187 1187
 	 * @param object $args      Arguments used to register the post type.
1188 1188
 	 */
1189
-	do_action( 'registered_post_type', $post_type, $args );
1189
+	do_action('registered_post_type', $post_type, $args);
1190 1190
 
1191 1191
 	return $args;
1192 1192
 }
@@ -1207,59 +1207,59 @@  discard block
 block discarded – undo
1207 1207
  * @param string $post_type Post type to unregister.
1208 1208
  * @return bool|WP_Error True on success, WP_Error on failure or if the post type doesn't exist.
1209 1209
  */
1210
-function unregister_post_type( $post_type ) {
1211
-	if ( ! post_type_exists( $post_type ) ) {
1212
-		return new WP_Error( 'invalid_post_type', __( 'Invalid post type' ) );
1210
+function unregister_post_type($post_type) {
1211
+	if ( ! post_type_exists($post_type)) {
1212
+		return new WP_Error('invalid_post_type', __('Invalid post type'));
1213 1213
 	}
1214 1214
 
1215
-	$post_type_args = get_post_type_object( $post_type );
1215
+	$post_type_args = get_post_type_object($post_type);
1216 1216
 
1217 1217
 	// Do not allow unregistering internal post types.
1218
-	if ( $post_type_args->_builtin ) {
1219
-		return new WP_Error( 'invalid_post_type', __( 'Unregistering a built-in post type is not allowed' ) );
1218
+	if ($post_type_args->_builtin) {
1219
+		return new WP_Error('invalid_post_type', __('Unregistering a built-in post type is not allowed'));
1220 1220
 	}
1221 1221
 
1222 1222
 	global $wp, $wp_rewrite, $_wp_post_type_features, $post_type_meta_caps, $wp_post_types;
1223 1223
 
1224 1224
 	// Remove query var.
1225
-	if ( false !== $post_type_args->query_var ) {
1226
-		$wp->remove_query_var( $post_type_args->query_var );
1225
+	if (false !== $post_type_args->query_var) {
1226
+		$wp->remove_query_var($post_type_args->query_var);
1227 1227
 	}
1228 1228
 
1229 1229
 	// Remove any rewrite rules, permastructs, and rules.
1230
-	if ( false !== $post_type_args->rewrite ) {
1231
-		remove_rewrite_tag( "%$post_type%" );
1232
-		remove_permastruct( $post_type );
1233
-		foreach ( $wp_rewrite->extra_rules_top as $regex => $query ) {
1234
-			if ( false !== strpos( $query, "index.php?post_type=$post_type" ) ) {
1235
-				unset( $wp_rewrite->extra_rules_top[ $regex ] );
1230
+	if (false !== $post_type_args->rewrite) {
1231
+		remove_rewrite_tag("%$post_type%");
1232
+		remove_permastruct($post_type);
1233
+		foreach ($wp_rewrite->extra_rules_top as $regex => $query) {
1234
+			if (false !== strpos($query, "index.php?post_type=$post_type")) {
1235
+				unset($wp_rewrite->extra_rules_top[$regex]);
1236 1236
 			}
1237 1237
 		}
1238 1238
 	}
1239 1239
 
1240 1240
 	// Remove registered custom meta capabilities.
1241
-	foreach ( $post_type_args->cap as $cap ) {
1242
-		unset( $post_type_meta_caps[ $cap ] );
1241
+	foreach ($post_type_args->cap as $cap) {
1242
+		unset($post_type_meta_caps[$cap]);
1243 1243
 	}
1244 1244
 
1245 1245
 	// Remove all post type support.
1246
-	unset( $_wp_post_type_features[ $post_type ] );
1246
+	unset($_wp_post_type_features[$post_type]);
1247 1247
 
1248 1248
 	// Unregister the post type meta box if a custom callback was specified.
1249
-	if ( $post_type_args->register_meta_box_cb ) {
1250
-		remove_action( 'add_meta_boxes_' . $post_type, $post_type_args->register_meta_box_cb );
1249
+	if ($post_type_args->register_meta_box_cb) {
1250
+		remove_action('add_meta_boxes_'.$post_type, $post_type_args->register_meta_box_cb);
1251 1251
 	}
1252 1252
 
1253 1253
 	// Remove the post type from all taxonomies.
1254
-	foreach ( get_object_taxonomies( $post_type ) as $taxonomy ) {
1255
-		unregister_taxonomy_for_object_type( $taxonomy, $post_type );
1254
+	foreach (get_object_taxonomies($post_type) as $taxonomy) {
1255
+		unregister_taxonomy_for_object_type($taxonomy, $post_type);
1256 1256
 	}
1257 1257
 
1258 1258
 	// Remove the future post hook action.
1259
-	remove_action( 'future_' . $post_type, '_future_post_hook', 5 );
1259
+	remove_action('future_'.$post_type, '_future_post_hook', 5);
1260 1260
 
1261 1261
 	// Remove the post type.
1262
-	unset( $wp_post_types[ $post_type ] );
1262
+	unset($wp_post_types[$post_type]);
1263 1263
 
1264 1264
 	/**
1265 1265
 	 * Fires after a post type was unregistered.
@@ -1268,7 +1268,7 @@  discard block
 block discarded – undo
1268 1268
 	 *
1269 1269
 	 * @param string $post_type Post type key.
1270 1270
 	 */
1271
-	do_action( 'unregistered_post_type', $post_type );
1271
+	do_action('unregistered_post_type', $post_type);
1272 1272
 
1273 1273
 	return true;
1274 1274
 }
@@ -1328,48 +1328,48 @@  discard block
 block discarded – undo
1328 1328
  * @param object $args Post type registration arguments.
1329 1329
  * @return object object with all the capabilities as member variables.
1330 1330
  */
1331
-function get_post_type_capabilities( $args ) {
1332
-	if ( ! is_array( $args->capability_type ) )
1333
-		$args->capability_type = array( $args->capability_type, $args->capability_type . 's' );
1331
+function get_post_type_capabilities($args) {
1332
+	if ( ! is_array($args->capability_type))
1333
+		$args->capability_type = array($args->capability_type, $args->capability_type.'s');
1334 1334
 
1335 1335
 	// Singular base for meta capabilities, plural base for primitive capabilities.
1336
-	list( $singular_base, $plural_base ) = $args->capability_type;
1336
+	list($singular_base, $plural_base) = $args->capability_type;
1337 1337
 
1338 1338
 	$default_capabilities = array(
1339 1339
 		// Meta capabilities
1340
-		'edit_post'          => 'edit_'         . $singular_base,
1341
-		'read_post'          => 'read_'         . $singular_base,
1342
-		'delete_post'        => 'delete_'       . $singular_base,
1340
+		'edit_post'          => 'edit_'.$singular_base,
1341
+		'read_post'          => 'read_'.$singular_base,
1342
+		'delete_post'        => 'delete_'.$singular_base,
1343 1343
 		// Primitive capabilities used outside of map_meta_cap():
1344
-		'edit_posts'         => 'edit_'         . $plural_base,
1345
-		'edit_others_posts'  => 'edit_others_'  . $plural_base,
1346
-		'publish_posts'      => 'publish_'      . $plural_base,
1347
-		'read_private_posts' => 'read_private_' . $plural_base,
1344
+		'edit_posts'         => 'edit_'.$plural_base,
1345
+		'edit_others_posts'  => 'edit_others_'.$plural_base,
1346
+		'publish_posts'      => 'publish_'.$plural_base,
1347
+		'read_private_posts' => 'read_private_'.$plural_base,
1348 1348
 	);
1349 1349
 
1350 1350
 	// Primitive capabilities used within map_meta_cap():
1351
-	if ( $args->map_meta_cap ) {
1351
+	if ($args->map_meta_cap) {
1352 1352
 		$default_capabilities_for_mapping = array(
1353 1353
 			'read'                   => 'read',
1354
-			'delete_posts'           => 'delete_'           . $plural_base,
1355
-			'delete_private_posts'   => 'delete_private_'   . $plural_base,
1356
-			'delete_published_posts' => 'delete_published_' . $plural_base,
1357
-			'delete_others_posts'    => 'delete_others_'    . $plural_base,
1358
-			'edit_private_posts'     => 'edit_private_'     . $plural_base,
1359
-			'edit_published_posts'   => 'edit_published_'   . $plural_base,
1354
+			'delete_posts'           => 'delete_'.$plural_base,
1355
+			'delete_private_posts'   => 'delete_private_'.$plural_base,
1356
+			'delete_published_posts' => 'delete_published_'.$plural_base,
1357
+			'delete_others_posts'    => 'delete_others_'.$plural_base,
1358
+			'edit_private_posts'     => 'edit_private_'.$plural_base,
1359
+			'edit_published_posts'   => 'edit_published_'.$plural_base,
1360 1360
 		);
1361
-		$default_capabilities = array_merge( $default_capabilities, $default_capabilities_for_mapping );
1361
+		$default_capabilities = array_merge($default_capabilities, $default_capabilities_for_mapping);
1362 1362
 	}
1363 1363
 
1364
-	$capabilities = array_merge( $default_capabilities, $args->capabilities );
1364
+	$capabilities = array_merge($default_capabilities, $args->capabilities);
1365 1365
 
1366 1366
 	// Post creation capability simply maps to edit_posts by default:
1367
-	if ( ! isset( $capabilities['create_posts'] ) )
1367
+	if ( ! isset($capabilities['create_posts']))
1368 1368
 		$capabilities['create_posts'] = $capabilities['edit_posts'];
1369 1369
 
1370 1370
 	// Remember meta capabilities for future reference.
1371
-	if ( $args->map_meta_cap )
1372
-		_post_type_meta_capabilities( $capabilities );
1371
+	if ($args->map_meta_cap)
1372
+		_post_type_meta_capabilities($capabilities);
1373 1373
 
1374 1374
 	return (object) $capabilities;
1375 1375
 }
@@ -1384,12 +1384,12 @@  discard block
 block discarded – undo
1384 1384
  *
1385 1385
  * @param array $capabilities Post type meta capabilities.
1386 1386
  */
1387
-function _post_type_meta_capabilities( $capabilities = null ) {
1387
+function _post_type_meta_capabilities($capabilities = null) {
1388 1388
 	global $post_type_meta_caps;
1389 1389
 
1390
-	foreach ( $capabilities as $core => $custom ) {
1391
-		if ( in_array( $core, array( 'read_post', 'delete_post', 'edit_post' ) ) ) {
1392
-			$post_type_meta_caps[ $custom ] = $core;
1390
+	foreach ($capabilities as $core => $custom) {
1391
+		if (in_array($core, array('read_post', 'delete_post', 'edit_post'))) {
1392
+			$post_type_meta_caps[$custom] = $core;
1393 1393
 		}
1394 1394
 	}
1395 1395
 }
@@ -1442,34 +1442,34 @@  discard block
 block discarded – undo
1442 1442
  * @param object $post_type_object Post type object.
1443 1443
  * @return object object with all the labels as member variables.
1444 1444
  */
1445
-function get_post_type_labels( $post_type_object ) {
1445
+function get_post_type_labels($post_type_object) {
1446 1446
 	$nohier_vs_hier_defaults = array(
1447
-		'name' => array( _x('Posts', 'post type general name'), _x('Pages', 'post type general name') ),
1448
-		'singular_name' => array( _x('Post', 'post type singular name'), _x('Page', 'post type singular name') ),
1449
-		'add_new' => array( _x('Add New', 'post'), _x('Add New', 'page') ),
1450
-		'add_new_item' => array( __('Add New Post'), __('Add New Page') ),
1451
-		'edit_item' => array( __('Edit Post'), __('Edit Page') ),
1452
-		'new_item' => array( __('New Post'), __('New Page') ),
1453
-		'view_item' => array( __('View Post'), __('View Page') ),
1454
-		'search_items' => array( __('Search Posts'), __('Search Pages') ),
1455
-		'not_found' => array( __('No posts found.'), __('No pages found.') ),
1456
-		'not_found_in_trash' => array( __('No posts found in Trash.'), __('No pages found in Trash.') ),
1457
-		'parent_item_colon' => array( null, __('Parent Page:') ),
1458
-		'all_items' => array( __( 'All Posts' ), __( 'All Pages' ) ),
1459
-		'archives' => array( __( 'Post Archives' ), __( 'Page Archives' ) ),
1460
-		'insert_into_item' => array( __( 'Insert into post' ), __( 'Insert into page' ) ),
1461
-		'uploaded_to_this_item' => array( __( 'Uploaded to this post' ), __( 'Uploaded to this page' ) ),
1462
-		'featured_image' => array( __( 'Featured Image' ), __( 'Featured Image' ) ),
1463
-		'set_featured_image' => array( __( 'Set featured image' ), __( 'Set featured image' ) ),
1464
-		'remove_featured_image' => array( __( 'Remove featured image' ), __( 'Remove featured image' ) ),
1465
-		'use_featured_image' => array( __( 'Use as featured image' ), __( 'Use as featured image' ) ),
1466
-		'filter_items_list' => array( __( 'Filter posts list' ), __( 'Filter pages list' ) ),
1467
-		'items_list_navigation' => array( __( 'Posts list navigation' ), __( 'Pages list navigation' ) ),
1468
-		'items_list' => array( __( 'Posts list' ), __( 'Pages list' ) ),
1447
+		'name' => array(_x('Posts', 'post type general name'), _x('Pages', 'post type general name')),
1448
+		'singular_name' => array(_x('Post', 'post type singular name'), _x('Page', 'post type singular name')),
1449
+		'add_new' => array(_x('Add New', 'post'), _x('Add New', 'page')),
1450
+		'add_new_item' => array(__('Add New Post'), __('Add New Page')),
1451
+		'edit_item' => array(__('Edit Post'), __('Edit Page')),
1452
+		'new_item' => array(__('New Post'), __('New Page')),
1453
+		'view_item' => array(__('View Post'), __('View Page')),
1454
+		'search_items' => array(__('Search Posts'), __('Search Pages')),
1455
+		'not_found' => array(__('No posts found.'), __('No pages found.')),
1456
+		'not_found_in_trash' => array(__('No posts found in Trash.'), __('No pages found in Trash.')),
1457
+		'parent_item_colon' => array(null, __('Parent Page:')),
1458
+		'all_items' => array(__('All Posts'), __('All Pages')),
1459
+		'archives' => array(__('Post Archives'), __('Page Archives')),
1460
+		'insert_into_item' => array(__('Insert into post'), __('Insert into page')),
1461
+		'uploaded_to_this_item' => array(__('Uploaded to this post'), __('Uploaded to this page')),
1462
+		'featured_image' => array(__('Featured Image'), __('Featured Image')),
1463
+		'set_featured_image' => array(__('Set featured image'), __('Set featured image')),
1464
+		'remove_featured_image' => array(__('Remove featured image'), __('Remove featured image')),
1465
+		'use_featured_image' => array(__('Use as featured image'), __('Use as featured image')),
1466
+		'filter_items_list' => array(__('Filter posts list'), __('Filter pages list')),
1467
+		'items_list_navigation' => array(__('Posts list navigation'), __('Pages list navigation')),
1468
+		'items_list' => array(__('Posts list'), __('Pages list')),
1469 1469
 	);
1470 1470
 	$nohier_vs_hier_defaults['menu_name'] = $nohier_vs_hier_defaults['name'];
1471 1471
 
1472
-	$labels = _get_custom_object_labels( $post_type_object, $nohier_vs_hier_defaults );
1472
+	$labels = _get_custom_object_labels($post_type_object, $nohier_vs_hier_defaults);
1473 1473
 
1474 1474
 	$post_type = $post_type_object->name;
1475 1475
 
@@ -1487,10 +1487,10 @@  discard block
 block discarded – undo
1487 1487
 	 *
1488 1488
 	 * @param object $labels Object with labels for the post type as member variables.
1489 1489
 	 */
1490
-	$labels = apply_filters( "post_type_labels_{$post_type}", $labels );
1490
+	$labels = apply_filters("post_type_labels_{$post_type}", $labels);
1491 1491
 
1492 1492
 	// Ensure that the filtered labels contain all required default values.
1493
-	$labels = (object) array_merge( (array) $default_labels, (array) $labels );
1493
+	$labels = (object) array_merge((array) $default_labels, (array) $labels);
1494 1494
 
1495 1495
 	return $labels;
1496 1496
 }
@@ -1506,33 +1506,33 @@  discard block
 block discarded – undo
1506 1506
  * @param array  $nohier_vs_hier_defaults Hierarchical vs non-hierarchical default labels.
1507 1507
  * @return object Object containing labels for the given custom-something object.
1508 1508
  */
1509
-function _get_custom_object_labels( $object, $nohier_vs_hier_defaults ) {
1509
+function _get_custom_object_labels($object, $nohier_vs_hier_defaults) {
1510 1510
 	$object->labels = (array) $object->labels;
1511 1511
 
1512
-	if ( isset( $object->label ) && empty( $object->labels['name'] ) )
1512
+	if (isset($object->label) && empty($object->labels['name']))
1513 1513
 		$object->labels['name'] = $object->label;
1514 1514
 
1515
-	if ( !isset( $object->labels['singular_name'] ) && isset( $object->labels['name'] ) )
1515
+	if ( ! isset($object->labels['singular_name']) && isset($object->labels['name']))
1516 1516
 		$object->labels['singular_name'] = $object->labels['name'];
1517 1517
 
1518
-	if ( ! isset( $object->labels['name_admin_bar'] ) )
1519
-		$object->labels['name_admin_bar'] = isset( $object->labels['singular_name'] ) ? $object->labels['singular_name'] : $object->name;
1518
+	if ( ! isset($object->labels['name_admin_bar']))
1519
+		$object->labels['name_admin_bar'] = isset($object->labels['singular_name']) ? $object->labels['singular_name'] : $object->name;
1520 1520
 
1521
-	if ( !isset( $object->labels['menu_name'] ) && isset( $object->labels['name'] ) )
1521
+	if ( ! isset($object->labels['menu_name']) && isset($object->labels['name']))
1522 1522
 		$object->labels['menu_name'] = $object->labels['name'];
1523 1523
 
1524
-	if ( !isset( $object->labels['all_items'] ) && isset( $object->labels['menu_name'] ) )
1524
+	if ( ! isset($object->labels['all_items']) && isset($object->labels['menu_name']))
1525 1525
 		$object->labels['all_items'] = $object->labels['menu_name'];
1526 1526
 
1527
-	if ( !isset( $object->labels['archives'] ) && isset( $object->labels['all_items'] ) ) {
1527
+	if ( ! isset($object->labels['archives']) && isset($object->labels['all_items'])) {
1528 1528
 		$object->labels['archives'] = $object->labels['all_items'];
1529 1529
 	}
1530 1530
 
1531 1531
 	$defaults = array();
1532
-	foreach ( $nohier_vs_hier_defaults as $key => $value ) {
1532
+	foreach ($nohier_vs_hier_defaults as $key => $value) {
1533 1533
 		$defaults[$key] = $object->hierarchical ? $value[1] : $value[0];
1534 1534
 	}
1535
-	$labels = array_merge( $defaults, $object->labels );
1535
+	$labels = array_merge($defaults, $object->labels);
1536 1536
 	$object->labels = (object) $object->labels;
1537 1537
 
1538 1538
 	return (object) $labels;
@@ -1545,12 +1545,12 @@  discard block
 block discarded – undo
1545 1545
  * @since 3.1.0
1546 1546
  */
1547 1547
 function _add_post_type_submenus() {
1548
-	foreach ( get_post_types( array( 'show_ui' => true ) ) as $ptype ) {
1549
-		$ptype_obj = get_post_type_object( $ptype );
1548
+	foreach (get_post_types(array('show_ui' => true)) as $ptype) {
1549
+		$ptype_obj = get_post_type_object($ptype);
1550 1550
 		// Sub-menus only.
1551
-		if ( ! $ptype_obj->show_in_menu || $ptype_obj->show_in_menu === true )
1551
+		if ( ! $ptype_obj->show_in_menu || $ptype_obj->show_in_menu === true)
1552 1552
 			continue;
1553
-		add_submenu_page( $ptype_obj->show_in_menu, $ptype_obj->labels->name, $ptype_obj->labels->all_items, $ptype_obj->cap->edit_posts, "edit.php?post_type=$ptype" );
1553
+		add_submenu_page($ptype_obj->show_in_menu, $ptype_obj->labels->name, $ptype_obj->labels->all_items, $ptype_obj->cap->edit_posts, "edit.php?post_type=$ptype");
1554 1554
 	}
1555 1555
 }
1556 1556
 
@@ -1574,15 +1574,15 @@  discard block
 block discarded – undo
1574 1574
  * @param string|array $feature   The feature being added, accepts an array of
1575 1575
  *                                feature strings or a single string.
1576 1576
  */
1577
-function add_post_type_support( $post_type, $feature ) {
1577
+function add_post_type_support($post_type, $feature) {
1578 1578
 	global $_wp_post_type_features;
1579 1579
 
1580 1580
 	$features = (array) $feature;
1581 1581
 	foreach ($features as $feature) {
1582
-		if ( func_num_args() == 2 )
1582
+		if (func_num_args() == 2)
1583 1583
 			$_wp_post_type_features[$post_type][$feature] = true;
1584 1584
 		else
1585
-			$_wp_post_type_features[$post_type][$feature] = array_slice( func_get_args(), 2 );
1585
+			$_wp_post_type_features[$post_type][$feature] = array_slice(func_get_args(), 2);
1586 1586
 	}
1587 1587
 }
1588 1588
 
@@ -1596,10 +1596,10 @@  discard block
 block discarded – undo
1596 1596
  * @param string $post_type The post type for which to remove the feature.
1597 1597
  * @param string $feature   The feature being removed.
1598 1598
  */
1599
-function remove_post_type_support( $post_type, $feature ) {
1599
+function remove_post_type_support($post_type, $feature) {
1600 1600
 	global $_wp_post_type_features;
1601 1601
 
1602
-	unset( $_wp_post_type_features[ $post_type ][ $feature ] );
1602
+	unset($_wp_post_type_features[$post_type][$feature]);
1603 1603
 }
1604 1604
 
1605 1605
 /**
@@ -1612,10 +1612,10 @@  discard block
 block discarded – undo
1612 1612
  * @param string $post_type The post type.
1613 1613
  * @return array Post type supports list.
1614 1614
  */
1615
-function get_all_post_type_supports( $post_type ) {
1615
+function get_all_post_type_supports($post_type) {
1616 1616
 	global $_wp_post_type_features;
1617 1617
 
1618
-	if ( isset( $_wp_post_type_features[$post_type] ) )
1618
+	if (isset($_wp_post_type_features[$post_type]))
1619 1619
 		return $_wp_post_type_features[$post_type];
1620 1620
 
1621 1621
 	return array();
@@ -1632,10 +1632,10 @@  discard block
 block discarded – undo
1632 1632
  * @param string $feature   The feature being checked.
1633 1633
  * @return bool Whether the post type supports the given feature.
1634 1634
  */
1635
-function post_type_supports( $post_type, $feature ) {
1635
+function post_type_supports($post_type, $feature) {
1636 1636
 	global $_wp_post_type_features;
1637 1637
 
1638
-	return ( isset( $_wp_post_type_features[$post_type][$feature] ) );
1638
+	return (isset($_wp_post_type_features[$post_type][$feature]));
1639 1639
 }
1640 1640
 
1641 1641
 /**
@@ -1652,12 +1652,12 @@  discard block
 block discarded – undo
1652 1652
  *                               match. Default 'and'.
1653 1653
  * @return array A list of post type names.
1654 1654
  */
1655
-function get_post_types_by_support( $feature, $operator = 'and' ) {
1655
+function get_post_types_by_support($feature, $operator = 'and') {
1656 1656
 	global $_wp_post_type_features;
1657 1657
 
1658
-	$features = array_fill_keys( (array) $feature, true );
1658
+	$features = array_fill_keys((array) $feature, true);
1659 1659
 
1660
-	return array_keys( wp_filter_object_list( $_wp_post_type_features, $features, $operator ) );
1660
+	return array_keys(wp_filter_object_list($_wp_post_type_features, $features, $operator));
1661 1661
 }
1662 1662
 
1663 1663
 /**
@@ -1674,13 +1674,13 @@  discard block
 block discarded – undo
1674 1674
  *                          name a few. Default 'post'.
1675 1675
  * @return int|false Amount of rows changed. Should be 1 for success and 0 for failure.
1676 1676
  */
1677
-function set_post_type( $post_id = 0, $post_type = 'post' ) {
1677
+function set_post_type($post_id = 0, $post_type = 'post') {
1678 1678
 	global $wpdb;
1679 1679
 
1680 1680
 	$post_type = sanitize_post_field('post_type', $post_type, $post_id, 'db');
1681
-	$return = $wpdb->update( $wpdb->posts, array('post_type' => $post_type), array('ID' => $post_id) );
1681
+	$return = $wpdb->update($wpdb->posts, array('post_type' => $post_type), array('ID' => $post_id));
1682 1682
 
1683
-	clean_post_cache( $post_id );
1683
+	clean_post_cache($post_id);
1684 1684
 
1685 1685
 	return $return;
1686 1686
 }
@@ -1697,15 +1697,15 @@  discard block
 block discarded – undo
1697 1697
  * @param object $post_type Post type name or object.
1698 1698
  * @return bool Whether the post type should be considered viewable.
1699 1699
  */
1700
-function is_post_type_viewable( $post_type ) {
1701
-	if ( is_scalar( $post_type ) ) {
1702
-		$post_type = get_post_type_object( $post_type );
1703
-		if ( ! $post_type ) {
1700
+function is_post_type_viewable($post_type) {
1701
+	if (is_scalar($post_type)) {
1702
+		$post_type = get_post_type_object($post_type);
1703
+		if ( ! $post_type) {
1704 1704
 			return false;
1705 1705
 		}
1706 1706
 	}
1707 1707
 
1708
-	return $post_type->publicly_queryable || ( $post_type->_builtin && $post_type->public );
1708
+	return $post_type->publicly_queryable || ($post_type->_builtin && $post_type->public);
1709 1709
 }
1710 1710
 
1711 1711
 /**
@@ -1732,7 +1732,7 @@  discard block
 block discarded – undo
1732 1732
  * }
1733 1733
  * @return array List of posts.
1734 1734
  */
1735
-function get_posts( $args = null ) {
1735
+function get_posts($args = null) {
1736 1736
 	$defaults = array(
1737 1737
 		'numberposts' => 5,
1738 1738
 		'category' => 0, 'orderby' => 'date',
@@ -1742,19 +1742,19 @@  discard block
 block discarded – undo
1742 1742
 		'suppress_filters' => true
1743 1743
 	);
1744 1744
 
1745
-	$r = wp_parse_args( $args, $defaults );
1746
-	if ( empty( $r['post_status'] ) )
1747
-		$r['post_status'] = ( 'attachment' == $r['post_type'] ) ? 'inherit' : 'publish';
1748
-	if ( ! empty($r['numberposts']) && empty($r['posts_per_page']) )
1745
+	$r = wp_parse_args($args, $defaults);
1746
+	if (empty($r['post_status']))
1747
+		$r['post_status'] = ('attachment' == $r['post_type']) ? 'inherit' : 'publish';
1748
+	if ( ! empty($r['numberposts']) && empty($r['posts_per_page']))
1749 1749
 		$r['posts_per_page'] = $r['numberposts'];
1750
-	if ( ! empty($r['category']) )
1750
+	if ( ! empty($r['category']))
1751 1751
 		$r['cat'] = $r['category'];
1752
-	if ( ! empty($r['include']) ) {
1753
-		$incposts = wp_parse_id_list( $r['include'] );
1754
-		$r['posts_per_page'] = count($incposts);  // only the number of posts included
1752
+	if ( ! empty($r['include'])) {
1753
+		$incposts = wp_parse_id_list($r['include']);
1754
+		$r['posts_per_page'] = count($incposts); // only the number of posts included
1755 1755
 		$r['post__in'] = $incposts;
1756
-	} elseif ( ! empty($r['exclude']) )
1757
-		$r['post__not_in'] = wp_parse_id_list( $r['exclude'] );
1756
+	} elseif ( ! empty($r['exclude']))
1757
+		$r['post__not_in'] = wp_parse_id_list($r['exclude']);
1758 1758
 
1759 1759
 	$r['ignore_sticky_posts'] = true;
1760 1760
 	$r['no_found_rows'] = true;
@@ -1782,9 +1782,9 @@  discard block
 block discarded – undo
1782 1782
  *                           Default false.
1783 1783
  * @return int|false Meta ID on success, false on failure.
1784 1784
  */
1785
-function add_post_meta( $post_id, $meta_key, $meta_value, $unique = false ) {
1785
+function add_post_meta($post_id, $meta_key, $meta_value, $unique = false) {
1786 1786
 	// Make sure meta is added to the post, not a revision.
1787
-	if ( $the_post = wp_is_post_revision($post_id) )
1787
+	if ($the_post = wp_is_post_revision($post_id))
1788 1788
 		$post_id = $the_post;
1789 1789
 
1790 1790
 	return add_metadata('post', $post_id, $meta_key, $meta_value, $unique);
@@ -1805,9 +1805,9 @@  discard block
 block discarded – undo
1805 1805
  *                           non-scalar. Default empty.
1806 1806
  * @return bool True on success, false on failure.
1807 1807
  */
1808
-function delete_post_meta( $post_id, $meta_key, $meta_value = '' ) {
1808
+function delete_post_meta($post_id, $meta_key, $meta_value = '') {
1809 1809
 	// Make sure meta is added to the post, not a revision.
1810
-	if ( $the_post = wp_is_post_revision($post_id) )
1810
+	if ($the_post = wp_is_post_revision($post_id))
1811 1811
 		$post_id = $the_post;
1812 1812
 
1813 1813
 	return delete_metadata('post', $post_id, $meta_key, $meta_value);
@@ -1825,7 +1825,7 @@  discard block
 block discarded – undo
1825 1825
  * @return mixed Will be an array if $single is false. Will be value of meta data
1826 1826
  *               field if $single is true.
1827 1827
  */
1828
-function get_post_meta( $post_id, $key = '', $single = false ) {
1828
+function get_post_meta($post_id, $key = '', $single = false) {
1829 1829
 	return get_metadata('post', $post_id, $key, $single);
1830 1830
 }
1831 1831
 
@@ -1847,9 +1847,9 @@  discard block
 block discarded – undo
1847 1847
  * @return int|bool Meta ID if the key didn't exist, true on successful update,
1848 1848
  *                  false on failure.
1849 1849
  */
1850
-function update_post_meta( $post_id, $meta_key, $meta_value, $prev_value = '' ) {
1850
+function update_post_meta($post_id, $meta_key, $meta_value, $prev_value = '') {
1851 1851
 	// Make sure meta is added to the post, not a revision.
1852
-	if ( $the_post = wp_is_post_revision($post_id) )
1852
+	if ($the_post = wp_is_post_revision($post_id))
1853 1853
 		$post_id = $the_post;
1854 1854
 
1855 1855
 	return update_metadata('post', $post_id, $meta_key, $meta_value, $prev_value);
@@ -1863,8 +1863,8 @@  discard block
 block discarded – undo
1863 1863
  * @param string $post_meta_key Key to search for when deleting.
1864 1864
  * @return bool Whether the post meta key was deleted from the database.
1865 1865
  */
1866
-function delete_post_meta_by_key( $post_meta_key ) {
1867
-	return delete_metadata( 'post', null, $post_meta_key, '', true );
1866
+function delete_post_meta_by_key($post_meta_key) {
1867
+	return delete_metadata('post', null, $post_meta_key, '', true);
1868 1868
 }
1869 1869
 
1870 1870
 /**
@@ -1878,12 +1878,12 @@  discard block
 block discarded – undo
1878 1878
  * @param int $post_id Optional. Post ID. Default is ID of the global $post.
1879 1879
  * @return array Post meta for the given post.
1880 1880
  */
1881
-function get_post_custom( $post_id = 0 ) {
1882
-	$post_id = absint( $post_id );
1883
-	if ( ! $post_id )
1881
+function get_post_custom($post_id = 0) {
1882
+	$post_id = absint($post_id);
1883
+	if ( ! $post_id)
1884 1884
 		$post_id = get_the_ID();
1885 1885
 
1886
-	return get_post_meta( $post_id );
1886
+	return get_post_meta($post_id);
1887 1887
 }
1888 1888
 
1889 1889
 /**
@@ -1896,13 +1896,13 @@  discard block
 block discarded – undo
1896 1896
  * @param int $post_id Optional. Post ID. Default is ID of the global $post.
1897 1897
  * @return array|void Array of the keys, if retrieved.
1898 1898
  */
1899
-function get_post_custom_keys( $post_id = 0 ) {
1900
-	$custom = get_post_custom( $post_id );
1899
+function get_post_custom_keys($post_id = 0) {
1900
+	$custom = get_post_custom($post_id);
1901 1901
 
1902
-	if ( !is_array($custom) )
1902
+	if ( ! is_array($custom))
1903 1903
 		return;
1904 1904
 
1905
-	if ( $keys = array_keys($custom) )
1905
+	if ($keys = array_keys($custom))
1906 1906
 		return $keys;
1907 1907
 }
1908 1908
 
@@ -1918,8 +1918,8 @@  discard block
 block discarded – undo
1918 1918
  * @param int    $post_id Optional. Post ID. Default is ID of the global $post.
1919 1919
  * @return array|null Meta field values.
1920 1920
  */
1921
-function get_post_custom_values( $key = '', $post_id = 0 ) {
1922
-	if ( !$key )
1921
+function get_post_custom_values($key = '', $post_id = 0) {
1922
+	if ( ! $key)
1923 1923
 		return null;
1924 1924
 
1925 1925
 	$custom = get_post_custom($post_id);
@@ -1938,18 +1938,18 @@  discard block
 block discarded – undo
1938 1938
  * @param int $post_id Optional. Post ID. Default is ID of the global $post.
1939 1939
  * @return bool Whether post is sticky.
1940 1940
  */
1941
-function is_sticky( $post_id = 0 ) {
1942
-	$post_id = absint( $post_id );
1941
+function is_sticky($post_id = 0) {
1942
+	$post_id = absint($post_id);
1943 1943
 
1944
-	if ( ! $post_id )
1944
+	if ( ! $post_id)
1945 1945
 		$post_id = get_the_ID();
1946 1946
 
1947
-	$stickies = get_option( 'sticky_posts' );
1947
+	$stickies = get_option('sticky_posts');
1948 1948
 
1949
-	if ( ! is_array( $stickies ) )
1949
+	if ( ! is_array($stickies))
1950 1950
 		return false;
1951 1951
 
1952
-	if ( in_array( $post_id, $stickies ) )
1952
+	if (in_array($post_id, $stickies))
1953 1953
 		return true;
1954 1954
 
1955 1955
 	return false;
@@ -1972,23 +1972,23 @@  discard block
 block discarded – undo
1972 1972
  * @return object|WP_Post|array The now sanitized Post Object or Array (will be the
1973 1973
  *                              same type as $post).
1974 1974
  */
1975
-function sanitize_post( $post, $context = 'display' ) {
1976
-	if ( is_object($post) ) {
1975
+function sanitize_post($post, $context = 'display') {
1976
+	if (is_object($post)) {
1977 1977
 		// Check if post already filtered for this context.
1978
-		if ( isset($post->filter) && $context == $post->filter )
1978
+		if (isset($post->filter) && $context == $post->filter)
1979 1979
 			return $post;
1980
-		if ( !isset($post->ID) )
1980
+		if ( ! isset($post->ID))
1981 1981
 			$post->ID = 0;
1982
-		foreach ( array_keys(get_object_vars($post)) as $field )
1982
+		foreach (array_keys(get_object_vars($post)) as $field)
1983 1983
 			$post->$field = sanitize_post_field($field, $post->$field, $post->ID, $context);
1984 1984
 		$post->filter = $context;
1985
-	} elseif ( is_array( $post ) ) {
1985
+	} elseif (is_array($post)) {
1986 1986
 		// Check if post already filtered for this context.
1987
-		if ( isset($post['filter']) && $context == $post['filter'] )
1987
+		if (isset($post['filter']) && $context == $post['filter'])
1988 1988
 			return $post;
1989
-		if ( !isset($post['ID']) )
1989
+		if ( ! isset($post['ID']))
1990 1990
 			$post['ID'] = 0;
1991
-		foreach ( array_keys($post) as $field )
1991
+		foreach (array_keys($post) as $field)
1992 1992
 			$post[$field] = sanitize_post_field($field, $post[$field], $post['ID'], $context);
1993 1993
 		$post['filter'] = $context;
1994 1994
 	}
@@ -2012,31 +2012,31 @@  discard block
 block discarded – undo
2012 2012
  *                        'db', 'display', 'attribute' and 'js'. Default 'display'.
2013 2013
  * @return mixed Sanitized value.
2014 2014
  */
2015
-function sanitize_post_field( $field, $value, $post_id, $context = 'display' ) {
2015
+function sanitize_post_field($field, $value, $post_id, $context = 'display') {
2016 2016
 	$int_fields = array('ID', 'post_parent', 'menu_order');
2017
-	if ( in_array($field, $int_fields) )
2017
+	if (in_array($field, $int_fields))
2018 2018
 		$value = (int) $value;
2019 2019
 
2020 2020
 	// Fields which contain arrays of integers.
2021
-	$array_int_fields = array( 'ancestors' );
2022
-	if ( in_array($field, $array_int_fields) ) {
2023
-		$value = array_map( 'absint', $value);
2021
+	$array_int_fields = array('ancestors');
2022
+	if (in_array($field, $array_int_fields)) {
2023
+		$value = array_map('absint', $value);
2024 2024
 		return $value;
2025 2025
 	}
2026 2026
 
2027
-	if ( 'raw' == $context )
2027
+	if ('raw' == $context)
2028 2028
 		return $value;
2029 2029
 
2030 2030
 	$prefixed = false;
2031
-	if ( false !== strpos($field, 'post_') ) {
2031
+	if (false !== strpos($field, 'post_')) {
2032 2032
 		$prefixed = true;
2033 2033
 		$field_no_prefix = str_replace('post_', '', $field);
2034 2034
 	}
2035 2035
 
2036
-	if ( 'edit' == $context ) {
2036
+	if ('edit' == $context) {
2037 2037
 		$format_to_edit = array('post_content', 'post_excerpt', 'post_title', 'post_password');
2038 2038
 
2039
-		if ( $prefixed ) {
2039
+		if ($prefixed) {
2040 2040
 
2041 2041
 			/**
2042 2042
 			 * Filter the value of a specific post field to edit.
@@ -2049,7 +2049,7 @@  discard block
 block discarded – undo
2049 2049
 			 * @param mixed $value   Value of the post field.
2050 2050
 			 * @param int   $post_id Post ID.
2051 2051
 			 */
2052
-			$value = apply_filters( "edit_{$field}", $value, $post_id );
2052
+			$value = apply_filters("edit_{$field}", $value, $post_id);
2053 2053
 
2054 2054
 			/**
2055 2055
 			 * Filter the value of a specific post field to edit.
@@ -2062,21 +2062,21 @@  discard block
 block discarded – undo
2062 2062
 			 * @param mixed $value   Value of the post field.
2063 2063
 			 * @param int   $post_id Post ID.
2064 2064
 			 */
2065
-			$value = apply_filters( "{$field_no_prefix}_edit_pre", $value, $post_id );
2065
+			$value = apply_filters("{$field_no_prefix}_edit_pre", $value, $post_id);
2066 2066
 		} else {
2067
-			$value = apply_filters( "edit_post_{$field}", $value, $post_id );
2067
+			$value = apply_filters("edit_post_{$field}", $value, $post_id);
2068 2068
 		}
2069 2069
 
2070
-		if ( in_array($field, $format_to_edit) ) {
2071
-			if ( 'post_content' == $field )
2070
+		if (in_array($field, $format_to_edit)) {
2071
+			if ('post_content' == $field)
2072 2072
 				$value = format_to_edit($value, user_can_richedit());
2073 2073
 			else
2074 2074
 				$value = format_to_edit($value);
2075 2075
 		} else {
2076 2076
 			$value = esc_attr($value);
2077 2077
 		}
2078
-	} elseif ( 'db' == $context ) {
2079
-		if ( $prefixed ) {
2078
+	} elseif ('db' == $context) {
2079
+		if ($prefixed) {
2080 2080
 
2081 2081
 			/**
2082 2082
 			 * Filter the value of a specific post field before saving.
@@ -2088,7 +2088,7 @@  discard block
 block discarded – undo
2088 2088
 			 *
2089 2089
 			 * @param mixed $value Value of the post field.
2090 2090
 			 */
2091
-			$value = apply_filters( "pre_{$field}", $value );
2091
+			$value = apply_filters("pre_{$field}", $value);
2092 2092
 
2093 2093
 			/**
2094 2094
 			 * Filter the value of a specific field before saving.
@@ -2100,9 +2100,9 @@  discard block
 block discarded – undo
2100 2100
 			 *
2101 2101
 			 * @param mixed $value Value of the post field.
2102 2102
 			 */
2103
-			$value = apply_filters( "{$field_no_prefix}_save_pre", $value );
2103
+			$value = apply_filters("{$field_no_prefix}_save_pre", $value);
2104 2104
 		} else {
2105
-			$value = apply_filters( "pre_post_{$field}", $value );
2105
+			$value = apply_filters("pre_post_{$field}", $value);
2106 2106
 
2107 2107
 			/**
2108 2108
 			 * Filter the value of a specific post field before saving.
@@ -2114,12 +2114,12 @@  discard block
 block discarded – undo
2114 2114
 			 *
2115 2115
 			 * @param mixed $value Value of the post field.
2116 2116
 			 */
2117
-			$value = apply_filters( "{$field}_pre", $value );
2117
+			$value = apply_filters("{$field}_pre", $value);
2118 2118
 		}
2119 2119
 	} else {
2120 2120
 
2121 2121
 		// Use display filters by default.
2122
-		if ( $prefixed ) {
2122
+		if ($prefixed) {
2123 2123
 
2124 2124
 			/**
2125 2125
 			 * Filter the value of a specific post field for display.
@@ -2135,15 +2135,15 @@  discard block
 block discarded – undo
2135 2135
 			 *                        values include 'raw', 'edit', 'db', 'display',
2136 2136
 			 *                        'attribute' and 'js'.
2137 2137
 			 */
2138
-			$value = apply_filters( $field, $value, $post_id, $context );
2138
+			$value = apply_filters($field, $value, $post_id, $context);
2139 2139
 		} else {
2140
-			$value = apply_filters( "post_{$field}", $value, $post_id, $context );
2140
+			$value = apply_filters("post_{$field}", $value, $post_id, $context);
2141 2141
 		}
2142 2142
 	}
2143 2143
 
2144
-	if ( 'attribute' == $context )
2144
+	if ('attribute' == $context)
2145 2145
 		$value = esc_attr($value);
2146
-	elseif ( 'js' == $context )
2146
+	elseif ('js' == $context)
2147 2147
 		$value = esc_js($value);
2148 2148
 
2149 2149
 	return $value;
@@ -2158,13 +2158,13 @@  discard block
 block discarded – undo
2158 2158
  *
2159 2159
  * @param int $post_id Post ID.
2160 2160
  */
2161
-function stick_post( $post_id ) {
2161
+function stick_post($post_id) {
2162 2162
 	$stickies = get_option('sticky_posts');
2163 2163
 
2164
-	if ( !is_array($stickies) )
2164
+	if ( ! is_array($stickies))
2165 2165
 		$stickies = array($post_id);
2166 2166
 
2167
-	if ( ! in_array($post_id, $stickies) )
2167
+	if ( ! in_array($post_id, $stickies))
2168 2168
 		$stickies[] = $post_id;
2169 2169
 
2170 2170
 	update_option('sticky_posts', $stickies);
@@ -2179,17 +2179,17 @@  discard block
 block discarded – undo
2179 2179
  *
2180 2180
  * @param int $post_id Post ID.
2181 2181
  */
2182
-function unstick_post( $post_id ) {
2182
+function unstick_post($post_id) {
2183 2183
 	$stickies = get_option('sticky_posts');
2184 2184
 
2185
-	if ( !is_array($stickies) )
2185
+	if ( ! is_array($stickies))
2186 2186
 		return;
2187 2187
 
2188
-	if ( ! in_array($post_id, $stickies) )
2188
+	if ( ! in_array($post_id, $stickies))
2189 2189
 		return;
2190 2190
 
2191 2191
 	$offset = array_search($post_id, $stickies);
2192
-	if ( false === $offset )
2192
+	if (false === $offset)
2193 2193
 		return;
2194 2194
 
2195 2195
 	array_splice($stickies, $offset, 1);
@@ -2206,12 +2206,12 @@  discard block
 block discarded – undo
2206 2206
  * @param string $perm Optional. 'readable' or empty. Default empty.
2207 2207
  * @return string The cache key.
2208 2208
  */
2209
-function _count_posts_cache_key( $type = 'post', $perm = '' ) {
2210
-	$cache_key = 'posts-' . $type;
2211
-	if ( 'readable' == $perm && is_user_logged_in() ) {
2212
-		$post_type_object = get_post_type_object( $type );
2213
-		if ( $post_type_object && ! current_user_can( $post_type_object->cap->read_private_posts ) ) {
2214
-			$cache_key .= '_' . $perm . '_' . get_current_user_id();
2209
+function _count_posts_cache_key($type = 'post', $perm = '') {
2210
+	$cache_key = 'posts-'.$type;
2211
+	if ('readable' == $perm && is_user_logged_in()) {
2212
+		$post_type_object = get_post_type_object($type);
2213
+		if ($post_type_object && ! current_user_can($post_type_object->cap->read_private_posts)) {
2214
+			$cache_key .= '_'.$perm.'_'.get_current_user_id();
2215 2215
 		}
2216 2216
 	}
2217 2217
 	return $cache_key;
@@ -2236,40 +2236,40 @@  discard block
 block discarded – undo
2236 2236
  * @param string $perm Optional. 'readable' or empty. Default empty.
2237 2237
  * @return object Number of posts for each status.
2238 2238
  */
2239
-function wp_count_posts( $type = 'post', $perm = '' ) {
2239
+function wp_count_posts($type = 'post', $perm = '') {
2240 2240
 	global $wpdb;
2241 2241
 
2242
-	if ( ! post_type_exists( $type ) )
2242
+	if ( ! post_type_exists($type))
2243 2243
 		return new stdClass;
2244 2244
 
2245
-	$cache_key = _count_posts_cache_key( $type, $perm );
2245
+	$cache_key = _count_posts_cache_key($type, $perm);
2246 2246
 
2247
-	$counts = wp_cache_get( $cache_key, 'counts' );
2248
-	if ( false !== $counts ) {
2247
+	$counts = wp_cache_get($cache_key, 'counts');
2248
+	if (false !== $counts) {
2249 2249
 		/** This filter is documented in wp-includes/post.php */
2250
-		return apply_filters( 'wp_count_posts', $counts, $type, $perm );
2250
+		return apply_filters('wp_count_posts', $counts, $type, $perm);
2251 2251
 	}
2252 2252
 
2253 2253
 	$query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s";
2254
-	if ( 'readable' == $perm && is_user_logged_in() ) {
2254
+	if ('readable' == $perm && is_user_logged_in()) {
2255 2255
 		$post_type_object = get_post_type_object($type);
2256
-		if ( ! current_user_can( $post_type_object->cap->read_private_posts ) ) {
2257
-			$query .= $wpdb->prepare( " AND (post_status != 'private' OR ( post_author = %d AND post_status = 'private' ))",
2256
+		if ( ! current_user_can($post_type_object->cap->read_private_posts)) {
2257
+			$query .= $wpdb->prepare(" AND (post_status != 'private' OR ( post_author = %d AND post_status = 'private' ))",
2258 2258
 				get_current_user_id()
2259 2259
 			);
2260 2260
 		}
2261 2261
 	}
2262 2262
 	$query .= ' GROUP BY post_status';
2263 2263
 
2264
-	$results = (array) $wpdb->get_results( $wpdb->prepare( $query, $type ), ARRAY_A );
2265
-	$counts = array_fill_keys( get_post_stati(), 0 );
2264
+	$results = (array) $wpdb->get_results($wpdb->prepare($query, $type), ARRAY_A);
2265
+	$counts = array_fill_keys(get_post_stati(), 0);
2266 2266
 
2267
-	foreach ( $results as $row ) {
2268
-		$counts[ $row['post_status'] ] = $row['num_posts'];
2267
+	foreach ($results as $row) {
2268
+		$counts[$row['post_status']] = $row['num_posts'];
2269 2269
 	}
2270 2270
 
2271 2271
 	$counts = (object) $counts;
2272
-	wp_cache_set( $cache_key, $counts, 'counts' );
2272
+	wp_cache_set($cache_key, $counts, 'counts');
2273 2273
 
2274 2274
 	/**
2275 2275
 	 * Modify returned post counts by status for the current post type.
@@ -2282,7 +2282,7 @@  discard block
 block discarded – undo
2282 2282
 	 * @param string $perm   The permission to determine if the posts are 'readable'
2283 2283
 	 *                       by the current user.
2284 2284
 	 */
2285
-	return apply_filters( 'wp_count_posts', $counts, $type, $perm );
2285
+	return apply_filters('wp_count_posts', $counts, $type, $perm);
2286 2286
 }
2287 2287
 
2288 2288
 /**
@@ -2301,17 +2301,17 @@  discard block
 block discarded – undo
2301 2301
  *                                MIME patterns. Default empty.
2302 2302
  * @return object An object containing the attachment counts by mime type.
2303 2303
  */
2304
-function wp_count_attachments( $mime_type = '' ) {
2304
+function wp_count_attachments($mime_type = '') {
2305 2305
 	global $wpdb;
2306 2306
 
2307
-	$and = wp_post_mime_type_where( $mime_type );
2308
-	$count = $wpdb->get_results( "SELECT post_mime_type, COUNT( * ) AS num_posts FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' $and GROUP BY post_mime_type", ARRAY_A );
2307
+	$and = wp_post_mime_type_where($mime_type);
2308
+	$count = $wpdb->get_results("SELECT post_mime_type, COUNT( * ) AS num_posts FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' $and GROUP BY post_mime_type", ARRAY_A);
2309 2309
 
2310 2310
 	$counts = array();
2311
-	foreach ( (array) $count as $row ) {
2312
-		$counts[ $row['post_mime_type'] ] = $row['num_posts'];
2311
+	foreach ((array) $count as $row) {
2312
+		$counts[$row['post_mime_type']] = $row['num_posts'];
2313 2313
 	}
2314
-	$counts['trash'] = $wpdb->get_var( "SELECT COUNT( * ) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status = 'trash' $and");
2314
+	$counts['trash'] = $wpdb->get_var("SELECT COUNT( * ) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status = 'trash' $and");
2315 2315
 
2316 2316
 	/**
2317 2317
 	 * Modify returned attachment counts by mime type.
@@ -2323,7 +2323,7 @@  discard block
 block discarded – undo
2323 2323
 	 * @param string $mime_type The mime type pattern used to filter the attachments
2324 2324
 	 *                          counted.
2325 2325
 	 */
2326
-	return apply_filters( 'wp_count_attachments', (object) $counts, $mime_type );
2326
+	return apply_filters('wp_count_attachments', (object) $counts, $mime_type);
2327 2327
 }
2328 2328
 
2329 2329
 /**
@@ -2347,7 +2347,7 @@  discard block
 block discarded – undo
2347 2347
 	 *
2348 2348
 	 * @param array $post_mime_types Default list of post mime types.
2349 2349
 	 */
2350
-	return apply_filters( 'post_mime_types', $post_mime_types );
2350
+	return apply_filters('post_mime_types', $post_mime_types);
2351 2351
 }
2352 2352
 
2353 2353
 /**
@@ -2364,35 +2364,35 @@  discard block
 block discarded – undo
2364 2364
  * @param string|array $real_mime_types     Real post mime type values.
2365 2365
  * @return array array(wildcard=>array(real types)).
2366 2366
  */
2367
-function wp_match_mime_types( $wildcard_mime_types, $real_mime_types ) {
2367
+function wp_match_mime_types($wildcard_mime_types, $real_mime_types) {
2368 2368
 	$matches = array();
2369
-	if ( is_string( $wildcard_mime_types ) ) {
2370
-		$wildcard_mime_types = array_map( 'trim', explode( ',', $wildcard_mime_types ) );
2369
+	if (is_string($wildcard_mime_types)) {
2370
+		$wildcard_mime_types = array_map('trim', explode(',', $wildcard_mime_types));
2371 2371
 	}
2372
-	if ( is_string( $real_mime_types ) ) {
2373
-		$real_mime_types = array_map( 'trim', explode( ',', $real_mime_types ) );
2372
+	if (is_string($real_mime_types)) {
2373
+		$real_mime_types = array_map('trim', explode(',', $real_mime_types));
2374 2374
 	}
2375 2375
 
2376 2376
 	$patternses = array();
2377 2377
 	$wild = '[-._a-z0-9]*';
2378 2378
 
2379
-	foreach ( (array) $wildcard_mime_types as $type ) {
2380
-		$mimes = array_map( 'trim', explode( ',', $type ) );
2381
-		foreach ( $mimes as $mime ) {
2382
-			$regex = str_replace( '__wildcard__', $wild, preg_quote( str_replace( '*', '__wildcard__', $mime ) ) );
2379
+	foreach ((array) $wildcard_mime_types as $type) {
2380
+		$mimes = array_map('trim', explode(',', $type));
2381
+		foreach ($mimes as $mime) {
2382
+			$regex = str_replace('__wildcard__', $wild, preg_quote(str_replace('*', '__wildcard__', $mime)));
2383 2383
 			$patternses[][$type] = "^$regex$";
2384
-			if ( false === strpos( $mime, '/' ) ) {
2384
+			if (false === strpos($mime, '/')) {
2385 2385
 				$patternses[][$type] = "^$regex/";
2386 2386
 				$patternses[][$type] = $regex;
2387 2387
 			}
2388 2388
 		}
2389 2389
 	}
2390
-	asort( $patternses );
2390
+	asort($patternses);
2391 2391
 
2392
-	foreach ( $patternses as $patterns ) {
2393
-		foreach ( $patterns as $type => $pattern ) {
2394
-			foreach ( (array) $real_mime_types as $real ) {
2395
-				if ( preg_match( "#$pattern#", $real ) && ( empty( $matches[$type] ) || false === array_search( $real, $matches[$type] ) ) ) {
2392
+	foreach ($patternses as $patterns) {
2393
+		foreach ($patterns as $type => $pattern) {
2394
+			foreach ((array) $real_mime_types as $real) {
2395
+				if (preg_match("#$pattern#", $real) && (empty($matches[$type]) || false === array_search($real, $matches[$type]))) {
2396 2396
 					$matches[$type][] = $real;
2397 2397
 				}
2398 2398
 			}
@@ -2412,43 +2412,43 @@  discard block
 block discarded – undo
2412 2412
  *                                      Default empty.
2413 2413
  * @return string The SQL AND clause for mime searching.
2414 2414
  */
2415
-function wp_post_mime_type_where( $post_mime_types, $table_alias = '' ) {
2415
+function wp_post_mime_type_where($post_mime_types, $table_alias = '') {
2416 2416
 	$where = '';
2417 2417
 	$wildcards = array('', '%', '%/%');
2418
-	if ( is_string($post_mime_types) )
2418
+	if (is_string($post_mime_types))
2419 2419
 		$post_mime_types = array_map('trim', explode(',', $post_mime_types));
2420 2420
 
2421 2421
 	$wheres = array();
2422 2422
 
2423
-	foreach ( (array) $post_mime_types as $mime_type ) {
2423
+	foreach ((array) $post_mime_types as $mime_type) {
2424 2424
 		$mime_type = preg_replace('/\s/', '', $mime_type);
2425 2425
 		$slashpos = strpos($mime_type, '/');
2426
-		if ( false !== $slashpos ) {
2426
+		if (false !== $slashpos) {
2427 2427
 			$mime_group = preg_replace('/[^-*.a-zA-Z0-9]/', '', substr($mime_type, 0, $slashpos));
2428 2428
 			$mime_subgroup = preg_replace('/[^-*.+a-zA-Z0-9]/', '', substr($mime_type, $slashpos + 1));
2429
-			if ( empty($mime_subgroup) )
2429
+			if (empty($mime_subgroup))
2430 2430
 				$mime_subgroup = '*';
2431 2431
 			else
2432 2432
 				$mime_subgroup = str_replace('/', '', $mime_subgroup);
2433 2433
 			$mime_pattern = "$mime_group/$mime_subgroup";
2434 2434
 		} else {
2435 2435
 			$mime_pattern = preg_replace('/[^-*.a-zA-Z0-9]/', '', $mime_type);
2436
-			if ( false === strpos($mime_pattern, '*') )
2436
+			if (false === strpos($mime_pattern, '*'))
2437 2437
 				$mime_pattern .= '/*';
2438 2438
 		}
2439 2439
 
2440 2440
 		$mime_pattern = preg_replace('/\*+/', '%', $mime_pattern);
2441 2441
 
2442
-		if ( in_array( $mime_type, $wildcards ) )
2442
+		if (in_array($mime_type, $wildcards))
2443 2443
 			return '';
2444 2444
 
2445
-		if ( false !== strpos($mime_pattern, '%') )
2445
+		if (false !== strpos($mime_pattern, '%'))
2446 2446
 			$wheres[] = empty($table_alias) ? "post_mime_type LIKE '$mime_pattern'" : "$table_alias.post_mime_type LIKE '$mime_pattern'";
2447 2447
 		else
2448 2448
 			$wheres[] = empty($table_alias) ? "post_mime_type = '$mime_pattern'" : "$table_alias.post_mime_type = '$mime_pattern'";
2449 2449
 	}
2450
-	if ( !empty($wheres) )
2451
-		$where = ' AND (' . join(' OR ', $wheres) . ') ';
2450
+	if ( ! empty($wheres))
2451
+		$where = ' AND ('.join(' OR ', $wheres).') ';
2452 2452
 	return $where;
2453 2453
 }
2454 2454
 
@@ -2473,17 +2473,17 @@  discard block
 block discarded – undo
2473 2473
  *                           Default false.
2474 2474
  * @return array|false|WP_Post False on failure.
2475 2475
  */
2476
-function wp_delete_post( $postid = 0, $force_delete = false ) {
2476
+function wp_delete_post($postid = 0, $force_delete = false) {
2477 2477
 	global $wpdb;
2478 2478
 
2479
-	if ( !$post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $postid)) )
2479
+	if ( ! $post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $postid)))
2480 2480
 		return $post;
2481 2481
 
2482
-	if ( !$force_delete && ( $post->post_type == 'post' || $post->post_type == 'page') && get_post_status( $postid ) != 'trash' && EMPTY_TRASH_DAYS )
2483
-		return wp_trash_post( $postid );
2482
+	if ( ! $force_delete && ($post->post_type == 'post' || $post->post_type == 'page') && get_post_status($postid) != 'trash' && EMPTY_TRASH_DAYS)
2483
+		return wp_trash_post($postid);
2484 2484
 
2485
-	if ( $post->post_type == 'attachment' )
2486
-		return wp_delete_attachment( $postid, $force_delete );
2485
+	if ($post->post_type == 'attachment')
2486
+		return wp_delete_attachment($postid, $force_delete);
2487 2487
 
2488 2488
 	/**
2489 2489
 	 * Filter whether a post deletion should take place.
@@ -2494,8 +2494,8 @@  discard block
 block discarded – undo
2494 2494
 	 * @param WP_Post $post         Post object.
2495 2495
 	 * @param bool    $force_delete Whether to bypass the trash.
2496 2496
 	 */
2497
-	$check = apply_filters( 'pre_delete_post', null, $post, $force_delete );
2498
-	if ( null !== $check ) {
2497
+	$check = apply_filters('pre_delete_post', null, $post, $force_delete);
2498
+	if (null !== $check) {
2499 2499
 		return $check;
2500 2500
 	}
2501 2501
 
@@ -2508,46 +2508,46 @@  discard block
 block discarded – undo
2508 2508
 	 *
2509 2509
 	 * @param int $postid Post ID.
2510 2510
 	 */
2511
-	do_action( 'before_delete_post', $postid );
2511
+	do_action('before_delete_post', $postid);
2512 2512
 
2513
-	delete_post_meta($postid,'_wp_trash_meta_status');
2514
-	delete_post_meta($postid,'_wp_trash_meta_time');
2513
+	delete_post_meta($postid, '_wp_trash_meta_status');
2514
+	delete_post_meta($postid, '_wp_trash_meta_time');
2515 2515
 
2516 2516
 	wp_delete_object_term_relationships($postid, get_object_taxonomies($post->post_type));
2517 2517
 
2518
-	$parent_data = array( 'post_parent' => $post->post_parent );
2519
-	$parent_where = array( 'post_parent' => $postid );
2518
+	$parent_data = array('post_parent' => $post->post_parent);
2519
+	$parent_where = array('post_parent' => $postid);
2520 2520
 
2521
-	if ( is_post_type_hierarchical( $post->post_type ) ) {
2521
+	if (is_post_type_hierarchical($post->post_type)) {
2522 2522
 		// Point children of this page to its parent, also clean the cache of affected children.
2523
-		$children_query = $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE post_parent = %d AND post_type = %s", $postid, $post->post_type );
2524
-		$children = $wpdb->get_results( $children_query );
2525
-		if ( $children ) {
2526
-			$wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => $post->post_type ) );
2523
+		$children_query = $wpdb->prepare("SELECT * FROM $wpdb->posts WHERE post_parent = %d AND post_type = %s", $postid, $post->post_type);
2524
+		$children = $wpdb->get_results($children_query);
2525
+		if ($children) {
2526
+			$wpdb->update($wpdb->posts, $parent_data, $parent_where + array('post_type' => $post->post_type));
2527 2527
 		}
2528 2528
 	}
2529 2529
 
2530 2530
 	// Do raw query. wp_get_post_revisions() is filtered.
2531
-	$revision_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'revision'", $postid ) );
2531
+	$revision_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'revision'", $postid));
2532 2532
 	// Use wp_delete_post (via wp_delete_post_revision) again. Ensures any meta/misplaced data gets cleaned up.
2533
-	foreach ( $revision_ids as $revision_id )
2534
-		wp_delete_post_revision( $revision_id );
2533
+	foreach ($revision_ids as $revision_id)
2534
+		wp_delete_post_revision($revision_id);
2535 2535
 
2536 2536
 	// Point all attachments to this post up one level.
2537
-	$wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => 'attachment' ) );
2537
+	$wpdb->update($wpdb->posts, $parent_data, $parent_where + array('post_type' => 'attachment'));
2538 2538
 
2539
-	wp_defer_comment_counting( true );
2539
+	wp_defer_comment_counting(true);
2540 2540
 
2541
-	$comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $postid ));
2542
-	foreach ( $comment_ids as $comment_id ) {
2543
-		wp_delete_comment( $comment_id, true );
2541
+	$comment_ids = $wpdb->get_col($wpdb->prepare("SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $postid));
2542
+	foreach ($comment_ids as $comment_id) {
2543
+		wp_delete_comment($comment_id, true);
2544 2544
 	}
2545 2545
 
2546
-	wp_defer_comment_counting( false );
2546
+	wp_defer_comment_counting(false);
2547 2547
 
2548
-	$post_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $postid ));
2549
-	foreach ( $post_meta_ids as $mid )
2550
-		delete_metadata_by_mid( 'post', $mid );
2548
+	$post_meta_ids = $wpdb->get_col($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $postid));
2549
+	foreach ($post_meta_ids as $mid)
2550
+		delete_metadata_by_mid('post', $mid);
2551 2551
 
2552 2552
 	/**
2553 2553
 	 * Fires immediately before a post is deleted from the database.
@@ -2556,9 +2556,9 @@  discard block
 block discarded – undo
2556 2556
 	 *
2557 2557
 	 * @param int $postid Post ID.
2558 2558
 	 */
2559
-	do_action( 'delete_post', $postid );
2560
-	$result = $wpdb->delete( $wpdb->posts, array( 'ID' => $postid ) );
2561
-	if ( ! $result ) {
2559
+	do_action('delete_post', $postid);
2560
+	$result = $wpdb->delete($wpdb->posts, array('ID' => $postid));
2561
+	if ( ! $result) {
2562 2562
 		return false;
2563 2563
 	}
2564 2564
 
@@ -2569,16 +2569,16 @@  discard block
 block discarded – undo
2569 2569
 	 *
2570 2570
 	 * @param int $postid Post ID.
2571 2571
 	 */
2572
-	do_action( 'deleted_post', $postid );
2572
+	do_action('deleted_post', $postid);
2573 2573
 
2574
-	clean_post_cache( $post );
2574
+	clean_post_cache($post);
2575 2575
 
2576
-	if ( is_post_type_hierarchical( $post->post_type ) && $children ) {
2577
-		foreach ( $children as $child )
2578
-			clean_post_cache( $child );
2576
+	if (is_post_type_hierarchical($post->post_type) && $children) {
2577
+		foreach ($children as $child)
2578
+			clean_post_cache($child);
2579 2579
 	}
2580 2580
 
2581
-	wp_clear_scheduled_hook('publish_future_post', array( $postid ) );
2581
+	wp_clear_scheduled_hook('publish_future_post', array($postid));
2582 2582
 
2583 2583
 	/**
2584 2584
 	 * Fires after a post is deleted, at the conclusion of wp_delete_post().
@@ -2589,7 +2589,7 @@  discard block
 block discarded – undo
2589 2589
 	 *
2590 2590
 	 * @param int $postid Post ID.
2591 2591
 	 */
2592
-	do_action( 'after_delete_post', $postid );
2592
+	do_action('after_delete_post', $postid);
2593 2593
 
2594 2594
 	return $post;
2595 2595
 }
@@ -2605,22 +2605,22 @@  discard block
 block discarded – undo
2605 2605
  *
2606 2606
  * @param int $post_id Post ID.
2607 2607
  */
2608
-function _reset_front_page_settings_for_post( $post_id ) {
2609
-	$post = get_post( $post_id );
2610
-	if ( 'page' == $post->post_type ) {
2608
+function _reset_front_page_settings_for_post($post_id) {
2609
+	$post = get_post($post_id);
2610
+	if ('page' == $post->post_type) {
2611 2611
 	 	/*
2612 2612
 	 	 * If the page is defined in option page_on_front or post_for_posts,
2613 2613
 	 	 * adjust the corresponding options.
2614 2614
 	 	 */
2615
-		if ( get_option( 'page_on_front' ) == $post->ID ) {
2616
-			update_option( 'show_on_front', 'posts' );
2617
-			update_option( 'page_on_front', 0 );
2615
+		if (get_option('page_on_front') == $post->ID) {
2616
+			update_option('show_on_front', 'posts');
2617
+			update_option('page_on_front', 0);
2618 2618
 		}
2619
-		if ( get_option( 'page_for_posts' ) == $post->ID ) {
2620
-			delete_option( 'page_for_posts', 0 );
2619
+		if (get_option('page_for_posts') == $post->ID) {
2620
+			delete_option('page_for_posts', 0);
2621 2621
 		}
2622 2622
 	}
2623
-	unstick_post( $post->ID );
2623
+	unstick_post($post->ID);
2624 2624
 }
2625 2625
 
2626 2626
 /**
@@ -2636,14 +2636,14 @@  discard block
 block discarded – undo
2636 2636
  *                     if EMPTY_TRASH_DAYS equals true.
2637 2637
  * @return false|array|WP_Post|null Post data array, otherwise false.
2638 2638
  */
2639
-function wp_trash_post( $post_id = 0 ) {
2640
-	if ( !EMPTY_TRASH_DAYS )
2639
+function wp_trash_post($post_id = 0) {
2640
+	if ( ! EMPTY_TRASH_DAYS)
2641 2641
 		return wp_delete_post($post_id, true);
2642 2642
 
2643
-	if ( !$post = get_post($post_id, ARRAY_A) )
2643
+	if ( ! $post = get_post($post_id, ARRAY_A))
2644 2644
 		return $post;
2645 2645
 
2646
-	if ( $post['post_status'] == 'trash' )
2646
+	if ($post['post_status'] == 'trash')
2647 2647
 		return false;
2648 2648
 
2649 2649
 	/**
@@ -2653,13 +2653,13 @@  discard block
 block discarded – undo
2653 2653
 	 *
2654 2654
 	 * @param int $post_id Post ID.
2655 2655
 	 */
2656
-	do_action( 'wp_trash_post', $post_id );
2656
+	do_action('wp_trash_post', $post_id);
2657 2657
 
2658
-	add_post_meta($post_id,'_wp_trash_meta_status', $post['post_status']);
2659
-	add_post_meta($post_id,'_wp_trash_meta_time', time());
2658
+	add_post_meta($post_id, '_wp_trash_meta_status', $post['post_status']);
2659
+	add_post_meta($post_id, '_wp_trash_meta_time', time());
2660 2660
 
2661 2661
 	$post['post_status'] = 'trash';
2662
-	wp_insert_post( wp_slash( $post ) );
2662
+	wp_insert_post(wp_slash($post));
2663 2663
 
2664 2664
 	wp_trash_post_comments($post_id);
2665 2665
 
@@ -2670,7 +2670,7 @@  discard block
 block discarded – undo
2670 2670
 	 *
2671 2671
 	 * @param int $post_id Post ID.
2672 2672
 	 */
2673
-	do_action( 'trashed_post', $post_id );
2673
+	do_action('trashed_post', $post_id);
2674 2674
 
2675 2675
 	return $post;
2676 2676
 }
@@ -2683,11 +2683,11 @@  discard block
 block discarded – undo
2683 2683
  * @param int $post_id Optional. Post ID. Default is ID of the global $post.
2684 2684
  * @return WP_Post|false WP_Post object. False on failure.
2685 2685
  */
2686
-function wp_untrash_post( $post_id = 0 ) {
2687
-	if ( !$post = get_post($post_id, ARRAY_A) )
2686
+function wp_untrash_post($post_id = 0) {
2687
+	if ( ! $post = get_post($post_id, ARRAY_A))
2688 2688
 		return $post;
2689 2689
 
2690
-	if ( $post['post_status'] != 'trash' )
2690
+	if ($post['post_status'] != 'trash')
2691 2691
 		return false;
2692 2692
 
2693 2693
 	/**
@@ -2697,7 +2697,7 @@  discard block
 block discarded – undo
2697 2697
 	 *
2698 2698
 	 * @param int $post_id Post ID.
2699 2699
 	 */
2700
-	do_action( 'untrash_post', $post_id );
2700
+	do_action('untrash_post', $post_id);
2701 2701
 
2702 2702
 	$post_status = get_post_meta($post_id, '_wp_trash_meta_status', true);
2703 2703
 
@@ -2706,7 +2706,7 @@  discard block
 block discarded – undo
2706 2706
 	delete_post_meta($post_id, '_wp_trash_meta_status');
2707 2707
 	delete_post_meta($post_id, '_wp_trash_meta_time');
2708 2708
 
2709
-	wp_insert_post( wp_slash( $post ) );
2709
+	wp_insert_post(wp_slash($post));
2710 2710
 
2711 2711
 	wp_untrash_post_comments($post_id);
2712 2712
 
@@ -2717,7 +2717,7 @@  discard block
 block discarded – undo
2717 2717
 	 *
2718 2718
 	 * @param int $post_id Post ID.
2719 2719
 	 */
2720
-	do_action( 'untrashed_post', $post_id );
2720
+	do_action('untrashed_post', $post_id);
2721 2721
 
2722 2722
 	return $post;
2723 2723
 }
@@ -2732,11 +2732,11 @@  discard block
 block discarded – undo
2732 2732
  * @param int|WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
2733 2733
  * @return mixed|void False on failure.
2734 2734
  */
2735
-function wp_trash_post_comments( $post = null ) {
2735
+function wp_trash_post_comments($post = null) {
2736 2736
 	global $wpdb;
2737 2737
 
2738 2738
 	$post = get_post($post);
2739
-	if ( empty($post) )
2739
+	if (empty($post))
2740 2740
 		return;
2741 2741
 
2742 2742
 	$post_id = $post->ID;
@@ -2748,22 +2748,22 @@  discard block
 block discarded – undo
2748 2748
 	 *
2749 2749
 	 * @param int $post_id Post ID.
2750 2750
 	 */
2751
-	do_action( 'trash_post_comments', $post_id );
2751
+	do_action('trash_post_comments', $post_id);
2752 2752
 
2753
-	$comments = $wpdb->get_results( $wpdb->prepare("SELECT comment_ID, comment_approved FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id) );
2754
-	if ( empty($comments) )
2753
+	$comments = $wpdb->get_results($wpdb->prepare("SELECT comment_ID, comment_approved FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id));
2754
+	if (empty($comments))
2755 2755
 		return;
2756 2756
 
2757 2757
 	// Cache current status for each comment.
2758 2758
 	$statuses = array();
2759
-	foreach ( $comments as $comment )
2759
+	foreach ($comments as $comment)
2760 2760
 		$statuses[$comment->comment_ID] = $comment->comment_approved;
2761 2761
 	add_post_meta($post_id, '_wp_trash_meta_comments_status', $statuses);
2762 2762
 
2763 2763
 	// Set status for all comments to post-trashed.
2764 2764
 	$result = $wpdb->update($wpdb->comments, array('comment_approved' => 'post-trashed'), array('comment_post_ID' => $post_id));
2765 2765
 
2766
-	clean_comment_cache( array_keys($statuses) );
2766
+	clean_comment_cache(array_keys($statuses));
2767 2767
 
2768 2768
 	/**
2769 2769
 	 * Fires after comments are sent to the trash.
@@ -2773,7 +2773,7 @@  discard block
 block discarded – undo
2773 2773
 	 * @param int   $post_id  Post ID.
2774 2774
 	 * @param array $statuses Array of comment statuses.
2775 2775
 	 */
2776
-	do_action( 'trashed_post_comments', $post_id, $statuses );
2776
+	do_action('trashed_post_comments', $post_id, $statuses);
2777 2777
 
2778 2778
 	return $result;
2779 2779
 }
@@ -2788,18 +2788,18 @@  discard block
 block discarded – undo
2788 2788
  * @param int|WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
2789 2789
  * @return true|void
2790 2790
  */
2791
-function wp_untrash_post_comments( $post = null ) {
2791
+function wp_untrash_post_comments($post = null) {
2792 2792
 	global $wpdb;
2793 2793
 
2794 2794
 	$post = get_post($post);
2795
-	if ( empty($post) )
2795
+	if (empty($post))
2796 2796
 		return;
2797 2797
 
2798 2798
 	$post_id = $post->ID;
2799 2799
 
2800 2800
 	$statuses = get_post_meta($post_id, '_wp_trash_meta_comments_status', true);
2801 2801
 
2802
-	if ( empty($statuses) )
2802
+	if (empty($statuses))
2803 2803
 		return true;
2804 2804
 
2805 2805
 	/**
@@ -2809,23 +2809,23 @@  discard block
 block discarded – undo
2809 2809
 	 *
2810 2810
 	 * @param int $post_id Post ID.
2811 2811
 	 */
2812
-	do_action( 'untrash_post_comments', $post_id );
2812
+	do_action('untrash_post_comments', $post_id);
2813 2813
 
2814 2814
 	// Restore each comment to its original status.
2815 2815
 	$group_by_status = array();
2816
-	foreach ( $statuses as $comment_id => $comment_status )
2816
+	foreach ($statuses as $comment_id => $comment_status)
2817 2817
 		$group_by_status[$comment_status][] = $comment_id;
2818 2818
 
2819
-	foreach ( $group_by_status as $status => $comments ) {
2819
+	foreach ($group_by_status as $status => $comments) {
2820 2820
 		// Sanity check. This shouldn't happen.
2821
-		if ( 'post-trashed' == $status ) {
2821
+		if ('post-trashed' == $status) {
2822 2822
 			$status = '0';
2823 2823
 		}
2824
-		$comments_in = implode( ', ', array_map( 'intval', $comments ) );
2825
-		$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->comments SET comment_approved = %s WHERE comment_ID IN ($comments_in)", $status ) );
2824
+		$comments_in = implode(', ', array_map('intval', $comments));
2825
+		$wpdb->query($wpdb->prepare("UPDATE $wpdb->comments SET comment_approved = %s WHERE comment_ID IN ($comments_in)", $status));
2826 2826
 	}
2827 2827
 
2828
-	clean_comment_cache( array_keys($statuses) );
2828
+	clean_comment_cache(array_keys($statuses));
2829 2829
 
2830 2830
 	delete_post_meta($post_id, '_wp_trash_meta_comments_status');
2831 2831
 
@@ -2836,7 +2836,7 @@  discard block
 block discarded – undo
2836 2836
 	 *
2837 2837
 	 * @param int $post_id Post ID.
2838 2838
 	 */
2839
-	do_action( 'untrashed_post_comments', $post_id );
2839
+	do_action('untrashed_post_comments', $post_id);
2840 2840
 }
2841 2841
 
2842 2842
 /**
@@ -2854,11 +2854,11 @@  discard block
 block discarded – undo
2854 2854
  * @param array $args    Optional. Category arguments. Default empty.
2855 2855
  * @return array List of categories.
2856 2856
  */
2857
-function wp_get_post_categories( $post_id = 0, $args = array() ) {
2857
+function wp_get_post_categories($post_id = 0, $args = array()) {
2858 2858
 	$post_id = (int) $post_id;
2859 2859
 
2860 2860
 	$defaults = array('fields' => 'ids');
2861
-	$args = wp_parse_args( $args, $defaults );
2861
+	$args = wp_parse_args($args, $defaults);
2862 2862
 
2863 2863
 	$cats = wp_get_object_terms($post_id, 'category', $args);
2864 2864
 	return $cats;
@@ -2878,8 +2878,8 @@  discard block
 block discarded – undo
2878 2878
  * @param array $args Optional. Overwrite the defaults
2879 2879
  * @return array List of post tags.
2880 2880
  */
2881
-function wp_get_post_tags( $post_id = 0, $args = array() ) {
2882
-	return wp_get_post_terms( $post_id, 'post_tag', $args);
2881
+function wp_get_post_tags($post_id = 0, $args = array()) {
2882
+	return wp_get_post_terms($post_id, 'post_tag', $args);
2883 2883
 }
2884 2884
 
2885 2885
 /**
@@ -2898,11 +2898,11 @@  discard block
 block discarded – undo
2898 2898
  * @return array|WP_Error  List of post terms or empty array if no terms were found. WP_Error object
2899 2899
  *                         if `$taxonomy` doesn't exist.
2900 2900
  */
2901
-function wp_get_post_terms( $post_id = 0, $taxonomy = 'post_tag', $args = array() ) {
2901
+function wp_get_post_terms($post_id = 0, $taxonomy = 'post_tag', $args = array()) {
2902 2902
 	$post_id = (int) $post_id;
2903 2903
 
2904 2904
 	$defaults = array('fields' => 'all');
2905
-	$args = wp_parse_args( $args, $defaults );
2905
+	$args = wp_parse_args($args, $defaults);
2906 2906
 
2907 2907
 	$tags = wp_get_object_terms($post_id, $taxonomy, $args);
2908 2908
 
@@ -2920,11 +2920,11 @@  discard block
 block discarded – undo
2920 2920
  * @param string $output     Optional. Type of output. Accepts ARRAY_A or ''. Default ARRAY_A.
2921 2921
  * @return array|false Associative array if $output equals ARRAY_A, array or false if no results.
2922 2922
  */
2923
-function wp_get_recent_posts( $args = array(), $output = ARRAY_A ) {
2923
+function wp_get_recent_posts($args = array(), $output = ARRAY_A) {
2924 2924
 
2925
-	if ( is_numeric( $args ) ) {
2926
-		_deprecated_argument( __FUNCTION__, '3.1', __( 'Passing an integer number of posts is deprecated. Pass an array of arguments instead.' ) );
2927
-		$args = array( 'numberposts' => absint( $args ) );
2925
+	if (is_numeric($args)) {
2926
+		_deprecated_argument(__FUNCTION__, '3.1', __('Passing an integer number of posts is deprecated. Pass an array of arguments instead.'));
2927
+		$args = array('numberposts' => absint($args));
2928 2928
 	}
2929 2929
 
2930 2930
 	// Set default arguments.
@@ -2937,14 +2937,14 @@  discard block
 block discarded – undo
2937 2937
 		'suppress_filters' => true
2938 2938
 	);
2939 2939
 
2940
-	$r = wp_parse_args( $args, $defaults );
2940
+	$r = wp_parse_args($args, $defaults);
2941 2941
 
2942
-	$results = get_posts( $r );
2942
+	$results = get_posts($r);
2943 2943
 
2944 2944
 	// Backward compatibility. Prior to 3.1 expected posts to be returned in array.
2945
-	if ( ARRAY_A == $output ){
2946
-		foreach ( $results as $key => $result ) {
2947
-			$results[$key] = get_object_vars( $result );
2945
+	if (ARRAY_A == $output) {
2946
+		foreach ($results as $key => $result) {
2947
+			$results[$key] = get_object_vars($result);
2948 2948
 		}
2949 2949
 		return $results ? $results : array();
2950 2950
 	}
@@ -3010,7 +3010,7 @@  discard block
 block discarded – undo
3010 3010
  * @param bool  $wp_error Optional. Whether to allow return of WP_Error on failure. Default false.
3011 3011
  * @return int|WP_Error The post ID on success. The value 0 or WP_Error on failure.
3012 3012
  */
3013
-function wp_insert_post( $postarr, $wp_error = false ) {
3013
+function wp_insert_post($postarr, $wp_error = false) {
3014 3014
 	global $wpdb;
3015 3015
 
3016 3016
 	$user_id = get_current_user_id();
@@ -3037,7 +3037,7 @@  discard block
 block discarded – undo
3037 3037
 
3038 3038
 	$postarr = wp_parse_args($postarr, $defaults);
3039 3039
 
3040
-	unset( $postarr[ 'filter' ] );
3040
+	unset($postarr['filter']);
3041 3041
 
3042 3042
 	$postarr = sanitize_post($postarr, 'db');
3043 3043
 
@@ -3046,42 +3046,42 @@  discard block
 block discarded – undo
3046 3046
 	$update = false;
3047 3047
 	$guid = $postarr['guid'];
3048 3048
 
3049
-	if ( ! empty( $postarr['ID'] ) ) {
3049
+	if ( ! empty($postarr['ID'])) {
3050 3050
 		$update = true;
3051 3051
 
3052 3052
 		// Get the post ID and GUID.
3053 3053
 		$post_ID = $postarr['ID'];
3054
-		$post_before = get_post( $post_ID );
3055
-		if ( is_null( $post_before ) ) {
3056
-			if ( $wp_error ) {
3057
-				return new WP_Error( 'invalid_post', __( 'Invalid post ID.' ) );
3054
+		$post_before = get_post($post_ID);
3055
+		if (is_null($post_before)) {
3056
+			if ($wp_error) {
3057
+				return new WP_Error('invalid_post', __('Invalid post ID.'));
3058 3058
 			}
3059 3059
 			return 0;
3060 3060
 		}
3061 3061
 
3062
-		$guid = get_post_field( 'guid', $post_ID );
3063
-		$previous_status = get_post_field('post_status', $post_ID );
3062
+		$guid = get_post_field('guid', $post_ID);
3063
+		$previous_status = get_post_field('post_status', $post_ID);
3064 3064
 	} else {
3065 3065
 		$previous_status = 'new';
3066 3066
 	}
3067 3067
 
3068
-	$post_type = empty( $postarr['post_type'] ) ? 'post' : $postarr['post_type'];
3068
+	$post_type = empty($postarr['post_type']) ? 'post' : $postarr['post_type'];
3069 3069
 
3070 3070
 	$post_title = $postarr['post_title'];
3071 3071
 	$post_content = $postarr['post_content'];
3072 3072
 	$post_excerpt = $postarr['post_excerpt'];
3073
-	if ( isset( $postarr['post_name'] ) ) {
3073
+	if (isset($postarr['post_name'])) {
3074 3074
 		$post_name = $postarr['post_name'];
3075
-	} elseif ( $update ) {
3075
+	} elseif ($update) {
3076 3076
 		// For an update, don't modify the post_name if it wasn't supplied as an argument.
3077 3077
 		$post_name = $post_before->post_name;
3078 3078
 	}
3079 3079
 
3080 3080
 	$maybe_empty = 'attachment' !== $post_type
3081 3081
 		&& ! $post_content && ! $post_title && ! $post_excerpt
3082
-		&& post_type_supports( $post_type, 'editor' )
3083
-		&& post_type_supports( $post_type, 'title' )
3084
-		&& post_type_supports( $post_type, 'excerpt' );
3082
+		&& post_type_supports($post_type, 'editor')
3083
+		&& post_type_supports($post_type, 'title')
3084
+		&& post_type_supports($post_type, 'excerpt');
3085 3085
 
3086 3086
 	/**
3087 3087
 	 * Filter whether the post should be considered "empty".
@@ -3099,36 +3099,36 @@  discard block
 block discarded – undo
3099 3099
 	 * @param bool  $maybe_empty Whether the post should be considered "empty".
3100 3100
 	 * @param array $postarr     Array of post data.
3101 3101
 	 */
3102
-	if ( apply_filters( 'wp_insert_post_empty_content', $maybe_empty, $postarr ) ) {
3103
-		if ( $wp_error ) {
3104
-			return new WP_Error( 'empty_content', __( 'Content, title, and excerpt are empty.' ) );
3102
+	if (apply_filters('wp_insert_post_empty_content', $maybe_empty, $postarr)) {
3103
+		if ($wp_error) {
3104
+			return new WP_Error('empty_content', __('Content, title, and excerpt are empty.'));
3105 3105
 		} else {
3106 3106
 			return 0;
3107 3107
 		}
3108 3108
 	}
3109 3109
 
3110
-	$post_status = empty( $postarr['post_status'] ) ? 'draft' : $postarr['post_status'];
3111
-	if ( 'attachment' === $post_type && ! in_array( $post_status, array( 'inherit', 'private', 'trash' ) ) ) {
3110
+	$post_status = empty($postarr['post_status']) ? 'draft' : $postarr['post_status'];
3111
+	if ('attachment' === $post_type && ! in_array($post_status, array('inherit', 'private', 'trash'))) {
3112 3112
 		$post_status = 'inherit';
3113 3113
 	}
3114 3114
 
3115
-	if ( ! empty( $postarr['post_category'] ) ) {
3115
+	if ( ! empty($postarr['post_category'])) {
3116 3116
 		// Filter out empty terms.
3117
-		$post_category = array_filter( $postarr['post_category'] );
3117
+		$post_category = array_filter($postarr['post_category']);
3118 3118
 	}
3119 3119
 
3120 3120
 	// Make sure we set a valid category.
3121
-	if ( empty( $post_category ) || 0 == count( $post_category ) || ! is_array( $post_category ) ) {
3121
+	if (empty($post_category) || 0 == count($post_category) || ! is_array($post_category)) {
3122 3122
 		// 'post' requires at least one category.
3123
-		if ( 'post' == $post_type && 'auto-draft' != $post_status ) {
3124
-			$post_category = array( get_option('default_category') );
3123
+		if ('post' == $post_type && 'auto-draft' != $post_status) {
3124
+			$post_category = array(get_option('default_category'));
3125 3125
 		} else {
3126 3126
 			$post_category = array();
3127 3127
 		}
3128 3128
 	}
3129 3129
 
3130 3130
 	// Don't allow contributors to set the post slug for pending review posts.
3131
-	if ( 'pending' == $post_status && !current_user_can( 'publish_posts' ) ) {
3131
+	if ('pending' == $post_status && ! current_user_can('publish_posts')) {
3132 3132
 		$post_name = '';
3133 3133
 	}
3134 3134
 
@@ -3136,16 +3136,16 @@  discard block
 block discarded – undo
3136 3136
 	 * Create a valid post name. Drafts and pending posts are allowed to have
3137 3137
 	 * an empty post name.
3138 3138
 	 */
3139
-	if ( empty($post_name) ) {
3140
-		if ( !in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) ) {
3139
+	if (empty($post_name)) {
3140
+		if ( ! in_array($post_status, array('draft', 'pending', 'auto-draft'))) {
3141 3141
 			$post_name = sanitize_title($post_title);
3142 3142
 		} else {
3143 3143
 			$post_name = '';
3144 3144
 		}
3145 3145
 	} else {
3146 3146
 		// On updates, we need to check to see if it's using the old, fixed sanitization context.
3147
-		$check_name = sanitize_title( $post_name, '', 'old-save' );
3148
-		if ( $update && strtolower( urlencode( $post_name ) ) == $check_name && get_post_field( 'post_name', $post_ID ) == $check_name ) {
3147
+		$check_name = sanitize_title($post_name, '', 'old-save');
3148
+		if ($update && strtolower(urlencode($post_name)) == $check_name && get_post_field('post_name', $post_ID) == $check_name) {
3149 3149
 			$post_name = $check_name;
3150 3150
 		} else { // new post, or slug has changed.
3151 3151
 			$post_name = sanitize_title($post_name);
@@ -3156,32 +3156,32 @@  discard block
 block discarded – undo
3156 3156
 	 * If the post date is empty (due to having been new or a draft) and status
3157 3157
 	 * is not 'draft' or 'pending', set date to now.
3158 3158
 	 */
3159
-	if ( empty( $postarr['post_date'] ) || '0000-00-00 00:00:00' == $postarr['post_date'] ) {
3160
-		if ( empty( $postarr['post_date_gmt'] ) || '0000-00-00 00:00:00' == $postarr['post_date_gmt'] ) {
3161
-			$post_date = current_time( 'mysql' );
3159
+	if (empty($postarr['post_date']) || '0000-00-00 00:00:00' == $postarr['post_date']) {
3160
+		if (empty($postarr['post_date_gmt']) || '0000-00-00 00:00:00' == $postarr['post_date_gmt']) {
3161
+			$post_date = current_time('mysql');
3162 3162
 		} else {
3163
-			$post_date = get_date_from_gmt( $postarr['post_date_gmt'] );
3163
+			$post_date = get_date_from_gmt($postarr['post_date_gmt']);
3164 3164
 		}
3165 3165
 	} else {
3166 3166
 		$post_date = $postarr['post_date'];
3167 3167
 	}
3168 3168
 
3169 3169
 	// Validate the date.
3170
-	$mm = substr( $post_date, 5, 2 );
3171
-	$jj = substr( $post_date, 8, 2 );
3172
-	$aa = substr( $post_date, 0, 4 );
3173
-	$valid_date = wp_checkdate( $mm, $jj, $aa, $post_date );
3174
-	if ( ! $valid_date ) {
3175
-		if ( $wp_error ) {
3176
-			return new WP_Error( 'invalid_date', __( 'Whoops, the provided date is invalid.' ) );
3170
+	$mm = substr($post_date, 5, 2);
3171
+	$jj = substr($post_date, 8, 2);
3172
+	$aa = substr($post_date, 0, 4);
3173
+	$valid_date = wp_checkdate($mm, $jj, $aa, $post_date);
3174
+	if ( ! $valid_date) {
3175
+		if ($wp_error) {
3176
+			return new WP_Error('invalid_date', __('Whoops, the provided date is invalid.'));
3177 3177
 		} else {
3178 3178
 			return 0;
3179 3179
 		}
3180 3180
 	}
3181 3181
 
3182
-	if ( empty( $postarr['post_date_gmt'] ) || '0000-00-00 00:00:00' == $postarr['post_date_gmt'] ) {
3183
-		if ( ! in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) ) {
3184
-			$post_date_gmt = get_gmt_from_date( $post_date );
3182
+	if (empty($postarr['post_date_gmt']) || '0000-00-00 00:00:00' == $postarr['post_date_gmt']) {
3183
+		if ( ! in_array($post_status, array('draft', 'pending', 'auto-draft'))) {
3184
+			$post_date_gmt = get_gmt_from_date($post_date);
3185 3185
 		} else {
3186 3186
 			$post_date_gmt = '0000-00-00 00:00:00';
3187 3187
 		}
@@ -3189,34 +3189,34 @@  discard block
 block discarded – undo
3189 3189
 		$post_date_gmt = $postarr['post_date_gmt'];
3190 3190
 	}
3191 3191
 
3192
-	if ( $update || '0000-00-00 00:00:00' == $post_date ) {
3193
-		$post_modified     = current_time( 'mysql' );
3194
-		$post_modified_gmt = current_time( 'mysql', 1 );
3192
+	if ($update || '0000-00-00 00:00:00' == $post_date) {
3193
+		$post_modified     = current_time('mysql');
3194
+		$post_modified_gmt = current_time('mysql', 1);
3195 3195
 	} else {
3196 3196
 		$post_modified     = $post_date;
3197 3197
 		$post_modified_gmt = $post_date_gmt;
3198 3198
 	}
3199 3199
 
3200
-	if ( 'attachment' !== $post_type ) {
3201
-		if ( 'publish' == $post_status ) {
3200
+	if ('attachment' !== $post_type) {
3201
+		if ('publish' == $post_status) {
3202 3202
 			$now = gmdate('Y-m-d H:i:59');
3203
-			if ( mysql2date('U', $post_date_gmt, false) > mysql2date('U', $now, false) ) {
3203
+			if (mysql2date('U', $post_date_gmt, false) > mysql2date('U', $now, false)) {
3204 3204
 				$post_status = 'future';
3205 3205
 			}
3206
-		} elseif ( 'future' == $post_status ) {
3206
+		} elseif ('future' == $post_status) {
3207 3207
 			$now = gmdate('Y-m-d H:i:59');
3208
-			if ( mysql2date('U', $post_date_gmt, false) <= mysql2date('U', $now, false) ) {
3208
+			if (mysql2date('U', $post_date_gmt, false) <= mysql2date('U', $now, false)) {
3209 3209
 				$post_status = 'publish';
3210 3210
 			}
3211 3211
 		}
3212 3212
 	}
3213 3213
 
3214 3214
 	// Comment status.
3215
-	if ( empty( $postarr['comment_status'] ) ) {
3216
-		if ( $update ) {
3215
+	if (empty($postarr['comment_status'])) {
3216
+		if ($update) {
3217 3217
 			$comment_status = 'closed';
3218 3218
 		} else {
3219
-			$comment_status = get_default_comment_status( $post_type );
3219
+			$comment_status = get_default_comment_status($post_type);
3220 3220
 		}
3221 3221
 	} else {
3222 3222
 		$comment_status = $postarr['comment_status'];
@@ -3224,28 +3224,28 @@  discard block
 block discarded – undo
3224 3224
 
3225 3225
 	// These variables are needed by compact() later.
3226 3226
 	$post_content_filtered = $postarr['post_content_filtered'];
3227
-	$post_author = isset( $postarr['post_author'] ) ? $postarr['post_author'] : $user_id;
3228
-	$ping_status = empty( $postarr['ping_status'] ) ? get_default_comment_status( $post_type, 'pingback' ) : $postarr['ping_status'];
3229
-	$to_ping = isset( $postarr['to_ping'] ) ? sanitize_trackback_urls( $postarr['to_ping'] ) : '';
3230
-	$pinged = isset( $postarr['pinged'] ) ? $postarr['pinged'] : '';
3231
-	$import_id = isset( $postarr['import_id'] ) ? $postarr['import_id'] : 0;
3227
+	$post_author = isset($postarr['post_author']) ? $postarr['post_author'] : $user_id;
3228
+	$ping_status = empty($postarr['ping_status']) ? get_default_comment_status($post_type, 'pingback') : $postarr['ping_status'];
3229
+	$to_ping = isset($postarr['to_ping']) ? sanitize_trackback_urls($postarr['to_ping']) : '';
3230
+	$pinged = isset($postarr['pinged']) ? $postarr['pinged'] : '';
3231
+	$import_id = isset($postarr['import_id']) ? $postarr['import_id'] : 0;
3232 3232
 
3233 3233
 	/*
3234 3234
 	 * The 'wp_insert_post_parent' filter expects all variables to be present.
3235 3235
 	 * Previously, these variables would have already been extracted
3236 3236
 	 */
3237
-	if ( isset( $postarr['menu_order'] ) ) {
3237
+	if (isset($postarr['menu_order'])) {
3238 3238
 		$menu_order = (int) $postarr['menu_order'];
3239 3239
 	} else {
3240 3240
 		$menu_order = 0;
3241 3241
 	}
3242 3242
 
3243
-	$post_password = isset( $postarr['post_password'] ) ? $postarr['post_password'] : '';
3244
-	if ( 'private' == $post_status ) {
3243
+	$post_password = isset($postarr['post_password']) ? $postarr['post_password'] : '';
3244
+	if ('private' == $post_status) {
3245 3245
 		$post_password = '';
3246 3246
 	}
3247 3247
 
3248
-	if ( isset( $postarr['post_parent'] ) ) {
3248
+	if (isset($postarr['post_parent'])) {
3249 3249
 		$post_parent = (int) $postarr['post_parent'];
3250 3250
 	} else {
3251 3251
 		$post_parent = 0;
@@ -3261,50 +3261,50 @@  discard block
 block discarded – undo
3261 3261
 	 * @param array $new_postarr Array of parsed post data.
3262 3262
 	 * @param array $postarr     Array of sanitized, but otherwise unmodified post data.
3263 3263
 	 */
3264
-	$post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_ID, compact( array_keys( $postarr ) ), $postarr );
3264
+	$post_parent = apply_filters('wp_insert_post_parent', $post_parent, $post_ID, compact(array_keys($postarr)), $postarr);
3265 3265
 
3266 3266
 	/*
3267 3267
 	 * If the post is being untrashed and it has a desired slug stored in post meta,
3268 3268
 	 * reassign it.
3269 3269
 	 */
3270
-	if ( 'trash' === $previous_status && 'trash' !== $post_status ) {
3271
-		$desired_post_slug = get_post_meta( $post_ID, '_wp_desired_post_slug', true );
3272
-		if ( $desired_post_slug ) {
3273
-			delete_post_meta( $post_ID, '_wp_desired_post_slug' );
3270
+	if ('trash' === $previous_status && 'trash' !== $post_status) {
3271
+		$desired_post_slug = get_post_meta($post_ID, '_wp_desired_post_slug', true);
3272
+		if ($desired_post_slug) {
3273
+			delete_post_meta($post_ID, '_wp_desired_post_slug');
3274 3274
 			$post_name = $desired_post_slug;
3275 3275
 		}
3276 3276
 	}
3277 3277
 
3278 3278
 	// If a trashed post has the desired slug, change it and let this post have it.
3279
-	if ( 'trash' !== $post_status && $post_name ) {
3280
-		wp_add_trashed_suffix_to_post_name_for_trashed_posts( $post_name, $post_ID );
3279
+	if ('trash' !== $post_status && $post_name) {
3280
+		wp_add_trashed_suffix_to_post_name_for_trashed_posts($post_name, $post_ID);
3281 3281
 	}
3282 3282
 
3283 3283
 	// When trashing an existing post, change its slug to allow non-trashed posts to use it.
3284
-	if ( 'trash' === $post_status && 'trash' !== $previous_status && 'new' !== $previous_status ) {
3285
-		$post_name = wp_add_trashed_suffix_to_post_name_for_post( $post_ID );
3284
+	if ('trash' === $post_status && 'trash' !== $previous_status && 'new' !== $previous_status) {
3285
+		$post_name = wp_add_trashed_suffix_to_post_name_for_post($post_ID);
3286 3286
 	}
3287 3287
 
3288
-	$post_name = wp_unique_post_slug( $post_name, $post_ID, $post_status, $post_type, $post_parent );
3288
+	$post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent);
3289 3289
 
3290 3290
 	// Don't unslash.
3291
-	$post_mime_type = isset( $postarr['post_mime_type'] ) ? $postarr['post_mime_type'] : '';
3291
+	$post_mime_type = isset($postarr['post_mime_type']) ? $postarr['post_mime_type'] : '';
3292 3292
 
3293 3293
 	// Expected_slashed (everything!).
3294
-	$data = compact( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order', 'post_mime_type', 'guid' );
3294
+	$data = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order', 'post_mime_type', 'guid');
3295 3295
 
3296
-	$emoji_fields = array( 'post_title', 'post_content', 'post_excerpt' );
3296
+	$emoji_fields = array('post_title', 'post_content', 'post_excerpt');
3297 3297
 
3298
-	foreach ( $emoji_fields as $emoji_field ) {
3299
-		if ( isset( $data[ $emoji_field ] ) ) {
3300
-			$charset = $wpdb->get_col_charset( $wpdb->posts, $emoji_field );
3301
-			if ( 'utf8' === $charset ) {
3302
-				$data[ $emoji_field ] = wp_encode_emoji( $data[ $emoji_field ] );
3298
+	foreach ($emoji_fields as $emoji_field) {
3299
+		if (isset($data[$emoji_field])) {
3300
+			$charset = $wpdb->get_col_charset($wpdb->posts, $emoji_field);
3301
+			if ('utf8' === $charset) {
3302
+				$data[$emoji_field] = wp_encode_emoji($data[$emoji_field]);
3303 3303
 			}
3304 3304
 		}
3305 3305
 	}
3306 3306
 
3307
-	if ( 'attachment' === $post_type ) {
3307
+	if ('attachment' === $post_type) {
3308 3308
 		/**
3309 3309
 		 * Filter attachment post data before it is updated in or added to the database.
3310 3310
 		 *
@@ -3313,7 +3313,7 @@  discard block
 block discarded – undo
3313 3313
 		 * @param array $data    An array of sanitized attachment post data.
3314 3314
 		 * @param array $postarr An array of unsanitized attachment post data.
3315 3315
 		 */
3316
-		$data = apply_filters( 'wp_insert_attachment_data', $data, $postarr );
3316
+		$data = apply_filters('wp_insert_attachment_data', $data, $postarr);
3317 3317
 	} else {
3318 3318
 		/**
3319 3319
 		 * Filter slashed post data just before it is inserted into the database.
@@ -3323,12 +3323,12 @@  discard block
 block discarded – undo
3323 3323
 		 * @param array $data    An array of slashed post data.
3324 3324
 		 * @param array $postarr An array of sanitized, but otherwise unmodified post data.
3325 3325
 		 */
3326
-		$data = apply_filters( 'wp_insert_post_data', $data, $postarr );
3326
+		$data = apply_filters('wp_insert_post_data', $data, $postarr);
3327 3327
 	}
3328
-	$data = wp_unslash( $data );
3329
-	$where = array( 'ID' => $post_ID );
3328
+	$data = wp_unslash($data);
3329
+	$where = array('ID' => $post_ID);
3330 3330
 
3331
-	if ( $update ) {
3331
+	if ($update) {
3332 3332
 		/**
3333 3333
 		 * Fires immediately before an existing post is updated in the database.
3334 3334
 		 *
@@ -3337,9 +3337,9 @@  discard block
 block discarded – undo
3337 3337
 		 * @param int   $post_ID Post ID.
3338 3338
 		 * @param array $data    Array of unslashed post data.
3339 3339
 		 */
3340
-		do_action( 'pre_post_update', $post_ID, $data );
3341
-		if ( false === $wpdb->update( $wpdb->posts, $data, $where ) ) {
3342
-			if ( $wp_error ) {
3340
+		do_action('pre_post_update', $post_ID, $data);
3341
+		if (false === $wpdb->update($wpdb->posts, $data, $where)) {
3342
+			if ($wp_error) {
3343 3343
 				return new WP_Error('db_update_error', __('Could not update post in the database'), $wpdb->last_error);
3344 3344
 			} else {
3345 3345
 				return 0;
@@ -3347,14 +3347,14 @@  discard block
 block discarded – undo
3347 3347
 		}
3348 3348
 	} else {
3349 3349
 		// If there is a suggested ID, use it if not already present.
3350
-		if ( ! empty( $import_id ) ) {
3350
+		if ( ! empty($import_id)) {
3351 3351
 			$import_id = (int) $import_id;
3352
-			if ( ! $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE ID = %d", $import_id) ) ) {
3352
+			if ( ! $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE ID = %d", $import_id))) {
3353 3353
 				$data['ID'] = $import_id;
3354 3354
 			}
3355 3355
 		}
3356
-		if ( false === $wpdb->insert( $wpdb->posts, $data ) ) {
3357
-			if ( $wp_error ) {
3356
+		if (false === $wpdb->insert($wpdb->posts, $data)) {
3357
+			if ($wp_error) {
3358 3358
 				return new WP_Error('db_insert_error', __('Could not insert post into the database'), $wpdb->last_error);
3359 3359
 			} else {
3360 3360
 				return 0;
@@ -3363,87 +3363,87 @@  discard block
 block discarded – undo
3363 3363
 		$post_ID = (int) $wpdb->insert_id;
3364 3364
 
3365 3365
 		// Use the newly generated $post_ID.
3366
-		$where = array( 'ID' => $post_ID );
3366
+		$where = array('ID' => $post_ID);
3367 3367
 	}
3368 3368
 
3369
-	if ( empty( $data['post_name'] ) && ! in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) ) {
3370
-		$data['post_name'] = wp_unique_post_slug( sanitize_title( $data['post_title'], $post_ID ), $post_ID, $data['post_status'], $post_type, $post_parent );
3371
-		$wpdb->update( $wpdb->posts, array( 'post_name' => $data['post_name'] ), $where );
3372
-		clean_post_cache( $post_ID );
3369
+	if (empty($data['post_name']) && ! in_array($data['post_status'], array('draft', 'pending', 'auto-draft'))) {
3370
+		$data['post_name'] = wp_unique_post_slug(sanitize_title($data['post_title'], $post_ID), $post_ID, $data['post_status'], $post_type, $post_parent);
3371
+		$wpdb->update($wpdb->posts, array('post_name' => $data['post_name']), $where);
3372
+		clean_post_cache($post_ID);
3373 3373
 	}
3374 3374
 
3375
-	if ( is_object_in_taxonomy( $post_type, 'category' ) ) {
3376
-		wp_set_post_categories( $post_ID, $post_category );
3375
+	if (is_object_in_taxonomy($post_type, 'category')) {
3376
+		wp_set_post_categories($post_ID, $post_category);
3377 3377
 	}
3378 3378
 
3379
-	if ( isset( $postarr['tags_input'] ) && is_object_in_taxonomy( $post_type, 'post_tag' ) ) {
3380
-		wp_set_post_tags( $post_ID, $postarr['tags_input'] );
3379
+	if (isset($postarr['tags_input']) && is_object_in_taxonomy($post_type, 'post_tag')) {
3380
+		wp_set_post_tags($post_ID, $postarr['tags_input']);
3381 3381
 	}
3382 3382
 
3383 3383
 	// New-style support for all custom taxonomies.
3384
-	if ( ! empty( $postarr['tax_input'] ) ) {
3385
-		foreach ( $postarr['tax_input'] as $taxonomy => $tags ) {
3384
+	if ( ! empty($postarr['tax_input'])) {
3385
+		foreach ($postarr['tax_input'] as $taxonomy => $tags) {
3386 3386
 			$taxonomy_obj = get_taxonomy($taxonomy);
3387
-			if ( ! $taxonomy_obj ) {
3387
+			if ( ! $taxonomy_obj) {
3388 3388
 				/* translators: %s: taxonomy name */
3389
-				_doing_it_wrong( __FUNCTION__, sprintf( __( 'Invalid taxonomy: %s.' ), $taxonomy ), '4.4.0' );
3389
+				_doing_it_wrong(__FUNCTION__, sprintf(__('Invalid taxonomy: %s.'), $taxonomy), '4.4.0');
3390 3390
 				continue;
3391 3391
 			}
3392 3392
 
3393 3393
 			// array = hierarchical, string = non-hierarchical.
3394
-			if ( is_array( $tags ) ) {
3394
+			if (is_array($tags)) {
3395 3395
 				$tags = array_filter($tags);
3396 3396
 			}
3397
-			if ( current_user_can( $taxonomy_obj->cap->assign_terms ) ) {
3398
-				wp_set_post_terms( $post_ID, $tags, $taxonomy );
3397
+			if (current_user_can($taxonomy_obj->cap->assign_terms)) {
3398
+				wp_set_post_terms($post_ID, $tags, $taxonomy);
3399 3399
 			}
3400 3400
 		}
3401 3401
 	}
3402 3402
 
3403
-	if ( ! empty( $postarr['meta_input'] ) ) {
3404
-		foreach ( $postarr['meta_input'] as $field => $value ) {
3405
-			update_post_meta( $post_ID, $field, $value );
3403
+	if ( ! empty($postarr['meta_input'])) {
3404
+		foreach ($postarr['meta_input'] as $field => $value) {
3405
+			update_post_meta($post_ID, $field, $value);
3406 3406
 		}
3407 3407
 	}
3408 3408
 
3409
-	$current_guid = get_post_field( 'guid', $post_ID );
3409
+	$current_guid = get_post_field('guid', $post_ID);
3410 3410
 
3411 3411
 	// Set GUID.
3412
-	if ( ! $update && '' == $current_guid ) {
3413
-		$wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post_ID ) ), $where );
3412
+	if ( ! $update && '' == $current_guid) {
3413
+		$wpdb->update($wpdb->posts, array('guid' => get_permalink($post_ID)), $where);
3414 3414
 	}
3415 3415
 
3416
-	if ( 'attachment' === $postarr['post_type'] ) {
3417
-		if ( ! empty( $postarr['file'] ) ) {
3418
-			update_attached_file( $post_ID, $postarr['file'] );
3416
+	if ('attachment' === $postarr['post_type']) {
3417
+		if ( ! empty($postarr['file'])) {
3418
+			update_attached_file($post_ID, $postarr['file']);
3419 3419
 		}
3420 3420
 
3421
-		if ( ! empty( $postarr['context'] ) ) {
3422
-			add_post_meta( $post_ID, '_wp_attachment_context', $postarr['context'], true );
3421
+		if ( ! empty($postarr['context'])) {
3422
+			add_post_meta($post_ID, '_wp_attachment_context', $postarr['context'], true);
3423 3423
 		}
3424 3424
 	}
3425 3425
 
3426
-	clean_post_cache( $post_ID );
3426
+	clean_post_cache($post_ID);
3427 3427
 
3428
-	$post = get_post( $post_ID );
3428
+	$post = get_post($post_ID);
3429 3429
 
3430
-	if ( ! empty( $postarr['page_template'] ) && 'page' == $data['post_type'] ) {
3430
+	if ( ! empty($postarr['page_template']) && 'page' == $data['post_type']) {
3431 3431
 		$post->page_template = $postarr['page_template'];
3432
-		$page_templates = wp_get_theme()->get_page_templates( $post );
3433
-		if ( 'default' != $postarr['page_template'] && ! isset( $page_templates[ $postarr['page_template'] ] ) ) {
3434
-			if ( $wp_error ) {
3432
+		$page_templates = wp_get_theme()->get_page_templates($post);
3433
+		if ('default' != $postarr['page_template'] && ! isset($page_templates[$postarr['page_template']])) {
3434
+			if ($wp_error) {
3435 3435
 				return new WP_Error('invalid_page_template', __('The page template is invalid.'));
3436 3436
 			}
3437
-			update_post_meta( $post_ID, '_wp_page_template', 'default' );
3437
+			update_post_meta($post_ID, '_wp_page_template', 'default');
3438 3438
 		} else {
3439
-			update_post_meta( $post_ID, '_wp_page_template', $postarr['page_template'] );
3439
+			update_post_meta($post_ID, '_wp_page_template', $postarr['page_template']);
3440 3440
 		}
3441 3441
 	}
3442 3442
 
3443
-	if ( 'attachment' !== $postarr['post_type'] ) {
3444
-		wp_transition_post_status( $data['post_status'], $previous_status, $post );
3443
+	if ('attachment' !== $postarr['post_type']) {
3444
+		wp_transition_post_status($data['post_status'], $previous_status, $post);
3445 3445
 	} else {
3446
-		if ( $update ) {
3446
+		if ($update) {
3447 3447
 			/**
3448 3448
 			 * Fires once an existing attachment has been updated.
3449 3449
 			 *
@@ -3451,8 +3451,8 @@  discard block
 block discarded – undo
3451 3451
 			 *
3452 3452
 			 * @param int $post_ID Attachment ID.
3453 3453
 			 */
3454
-			do_action( 'edit_attachment', $post_ID );
3455
-			$post_after = get_post( $post_ID );
3454
+			do_action('edit_attachment', $post_ID);
3455
+			$post_after = get_post($post_ID);
3456 3456
 
3457 3457
 			/**
3458 3458
 			 * Fires once an existing attachment has been updated.
@@ -3463,7 +3463,7 @@  discard block
 block discarded – undo
3463 3463
 			 * @param WP_Post $post_after   Post object following the update.
3464 3464
 			 * @param WP_Post $post_before  Post object before the update.
3465 3465
 			 */
3466
-			do_action( 'attachment_updated', $post_ID, $post_after, $post_before );
3466
+			do_action('attachment_updated', $post_ID, $post_after, $post_before);
3467 3467
 		} else {
3468 3468
 
3469 3469
 			/**
@@ -3473,13 +3473,13 @@  discard block
 block discarded – undo
3473 3473
 			 *
3474 3474
 			 * @param int $post_ID Attachment ID.
3475 3475
 			 */
3476
-			do_action( 'add_attachment', $post_ID );
3476
+			do_action('add_attachment', $post_ID);
3477 3477
 		}
3478 3478
 
3479 3479
 		return $post_ID;
3480 3480
 	}
3481 3481
 
3482
-	if ( $update ) {
3482
+	if ($update) {
3483 3483
 		/**
3484 3484
 		 * Fires once an existing post has been updated.
3485 3485
 		 *
@@ -3488,7 +3488,7 @@  discard block
 block discarded – undo
3488 3488
 		 * @param int     $post_ID Post ID.
3489 3489
 		 * @param WP_Post $post    Post object.
3490 3490
 		 */
3491
-		do_action( 'edit_post', $post_ID, $post );
3491
+		do_action('edit_post', $post_ID, $post);
3492 3492
 		$post_after = get_post($post_ID);
3493 3493
 
3494 3494
 		/**
@@ -3500,7 +3500,7 @@  discard block
 block discarded – undo
3500 3500
 		 * @param WP_Post $post_after   Post object following the update.
3501 3501
 		 * @param WP_Post $post_before  Post object before the update.
3502 3502
 		 */
3503
-		do_action( 'post_updated', $post_ID, $post_after, $post_before);
3503
+		do_action('post_updated', $post_ID, $post_after, $post_before);
3504 3504
 	}
3505 3505
 
3506 3506
 	/**
@@ -3515,7 +3515,7 @@  discard block
 block discarded – undo
3515 3515
 	 * @param WP_Post $post    Post object.
3516 3516
 	 * @param bool    $update  Whether this is an existing post being updated or not.
3517 3517
 	 */
3518
-	do_action( "save_post_{$post->post_type}", $post_ID, $post, $update );
3518
+	do_action("save_post_{$post->post_type}", $post_ID, $post, $update);
3519 3519
 
3520 3520
 	/**
3521 3521
 	 * Fires once a post has been saved.
@@ -3526,7 +3526,7 @@  discard block
 block discarded – undo
3526 3526
 	 * @param WP_Post $post    Post object.
3527 3527
 	 * @param bool    $update  Whether this is an existing post being updated or not.
3528 3528
 	 */
3529
-	do_action( 'save_post', $post_ID, $post, $update );
3529
+	do_action('save_post', $post_ID, $post, $update);
3530 3530
 
3531 3531
 	/**
3532 3532
 	 * Fires once a post has been saved.
@@ -3537,7 +3537,7 @@  discard block
 block discarded – undo
3537 3537
 	 * @param WP_Post $post    Post object.
3538 3538
 	 * @param bool    $update  Whether this is an existing post being updated or not.
3539 3539
 	 */
3540
-	do_action( 'wp_insert_post', $post_ID, $post, $update );
3540
+	do_action('wp_insert_post', $post_ID, $post, $update);
3541 3541
 
3542 3542
 	return $post_ID;
3543 3543
 }
@@ -3555,8 +3555,8 @@  discard block
 block discarded – undo
3555 3555
  * @param bool         $wp_error Optional. Allow return of WP_Error on failure. Default false.
3556 3556
  * @return int|WP_Error The value 0 or WP_Error on failure. The post ID on success.
3557 3557
  */
3558
-function wp_update_post( $postarr = array(), $wp_error = false ) {
3559
-	if ( is_object($postarr) ) {
3558
+function wp_update_post($postarr = array(), $wp_error = false) {
3559
+	if (is_object($postarr)) {
3560 3560
 		// Non-escaped post was passed.
3561 3561
 		$postarr = get_object_vars($postarr);
3562 3562
 		$postarr = wp_slash($postarr);
@@ -3565,9 +3565,9 @@  discard block
 block discarded – undo
3565 3565
 	// First, get all of the original fields.
3566 3566
 	$post = get_post($postarr['ID'], ARRAY_A);
3567 3567
 
3568
-	if ( is_null( $post ) ) {
3569
-		if ( $wp_error )
3570
-			return new WP_Error( 'invalid_post', __( 'Invalid post ID.' ) );
3568
+	if (is_null($post)) {
3569
+		if ($wp_error)
3570
+			return new WP_Error('invalid_post', __('Invalid post ID.'));
3571 3571
 		return 0;
3572 3572
 	}
3573 3573
 
@@ -3575,15 +3575,15 @@  discard block
 block discarded – undo
3575 3575
 	$post = wp_slash($post);
3576 3576
 
3577 3577
 	// Passed post category list overwrites existing category list if not empty.
3578
-	if ( isset($postarr['post_category']) && is_array($postarr['post_category'])
3579
-			 && 0 != count($postarr['post_category']) )
3578
+	if (isset($postarr['post_category']) && is_array($postarr['post_category'])
3579
+			 && 0 != count($postarr['post_category']))
3580 3580
 		$post_cats = $postarr['post_category'];
3581 3581
 	else
3582 3582
 		$post_cats = $post['post_category'];
3583 3583
 
3584 3584
 	// Drafts shouldn't be assigned a date unless explicitly done so by the user.
3585
-	if ( isset( $post['post_status'] ) && in_array($post['post_status'], array('draft', 'pending', 'auto-draft')) && empty($postarr['edit_date']) &&
3586
-			 ('0000-00-00 00:00:00' == $post['post_date_gmt']) )
3585
+	if (isset($post['post_status']) && in_array($post['post_status'], array('draft', 'pending', 'auto-draft')) && empty($postarr['edit_date']) &&
3586
+			 ('0000-00-00 00:00:00' == $post['post_date_gmt']))
3587 3587
 		$clear_date = true;
3588 3588
 	else
3589 3589
 		$clear_date = false;
@@ -3591,7 +3591,7 @@  discard block
 block discarded – undo
3591 3591
 	// Merge old and new fields with new fields overwriting old ones.
3592 3592
 	$postarr = array_merge($post, $postarr);
3593 3593
 	$postarr['post_category'] = $post_cats;
3594
-	if ( $clear_date ) {
3594
+	if ($clear_date) {
3595 3595
 		$postarr['post_date'] = current_time('mysql');
3596 3596
 		$postarr['post_date_gmt'] = '';
3597 3597
 	}
@@ -3599,7 +3599,7 @@  discard block
 block discarded – undo
3599 3599
 	if ($postarr['post_type'] == 'attachment')
3600 3600
 		return wp_insert_attachment($postarr);
3601 3601
 
3602
-	return wp_insert_post( $postarr, $wp_error );
3602
+	return wp_insert_post($postarr, $wp_error);
3603 3603
 }
3604 3604
 
3605 3605
 /**
@@ -3611,34 +3611,34 @@  discard block
 block discarded – undo
3611 3611
  *
3612 3612
  * @param int|WP_Post $post Post ID or post object.
3613 3613
  */
3614
-function wp_publish_post( $post ) {
3614
+function wp_publish_post($post) {
3615 3615
 	global $wpdb;
3616 3616
 
3617
-	if ( ! $post = get_post( $post ) )
3617
+	if ( ! $post = get_post($post))
3618 3618
 		return;
3619 3619
 
3620
-	if ( 'publish' == $post->post_status )
3620
+	if ('publish' == $post->post_status)
3621 3621
 		return;
3622 3622
 
3623
-	$wpdb->update( $wpdb->posts, array( 'post_status' => 'publish' ), array( 'ID' => $post->ID ) );
3623
+	$wpdb->update($wpdb->posts, array('post_status' => 'publish'), array('ID' => $post->ID));
3624 3624
 
3625
-	clean_post_cache( $post->ID );
3625
+	clean_post_cache($post->ID);
3626 3626
 
3627 3627
 	$old_status = $post->post_status;
3628 3628
 	$post->post_status = 'publish';
3629
-	wp_transition_post_status( 'publish', $old_status, $post );
3629
+	wp_transition_post_status('publish', $old_status, $post);
3630 3630
 
3631 3631
 	/** This action is documented in wp-includes/post.php */
3632
-	do_action( 'edit_post', $post->ID, $post );
3632
+	do_action('edit_post', $post->ID, $post);
3633 3633
 
3634 3634
 	/** This action is documented in wp-includes/post.php */
3635
-	do_action( "save_post_{$post->post_type}", $post->ID, $post, true );
3635
+	do_action("save_post_{$post->post_type}", $post->ID, $post, true);
3636 3636
 
3637 3637
 	/** This action is documented in wp-includes/post.php */
3638
-	do_action( 'save_post', $post->ID, $post, true );
3638
+	do_action('save_post', $post->ID, $post, true);
3639 3639
 
3640 3640
 	/** This action is documented in wp-includes/post.php */
3641
-	do_action( 'wp_insert_post', $post->ID, $post, true );
3641
+	do_action('wp_insert_post', $post->ID, $post, true);
3642 3642
 }
3643 3643
 
3644 3644
 /**
@@ -3651,26 +3651,26 @@  discard block
 block discarded – undo
3651 3651
  *
3652 3652
  * @param int|WP_Post $post_id Post ID or post object.
3653 3653
  */
3654
-function check_and_publish_future_post( $post_id ) {
3654
+function check_and_publish_future_post($post_id) {
3655 3655
 	$post = get_post($post_id);
3656 3656
 
3657
-	if ( empty($post) )
3657
+	if (empty($post))
3658 3658
 		return;
3659 3659
 
3660
-	if ( 'future' != $post->post_status )
3660
+	if ('future' != $post->post_status)
3661 3661
 		return;
3662 3662
 
3663
-	$time = strtotime( $post->post_date_gmt . ' GMT' );
3663
+	$time = strtotime($post->post_date_gmt.' GMT');
3664 3664
 
3665 3665
 	// Uh oh, someone jumped the gun!
3666
-	if ( $time > time() ) {
3667
-		wp_clear_scheduled_hook( 'publish_future_post', array( $post_id ) ); // clear anything else in the system
3668
-		wp_schedule_single_event( $time, 'publish_future_post', array( $post_id ) );
3666
+	if ($time > time()) {
3667
+		wp_clear_scheduled_hook('publish_future_post', array($post_id)); // clear anything else in the system
3668
+		wp_schedule_single_event($time, 'publish_future_post', array($post_id));
3669 3669
 		return;
3670 3670
 	}
3671 3671
 
3672 3672
 	// wp_publish_post(_ returns no meaningful value.
3673
-	wp_publish_post( $post_id );
3673
+	wp_publish_post($post_id);
3674 3674
 }
3675 3675
 
3676 3676
 /**
@@ -3688,8 +3688,8 @@  discard block
 block discarded – undo
3688 3688
  * @param int    $post_parent Post parent ID.
3689 3689
  * @return string Unique slug for the post, based on $post_name (with a -1, -2, etc. suffix)
3690 3690
  */
3691
-function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_parent ) {
3692
-	if ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) || ( 'inherit' == $post_status && 'revision' == $post_type ) )
3691
+function wp_unique_post_slug($slug, $post_ID, $post_status, $post_type, $post_parent) {
3692
+	if (in_array($post_status, array('draft', 'pending', 'auto-draft')) || ('inherit' == $post_status && 'revision' == $post_type))
3693 3693
 		return $slug;
3694 3694
 
3695 3695
 	global $wpdb, $wp_rewrite;
@@ -3697,13 +3697,13 @@  discard block
 block discarded – undo
3697 3697
 	$original_slug = $slug;
3698 3698
 
3699 3699
 	$feeds = $wp_rewrite->feeds;
3700
-	if ( ! is_array( $feeds ) )
3700
+	if ( ! is_array($feeds))
3701 3701
 		$feeds = array();
3702 3702
 
3703
-	if ( 'attachment' == $post_type ) {
3703
+	if ('attachment' == $post_type) {
3704 3704
 		// Attachment slugs must be unique across all types.
3705 3705
 		$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND ID != %d LIMIT 1";
3706
-		$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID ) );
3706
+		$post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $slug, $post_ID));
3707 3707
 
3708 3708
 		/**
3709 3709
 		 * Filter whether the post slug would make a bad attachment slug.
@@ -3713,17 +3713,17 @@  discard block
 block discarded – undo
3713 3713
 		 * @param bool   $bad_slug Whether the slug would be bad as an attachment slug.
3714 3714
 		 * @param string $slug     The post slug.
3715 3715
 		 */
3716
-		if ( $post_name_check || in_array( $slug, $feeds ) || 'embed' === $slug || apply_filters( 'wp_unique_post_slug_is_bad_attachment_slug', false, $slug ) ) {
3716
+		if ($post_name_check || in_array($slug, $feeds) || 'embed' === $slug || apply_filters('wp_unique_post_slug_is_bad_attachment_slug', false, $slug)) {
3717 3717
 			$suffix = 2;
3718 3718
 			do {
3719
-				$alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
3720
-				$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_ID ) );
3719
+				$alt_post_name = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1))."-$suffix";
3720
+				$post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $alt_post_name, $post_ID));
3721 3721
 				$suffix++;
3722
-			} while ( $post_name_check );
3722
+			} while ($post_name_check);
3723 3723
 			$slug = $alt_post_name;
3724 3724
 		}
3725
-	} elseif ( is_post_type_hierarchical( $post_type ) ) {
3726
-		if ( 'nav_menu_item' == $post_type )
3725
+	} elseif (is_post_type_hierarchical($post_type)) {
3726
+		if ('nav_menu_item' == $post_type)
3727 3727
 			return $slug;
3728 3728
 
3729 3729
 		/*
@@ -3731,7 +3731,7 @@  discard block
 block discarded – undo
3731 3731
 		 * namespace than posts so page slugs are allowed to overlap post slugs.
3732 3732
 		 */
3733 3733
 		$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ( %s, 'attachment' ) AND ID != %d AND post_parent = %d LIMIT 1";
3734
-		$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID, $post_parent ) );
3734
+		$post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $slug, $post_type, $post_ID, $post_parent));
3735 3735
 
3736 3736
 		/**
3737 3737
 		 * Filter whether the post slug would make a bad hierarchical post slug.
@@ -3743,26 +3743,26 @@  discard block
 block discarded – undo
3743 3743
 		 * @param string $post_type   Post type.
3744 3744
 		 * @param int    $post_parent Post parent ID.
3745 3745
 		 */
3746
-		if ( $post_name_check || in_array( $slug, $feeds ) || 'embed' === $slug || preg_match( "@^($wp_rewrite->pagination_base)?\d+$@", $slug )  || apply_filters( 'wp_unique_post_slug_is_bad_hierarchical_slug', false, $slug, $post_type, $post_parent ) ) {
3746
+		if ($post_name_check || in_array($slug, $feeds) || 'embed' === $slug || preg_match("@^($wp_rewrite->pagination_base)?\d+$@", $slug) || apply_filters('wp_unique_post_slug_is_bad_hierarchical_slug', false, $slug, $post_type, $post_parent)) {
3747 3747
 			$suffix = 2;
3748 3748
 			do {
3749
-				$alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
3750
-				$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_ID, $post_parent ) );
3749
+				$alt_post_name = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1))."-$suffix";
3750
+				$post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $alt_post_name, $post_type, $post_ID, $post_parent));
3751 3751
 				$suffix++;
3752
-			} while ( $post_name_check );
3752
+			} while ($post_name_check);
3753 3753
 			$slug = $alt_post_name;
3754 3754
 		}
3755 3755
 	} else {
3756 3756
 		// Post slugs must be unique across all posts.
3757 3757
 		$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1";
3758
-		$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID ) );
3758
+		$post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $slug, $post_type, $post_ID));
3759 3759
 
3760 3760
 		// Prevent new post slugs that could result in URLs that conflict with date archives.
3761
-		$post = get_post( $post_ID );
3761
+		$post = get_post($post_ID);
3762 3762
 		$conflicts_with_date_archive = false;
3763
-		if ( 'post' === $post_type && ( ! $post || $post->post_name !== $slug ) && preg_match( '/^[0-9]+$/', $slug ) && $slug_num = intval( $slug ) ) {
3764
-			$permastructs   = array_values( array_filter( explode( '/', get_option( 'permalink_structure' ) ) ) );
3765
-			$postname_index = array_search( '%postname%', $permastructs );
3763
+		if ('post' === $post_type && ( ! $post || $post->post_name !== $slug) && preg_match('/^[0-9]+$/', $slug) && $slug_num = intval($slug)) {
3764
+			$permastructs   = array_values(array_filter(explode('/', get_option('permalink_structure'))));
3765
+			$postname_index = array_search('%postname%', $permastructs);
3766 3766
 
3767 3767
 			/*
3768 3768
 			 * Potential date clashes are as follows:
@@ -3771,9 +3771,9 @@  discard block
 block discarded – undo
3771 3771
 			 * - An integer between 1 and 12 that follows 'year' conflicts with 'monthnum'.
3772 3772
 			 * - An integer between 1 and 31 that follows 'monthnum' conflicts with 'day'.
3773 3773
 			 */
3774
-			if ( 0 === $postname_index ||
3775
-				( $postname_index && '%year%' === $permastructs[ $postname_index - 1 ] && 13 > $slug_num ) ||
3776
-				( $postname_index && '%monthnum%' === $permastructs[ $postname_index - 1 ] && 32 > $slug_num )
3774
+			if (0 === $postname_index ||
3775
+				($postname_index && '%year%' === $permastructs[$postname_index - 1] && 13 > $slug_num) ||
3776
+				($postname_index && '%monthnum%' === $permastructs[$postname_index - 1] && 32 > $slug_num)
3777 3777
 			) {
3778 3778
 				$conflicts_with_date_archive = true;
3779 3779
 			}
@@ -3788,13 +3788,13 @@  discard block
 block discarded – undo
3788 3788
 		 * @param string $slug      The post slug.
3789 3789
 		 * @param string $post_type Post type.
3790 3790
 		 */
3791
-		if ( $post_name_check || in_array( $slug, $feeds ) || 'embed' === $slug || $conflicts_with_date_archive || apply_filters( 'wp_unique_post_slug_is_bad_flat_slug', false, $slug, $post_type ) ) {
3791
+		if ($post_name_check || in_array($slug, $feeds) || 'embed' === $slug || $conflicts_with_date_archive || apply_filters('wp_unique_post_slug_is_bad_flat_slug', false, $slug, $post_type)) {
3792 3792
 			$suffix = 2;
3793 3793
 			do {
3794
-				$alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
3795
-				$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_ID ) );
3794
+				$alt_post_name = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1))."-$suffix";
3795
+				$post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $alt_post_name, $post_type, $post_ID));
3796 3796
 				$suffix++;
3797
-			} while ( $post_name_check );
3797
+			} while ($post_name_check);
3798 3798
 			$slug = $alt_post_name;
3799 3799
 		}
3800 3800
 	}
@@ -3811,7 +3811,7 @@  discard block
 block discarded – undo
3811 3811
 	 * @param int    $post_parent   Post parent ID
3812 3812
 	 * @param string $original_slug The original post slug.
3813 3813
 	 */
3814
-	return apply_filters( 'wp_unique_post_slug', $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug );
3814
+	return apply_filters('wp_unique_post_slug', $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug);
3815 3815
 }
3816 3816
 
3817 3817
 /**
@@ -3826,16 +3826,16 @@  discard block
 block discarded – undo
3826 3826
  * @param int    $length Optional. Max length of the slug. Default 200 (characters).
3827 3827
  * @return string The truncated slug.
3828 3828
  */
3829
-function _truncate_post_slug( $slug, $length = 200 ) {
3830
-	if ( strlen( $slug ) > $length ) {
3831
-		$decoded_slug = urldecode( $slug );
3832
-		if ( $decoded_slug === $slug )
3833
-			$slug = substr( $slug, 0, $length );
3829
+function _truncate_post_slug($slug, $length = 200) {
3830
+	if (strlen($slug) > $length) {
3831
+		$decoded_slug = urldecode($slug);
3832
+		if ($decoded_slug === $slug)
3833
+			$slug = substr($slug, 0, $length);
3834 3834
 		else
3835
-			$slug = utf8_uri_encode( $decoded_slug, $length );
3835
+			$slug = utf8_uri_encode($decoded_slug, $length);
3836 3836
 	}
3837 3837
 
3838
-	return rtrim( $slug, '-' );
3838
+	return rtrim($slug, '-');
3839 3839
 }
3840 3840
 
3841 3841
 /**
@@ -3850,7 +3850,7 @@  discard block
 block discarded – undo
3850 3850
  *                              separated by commas. Default empty.
3851 3851
  * @return array|false|WP_Error Array of affected term IDs. WP_Error or false on failure.
3852 3852
  */
3853
-function wp_add_post_tags( $post_id = 0, $tags = '' ) {
3853
+function wp_add_post_tags($post_id = 0, $tags = '') {
3854 3854
 	return wp_set_post_tags($post_id, $tags, true);
3855 3855
 }
3856 3856
 
@@ -3868,8 +3868,8 @@  discard block
 block discarded – undo
3868 3868
  *                              replace the tags with the new tags. Default false.
3869 3869
  * @return array|false|WP_Error Array of term taxonomy IDs of affected terms. WP_Error or false on failure.
3870 3870
  */
3871
-function wp_set_post_tags( $post_id = 0, $tags = '', $append = false ) {
3872
-	return wp_set_post_terms( $post_id, $tags, 'post_tag', $append);
3871
+function wp_set_post_tags($post_id = 0, $tags = '', $append = false) {
3872
+	return wp_set_post_terms($post_id, $tags, 'post_tag', $append);
3873 3873
 }
3874 3874
 
3875 3875
 /**
@@ -3887,31 +3887,31 @@  discard block
 block discarded – undo
3887 3887
  *                               replace the terms with the new terms. Default false.
3888 3888
  * @return array|false|WP_Error Array of term taxonomy IDs of affected terms. WP_Error or false on failure.
3889 3889
  */
3890
-function wp_set_post_terms( $post_id = 0, $tags = '', $taxonomy = 'post_tag', $append = false ) {
3890
+function wp_set_post_terms($post_id = 0, $tags = '', $taxonomy = 'post_tag', $append = false) {
3891 3891
 	$post_id = (int) $post_id;
3892 3892
 
3893
-	if ( !$post_id )
3893
+	if ( ! $post_id)
3894 3894
 		return false;
3895 3895
 
3896
-	if ( empty($tags) )
3896
+	if (empty($tags))
3897 3897
 		$tags = array();
3898 3898
 
3899
-	if ( ! is_array( $tags ) ) {
3900
-		$comma = _x( ',', 'tag delimiter' );
3901
-		if ( ',' !== $comma )
3902
-			$tags = str_replace( $comma, ',', $tags );
3903
-		$tags = explode( ',', trim( $tags, " \n\t\r\0\x0B," ) );
3899
+	if ( ! is_array($tags)) {
3900
+		$comma = _x(',', 'tag delimiter');
3901
+		if (',' !== $comma)
3902
+			$tags = str_replace($comma, ',', $tags);
3903
+		$tags = explode(',', trim($tags, " \n\t\r\0\x0B,"));
3904 3904
 	}
3905 3905
 
3906 3906
 	/*
3907 3907
 	 * Hierarchical taxonomies must always pass IDs rather than names so that
3908 3908
 	 * children with the same names but different parents aren't confused.
3909 3909
 	 */
3910
-	if ( is_taxonomy_hierarchical( $taxonomy ) ) {
3911
-		$tags = array_unique( array_map( 'intval', $tags ) );
3910
+	if (is_taxonomy_hierarchical($taxonomy)) {
3911
+		$tags = array_unique(array_map('intval', $tags));
3912 3912
 	}
3913 3913
 
3914
-	return wp_set_object_terms( $post_id, $tags, $taxonomy, $append );
3914
+	return wp_set_object_terms($post_id, $tags, $taxonomy, $append);
3915 3915
 }
3916 3916
 
3917 3917
 /**
@@ -3930,24 +3930,24 @@  discard block
 block discarded – undo
3930 3930
  *                                  If false, replace the categories with the new categories.
3931 3931
  * @return array|false|WP_Error Array of term taxonomy IDs of affected categories. WP_Error or false on failure.
3932 3932
  */
3933
-function wp_set_post_categories( $post_ID = 0, $post_categories = array(), $append = false ) {
3933
+function wp_set_post_categories($post_ID = 0, $post_categories = array(), $append = false) {
3934 3934
 	$post_ID = (int) $post_ID;
3935
-	$post_type = get_post_type( $post_ID );
3936
-	$post_status = get_post_status( $post_ID );
3935
+	$post_type = get_post_type($post_ID);
3936
+	$post_status = get_post_status($post_ID);
3937 3937
 	// If $post_categories isn't already an array, make it one:
3938 3938
 	$post_categories = (array) $post_categories;
3939
-	if ( empty( $post_categories ) ) {
3940
-		if ( 'post' == $post_type && 'auto-draft' != $post_status ) {
3941
-			$post_categories = array( get_option('default_category') );
3939
+	if (empty($post_categories)) {
3940
+		if ('post' == $post_type && 'auto-draft' != $post_status) {
3941
+			$post_categories = array(get_option('default_category'));
3942 3942
 			$append = false;
3943 3943
 		} else {
3944 3944
 			$post_categories = array();
3945 3945
 		}
3946
-	} elseif ( 1 == count( $post_categories ) && '' == reset( $post_categories ) ) {
3946
+	} elseif (1 == count($post_categories) && '' == reset($post_categories)) {
3947 3947
 		return true;
3948 3948
 	}
3949 3949
 
3950
-	return wp_set_post_terms( $post_ID, $post_categories, 'category', $append );
3950
+	return wp_set_post_terms($post_ID, $post_categories, 'category', $append);
3951 3951
 }
3952 3952
 
3953 3953
 /**
@@ -3971,7 +3971,7 @@  discard block
 block discarded – undo
3971 3971
  * @param string  $old_status Previous post status.
3972 3972
  * @param WP_Post $post Post data.
3973 3973
  */
3974
-function wp_transition_post_status( $new_status, $old_status, $post ) {
3974
+function wp_transition_post_status($new_status, $old_status, $post) {
3975 3975
 	/**
3976 3976
 	 * Fires when a post is transitioned from one status to another.
3977 3977
 	 *
@@ -3981,7 +3981,7 @@  discard block
 block discarded – undo
3981 3981
 	 * @param string  $old_status Old post status.
3982 3982
 	 * @param WP_Post $post       Post object.
3983 3983
 	 */
3984
-	do_action( 'transition_post_status', $new_status, $old_status, $post );
3984
+	do_action('transition_post_status', $new_status, $old_status, $post);
3985 3985
 
3986 3986
 	/**
3987 3987
 	 * Fires when a post is transitioned from one status to another.
@@ -3993,7 +3993,7 @@  discard block
 block discarded – undo
3993 3993
 	 *
3994 3994
 	 * @param WP_Post $post Post object.
3995 3995
 	 */
3996
-	do_action( "{$old_status}_to_{$new_status}", $post );
3996
+	do_action("{$old_status}_to_{$new_status}", $post);
3997 3997
 
3998 3998
 	/**
3999 3999
 	 * Fires when a post is transitioned from one status to another.
@@ -4014,7 +4014,7 @@  discard block
 block discarded – undo
4014 4014
 	 * @param int     $post_id Post ID.
4015 4015
 	 * @param WP_Post $post    Post object.
4016 4016
 	 */
4017
-	do_action( "{$new_status}_{$post->post_type}", $post->ID, $post );
4017
+	do_action("{$new_status}_{$post->post_type}", $post->ID, $post);
4018 4018
 }
4019 4019
 
4020 4020
 //
@@ -4032,9 +4032,9 @@  discard block
 block discarded – undo
4032 4032
  * @param string $uri     Ping URI.
4033 4033
  * @return int|false How many rows were updated.
4034 4034
  */
4035
-function add_ping( $post_id, $uri ) {
4035
+function add_ping($post_id, $uri) {
4036 4036
 	global $wpdb;
4037
-	$pung = $wpdb->get_var( $wpdb->prepare( "SELECT pinged FROM $wpdb->posts WHERE ID = %d", $post_id ));
4037
+	$pung = $wpdb->get_var($wpdb->prepare("SELECT pinged FROM $wpdb->posts WHERE ID = %d", $post_id));
4038 4038
 	$pung = trim($pung);
4039 4039
 	$pung = preg_split('/\s/', $pung);
4040 4040
 	$pung[] = $uri;
@@ -4047,11 +4047,11 @@  discard block
 block discarded – undo
4047 4047
 	 *
4048 4048
 	 * @param string $new New ping URL to add.
4049 4049
 	 */
4050
-	$new = apply_filters( 'add_ping', $new );
4050
+	$new = apply_filters('add_ping', $new);
4051 4051
 
4052 4052
 	// expected_slashed ($new).
4053 4053
 	$new = wp_unslash($new);
4054
-	return $wpdb->update( $wpdb->posts, array( 'pinged' => $new ), array( 'ID' => $post_id ) );
4054
+	return $wpdb->update($wpdb->posts, array('pinged' => $new), array('ID' => $post_id));
4055 4055
 }
4056 4056
 
4057 4057
 /**
@@ -4062,18 +4062,18 @@  discard block
 block discarded – undo
4062 4062
  * @param int $post_id Post ID.
4063 4063
  * @return array List of enclosures.
4064 4064
  */
4065
-function get_enclosed( $post_id ) {
4066
-	$custom_fields = get_post_custom( $post_id );
4065
+function get_enclosed($post_id) {
4066
+	$custom_fields = get_post_custom($post_id);
4067 4067
 	$pung = array();
4068
-	if ( !is_array( $custom_fields ) )
4068
+	if ( ! is_array($custom_fields))
4069 4069
 		return $pung;
4070 4070
 
4071
-	foreach ( $custom_fields as $key => $val ) {
4072
-		if ( 'enclosure' != $key || !is_array( $val ) )
4071
+	foreach ($custom_fields as $key => $val) {
4072
+		if ('enclosure' != $key || ! is_array($val))
4073 4073
 			continue;
4074
-		foreach ( $val as $enc ) {
4075
-			$enclosure = explode( "\n", $enc );
4076
-			$pung[] = trim( $enclosure[ 0 ] );
4074
+		foreach ($val as $enc) {
4075
+			$enclosure = explode("\n", $enc);
4076
+			$pung[] = trim($enclosure[0]);
4077 4077
 		}
4078 4078
 	}
4079 4079
 
@@ -4085,7 +4085,7 @@  discard block
 block discarded – undo
4085 4085
 	 * @param array $pung    Array of enclosures for the given post.
4086 4086
 	 * @param int   $post_id Post ID.
4087 4087
 	 */
4088
-	return apply_filters( 'get_enclosed', $pung, $post_id );
4088
+	return apply_filters('get_enclosed', $pung, $post_id);
4089 4089
 }
4090 4090
 
4091 4091
 /**
@@ -4098,9 +4098,9 @@  discard block
 block discarded – undo
4098 4098
  * @param int $post_id Post ID.
4099 4099
  * @return array
4100 4100
  */
4101
-function get_pung( $post_id ) {
4101
+function get_pung($post_id) {
4102 4102
 	global $wpdb;
4103
-	$pung = $wpdb->get_var( $wpdb->prepare( "SELECT pinged FROM $wpdb->posts WHERE ID = %d", $post_id ));
4103
+	$pung = $wpdb->get_var($wpdb->prepare("SELECT pinged FROM $wpdb->posts WHERE ID = %d", $post_id));
4104 4104
 	$pung = trim($pung);
4105 4105
 	$pung = preg_split('/\s/', $pung);
4106 4106
 
@@ -4111,7 +4111,7 @@  discard block
 block discarded – undo
4111 4111
 	 *
4112 4112
 	 * @param array $pung Array of URLs already pinged for the given post.
4113 4113
 	 */
4114
-	return apply_filters( 'get_pung', $pung );
4114
+	return apply_filters('get_pung', $pung);
4115 4115
 }
4116 4116
 
4117 4117
 /**
@@ -4124,10 +4124,10 @@  discard block
 block discarded – undo
4124 4124
  * @param int $post_id Post ID
4125 4125
  * @return array
4126 4126
  */
4127
-function get_to_ping( $post_id ) {
4127
+function get_to_ping($post_id) {
4128 4128
 	global $wpdb;
4129
-	$to_ping = $wpdb->get_var( $wpdb->prepare( "SELECT to_ping FROM $wpdb->posts WHERE ID = %d", $post_id ));
4130
-	$to_ping = sanitize_trackback_urls( $to_ping );
4129
+	$to_ping = $wpdb->get_var($wpdb->prepare("SELECT to_ping FROM $wpdb->posts WHERE ID = %d", $post_id));
4130
+	$to_ping = sanitize_trackback_urls($to_ping);
4131 4131
 	$to_ping = preg_split('/\s/', $to_ping, -1, PREG_SPLIT_NO_EMPTY);
4132 4132
 
4133 4133
 	/**
@@ -4137,7 +4137,7 @@  discard block
 block discarded – undo
4137 4137
 	 *
4138 4138
 	 * @param array $to_ping List of URLs yet to ping.
4139 4139
 	 */
4140
-	return apply_filters( 'get_to_ping', $to_ping );
4140
+	return apply_filters('get_to_ping', $to_ping);
4141 4141
 }
4142 4142
 
4143 4143
 /**
@@ -4148,22 +4148,22 @@  discard block
 block discarded – undo
4148 4148
  * @param string $tb_list Comma separated list of URLs.
4149 4149
  * @param int    $post_id Post ID.
4150 4150
  */
4151
-function trackback_url_list( $tb_list, $post_id ) {
4152
-	if ( ! empty( $tb_list ) ) {
4151
+function trackback_url_list($tb_list, $post_id) {
4152
+	if ( ! empty($tb_list)) {
4153 4153
 		// Get post data.
4154
-		$postdata = get_post( $post_id, ARRAY_A );
4154
+		$postdata = get_post($post_id, ARRAY_A);
4155 4155
 
4156 4156
 		// Form an excerpt.
4157
-		$excerpt = strip_tags( $postdata['post_excerpt'] ? $postdata['post_excerpt'] : $postdata['post_content'] );
4157
+		$excerpt = strip_tags($postdata['post_excerpt'] ? $postdata['post_excerpt'] : $postdata['post_content']);
4158 4158
 
4159
-		if ( strlen( $excerpt ) > 255 ) {
4160
-			$excerpt = substr( $excerpt, 0, 252 ) . '&hellip;';
4159
+		if (strlen($excerpt) > 255) {
4160
+			$excerpt = substr($excerpt, 0, 252).'&hellip;';
4161 4161
 		}
4162 4162
 
4163
-		$trackback_urls = explode( ',', $tb_list );
4164
-		foreach ( (array) $trackback_urls as $tb_url ) {
4165
-			$tb_url = trim( $tb_url );
4166
-			trackback( $tb_url, wp_unslash( $postdata['post_title'] ), $excerpt, $post_id );
4163
+		$trackback_urls = explode(',', $tb_list);
4164
+		foreach ((array) $trackback_urls as $tb_url) {
4165
+			$tb_url = trim($tb_url);
4166
+			trackback($tb_url, wp_unslash($postdata['post_title']), $excerpt, $post_id);
4167 4167
 		}
4168 4168
 	}
4169 4169
 }
@@ -4185,7 +4185,7 @@  discard block
 block discarded – undo
4185 4185
 	global $wpdb;
4186 4186
 
4187 4187
 	$page_ids = wp_cache_get('all_page_ids', 'posts');
4188
-	if ( ! is_array( $page_ids ) ) {
4188
+	if ( ! is_array($page_ids)) {
4189 4189
 		$page_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type = 'page'");
4190 4190
 		wp_cache_add('all_page_ids', $page_ids, 'posts');
4191 4191
 	}
@@ -4208,8 +4208,8 @@  discard block
 block discarded – undo
4208 4208
  *                       'edit', 'db', 'display'. Default 'raw'.
4209 4209
  * @return WP_Post|array|null WP_Post on success or null on failure.
4210 4210
  */
4211
-function get_page( $page, $output = OBJECT, $filter = 'raw') {
4212
-	return get_post( $page, $output, $filter );
4211
+function get_page($page, $output = OBJECT, $filter = 'raw') {
4212
+	return get_post($page, $output, $filter);
4213 4213
 }
4214 4214
 
4215 4215
 /**
@@ -4225,26 +4225,26 @@  discard block
 block discarded – undo
4225 4225
  * @param string|array $post_type Optional. Post type or array of post types. Default 'page'.
4226 4226
  * @return WP_Post|array|void WP_Post on success.
4227 4227
  */
4228
-function get_page_by_path( $page_path, $output = OBJECT, $post_type = 'page' ) {
4228
+function get_page_by_path($page_path, $output = OBJECT, $post_type = 'page') {
4229 4229
 	global $wpdb;
4230 4230
 
4231 4231
 	$page_path = rawurlencode(urldecode($page_path));
4232 4232
 	$page_path = str_replace('%2F', '/', $page_path);
4233 4233
 	$page_path = str_replace('%20', ' ', $page_path);
4234
-	$parts = explode( '/', trim( $page_path, '/' ) );
4235
-	$parts = esc_sql( $parts );
4236
-	$parts = array_map( 'sanitize_title_for_query', $parts );
4234
+	$parts = explode('/', trim($page_path, '/'));
4235
+	$parts = esc_sql($parts);
4236
+	$parts = array_map('sanitize_title_for_query', $parts);
4237 4237
 
4238
-	$in_string = "'" . implode( "','", $parts ) . "'";
4238
+	$in_string = "'".implode("','", $parts)."'";
4239 4239
 
4240
-	if ( is_array( $post_type ) ) {
4240
+	if (is_array($post_type)) {
4241 4241
 		$post_types = $post_type;
4242 4242
 	} else {
4243
-		$post_types = array( $post_type, 'attachment' );
4243
+		$post_types = array($post_type, 'attachment');
4244 4244
 	}
4245 4245
 
4246
-	$post_types = esc_sql( $post_types );
4247
-	$post_type_in_string = "'" . implode( "','", $post_types ) . "'";
4246
+	$post_types = esc_sql($post_types);
4247
+	$post_type_in_string = "'".implode("','", $post_types)."'";
4248 4248
 	$sql = "
4249 4249
 		SELECT ID, post_name, post_parent, post_type
4250 4250
 		FROM $wpdb->posts
@@ -4252,13 +4252,13 @@  discard block
 block discarded – undo
4252 4252
 		AND post_type IN ($post_type_in_string)
4253 4253
 	";
4254 4254
 
4255
-	$pages = $wpdb->get_results( $sql, OBJECT_K );
4255
+	$pages = $wpdb->get_results($sql, OBJECT_K);
4256 4256
 
4257
-	$revparts = array_reverse( $parts );
4257
+	$revparts = array_reverse($parts);
4258 4258
 
4259 4259
 	$foundid = 0;
4260
-	foreach ( (array) $pages as $page ) {
4261
-		if ( $page->post_name == $revparts[0] ) {
4260
+	foreach ((array) $pages as $page) {
4261
+		if ($page->post_name == $revparts[0]) {
4262 4262
 			$count = 0;
4263 4263
 			$p = $page;
4264 4264
 
@@ -4266,24 +4266,24 @@  discard block
 block discarded – undo
4266 4266
 			 * Loop through the given path parts from right to left,
4267 4267
 			 * ensuring each matches the post ancestry.
4268 4268
 			 */
4269
-			while ( $p->post_parent != 0 && isset( $pages[ $p->post_parent ] ) ) {
4269
+			while ($p->post_parent != 0 && isset($pages[$p->post_parent])) {
4270 4270
 				$count++;
4271
-				$parent = $pages[ $p->post_parent ];
4272
-				if ( ! isset( $revparts[ $count ] ) || $parent->post_name != $revparts[ $count ] )
4271
+				$parent = $pages[$p->post_parent];
4272
+				if ( ! isset($revparts[$count]) || $parent->post_name != $revparts[$count])
4273 4273
 					break;
4274 4274
 				$p = $parent;
4275 4275
 			}
4276 4276
 
4277
-			if ( $p->post_parent == 0 && $count+1 == count( $revparts ) && $p->post_name == $revparts[ $count ] ) {
4277
+			if ($p->post_parent == 0 && $count + 1 == count($revparts) && $p->post_name == $revparts[$count]) {
4278 4278
 				$foundid = $page->ID;
4279
-				if ( $page->post_type == $post_type )
4279
+				if ($page->post_type == $post_type)
4280 4280
 					break;
4281 4281
 			}
4282 4282
 		}
4283 4283
 	}
4284 4284
 
4285
-	if ( $foundid ) {
4286
-		return get_post( $foundid, $output );
4285
+	if ($foundid) {
4286
+		return get_post($foundid, $output);
4287 4287
 	}
4288 4288
 }
4289 4289
 
@@ -4300,31 +4300,31 @@  discard block
 block discarded – undo
4300 4300
  * @param string|array $post_type  Optional. Post type or array of post types. Default 'page'.
4301 4301
  * @return WP_Post|array|void WP_Post on success or null on failure
4302 4302
  */
4303
-function get_page_by_title( $page_title, $output = OBJECT, $post_type = 'page' ) {
4303
+function get_page_by_title($page_title, $output = OBJECT, $post_type = 'page') {
4304 4304
 	global $wpdb;
4305 4305
 
4306
-	if ( is_array( $post_type ) ) {
4307
-		$post_type = esc_sql( $post_type );
4308
-		$post_type_in_string = "'" . implode( "','", $post_type ) . "'";
4309
-		$sql = $wpdb->prepare( "
4306
+	if (is_array($post_type)) {
4307
+		$post_type = esc_sql($post_type);
4308
+		$post_type_in_string = "'".implode("','", $post_type)."'";
4309
+		$sql = $wpdb->prepare("
4310 4310
 			SELECT ID
4311 4311
 			FROM $wpdb->posts
4312 4312
 			WHERE post_title = %s
4313 4313
 			AND post_type IN ($post_type_in_string)
4314
-		", $page_title );
4314
+		", $page_title);
4315 4315
 	} else {
4316
-		$sql = $wpdb->prepare( "
4316
+		$sql = $wpdb->prepare("
4317 4317
 			SELECT ID
4318 4318
 			FROM $wpdb->posts
4319 4319
 			WHERE post_title = %s
4320 4320
 			AND post_type = %s
4321
-		", $page_title, $post_type );
4321
+		", $page_title, $post_type);
4322 4322
 	}
4323 4323
 
4324
-	$page = $wpdb->get_var( $sql );
4324
+	$page = $wpdb->get_var($sql);
4325 4325
 
4326
-	if ( $page ) {
4327
-		return get_post( $page, $output );
4326
+	if ($page) {
4327
+		return get_post($page, $output);
4328 4328
 	}
4329 4329
 }
4330 4330
 
@@ -4339,25 +4339,25 @@  discard block
 block discarded – undo
4339 4339
  * @param array $pages   List of page objects from which descendants should be identified.
4340 4340
  * @return array List of page children.
4341 4341
  */
4342
-function get_page_children( $page_id, $pages ) {
4342
+function get_page_children($page_id, $pages) {
4343 4343
 	// Build a hash of ID -> children.
4344 4344
 	$children = array();
4345
-	foreach ( (array) $pages as $page ) {
4346
-		$children[ intval( $page->post_parent ) ][] = $page;
4345
+	foreach ((array) $pages as $page) {
4346
+		$children[intval($page->post_parent)][] = $page;
4347 4347
 	}
4348 4348
 
4349 4349
 	$page_list = array();
4350 4350
 
4351 4351
 	// Start the search by looking at immediate children.
4352
-	if ( isset( $children[ $page_id ] ) ) {
4352
+	if (isset($children[$page_id])) {
4353 4353
 		// Always start at the end of the stack in order to preserve original `$pages` order.
4354
-		$to_look = array_reverse( $children[ $page_id ] );
4354
+		$to_look = array_reverse($children[$page_id]);
4355 4355
 
4356
-		while ( $to_look ) {
4357
-			$p = array_pop( $to_look );
4356
+		while ($to_look) {
4357
+			$p = array_pop($to_look);
4358 4358
 			$page_list[] = $p;
4359
-			if ( isset( $children[ $p->ID ] ) ) {
4360
-				foreach ( array_reverse( $children[ $p->ID ] ) as $child ) {
4359
+			if (isset($children[$p->ID])) {
4360
+				foreach (array_reverse($children[$p->ID]) as $child) {
4361 4361
 					// Append to the `$to_look` stack to descend the tree.
4362 4362
 					$to_look[] = $child;
4363 4363
 				}
@@ -4380,19 +4380,19 @@  discard block
 block discarded – undo
4380 4380
  * @param int   $page_id Optional. Parent page ID. Default 0.
4381 4381
  * @return array A list arranged by hierarchy. Children immediately follow their parents.
4382 4382
  */
4383
-function get_page_hierarchy( &$pages, $page_id = 0 ) {
4384
-	if ( empty( $pages ) ) {
4383
+function get_page_hierarchy(&$pages, $page_id = 0) {
4384
+	if (empty($pages)) {
4385 4385
 		return array();
4386 4386
 	}
4387 4387
 
4388 4388
 	$children = array();
4389
-	foreach ( (array) $pages as $p ) {
4390
-		$parent_id = intval( $p->post_parent );
4391
-		$children[ $parent_id ][] = $p;
4389
+	foreach ((array) $pages as $p) {
4390
+		$parent_id = intval($p->post_parent);
4391
+		$children[$parent_id][] = $p;
4392 4392
 	}
4393 4393
 
4394 4394
 	$result = array();
4395
-	_page_traverse_name( $page_id, $children, $result );
4395
+	_page_traverse_name($page_id, $children, $result);
4396 4396
 
4397 4397
 	return $result;
4398 4398
 }
@@ -4410,11 +4410,11 @@  discard block
 block discarded – undo
4410 4410
  * @param array $children  Parent-children relations, passed by reference.
4411 4411
  * @param array $result    Result, passed by reference.
4412 4412
  */
4413
-function _page_traverse_name( $page_id, &$children, &$result ){
4414
-	if ( isset( $children[ $page_id ] ) ){
4415
-		foreach ( (array)$children[ $page_id ] as $child ) {
4416
-			$result[ $child->ID ] = $child->post_name;
4417
-			_page_traverse_name( $child->ID, $children, $result );
4413
+function _page_traverse_name($page_id, &$children, &$result) {
4414
+	if (isset($children[$page_id])) {
4415
+		foreach ((array) $children[$page_id] as $child) {
4416
+			$result[$child->ID] = $child->post_name;
4417
+			_page_traverse_name($child->ID, $children, $result);
4418 4418
 		}
4419 4419
 	}
4420 4420
 }
@@ -4429,20 +4429,20 @@  discard block
 block discarded – undo
4429 4429
  * @param WP_Post|object|int $page Page object or page ID.
4430 4430
  * @return string|false Page URI, false on error.
4431 4431
  */
4432
-function get_page_uri( $page ) {
4433
-	if ( ! $page instanceof WP_Post ) {
4434
-		$page = get_post( $page );
4432
+function get_page_uri($page) {
4433
+	if ( ! $page instanceof WP_Post) {
4434
+		$page = get_post($page);
4435 4435
 	}
4436 4436
 
4437
-	if ( ! $page )
4437
+	if ( ! $page)
4438 4438
 		return false;
4439 4439
 
4440 4440
 	$uri = $page->post_name;
4441 4441
 
4442
-	foreach ( $page->ancestors as $parent ) {
4443
-		$parent = get_post( $parent );
4444
-		if ( $parent ) {
4445
-			$uri = $parent->post_name . '/' . $uri;
4442
+	foreach ($page->ancestors as $parent) {
4443
+		$parent = get_post($parent);
4444
+		if ($parent) {
4445
+			$uri = $parent->post_name.'/'.$uri;
4446 4446
 		}
4447 4447
 	}
4448 4448
 
@@ -4454,7 +4454,7 @@  discard block
 block discarded – undo
4454 4454
 	 * @param string  $uri  Page URI.
4455 4455
 	 * @param WP_Post $page Page object.
4456 4456
 	 */
4457
-	return apply_filters( 'get_page_uri', $uri, $page );
4457
+	return apply_filters('get_page_uri', $uri, $page);
4458 4458
 }
4459 4459
 
4460 4460
 /**
@@ -4499,7 +4499,7 @@  discard block
 block discarded – undo
4499 4499
  * }
4500 4500
  * @return array|false List of pages matching defaults or `$args`.
4501 4501
  */
4502
-function get_pages( $args = array() ) {
4502
+function get_pages($args = array()) {
4503 4503
 	global $wpdb;
4504 4504
 
4505 4505
 	$defaults = array(
@@ -4512,7 +4512,7 @@  discard block
 block discarded – undo
4512 4512
 		'post_type' => 'page', 'post_status' => 'publish',
4513 4513
 	);
4514 4514
 
4515
-	$r = wp_parse_args( $args, $defaults );
4515
+	$r = wp_parse_args($args, $defaults);
4516 4516
 
4517 4517
 	$number = (int) $r['number'];
4518 4518
 	$offset = (int) $r['offset'];
@@ -4525,87 +4525,87 @@  discard block
 block discarded – undo
4525 4525
 	$post_status = $r['post_status'];
4526 4526
 
4527 4527
 	// Make sure the post type is hierarchical.
4528
-	$hierarchical_post_types = get_post_types( array( 'hierarchical' => true ) );
4529
-	if ( ! in_array( $r['post_type'], $hierarchical_post_types ) ) {
4528
+	$hierarchical_post_types = get_post_types(array('hierarchical' => true));
4529
+	if ( ! in_array($r['post_type'], $hierarchical_post_types)) {
4530 4530
 		return false;
4531 4531
 	}
4532 4532
 
4533
-	if ( $parent > 0 && ! $child_of ) {
4533
+	if ($parent > 0 && ! $child_of) {
4534 4534
 		$hierarchical = false;
4535 4535
 	}
4536 4536
 
4537 4537
 	// Make sure we have a valid post status.
4538
-	if ( ! is_array( $post_status ) ) {
4539
-		$post_status = explode( ',', $post_status );
4538
+	if ( ! is_array($post_status)) {
4539
+		$post_status = explode(',', $post_status);
4540 4540
 	}
4541
-	if ( array_diff( $post_status, get_post_stati() ) ) {
4541
+	if (array_diff($post_status, get_post_stati())) {
4542 4542
 		return false;
4543 4543
 	}
4544 4544
 
4545 4545
 	// $args can be whatever, only use the args defined in defaults to compute the key.
4546
-	$key = md5( serialize( wp_array_slice_assoc( $r, array_keys( $defaults ) ) ) );
4547
-	$last_changed = wp_cache_get( 'last_changed', 'posts' );
4548
-	if ( ! $last_changed ) {
4546
+	$key = md5(serialize(wp_array_slice_assoc($r, array_keys($defaults))));
4547
+	$last_changed = wp_cache_get('last_changed', 'posts');
4548
+	if ( ! $last_changed) {
4549 4549
 		$last_changed = microtime();
4550
-		wp_cache_set( 'last_changed', $last_changed, 'posts' );
4550
+		wp_cache_set('last_changed', $last_changed, 'posts');
4551 4551
 	}
4552 4552
 
4553 4553
 	$cache_key = "get_pages:$key:$last_changed";
4554
-	if ( $cache = wp_cache_get( $cache_key, 'posts' ) ) {
4554
+	if ($cache = wp_cache_get($cache_key, 'posts')) {
4555 4555
 		// Convert to WP_Post instances.
4556
-		$pages = array_map( 'get_post', $cache );
4556
+		$pages = array_map('get_post', $cache);
4557 4557
 		/** This filter is documented in wp-includes/post.php */
4558
-		$pages = apply_filters( 'get_pages', $pages, $r );
4558
+		$pages = apply_filters('get_pages', $pages, $r);
4559 4559
 		return $pages;
4560 4560
 	}
4561 4561
 
4562 4562
 	$inclusions = '';
4563
-	if ( ! empty( $r['include'] ) ) {
4563
+	if ( ! empty($r['include'])) {
4564 4564
 		$child_of = 0; //ignore child_of, parent, exclude, meta_key, and meta_value params if using include
4565 4565
 		$parent = -1;
4566 4566
 		$exclude = '';
4567 4567
 		$meta_key = '';
4568 4568
 		$meta_value = '';
4569 4569
 		$hierarchical = false;
4570
-		$incpages = wp_parse_id_list( $r['include'] );
4571
-		if ( ! empty( $incpages ) ) {
4572
-			$inclusions = ' AND ID IN (' . implode( ',', $incpages ) .  ')';
4570
+		$incpages = wp_parse_id_list($r['include']);
4571
+		if ( ! empty($incpages)) {
4572
+			$inclusions = ' AND ID IN ('.implode(',', $incpages).')';
4573 4573
 		}
4574 4574
 	}
4575 4575
 
4576 4576
 	$exclusions = '';
4577
-	if ( ! empty( $exclude ) ) {
4578
-		$expages = wp_parse_id_list( $exclude );
4579
-		if ( ! empty( $expages ) ) {
4580
-			$exclusions = ' AND ID NOT IN (' . implode( ',', $expages ) .  ')';
4577
+	if ( ! empty($exclude)) {
4578
+		$expages = wp_parse_id_list($exclude);
4579
+		if ( ! empty($expages)) {
4580
+			$exclusions = ' AND ID NOT IN ('.implode(',', $expages).')';
4581 4581
 		}
4582 4582
 	}
4583 4583
 
4584 4584
 	$author_query = '';
4585
-	if ( ! empty( $r['authors'] ) ) {
4586
-		$post_authors = preg_split( '/[\s,]+/', $r['authors'] );
4585
+	if ( ! empty($r['authors'])) {
4586
+		$post_authors = preg_split('/[\s,]+/', $r['authors']);
4587 4587
 
4588
-		if ( ! empty( $post_authors ) ) {
4589
-			foreach ( $post_authors as $post_author ) {
4588
+		if ( ! empty($post_authors)) {
4589
+			foreach ($post_authors as $post_author) {
4590 4590
 				//Do we have an author id or an author login?
4591
-				if ( 0 == intval($post_author) ) {
4591
+				if (0 == intval($post_author)) {
4592 4592
 					$post_author = get_user_by('login', $post_author);
4593
-					if ( empty( $post_author ) ) {
4593
+					if (empty($post_author)) {
4594 4594
 						continue;
4595 4595
 					}
4596
-					if ( empty( $post_author->ID ) ) {
4596
+					if (empty($post_author->ID)) {
4597 4597
 						continue;
4598 4598
 					}
4599 4599
 					$post_author = $post_author->ID;
4600 4600
 				}
4601 4601
 
4602
-				if ( '' == $author_query ) {
4602
+				if ('' == $author_query) {
4603 4603
 					$author_query = $wpdb->prepare(' post_author = %d ', $post_author);
4604 4604
 				} else {
4605 4605
 					$author_query .= $wpdb->prepare(' OR post_author = %d ', $post_author);
4606 4606
 				}
4607 4607
 			}
4608
-			if ( '' != $author_query ) {
4608
+			if ('' != $author_query) {
4609 4609
 				$author_query = " AND ($author_query)";
4610 4610
 			}
4611 4611
 		}
@@ -4613,49 +4613,49 @@  discard block
 block discarded – undo
4613 4613
 
4614 4614
 	$join = '';
4615 4615
 	$where = "$exclusions $inclusions ";
4616
-	if ( '' !== $meta_key || '' !== $meta_value ) {
4616
+	if ('' !== $meta_key || '' !== $meta_value) {
4617 4617
 		$join = " LEFT JOIN $wpdb->postmeta ON ( $wpdb->posts.ID = $wpdb->postmeta.post_id )";
4618 4618
 
4619 4619
 		// meta_key and meta_value might be slashed
4620 4620
 		$meta_key = wp_unslash($meta_key);
4621 4621
 		$meta_value = wp_unslash($meta_value);
4622
-		if ( '' !== $meta_key ) {
4622
+		if ('' !== $meta_key) {
4623 4623
 			$where .= $wpdb->prepare(" AND $wpdb->postmeta.meta_key = %s", $meta_key);
4624 4624
 		}
4625
-		if ( '' !== $meta_value ) {
4625
+		if ('' !== $meta_value) {
4626 4626
 			$where .= $wpdb->prepare(" AND $wpdb->postmeta.meta_value = %s", $meta_value);
4627 4627
 		}
4628 4628
 
4629 4629
 	}
4630 4630
 
4631
-	if ( is_array( $parent ) ) {
4632
-		$post_parent__in = implode( ',', array_map( 'absint', (array) $parent ) );
4633
-		if ( ! empty( $post_parent__in ) ) {
4631
+	if (is_array($parent)) {
4632
+		$post_parent__in = implode(',', array_map('absint', (array) $parent));
4633
+		if ( ! empty($post_parent__in)) {
4634 4634
 			$where .= " AND post_parent IN ($post_parent__in)";
4635 4635
 		}
4636
-	} elseif ( $parent >= 0 ) {
4636
+	} elseif ($parent >= 0) {
4637 4637
 		$where .= $wpdb->prepare(' AND post_parent = %d ', $parent);
4638 4638
 	}
4639 4639
 
4640
-	if ( 1 == count( $post_status ) ) {
4641
-		$where_post_type = $wpdb->prepare( "post_type = %s AND post_status = %s", $r['post_type'], reset( $post_status ) );
4640
+	if (1 == count($post_status)) {
4641
+		$where_post_type = $wpdb->prepare("post_type = %s AND post_status = %s", $r['post_type'], reset($post_status));
4642 4642
 	} else {
4643
-		$post_status = implode( "', '", $post_status );
4644
-		$where_post_type = $wpdb->prepare( "post_type = %s AND post_status IN ('$post_status')", $r['post_type'] );
4643
+		$post_status = implode("', '", $post_status);
4644
+		$where_post_type = $wpdb->prepare("post_type = %s AND post_status IN ('$post_status')", $r['post_type']);
4645 4645
 	}
4646 4646
 
4647 4647
 	$orderby_array = array();
4648
-	$allowed_keys = array( 'author', 'post_author', 'date', 'post_date', 'title', 'post_title', 'name', 'post_name', 'modified',
4648
+	$allowed_keys = array('author', 'post_author', 'date', 'post_date', 'title', 'post_title', 'name', 'post_name', 'modified',
4649 4649
 		'post_modified', 'modified_gmt', 'post_modified_gmt', 'menu_order', 'parent', 'post_parent',
4650
-		'ID', 'rand', 'comment_count' );
4650
+		'ID', 'rand', 'comment_count');
4651 4651
 
4652
-	foreach ( explode( ',', $r['sort_column'] ) as $orderby ) {
4653
-		$orderby = trim( $orderby );
4654
-		if ( ! in_array( $orderby, $allowed_keys ) ) {
4652
+	foreach (explode(',', $r['sort_column']) as $orderby) {
4653
+		$orderby = trim($orderby);
4654
+		if ( ! in_array($orderby, $allowed_keys)) {
4655 4655
 			continue;
4656 4656
 		}
4657 4657
 
4658
-		switch ( $orderby ) {
4658
+		switch ($orderby) {
4659 4659
 			case 'menu_order':
4660 4660
 				break;
4661 4661
 			case 'ID':
@@ -4668,36 +4668,36 @@  discard block
 block discarded – undo
4668 4668
 				$orderby = "$wpdb->posts.comment_count";
4669 4669
 				break;
4670 4670
 			default:
4671
-				if ( 0 === strpos( $orderby, 'post_' ) ) {
4672
-					$orderby = "$wpdb->posts." . $orderby;
4671
+				if (0 === strpos($orderby, 'post_')) {
4672
+					$orderby = "$wpdb->posts.".$orderby;
4673 4673
 				} else {
4674
-					$orderby = "$wpdb->posts.post_" . $orderby;
4674
+					$orderby = "$wpdb->posts.post_".$orderby;
4675 4675
 				}
4676 4676
 		}
4677 4677
 
4678 4678
 		$orderby_array[] = $orderby;
4679 4679
 
4680 4680
 	}
4681
-	$sort_column = ! empty( $orderby_array ) ? implode( ',', $orderby_array ) : "$wpdb->posts.post_title";
4681
+	$sort_column = ! empty($orderby_array) ? implode(',', $orderby_array) : "$wpdb->posts.post_title";
4682 4682
 
4683
-	$sort_order = strtoupper( $r['sort_order'] );
4684
-	if ( '' !== $sort_order && ! in_array( $sort_order, array( 'ASC', 'DESC' ) ) ) {
4683
+	$sort_order = strtoupper($r['sort_order']);
4684
+	if ('' !== $sort_order && ! in_array($sort_order, array('ASC', 'DESC'))) {
4685 4685
 		$sort_order = 'ASC';
4686 4686
 	}
4687 4687
 
4688 4688
 	$query = "SELECT * FROM $wpdb->posts $join WHERE ($where_post_type) $where ";
4689 4689
 	$query .= $author_query;
4690
-	$query .= " ORDER BY " . $sort_column . " " . $sort_order ;
4690
+	$query .= " ORDER BY ".$sort_column." ".$sort_order;
4691 4691
 
4692
-	if ( ! empty( $number ) ) {
4693
-		$query .= ' LIMIT ' . $offset . ',' . $number;
4692
+	if ( ! empty($number)) {
4693
+		$query .= ' LIMIT '.$offset.','.$number;
4694 4694
 	}
4695 4695
 
4696 4696
 	$pages = $wpdb->get_results($query);
4697 4697
 
4698
-	if ( empty($pages) ) {
4698
+	if (empty($pages)) {
4699 4699
 		/** This filter is documented in wp-includes/post.php */
4700
-		$pages = apply_filters( 'get_pages', array(), $r );
4700
+		$pages = apply_filters('get_pages', array(), $r);
4701 4701
 		return $pages;
4702 4702
 	}
4703 4703
 
@@ -4708,38 +4708,38 @@  discard block
 block discarded – undo
4708 4708
 	}
4709 4709
 
4710 4710
 	// Update cache.
4711
-	update_post_cache( $pages );
4711
+	update_post_cache($pages);
4712 4712
 
4713
-	if ( $child_of || $hierarchical ) {
4713
+	if ($child_of || $hierarchical) {
4714 4714
 		$pages = get_page_children($child_of, $pages);
4715 4715
 	}
4716 4716
 
4717
-	if ( ! empty( $r['exclude_tree'] ) ) {
4718
-		$exclude = wp_parse_id_list( $r['exclude_tree'] );
4719
-		foreach ( $exclude as $id ) {
4720
-			$children = get_page_children( $id, $pages );
4721
-			foreach ( $children as $child ) {
4717
+	if ( ! empty($r['exclude_tree'])) {
4718
+		$exclude = wp_parse_id_list($r['exclude_tree']);
4719
+		foreach ($exclude as $id) {
4720
+			$children = get_page_children($id, $pages);
4721
+			foreach ($children as $child) {
4722 4722
 				$exclude[] = $child->ID;
4723 4723
 			}
4724 4724
 		}
4725 4725
 
4726
-		$num_pages = count( $pages );
4727
-		for ( $i = 0; $i < $num_pages; $i++ ) {
4728
-			if ( in_array( $pages[$i]->ID, $exclude ) ) {
4729
-				unset( $pages[$i] );
4726
+		$num_pages = count($pages);
4727
+		for ($i = 0; $i < $num_pages; $i++) {
4728
+			if (in_array($pages[$i]->ID, $exclude)) {
4729
+				unset($pages[$i]);
4730 4730
 			}
4731 4731
 		}
4732 4732
 	}
4733 4733
 
4734 4734
 	$page_structure = array();
4735
-	foreach ( $pages as $page ) {
4735
+	foreach ($pages as $page) {
4736 4736
 		$page_structure[] = $page->ID;
4737 4737
 	}
4738 4738
 
4739
-	wp_cache_set( $cache_key, $page_structure, 'posts' );
4739
+	wp_cache_set($cache_key, $page_structure, 'posts');
4740 4740
 
4741 4741
 	// Convert to WP_Post instances
4742
-	$pages = array_map( 'get_post', $pages );
4742
+	$pages = array_map('get_post', $pages);
4743 4743
 
4744 4744
 	/**
4745 4745
 	 * Filter the retrieved list of pages.
@@ -4749,7 +4749,7 @@  discard block
 block discarded – undo
4749 4749
 	 * @param array $pages List of pages to retrieve.
4750 4750
 	 * @param array $r     Array of get_pages() arguments.
4751 4751
 	 */
4752
-	return apply_filters( 'get_pages', $pages, $r );
4752
+	return apply_filters('get_pages', $pages, $r);
4753 4753
 }
4754 4754
 
4755 4755
 //
@@ -4769,9 +4769,9 @@  discard block
 block discarded – undo
4769 4769
 		return false;
4770 4770
 	if (strpos($url, home_url('/?attachment_id=')) !== false)
4771 4771
 		return true;
4772
-	if ( $id = url_to_postid($url) ) {
4772
+	if ($id = url_to_postid($url)) {
4773 4773
 		$post = get_post($id);
4774
-		if ( 'attachment' == $post->post_type )
4774
+		if ('attachment' == $post->post_type)
4775 4775
 			return true;
4776 4776
 	}
4777 4777
 	return false;
@@ -4800,21 +4800,21 @@  discard block
 block discarded – undo
4800 4800
  * @param int          $parent Optional. Parent post ID.
4801 4801
  * @return int Attachment ID.
4802 4802
  */
4803
-function wp_insert_attachment( $args, $file = false, $parent = 0 ) {
4803
+function wp_insert_attachment($args, $file = false, $parent = 0) {
4804 4804
 	$defaults = array(
4805 4805
 		'file'        => $file,
4806 4806
 		'post_parent' => 0
4807 4807
 	);
4808 4808
 
4809
-	$data = wp_parse_args( $args, $defaults );
4809
+	$data = wp_parse_args($args, $defaults);
4810 4810
 
4811
-	if ( ! empty( $parent ) ) {
4811
+	if ( ! empty($parent)) {
4812 4812
 		$data['post_parent'] = $parent;
4813 4813
 	}
4814 4814
 
4815 4815
 	$data['post_type'] = 'attachment';
4816 4816
 
4817
-	return wp_insert_post( $data );
4817
+	return wp_insert_post($data);
4818 4818
 }
4819 4819
 
4820 4820
 /**
@@ -4836,27 +4836,27 @@  discard block
 block discarded – undo
4836 4836
  *                           Default false.
4837 4837
  * @return mixed False on failure. Post data on success.
4838 4838
  */
4839
-function wp_delete_attachment( $post_id, $force_delete = false ) {
4839
+function wp_delete_attachment($post_id, $force_delete = false) {
4840 4840
 	global $wpdb;
4841 4841
 
4842
-	if ( !$post = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $post_id) ) )
4842
+	if ( ! $post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $post_id)))
4843 4843
 		return $post;
4844 4844
 
4845
-	if ( 'attachment' != $post->post_type )
4845
+	if ('attachment' != $post->post_type)
4846 4846
 		return false;
4847 4847
 
4848
-	if ( !$force_delete && EMPTY_TRASH_DAYS && MEDIA_TRASH && 'trash' != $post->post_status )
4849
-		return wp_trash_post( $post_id );
4848
+	if ( ! $force_delete && EMPTY_TRASH_DAYS && MEDIA_TRASH && 'trash' != $post->post_status)
4849
+		return wp_trash_post($post_id);
4850 4850
 
4851 4851
 	delete_post_meta($post_id, '_wp_trash_meta_status');
4852 4852
 	delete_post_meta($post_id, '_wp_trash_meta_time');
4853 4853
 
4854
-	$meta = wp_get_attachment_metadata( $post_id );
4855
-	$backup_sizes = get_post_meta( $post->ID, '_wp_attachment_backup_sizes', true );
4856
-	$file = get_attached_file( $post_id );
4854
+	$meta = wp_get_attachment_metadata($post_id);
4855
+	$backup_sizes = get_post_meta($post->ID, '_wp_attachment_backup_sizes', true);
4856
+	$file = get_attached_file($post_id);
4857 4857
 
4858
-	if ( is_multisite() )
4859
-		delete_transient( 'dirsize_cache' );
4858
+	if (is_multisite())
4859
+		delete_transient('dirsize_cache');
4860 4860
 
4861 4861
 	/**
4862 4862
 	 * Fires before an attachment is deleted, at the start of wp_delete_attachment().
@@ -4865,70 +4865,70 @@  discard block
 block discarded – undo
4865 4865
 	 *
4866 4866
 	 * @param int $post_id Attachment ID.
4867 4867
 	 */
4868
-	do_action( 'delete_attachment', $post_id );
4868
+	do_action('delete_attachment', $post_id);
4869 4869
 
4870 4870
 	wp_delete_object_term_relationships($post_id, array('category', 'post_tag'));
4871 4871
 	wp_delete_object_term_relationships($post_id, get_object_taxonomies($post->post_type));
4872 4872
 
4873 4873
 	// Delete all for any posts.
4874
-	delete_metadata( 'post', null, '_thumbnail_id', $post_id, true );
4874
+	delete_metadata('post', null, '_thumbnail_id', $post_id, true);
4875 4875
 
4876
-	wp_defer_comment_counting( true );
4876
+	wp_defer_comment_counting(true);
4877 4877
 
4878
-	$comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id ));
4879
-	foreach ( $comment_ids as $comment_id ) {
4880
-		wp_delete_comment( $comment_id, true );
4878
+	$comment_ids = $wpdb->get_col($wpdb->prepare("SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id));
4879
+	foreach ($comment_ids as $comment_id) {
4880
+		wp_delete_comment($comment_id, true);
4881 4881
 	}
4882 4882
 
4883
-	wp_defer_comment_counting( false );
4883
+	wp_defer_comment_counting(false);
4884 4884
 
4885
-	$post_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $post_id ));
4886
-	foreach ( $post_meta_ids as $mid )
4887
-		delete_metadata_by_mid( 'post', $mid );
4885
+	$post_meta_ids = $wpdb->get_col($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $post_id));
4886
+	foreach ($post_meta_ids as $mid)
4887
+		delete_metadata_by_mid('post', $mid);
4888 4888
 
4889 4889
 	/** This action is documented in wp-includes/post.php */
4890
-	do_action( 'delete_post', $post_id );
4891
-	$result = $wpdb->delete( $wpdb->posts, array( 'ID' => $post_id ) );
4892
-	if ( ! $result ) {
4890
+	do_action('delete_post', $post_id);
4891
+	$result = $wpdb->delete($wpdb->posts, array('ID' => $post_id));
4892
+	if ( ! $result) {
4893 4893
 		return false;
4894 4894
 	}
4895 4895
 	/** This action is documented in wp-includes/post.php */
4896
-	do_action( 'deleted_post', $post_id );
4896
+	do_action('deleted_post', $post_id);
4897 4897
 
4898 4898
 	$uploadpath = wp_get_upload_dir();
4899 4899
 
4900
-	if ( ! empty($meta['thumb']) ) {
4900
+	if ( ! empty($meta['thumb'])) {
4901 4901
 		// Don't delete the thumb if another attachment uses it.
4902
-		if (! $wpdb->get_row( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attachment_metadata' AND meta_value LIKE %s AND post_id <> %d", '%' . $wpdb->esc_like( $meta['thumb'] ) . '%', $post_id)) ) {
4902
+		if ( ! $wpdb->get_row($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attachment_metadata' AND meta_value LIKE %s AND post_id <> %d", '%'.$wpdb->esc_like($meta['thumb']).'%', $post_id))) {
4903 4903
 			$thumbfile = str_replace(basename($file), $meta['thumb'], $file);
4904 4904
 			/** This filter is documented in wp-includes/functions.php */
4905
-			$thumbfile = apply_filters( 'wp_delete_file', $thumbfile );
4906
-			@ unlink( path_join($uploadpath['basedir'], $thumbfile) );
4905
+			$thumbfile = apply_filters('wp_delete_file', $thumbfile);
4906
+			@ unlink(path_join($uploadpath['basedir'], $thumbfile));
4907 4907
 		}
4908 4908
 	}
4909 4909
 
4910 4910
 	// Remove intermediate and backup images if there are any.
4911
-	if ( isset( $meta['sizes'] ) && is_array( $meta['sizes'] ) ) {
4912
-		foreach ( $meta['sizes'] as $size => $sizeinfo ) {
4913
-			$intermediate_file = str_replace( basename( $file ), $sizeinfo['file'], $file );
4911
+	if (isset($meta['sizes']) && is_array($meta['sizes'])) {
4912
+		foreach ($meta['sizes'] as $size => $sizeinfo) {
4913
+			$intermediate_file = str_replace(basename($file), $sizeinfo['file'], $file);
4914 4914
 			/** This filter is documented in wp-includes/functions.php */
4915
-			$intermediate_file = apply_filters( 'wp_delete_file', $intermediate_file );
4916
-			@ unlink( path_join( $uploadpath['basedir'], $intermediate_file ) );
4915
+			$intermediate_file = apply_filters('wp_delete_file', $intermediate_file);
4916
+			@ unlink(path_join($uploadpath['basedir'], $intermediate_file));
4917 4917
 		}
4918 4918
 	}
4919 4919
 
4920
-	if ( is_array($backup_sizes) ) {
4921
-		foreach ( $backup_sizes as $size ) {
4922
-			$del_file = path_join( dirname($meta['file']), $size['file'] );
4920
+	if (is_array($backup_sizes)) {
4921
+		foreach ($backup_sizes as $size) {
4922
+			$del_file = path_join(dirname($meta['file']), $size['file']);
4923 4923
 			/** This filter is documented in wp-includes/functions.php */
4924
-			$del_file = apply_filters( 'wp_delete_file', $del_file );
4925
-			@ unlink( path_join($uploadpath['basedir'], $del_file) );
4924
+			$del_file = apply_filters('wp_delete_file', $del_file);
4925
+			@ unlink(path_join($uploadpath['basedir'], $del_file));
4926 4926
 		}
4927 4927
 	}
4928 4928
 
4929
-	wp_delete_file( $file );
4929
+	wp_delete_file($file);
4930 4930
 
4931
-	clean_post_cache( $post );
4931
+	clean_post_cache($post);
4932 4932
 
4933 4933
 	return $post;
4934 4934
 }
@@ -4942,14 +4942,14 @@  discard block
 block discarded – undo
4942 4942
  * @param bool $unfiltered Optional. If true, filters are not run. Default false.
4943 4943
  * @return mixed Attachment meta field. False on failure.
4944 4944
  */
4945
-function wp_get_attachment_metadata( $post_id = 0, $unfiltered = false ) {
4945
+function wp_get_attachment_metadata($post_id = 0, $unfiltered = false) {
4946 4946
 	$post_id = (int) $post_id;
4947
-	if ( !$post = get_post( $post_id ) )
4947
+	if ( ! $post = get_post($post_id))
4948 4948
 		return false;
4949 4949
 
4950
-	$data = get_post_meta( $post->ID, '_wp_attachment_metadata', true );
4950
+	$data = get_post_meta($post->ID, '_wp_attachment_metadata', true);
4951 4951
 
4952
-	if ( $unfiltered )
4952
+	if ($unfiltered)
4953 4953
 		return $data;
4954 4954
 
4955 4955
 	/**
@@ -4961,7 +4961,7 @@  discard block
 block discarded – undo
4961 4961
 	 *                            if the object does not exist.
4962 4962
 	 * @param int        $post_id Attachment ID.
4963 4963
 	 */
4964
-	return apply_filters( 'wp_get_attachment_metadata', $data, $post->ID );
4964
+	return apply_filters('wp_get_attachment_metadata', $data, $post->ID);
4965 4965
 }
4966 4966
 
4967 4967
 /**
@@ -4973,9 +4973,9 @@  discard block
 block discarded – undo
4973 4973
  * @param array $data    Attachment data.
4974 4974
  * @return int|bool False if $post is invalid.
4975 4975
  */
4976
-function wp_update_attachment_metadata( $post_id, $data ) {
4976
+function wp_update_attachment_metadata($post_id, $data) {
4977 4977
 	$post_id = (int) $post_id;
4978
-	if ( !$post = get_post( $post_id ) )
4978
+	if ( ! $post = get_post($post_id))
4979 4979
 		return false;
4980 4980
 
4981 4981
 	/**
@@ -4986,10 +4986,10 @@  discard block
 block discarded – undo
4986 4986
 	 * @param array $data    Array of updated attachment meta data.
4987 4987
 	 * @param int   $post_id Attachment ID.
4988 4988
 	 */
4989
-	if ( $data = apply_filters( 'wp_update_attachment_metadata', $data, $post->ID ) )
4990
-		return update_post_meta( $post->ID, '_wp_attachment_metadata', $data );
4989
+	if ($data = apply_filters('wp_update_attachment_metadata', $data, $post->ID))
4990
+		return update_post_meta($post->ID, '_wp_attachment_metadata', $data);
4991 4991
 	else
4992
-		return delete_post_meta( $post->ID, '_wp_attachment_metadata' );
4992
+		return delete_post_meta($post->ID, '_wp_attachment_metadata');
4993 4993
 }
4994 4994
 
4995 4995
 /**
@@ -5002,29 +5002,29 @@  discard block
 block discarded – undo
5002 5002
  * @param int $post_id Optional. Attachment ID. Default 0.
5003 5003
  * @return string|false Attachment URL, otherwise false.
5004 5004
  */
5005
-function wp_get_attachment_url( $post_id = 0 ) {
5005
+function wp_get_attachment_url($post_id = 0) {
5006 5006
 	$post_id = (int) $post_id;
5007
-	if ( !$post = get_post( $post_id ) )
5007
+	if ( ! $post = get_post($post_id))
5008 5008
 		return false;
5009 5009
 
5010
-	if ( 'attachment' != $post->post_type )
5010
+	if ('attachment' != $post->post_type)
5011 5011
 		return false;
5012 5012
 
5013 5013
 	$url = '';
5014 5014
 	// Get attached file.
5015
-	if ( $file = get_post_meta( $post->ID, '_wp_attached_file', true ) ) {
5015
+	if ($file = get_post_meta($post->ID, '_wp_attached_file', true)) {
5016 5016
 		// Get upload directory.
5017
-		if ( ( $uploads = wp_get_upload_dir() ) && false === $uploads['error'] ) {
5017
+		if (($uploads = wp_get_upload_dir()) && false === $uploads['error']) {
5018 5018
 			// Check that the upload base exists in the file location.
5019
-			if ( 0 === strpos( $file, $uploads['basedir'] ) ) {
5019
+			if (0 === strpos($file, $uploads['basedir'])) {
5020 5020
 				// Replace file location with url location.
5021 5021
 				$url = str_replace($uploads['basedir'], $uploads['baseurl'], $file);
5022
-			} elseif ( false !== strpos($file, 'wp-content/uploads') ) {
5022
+			} elseif (false !== strpos($file, 'wp-content/uploads')) {
5023 5023
 				// Get the directory name relative to the basedir (back compat for pre-2.7 uploads)
5024
-				$url = trailingslashit( $uploads['baseurl'] . '/' . _wp_get_attachment_relative_path( $file ) ) . basename( $file );
5024
+				$url = trailingslashit($uploads['baseurl'].'/'._wp_get_attachment_relative_path($file)).basename($file);
5025 5025
 			} else {
5026 5026
 				// It's a newly-uploaded file, therefore $file is relative to the basedir.
5027
-				$url = $uploads['baseurl'] . "/$file";
5027
+				$url = $uploads['baseurl']."/$file";
5028 5028
 			}
5029 5029
 		}
5030 5030
 	}
@@ -5033,13 +5033,13 @@  discard block
 block discarded – undo
5033 5033
 	 * If any of the above options failed, Fallback on the GUID as used pre-2.7,
5034 5034
 	 * not recommended to rely upon this.
5035 5035
 	 */
5036
-	if ( empty($url) ) {
5037
-		$url = get_the_guid( $post->ID );
5036
+	if (empty($url)) {
5037
+		$url = get_the_guid($post->ID);
5038 5038
 	}
5039 5039
 
5040 5040
 	// On SSL front end, URLs should be HTTPS.
5041
-	if ( is_ssl() && ! is_admin() && 'wp-login.php' !== $GLOBALS['pagenow'] ) {
5042
-		$url = set_url_scheme( $url );
5041
+	if (is_ssl() && ! is_admin() && 'wp-login.php' !== $GLOBALS['pagenow']) {
5042
+		$url = set_url_scheme($url);
5043 5043
 	}
5044 5044
 
5045 5045
 	/**
@@ -5050,9 +5050,9 @@  discard block
 block discarded – undo
5050 5050
 	 * @param string $url     URL for the given attachment.
5051 5051
 	 * @param int    $post_id Attachment ID.
5052 5052
 	 */
5053
-	$url = apply_filters( 'wp_get_attachment_url', $url, $post->ID );
5053
+	$url = apply_filters('wp_get_attachment_url', $url, $post->ID);
5054 5054
 
5055
-	if ( empty( $url ) )
5055
+	if (empty($url))
5056 5056
 		return false;
5057 5057
 
5058 5058
 	return $url;
@@ -5066,16 +5066,16 @@  discard block
 block discarded – undo
5066 5066
  * @param int $post_id Optional. Attachment ID. Default 0.
5067 5067
  * @return string|false False on failure. Thumbnail file path on success.
5068 5068
  */
5069
-function wp_get_attachment_thumb_file( $post_id = 0 ) {
5069
+function wp_get_attachment_thumb_file($post_id = 0) {
5070 5070
 	$post_id = (int) $post_id;
5071
-	if ( !$post = get_post( $post_id ) )
5071
+	if ( ! $post = get_post($post_id))
5072 5072
 		return false;
5073
-	if ( !is_array( $imagedata = wp_get_attachment_metadata( $post->ID ) ) )
5073
+	if ( ! is_array($imagedata = wp_get_attachment_metadata($post->ID)))
5074 5074
 		return false;
5075 5075
 
5076
-	$file = get_attached_file( $post->ID );
5076
+	$file = get_attached_file($post->ID);
5077 5077
 
5078
-	if ( !empty($imagedata['thumb']) && ($thumbfile = str_replace(basename($file), $imagedata['thumb'], $file)) && file_exists($thumbfile) ) {
5078
+	if ( ! empty($imagedata['thumb']) && ($thumbfile = str_replace(basename($file), $imagedata['thumb'], $file)) && file_exists($thumbfile)) {
5079 5079
 		/**
5080 5080
 		 * Filter the attachment thumbnail file path.
5081 5081
 		 *
@@ -5084,7 +5084,7 @@  discard block
 block discarded – undo
5084 5084
 		 * @param string $thumbfile File path to the attachment thumbnail.
5085 5085
 		 * @param int    $post_id   Attachment ID.
5086 5086
 		 */
5087
-		return apply_filters( 'wp_get_attachment_thumb_file', $thumbfile, $post->ID );
5087
+		return apply_filters('wp_get_attachment_thumb_file', $thumbfile, $post->ID);
5088 5088
 	}
5089 5089
 	return false;
5090 5090
 }
@@ -5097,18 +5097,18 @@  discard block
 block discarded – undo
5097 5097
  * @param int $post_id Optional. Attachment ID. Default 0.
5098 5098
  * @return string|false False on failure. Thumbnail URL on success.
5099 5099
  */
5100
-function wp_get_attachment_thumb_url( $post_id = 0 ) {
5100
+function wp_get_attachment_thumb_url($post_id = 0) {
5101 5101
 	$post_id = (int) $post_id;
5102
-	if ( !$post = get_post( $post_id ) )
5102
+	if ( ! $post = get_post($post_id))
5103 5103
 		return false;
5104
-	if ( !$url = wp_get_attachment_url( $post->ID ) )
5104
+	if ( ! $url = wp_get_attachment_url($post->ID))
5105 5105
 		return false;
5106 5106
 
5107
-	$sized = image_downsize( $post_id, 'thumbnail' );
5108
-	if ( $sized )
5107
+	$sized = image_downsize($post_id, 'thumbnail');
5108
+	if ($sized)
5109 5109
 		return $sized[0];
5110 5110
 
5111
-	if ( !$thumb = wp_get_attachment_thumb_file( $post->ID ) )
5111
+	if ( ! $thumb = wp_get_attachment_thumb_file($post->ID))
5112 5112
 		return false;
5113 5113
 
5114 5114
 	$url = str_replace(basename($url), basename($thumb), $url);
@@ -5121,7 +5121,7 @@  discard block
 block discarded – undo
5121 5121
 	 * @param string $url     URL for the attachment thumbnail.
5122 5122
 	 * @param int    $post_id Attachment ID.
5123 5123
 	 */
5124
-	return apply_filters( 'wp_get_attachment_thumb_url', $url, $post->ID );
5124
+	return apply_filters('wp_get_attachment_thumb_url', $url, $post->ID);
5125 5125
 }
5126 5126
 
5127 5127
 /**
@@ -5133,40 +5133,40 @@  discard block
 block discarded – undo
5133 5133
  * @param int|WP_Post $post_id Optional. Attachment ID. Default 0.
5134 5134
  * @return bool True if one of the accepted types, false otherwise.
5135 5135
  */
5136
-function wp_attachment_is( $type, $post_id = 0 ) {
5137
-	if ( ! $post = get_post( $post_id ) ) {
5136
+function wp_attachment_is($type, $post_id = 0) {
5137
+	if ( ! $post = get_post($post_id)) {
5138 5138
 		return false;
5139 5139
 	}
5140 5140
 
5141
-	if ( ! $file = get_attached_file( $post->ID ) ) {
5141
+	if ( ! $file = get_attached_file($post->ID)) {
5142 5142
 		return false;
5143 5143
 	}
5144 5144
 
5145
-	if ( 0 === strpos( $post->post_mime_type, $type . '/' ) ) {
5145
+	if (0 === strpos($post->post_mime_type, $type.'/')) {
5146 5146
 		return true;
5147 5147
 	}
5148 5148
 
5149
-	$check = wp_check_filetype( $file );
5150
-	if ( empty( $check['ext'] ) ) {
5149
+	$check = wp_check_filetype($file);
5150
+	if (empty($check['ext'])) {
5151 5151
 		return false;
5152 5152
 	}
5153 5153
 
5154 5154
 	$ext = $check['ext'];
5155 5155
 
5156
-	if ( 'import' !== $post->post_mime_type ) {
5156
+	if ('import' !== $post->post_mime_type) {
5157 5157
 		return $type === $ext;
5158 5158
 	}
5159 5159
 
5160
-	switch ( $type ) {
5160
+	switch ($type) {
5161 5161
 	case 'image':
5162
-		$image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' );
5163
-		return in_array( $ext, $image_exts );
5162
+		$image_exts = array('jpg', 'jpeg', 'jpe', 'gif', 'png');
5163
+		return in_array($ext, $image_exts);
5164 5164
 
5165 5165
 	case 'audio':
5166
-		return in_array( $ext, wp_get_audio_extensions() );
5166
+		return in_array($ext, wp_get_audio_extensions());
5167 5167
 
5168 5168
 	case 'video':
5169
-		return in_array( $ext, wp_get_video_extensions() );
5169
+		return in_array($ext, wp_get_video_extensions());
5170 5170
 
5171 5171
 	default:
5172 5172
 		return $type === $ext;
@@ -5183,8 +5183,8 @@  discard block
 block discarded – undo
5183 5183
  * @param int|WP_Post $post Optional. Attachment ID. Default 0.
5184 5184
  * @return bool Whether the attachment is an image.
5185 5185
  */
5186
-function wp_attachment_is_image( $post = 0 ) {
5187
-	return wp_attachment_is( 'image', $post );
5186
+function wp_attachment_is_image($post = 0) {
5187
+	return wp_attachment_is('image', $post);
5188 5188
 }
5189 5189
 
5190 5190
 /**
@@ -5195,22 +5195,22 @@  discard block
 block discarded – undo
5195 5195
  * @param string|int $mime MIME type or attachment ID.
5196 5196
  * @return string|false Icon, false otherwise.
5197 5197
  */
5198
-function wp_mime_type_icon( $mime = 0 ) {
5199
-	if ( !is_numeric($mime) )
5198
+function wp_mime_type_icon($mime = 0) {
5199
+	if ( ! is_numeric($mime))
5200 5200
 		$icon = wp_cache_get("mime_type_icon_$mime");
5201 5201
 
5202 5202
 	$post_id = 0;
5203
-	if ( empty($icon) ) {
5203
+	if (empty($icon)) {
5204 5204
 		$post_mimes = array();
5205
-		if ( is_numeric($mime) ) {
5205
+		if (is_numeric($mime)) {
5206 5206
 			$mime = (int) $mime;
5207
-			if ( $post = get_post( $mime ) ) {
5207
+			if ($post = get_post($mime)) {
5208 5208
 				$post_id = (int) $post->ID;
5209
-				$file = get_attached_file( $post_id );
5209
+				$file = get_attached_file($post_id);
5210 5210
 				$ext = preg_replace('/^.+?\.([^.]+)$/', '$1', $file);
5211
-				if ( !empty($ext) ) {
5211
+				if ( ! empty($ext)) {
5212 5212
 					$post_mimes[] = $ext;
5213
-					if ( $ext_type = wp_ext2type( $ext ) )
5213
+					if ($ext_type = wp_ext2type($ext))
5214 5214
 						$post_mimes[] = $ext_type;
5215 5215
 				}
5216 5216
 				$mime = $post->post_mime_type;
@@ -5223,7 +5223,7 @@  discard block
 block discarded – undo
5223 5223
 
5224 5224
 		$icon_files = wp_cache_get('icon_files');
5225 5225
 
5226
-		if ( !is_array($icon_files) ) {
5226
+		if ( ! is_array($icon_files)) {
5227 5227
 			/**
5228 5228
 			 * Filter the icon directory path.
5229 5229
 			 *
@@ -5231,7 +5231,7 @@  discard block
 block discarded – undo
5231 5231
 			 *
5232 5232
 			 * @param string $path Icon directory absolute path.
5233 5233
 			 */
5234
-			$icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/media' );
5234
+			$icon_dir = apply_filters('icon_dir', ABSPATH.WPINC.'/images/media');
5235 5235
 
5236 5236
 			/**
5237 5237
 			 * Filter the icon directory URI.
@@ -5240,7 +5240,7 @@  discard block
 block discarded – undo
5240 5240
 			 *
5241 5241
 			 * @param string $uri Icon directory URI.
5242 5242
 			 */
5243
-			$icon_dir_uri = apply_filters( 'icon_dir_uri', includes_url( 'images/media' ) );
5243
+			$icon_dir_uri = apply_filters('icon_dir_uri', includes_url('images/media'));
5244 5244
 
5245 5245
 			/**
5246 5246
 			 * Filter the list of icon directory URIs.
@@ -5249,19 +5249,19 @@  discard block
 block discarded – undo
5249 5249
 			 *
5250 5250
 			 * @param array $uris List of icon directory URIs.
5251 5251
 			 */
5252
-			$dirs = apply_filters( 'icon_dirs', array( $icon_dir => $icon_dir_uri ) );
5252
+			$dirs = apply_filters('icon_dirs', array($icon_dir => $icon_dir_uri));
5253 5253
 			$icon_files = array();
5254
-			while ( $dirs ) {
5255
-				$keys = array_keys( $dirs );
5256
-				$dir = array_shift( $keys );
5254
+			while ($dirs) {
5255
+				$keys = array_keys($dirs);
5256
+				$dir = array_shift($keys);
5257 5257
 				$uri = array_shift($dirs);
5258
-				if ( $dh = opendir($dir) ) {
5259
-					while ( false !== $file = readdir($dh) ) {
5258
+				if ($dh = opendir($dir)) {
5259
+					while (false !== $file = readdir($dh)) {
5260 5260
 						$file = basename($file);
5261
-						if ( substr($file, 0, 1) == '.' )
5261
+						if (substr($file, 0, 1) == '.')
5262 5262
 							continue;
5263
-						if ( !in_array(strtolower(substr($file, -4)), array('.png', '.gif', '.jpg') ) ) {
5264
-							if ( is_dir("$dir/$file") )
5263
+						if ( ! in_array(strtolower(substr($file, -4)), array('.png', '.gif', '.jpg'))) {
5264
+							if (is_dir("$dir/$file"))
5265 5265
 								$dirs["$dir/$file"] = "$uri/$file";
5266 5266
 							continue;
5267 5267
 						}
@@ -5270,15 +5270,15 @@  discard block
 block discarded – undo
5270 5270
 					closedir($dh);
5271 5271
 				}
5272 5272
 			}
5273
-			wp_cache_add( 'icon_files', $icon_files, 'default', 600 );
5273
+			wp_cache_add('icon_files', $icon_files, 'default', 600);
5274 5274
 		}
5275 5275
 
5276 5276
 		$types = array();
5277 5277
 		// Icon basename - extension = MIME wildcard.
5278
-		foreach ( $icon_files as $file => $uri )
5279
-			$types[ preg_replace('/^([^.]*).*$/', '$1', basename($file)) ] =& $icon_files[$file];
5278
+		foreach ($icon_files as $file => $uri)
5279
+			$types[preg_replace('/^([^.]*).*$/', '$1', basename($file))] = & $icon_files[$file];
5280 5280
 
5281
-		if ( ! empty($mime) ) {
5281
+		if ( ! empty($mime)) {
5282 5282
 			$post_mimes[] = substr($mime, 0, strpos($mime, '/'));
5283 5283
 			$post_mimes[] = substr($mime, strpos($mime, '/') + 1);
5284 5284
 			$post_mimes[] = str_replace('/', '_', $mime);
@@ -5287,15 +5287,15 @@  discard block
 block discarded – undo
5287 5287
 		$matches = wp_match_mime_types(array_keys($types), $post_mimes);
5288 5288
 		$matches['default'] = array('default');
5289 5289
 
5290
-		foreach ( $matches as $match => $wilds ) {
5291
-			foreach ( $wilds as $wild ) {
5292
-				if ( ! isset( $types[ $wild ] ) ) {
5290
+		foreach ($matches as $match => $wilds) {
5291
+			foreach ($wilds as $wild) {
5292
+				if ( ! isset($types[$wild])) {
5293 5293
 					continue;
5294 5294
 				}
5295 5295
 
5296
-				$icon = $types[ $wild ];
5297
-				if ( ! is_numeric( $mime ) ) {
5298
-					wp_cache_add( "mime_type_icon_$mime", $icon );
5296
+				$icon = $types[$wild];
5297
+				if ( ! is_numeric($mime)) {
5298
+					wp_cache_add("mime_type_icon_$mime", $icon);
5299 5299
 				}
5300 5300
 				break 2;
5301 5301
 			}
@@ -5312,7 +5312,7 @@  discard block
 block discarded – undo
5312 5312
 	 * @param int    $post_id Attachment ID. Will equal 0 if the function passed
5313 5313
 	 *                        the mime type.
5314 5314
 	 */
5315
-	return apply_filters( 'wp_mime_type_icon', $icon, $mime, $post_id );
5315
+	return apply_filters('wp_mime_type_icon', $icon, $mime, $post_id);
5316 5316
 }
5317 5317
 
5318 5318
 /**
@@ -5334,27 +5334,27 @@  discard block
 block discarded – undo
5334 5334
  * @param WP_Post $post        The Post Object
5335 5335
  * @param WP_Post $post_before The Previous Post Object
5336 5336
  */
5337
-function wp_check_for_changed_slugs( $post_id, $post, $post_before ) {
5337
+function wp_check_for_changed_slugs($post_id, $post, $post_before) {
5338 5338
 	// Don't bother if it hasn't changed.
5339
-	if ( $post->post_name == $post_before->post_name ) {
5339
+	if ($post->post_name == $post_before->post_name) {
5340 5340
 		return;
5341 5341
 	}
5342 5342
 
5343 5343
 	// We're only concerned with published, non-hierarchical objects.
5344
-	if ( ! ( 'publish' === $post->post_status || ( 'attachment' === get_post_type( $post ) && 'inherit' === $post->post_status ) ) || is_post_type_hierarchical( $post->post_type ) ) {
5344
+	if ( ! ('publish' === $post->post_status || ('attachment' === get_post_type($post) && 'inherit' === $post->post_status)) || is_post_type_hierarchical($post->post_type)) {
5345 5345
 		return;
5346 5346
 	}
5347 5347
 
5348
-	$old_slugs = (array) get_post_meta( $post_id, '_wp_old_slug' );
5348
+	$old_slugs = (array) get_post_meta($post_id, '_wp_old_slug');
5349 5349
 
5350 5350
 	// If we haven't added this old slug before, add it now.
5351
-	if ( ! empty( $post_before->post_name ) && ! in_array( $post_before->post_name, $old_slugs ) ) {
5352
-		add_post_meta( $post_id, '_wp_old_slug', $post_before->post_name );
5351
+	if ( ! empty($post_before->post_name) && ! in_array($post_before->post_name, $old_slugs)) {
5352
+		add_post_meta($post_id, '_wp_old_slug', $post_before->post_name);
5353 5353
 	}
5354 5354
 
5355 5355
 	// If the new slug was used previously, delete it from the list.
5356
-	if ( in_array( $post->post_name, $old_slugs ) ) {
5357
-		delete_post_meta( $post_id, '_wp_old_slug', $post->post_name );
5356
+	if (in_array($post->post_name, $old_slugs)) {
5357
+		delete_post_meta($post_id, '_wp_old_slug', $post->post_name);
5358 5358
 	}
5359 5359
 }
5360 5360
 
@@ -5372,8 +5372,8 @@  discard block
 block discarded – undo
5372 5372
  * @param string|array $post_type Single post type or an array of post types. Currently only supports 'post' or 'page'.
5373 5373
  * @return string SQL code that can be added to a where clause.
5374 5374
  */
5375
-function get_private_posts_cap_sql( $post_type ) {
5376
-	return get_posts_by_author_sql( $post_type, false );
5375
+function get_private_posts_cap_sql($post_type) {
5376
+	return get_posts_by_author_sql($post_type, false);
5377 5377
 }
5378 5378
 
5379 5379
 /**
@@ -5393,19 +5393,19 @@  discard block
 block discarded – undo
5393 5393
  *                                    $current_user.  Default false.
5394 5394
  * @return string SQL WHERE code that can be added to a query.
5395 5395
  */
5396
-function get_posts_by_author_sql( $post_type, $full = true, $post_author = null, $public_only = false ) {
5396
+function get_posts_by_author_sql($post_type, $full = true, $post_author = null, $public_only = false) {
5397 5397
 	global $wpdb;
5398 5398
 
5399
-	if ( is_array( $post_type ) ) {
5399
+	if (is_array($post_type)) {
5400 5400
 		$post_types = $post_type;
5401 5401
 	} else {
5402
-		$post_types = array( $post_type );
5402
+		$post_types = array($post_type);
5403 5403
 	}
5404 5404
 
5405 5405
 	$post_type_clauses = array();
5406
-	foreach ( $post_types as $post_type ) {
5407
-		$post_type_obj = get_post_type_object( $post_type );
5408
-		if ( ! $post_type_obj ) {
5406
+	foreach ($post_types as $post_type) {
5407
+		$post_type_obj = get_post_type_object($post_type);
5408
+		if ( ! $post_type_obj) {
5409 5409
 			continue;
5410 5410
 		}
5411 5411
 
@@ -5418,42 +5418,42 @@  discard block
 block discarded – undo
5418 5418
 		 *
5419 5419
 		 * @param string $cap Capability.
5420 5420
 		 */
5421
-		if ( ! $cap = apply_filters( 'pub_priv_sql_capability', '' ) ) {
5422
-			$cap = current_user_can( $post_type_obj->cap->read_private_posts );
5421
+		if ( ! $cap = apply_filters('pub_priv_sql_capability', '')) {
5422
+			$cap = current_user_can($post_type_obj->cap->read_private_posts);
5423 5423
 		}
5424 5424
 
5425 5425
 		// Only need to check the cap if $public_only is false.
5426 5426
 		$post_status_sql = "post_status = 'publish'";
5427
-		if ( false === $public_only ) {
5428
-			if ( $cap ) {
5427
+		if (false === $public_only) {
5428
+			if ($cap) {
5429 5429
 				// Does the user have the capability to view private posts? Guess so.
5430 5430
 				$post_status_sql .= " OR post_status = 'private'";
5431
-			} elseif ( is_user_logged_in() ) {
5431
+			} elseif (is_user_logged_in()) {
5432 5432
 				// Users can view their own private posts.
5433 5433
 				$id = get_current_user_id();
5434
-				if ( null === $post_author || ! $full ) {
5434
+				if (null === $post_author || ! $full) {
5435 5435
 					$post_status_sql .= " OR post_status = 'private' AND post_author = $id";
5436
-				} elseif ( $id == (int) $post_author ) {
5436
+				} elseif ($id == (int) $post_author) {
5437 5437
 					$post_status_sql .= " OR post_status = 'private'";
5438 5438
 				} // else none
5439 5439
 			} // else none
5440 5440
 		}
5441 5441
 
5442
-		$post_type_clauses[] = "( post_type = '" . $post_type . "' AND ( $post_status_sql ) )";
5442
+		$post_type_clauses[] = "( post_type = '".$post_type."' AND ( $post_status_sql ) )";
5443 5443
 	}
5444 5444
 
5445
-	if ( empty( $post_type_clauses ) ) {
5445
+	if (empty($post_type_clauses)) {
5446 5446
 		return $full ? 'WHERE 1 = 0' : '1 = 0';
5447 5447
 	}
5448 5448
 
5449
-	$sql = '( '. implode( ' OR ', $post_type_clauses ) . ' )';
5449
+	$sql = '( '.implode(' OR ', $post_type_clauses).' )';
5450 5450
 
5451
-	if ( null !== $post_author ) {
5452
-		$sql .= $wpdb->prepare( ' AND post_author = %d', $post_author );
5451
+	if (null !== $post_author) {
5452
+		$sql .= $wpdb->prepare(' AND post_author = %d', $post_author);
5453 5453
 	}
5454 5454
 
5455
-	if ( $full ) {
5456
-		$sql = 'WHERE ' . $sql;
5455
+	if ($full) {
5456
+		$sql = 'WHERE '.$sql;
5457 5457
 	}
5458 5458
 
5459 5459
 	return $sql;
@@ -5477,7 +5477,7 @@  discard block
 block discarded – undo
5477 5477
  * @param string $post_type Optional. The post type to check. Default 'any'.
5478 5478
  * @return string The date of the last post.
5479 5479
  */
5480
-function get_lastpostdate( $timezone = 'server', $post_type = 'any' ) {
5480
+function get_lastpostdate($timezone = 'server', $post_type = 'any') {
5481 5481
 	/**
5482 5482
 	 * Filter the date the last post was published.
5483 5483
 	 *
@@ -5487,7 +5487,7 @@  discard block
 block discarded – undo
5487 5487
 	 * @param string $timezone Location to use for getting the post published date.
5488 5488
 	 *                         See {@see get_lastpostdate()} for accepted `$timezone` values.
5489 5489
 	 */
5490
-	return apply_filters( 'get_lastpostdate', _get_last_post_time( $timezone, 'date', $post_type ), $timezone );
5490
+	return apply_filters('get_lastpostdate', _get_last_post_time($timezone, 'date', $post_type), $timezone);
5491 5491
 }
5492 5492
 
5493 5493
 /**
@@ -5506,7 +5506,7 @@  discard block
 block discarded – undo
5506 5506
  * @param string $post_type Optional. The post type to check. Default 'any'.
5507 5507
  * @return string The timestamp.
5508 5508
  */
5509
-function get_lastpostmodified( $timezone = 'server', $post_type = 'any' ) {
5509
+function get_lastpostmodified($timezone = 'server', $post_type = 'any') {
5510 5510
 	/**
5511 5511
 	 * Pre-filter the return value of get_lastpostmodified() before the query is run.
5512 5512
 	 *
@@ -5518,15 +5518,15 @@  discard block
 block discarded – undo
5518 5518
 	 *                                 See {@see get_lastpostdate()} for accepted `$timezone` values.
5519 5519
 	 * @param string $post_type        The post type to check.
5520 5520
 	 */
5521
-	$lastpostmodified = apply_filters( 'pre_get_lastpostmodified', false, $timezone, $post_type );
5522
-	if ( false !== $lastpostmodified ) {
5521
+	$lastpostmodified = apply_filters('pre_get_lastpostmodified', false, $timezone, $post_type);
5522
+	if (false !== $lastpostmodified) {
5523 5523
 		return $lastpostmodified;
5524 5524
 	}
5525 5525
 
5526
-	$lastpostmodified = _get_last_post_time( $timezone, 'modified', $post_type );
5526
+	$lastpostmodified = _get_last_post_time($timezone, 'modified', $post_type);
5527 5527
 
5528 5528
 	$lastpostdate = get_lastpostdate($timezone);
5529
-	if ( $lastpostdate > $lastpostmodified ) {
5529
+	if ($lastpostdate > $lastpostmodified) {
5530 5530
 		$lastpostmodified = $lastpostdate;
5531 5531
 	}
5532 5532
 
@@ -5539,7 +5539,7 @@  discard block
 block discarded – undo
5539 5539
 	 * @param string $timezone         Location to use for getting the post modified date.
5540 5540
 	 *                                 See {@see get_lastpostdate()} for accepted `$timezone` values.
5541 5541
 	 */
5542
-	return apply_filters( 'get_lastpostmodified', $lastpostmodified, $timezone );
5542
+	return apply_filters('get_lastpostmodified', $lastpostmodified, $timezone);
5543 5543
 }
5544 5544
 
5545 5545
 /**
@@ -5557,32 +5557,32 @@  discard block
 block discarded – undo
5557 5557
  * @param string $post_type Optional. The post type to check. Default 'any'.
5558 5558
  * @return string|false The timestamp.
5559 5559
  */
5560
-function _get_last_post_time( $timezone, $field, $post_type = 'any' ) {
5560
+function _get_last_post_time($timezone, $field, $post_type = 'any') {
5561 5561
 	global $wpdb;
5562 5562
 
5563
-	if ( ! in_array( $field, array( 'date', 'modified' ) ) ) {
5563
+	if ( ! in_array($field, array('date', 'modified'))) {
5564 5564
 		return false;
5565 5565
 	}
5566 5566
 
5567
-	$timezone = strtolower( $timezone );
5567
+	$timezone = strtolower($timezone);
5568 5568
 
5569 5569
 	$key = "lastpost{$field}:$timezone";
5570
-	if ( 'any' !== $post_type ) {
5571
-		$key .= ':' . sanitize_key( $post_type );
5570
+	if ('any' !== $post_type) {
5571
+		$key .= ':'.sanitize_key($post_type);
5572 5572
 	}
5573 5573
 
5574
-	$date = wp_cache_get( $key, 'timeinfo' );
5574
+	$date = wp_cache_get($key, 'timeinfo');
5575 5575
 
5576
-	if ( ! $date ) {
5577
-		if ( 'any' === $post_type ) {
5578
-			$post_types = get_post_types( array( 'public' => true ) );
5579
-			array_walk( $post_types, array( $wpdb, 'escape_by_ref' ) );
5580
-			$post_types = "'" . implode( "', '", $post_types ) . "'";
5576
+	if ( ! $date) {
5577
+		if ('any' === $post_type) {
5578
+			$post_types = get_post_types(array('public' => true));
5579
+			array_walk($post_types, array($wpdb, 'escape_by_ref'));
5580
+			$post_types = "'".implode("', '", $post_types)."'";
5581 5581
 		} else {
5582
-			$post_types = "'" . sanitize_key( $post_type ) . "'";
5582
+			$post_types = "'".sanitize_key($post_type)."'";
5583 5583
 		}
5584 5584
 
5585
-		switch ( $timezone ) {
5585
+		switch ($timezone) {
5586 5586
 			case 'gmt':
5587 5587
 				$date = $wpdb->get_var("SELECT post_{$field}_gmt FROM $wpdb->posts WHERE post_status = 'publish' AND post_type IN ({$post_types}) ORDER BY post_{$field}_gmt DESC LIMIT 1");
5588 5588
 				break;
@@ -5590,13 +5590,13 @@  discard block
 block discarded – undo
5590 5590
 				$date = $wpdb->get_var("SELECT post_{$field} FROM $wpdb->posts WHERE post_status = 'publish' AND post_type IN ({$post_types}) ORDER BY post_{$field}_gmt DESC LIMIT 1");
5591 5591
 				break;
5592 5592
 			case 'server':
5593
-				$add_seconds_server = date( 'Z' );
5593
+				$add_seconds_server = date('Z');
5594 5594
 				$date = $wpdb->get_var("SELECT DATE_ADD(post_{$field}_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type IN ({$post_types}) ORDER BY post_{$field}_gmt DESC LIMIT 1");
5595 5595
 				break;
5596 5596
 		}
5597 5597
 
5598
-		if ( $date ) {
5599
-			wp_cache_set( $key, $date, 'timeinfo' );
5598
+		if ($date) {
5599
+			wp_cache_set($key, $date, 'timeinfo');
5600 5600
 		}
5601 5601
 	}
5602 5602
 
@@ -5610,12 +5610,12 @@  discard block
 block discarded – undo
5610 5610
  *
5611 5611
  * @param array $posts Array of post objects, passed by reference.
5612 5612
  */
5613
-function update_post_cache( &$posts ) {
5614
-	if ( ! $posts )
5613
+function update_post_cache(&$posts) {
5614
+	if ( ! $posts)
5615 5615
 		return;
5616 5616
 
5617
-	foreach ( $posts as $post )
5618
-		wp_cache_add( $post->ID, $post, 'posts' );
5617
+	foreach ($posts as $post)
5618
+		wp_cache_add($post->ID, $post, 'posts');
5619 5619
 }
5620 5620
 
5621 5621
 /**
@@ -5633,22 +5633,22 @@  discard block
 block discarded – undo
5633 5633
  *
5634 5634
  * @param int|WP_Post $post Post ID or post object to remove from the cache.
5635 5635
  */
5636
-function clean_post_cache( $post ) {
5636
+function clean_post_cache($post) {
5637 5637
 	global $_wp_suspend_cache_invalidation;
5638 5638
 
5639
-	if ( ! empty( $_wp_suspend_cache_invalidation ) )
5639
+	if ( ! empty($_wp_suspend_cache_invalidation))
5640 5640
 		return;
5641 5641
 
5642
-	$post = get_post( $post );
5643
-	if ( empty( $post ) )
5642
+	$post = get_post($post);
5643
+	if (empty($post))
5644 5644
 		return;
5645 5645
 
5646
-	wp_cache_delete( $post->ID, 'posts' );
5647
-	wp_cache_delete( $post->ID, 'post_meta' );
5646
+	wp_cache_delete($post->ID, 'posts');
5647
+	wp_cache_delete($post->ID, 'post_meta');
5648 5648
 
5649
-	clean_object_term_cache( $post->ID, $post->post_type );
5649
+	clean_object_term_cache($post->ID, $post->post_type);
5650 5650
 
5651
-	wp_cache_delete( 'wp_get_archives', 'general' );
5651
+	wp_cache_delete('wp_get_archives', 'general');
5652 5652
 
5653 5653
 	/**
5654 5654
 	 * Fires immediately after the given post's cache is cleaned.
@@ -5658,10 +5658,10 @@  discard block
 block discarded – undo
5658 5658
 	 * @param int     $post_id Post ID.
5659 5659
 	 * @param WP_Post $post    Post object.
5660 5660
 	 */
5661
-	do_action( 'clean_post_cache', $post->ID, $post );
5661
+	do_action('clean_post_cache', $post->ID, $post);
5662 5662
 
5663
-	if ( 'page' == $post->post_type ) {
5664
-		wp_cache_delete( 'all_page_ids', 'posts' );
5663
+	if ('page' == $post->post_type) {
5664
+		wp_cache_delete('all_page_ids', 'posts');
5665 5665
 
5666 5666
 		/**
5667 5667
 		 * Fires immediately after the given page's cache is cleaned.
@@ -5670,10 +5670,10 @@  discard block
 block discarded – undo
5670 5670
 		 *
5671 5671
 		 * @param int $post_id Post ID.
5672 5672
 		 */
5673
-		do_action( 'clean_page_cache', $post->ID );
5673
+		do_action('clean_page_cache', $post->ID);
5674 5674
 	}
5675 5675
 
5676
-	wp_cache_set( 'last_changed', microtime(), 'posts' );
5676
+	wp_cache_set('last_changed', microtime(), 'posts');
5677 5677
 }
5678 5678
 
5679 5679
 /**
@@ -5686,27 +5686,27 @@  discard block
 block discarded – undo
5686 5686
  * @param bool   $update_term_cache Optional. Whether to update the term cache. Default true.
5687 5687
  * @param bool   $update_meta_cache Optional. Whether to update the meta cache. Default true.
5688 5688
  */
5689
-function update_post_caches( &$posts, $post_type = 'post', $update_term_cache = true, $update_meta_cache = true ) {
5689
+function update_post_caches(&$posts, $post_type = 'post', $update_term_cache = true, $update_meta_cache = true) {
5690 5690
 	// No point in doing all this work if we didn't match any posts.
5691
-	if ( !$posts )
5691
+	if ( ! $posts)
5692 5692
 		return;
5693 5693
 
5694 5694
 	update_post_cache($posts);
5695 5695
 
5696 5696
 	$post_ids = array();
5697
-	foreach ( $posts as $post )
5697
+	foreach ($posts as $post)
5698 5698
 		$post_ids[] = $post->ID;
5699 5699
 
5700
-	if ( ! $post_type )
5700
+	if ( ! $post_type)
5701 5701
 		$post_type = 'any';
5702 5702
 
5703
-	if ( $update_term_cache ) {
5704
-		if ( is_array($post_type) ) {
5703
+	if ($update_term_cache) {
5704
+		if (is_array($post_type)) {
5705 5705
 			$ptypes = $post_type;
5706
-		} elseif ( 'any' == $post_type ) {
5706
+		} elseif ('any' == $post_type) {
5707 5707
 			$ptypes = array();
5708 5708
 			// Just use the post_types in the supplied posts.
5709
-			foreach ( $posts as $post ) {
5709
+			foreach ($posts as $post) {
5710 5710
 				$ptypes[] = $post->post_type;
5711 5711
 			}
5712 5712
 			$ptypes = array_unique($ptypes);
@@ -5714,11 +5714,11 @@  discard block
 block discarded – undo
5714 5714
 			$ptypes = array($post_type);
5715 5715
 		}
5716 5716
 
5717
-		if ( ! empty($ptypes) )
5717
+		if ( ! empty($ptypes))
5718 5718
 			update_object_term_cache($post_ids, $ptypes);
5719 5719
 	}
5720 5720
 
5721
-	if ( $update_meta_cache )
5721
+	if ($update_meta_cache)
5722 5722
 		update_postmeta_cache($post_ids);
5723 5723
 }
5724 5724
 
@@ -5735,7 +5735,7 @@  discard block
 block discarded – undo
5735 5735
  * @return array|false Returns false if there is nothing to update or an array
5736 5736
  *                     of metadata.
5737 5737
  */
5738
-function update_postmeta_cache( $post_ids ) {
5738
+function update_postmeta_cache($post_ids) {
5739 5739
 	return update_meta_cache('post', $post_ids);
5740 5740
 }
5741 5741
 
@@ -5754,10 +5754,10 @@  discard block
 block discarded – undo
5754 5754
  * @param int  $id          The attachment ID in the cache to clean.
5755 5755
  * @param bool $clean_terms Optional. Whether to clean terms cache. Default false.
5756 5756
  */
5757
-function clean_attachment_cache( $id, $clean_terms = false ) {
5757
+function clean_attachment_cache($id, $clean_terms = false) {
5758 5758
 	global $_wp_suspend_cache_invalidation;
5759 5759
 
5760
-	if ( !empty($_wp_suspend_cache_invalidation) )
5760
+	if ( ! empty($_wp_suspend_cache_invalidation))
5761 5761
 		return;
5762 5762
 
5763 5763
 	$id = (int) $id;
@@ -5765,7 +5765,7 @@  discard block
 block discarded – undo
5765 5765
 	wp_cache_delete($id, 'posts');
5766 5766
 	wp_cache_delete($id, 'post_meta');
5767 5767
 
5768
-	if ( $clean_terms )
5768
+	if ($clean_terms)
5769 5769
 		clean_object_term_cache($id, 'attachment');
5770 5770
 
5771 5771
 	/**
@@ -5775,7 +5775,7 @@  discard block
 block discarded – undo
5775 5775
 	 *
5776 5776
 	 * @param int $id Attachment ID.
5777 5777
 	 */
5778
-	do_action( 'clean_attachment_cache', $id );
5778
+	do_action('clean_attachment_cache', $id);
5779 5779
 }
5780 5780
 
5781 5781
 //
@@ -5795,13 +5795,13 @@  discard block
 block discarded – undo
5795 5795
  * @param string  $old_status Previous post status.
5796 5796
  * @param WP_Post $post       Post object.
5797 5797
  */
5798
-function _transition_post_status( $new_status, $old_status, $post ) {
5798
+function _transition_post_status($new_status, $old_status, $post) {
5799 5799
 	global $wpdb;
5800 5800
 
5801
-	if ( $old_status != 'publish' && $new_status == 'publish' ) {
5801
+	if ($old_status != 'publish' && $new_status == 'publish') {
5802 5802
 		// Reset GUID if transitioning to publish and it is empty.
5803
-		if ( '' == get_the_guid($post->ID) )
5804
-			$wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post->ID ) ), array( 'ID' => $post->ID ) );
5803
+		if ('' == get_the_guid($post->ID))
5804
+			$wpdb->update($wpdb->posts, array('guid' => get_permalink($post->ID)), array('ID' => $post->ID));
5805 5805
 
5806 5806
 		/**
5807 5807
 		 * Fires when a post's status is transitioned from private to published.
@@ -5815,21 +5815,21 @@  discard block
 block discarded – undo
5815 5815
 	}
5816 5816
 
5817 5817
 	// If published posts changed clear the lastpostmodified cache.
5818
-	if ( 'publish' == $new_status || 'publish' == $old_status) {
5819
-		foreach ( array( 'server', 'gmt', 'blog' ) as $timezone ) {
5820
-			wp_cache_delete( "lastpostmodified:$timezone", 'timeinfo' );
5821
-			wp_cache_delete( "lastpostdate:$timezone", 'timeinfo' );
5822
-			wp_cache_delete( "lastpostdate:$timezone:{$post->post_type}", 'timeinfo' );
5818
+	if ('publish' == $new_status || 'publish' == $old_status) {
5819
+		foreach (array('server', 'gmt', 'blog') as $timezone) {
5820
+			wp_cache_delete("lastpostmodified:$timezone", 'timeinfo');
5821
+			wp_cache_delete("lastpostdate:$timezone", 'timeinfo');
5822
+			wp_cache_delete("lastpostdate:$timezone:{$post->post_type}", 'timeinfo');
5823 5823
 		}
5824 5824
 	}
5825 5825
 
5826
-	if ( $new_status !== $old_status ) {
5827
-		wp_cache_delete( _count_posts_cache_key( $post->post_type ), 'counts' );
5828
-		wp_cache_delete( _count_posts_cache_key( $post->post_type, 'readable' ), 'counts' );
5826
+	if ($new_status !== $old_status) {
5827
+		wp_cache_delete(_count_posts_cache_key($post->post_type), 'counts');
5828
+		wp_cache_delete(_count_posts_cache_key($post->post_type, 'readable'), 'counts');
5829 5829
 	}
5830 5830
 
5831 5831
 	// Always clears the hook in case the post status bounced from future to draft.
5832
-	wp_clear_scheduled_hook('publish_future_post', array( $post->ID ) );
5832
+	wp_clear_scheduled_hook('publish_future_post', array($post->ID));
5833 5833
 }
5834 5834
 
5835 5835
 /**
@@ -5846,9 +5846,9 @@  discard block
 block discarded – undo
5846 5846
  *                            {@see _future_post_hook()}.
5847 5847
  * @param WP_Post $post       Post object.
5848 5848
  */
5849
-function _future_post_hook( $deprecated, $post ) {
5850
-	wp_clear_scheduled_hook( 'publish_future_post', array( $post->ID ) );
5851
-	wp_schedule_single_event( strtotime( get_gmt_from_date( $post->post_date ) . ' GMT') , 'publish_future_post', array( $post->ID ) );
5849
+function _future_post_hook($deprecated, $post) {
5850
+	wp_clear_scheduled_hook('publish_future_post', array($post->ID));
5851
+	wp_schedule_single_event(strtotime(get_gmt_from_date($post->post_date).' GMT'), 'publish_future_post', array($post->ID));
5852 5852
 }
5853 5853
 
5854 5854
 /**
@@ -5861,8 +5861,8 @@  discard block
 block discarded – undo
5861 5861
  *
5862 5862
  * @param int $post_id The ID in the database table of the post being published.
5863 5863
  */
5864
-function _publish_post_hook( $post_id ) {
5865
-	if ( defined( 'XMLRPC_REQUEST' ) ) {
5864
+function _publish_post_hook($post_id) {
5865
+	if (defined('XMLRPC_REQUEST')) {
5866 5866
 		/**
5867 5867
 		 * Fires when _publish_post_hook() is called during an XML-RPC request.
5868 5868
 		 *
@@ -5870,15 +5870,15 @@  discard block
 block discarded – undo
5870 5870
 		 *
5871 5871
 		 * @param int $post_id Post ID.
5872 5872
 		 */
5873
-		do_action( 'xmlrpc_publish_post', $post_id );
5873
+		do_action('xmlrpc_publish_post', $post_id);
5874 5874
 	}
5875 5875
 
5876
-	if ( defined('WP_IMPORTING') )
5876
+	if (defined('WP_IMPORTING'))
5877 5877
 		return;
5878 5878
 
5879
-	if ( get_option('default_pingback_flag') )
5880
-		add_post_meta( $post_id, '_pingme', '1' );
5881
-	add_post_meta( $post_id, '_encloseme', '1' );
5879
+	if (get_option('default_pingback_flag'))
5880
+		add_post_meta($post_id, '_pingme', '1');
5881
+	add_post_meta($post_id, '_encloseme', '1');
5882 5882
 
5883 5883
 	wp_schedule_single_event(time(), 'do_pings');
5884 5884
 }
@@ -5892,9 +5892,9 @@  discard block
 block discarded – undo
5892 5892
  *
5893 5893
  * @return int|false Post parent ID, otherwise false.
5894 5894
  */
5895
-function wp_get_post_parent_id( $post_ID ) {
5896
-	$post = get_post( $post_ID );
5897
-	if ( !$post || is_wp_error( $post ) )
5895
+function wp_get_post_parent_id($post_ID) {
5896
+	$post = get_post($post_ID);
5897
+	if ( ! $post || is_wp_error($post))
5898 5898
 		return false;
5899 5899
 	return (int) $post->post_parent;
5900 5900
 }
@@ -5913,30 +5913,30 @@  discard block
 block discarded – undo
5913 5913
  * @param int $post_ID     ID of the post we're checking.
5914 5914
  * @return int The new post_parent for the post, 0 otherwise.
5915 5915
  */
5916
-function wp_check_post_hierarchy_for_loops( $post_parent, $post_ID ) {
5916
+function wp_check_post_hierarchy_for_loops($post_parent, $post_ID) {
5917 5917
 	// Nothing fancy here - bail.
5918
-	if ( !$post_parent )
5918
+	if ( ! $post_parent)
5919 5919
 		return 0;
5920 5920
 
5921 5921
 	// New post can't cause a loop.
5922
-	if ( empty( $post_ID ) )
5922
+	if (empty($post_ID))
5923 5923
 		return $post_parent;
5924 5924
 
5925 5925
 	// Can't be its own parent.
5926
-	if ( $post_parent == $post_ID )
5926
+	if ($post_parent == $post_ID)
5927 5927
 		return 0;
5928 5928
 
5929 5929
 	// Now look for larger loops.
5930
-	if ( !$loop = wp_find_hierarchy_loop( 'wp_get_post_parent_id', $post_ID, $post_parent ) )
5930
+	if ( ! $loop = wp_find_hierarchy_loop('wp_get_post_parent_id', $post_ID, $post_parent))
5931 5931
 		return $post_parent; // No loop
5932 5932
 
5933 5933
 	// Setting $post_parent to the given value causes a loop.
5934
-	if ( isset( $loop[$post_ID] ) )
5934
+	if (isset($loop[$post_ID]))
5935 5935
 		return 0;
5936 5936
 
5937 5937
 	// There's a loop, but it doesn't contain $post_ID. Break the loop.
5938
-	foreach ( array_keys( $loop ) as $loop_member )
5939
-		wp_update_post( array( 'ID' => $loop_member, 'post_parent' => 0 ) );
5938
+	foreach (array_keys($loop) as $loop_member)
5939
+		wp_update_post(array('ID' => $loop_member, 'post_parent' => 0));
5940 5940
 
5941 5941
 	return $post_parent;
5942 5942
 }
@@ -5950,14 +5950,14 @@  discard block
 block discarded – undo
5950 5950
  * @param int         $thumbnail_id Thumbnail to attach.
5951 5951
  * @return int|bool True on success, false on failure.
5952 5952
  */
5953
-function set_post_thumbnail( $post, $thumbnail_id ) {
5954
-	$post = get_post( $post );
5955
-	$thumbnail_id = absint( $thumbnail_id );
5956
-	if ( $post && $thumbnail_id && get_post( $thumbnail_id ) ) {
5957
-		if ( wp_get_attachment_image( $thumbnail_id, 'thumbnail' ) )
5958
-			return update_post_meta( $post->ID, '_thumbnail_id', $thumbnail_id );
5953
+function set_post_thumbnail($post, $thumbnail_id) {
5954
+	$post = get_post($post);
5955
+	$thumbnail_id = absint($thumbnail_id);
5956
+	if ($post && $thumbnail_id && get_post($thumbnail_id)) {
5957
+		if (wp_get_attachment_image($thumbnail_id, 'thumbnail'))
5958
+			return update_post_meta($post->ID, '_thumbnail_id', $thumbnail_id);
5959 5959
 		else
5960
-			return delete_post_meta( $post->ID, '_thumbnail_id' );
5960
+			return delete_post_meta($post->ID, '_thumbnail_id');
5961 5961
 	}
5962 5962
 	return false;
5963 5963
 }
@@ -5970,10 +5970,10 @@  discard block
 block discarded – undo
5970 5970
  * @param int|WP_Post $post Post ID or post object where thumbnail should be removed from.
5971 5971
  * @return bool True on success, false on failure.
5972 5972
  */
5973
-function delete_post_thumbnail( $post ) {
5974
-	$post = get_post( $post );
5975
-	if ( $post )
5976
-		return delete_post_meta( $post->ID, '_thumbnail_id' );
5973
+function delete_post_thumbnail($post) {
5974
+	$post = get_post($post);
5975
+	if ($post)
5976
+		return delete_post_meta($post->ID, '_thumbnail_id');
5977 5977
 	return false;
5978 5978
 }
5979 5979
 
@@ -5988,10 +5988,10 @@  discard block
 block discarded – undo
5988 5988
 	global $wpdb;
5989 5989
 
5990 5990
 	// Cleanup old auto-drafts more than 7 days old.
5991
-	$old_posts = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date" );
5992
-	foreach ( (array) $old_posts as $delete ) {
5991
+	$old_posts = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date");
5992
+	foreach ((array) $old_posts as $delete) {
5993 5993
 		// Force delete.
5994
-		wp_delete_post( $delete, true );
5994
+		wp_delete_post($delete, true);
5995 5995
 	}
5996 5996
 }
5997 5997
 
@@ -6002,23 +6002,23 @@  discard block
 block discarded – undo
6002 6002
  *
6003 6003
  * @param array $posts Array of WP_Post objects.
6004 6004
  */
6005
-function wp_queue_posts_for_term_meta_lazyload( $posts ) {
6005
+function wp_queue_posts_for_term_meta_lazyload($posts) {
6006 6006
 	$post_type_taxonomies = $term_ids = array();
6007
-	foreach ( $posts as $post ) {
6008
-		if ( ! ( $post instanceof WP_Post ) ) {
6007
+	foreach ($posts as $post) {
6008
+		if ( ! ($post instanceof WP_Post)) {
6009 6009
 			continue;
6010 6010
 		}
6011 6011
 
6012
-		if ( ! isset( $post_type_taxonomies[ $post->post_type ] ) ) {
6013
-			$post_type_taxonomies[ $post->post_type ] = get_object_taxonomies( $post->post_type );
6012
+		if ( ! isset($post_type_taxonomies[$post->post_type])) {
6013
+			$post_type_taxonomies[$post->post_type] = get_object_taxonomies($post->post_type);
6014 6014
 		}
6015 6015
 
6016
-		foreach ( $post_type_taxonomies[ $post->post_type ] as $taxonomy ) {
6016
+		foreach ($post_type_taxonomies[$post->post_type] as $taxonomy) {
6017 6017
 			// Term cache should already be primed by `update_post_term_cache()`.
6018
-			$terms = get_object_term_cache( $post->ID, $taxonomy );
6019
-			if ( false !== $terms ) {
6020
-				foreach ( $terms as $term ) {
6021
-					if ( ! isset( $term_ids[ $term->term_id ] ) ) {
6018
+			$terms = get_object_term_cache($post->ID, $taxonomy);
6019
+			if (false !== $terms) {
6020
+				foreach ($terms as $term) {
6021
+					if ( ! isset($term_ids[$term->term_id])) {
6022 6022
 						$term_ids[] = $term->term_id;
6023 6023
 					}
6024 6024
 				}
@@ -6026,9 +6026,9 @@  discard block
 block discarded – undo
6026 6026
 		}
6027 6027
 	}
6028 6028
 
6029
-	if ( $term_ids ) {
6029
+	if ($term_ids) {
6030 6030
 		$lazyloader = wp_metadata_lazyloader();
6031
-		$lazyloader->queue_objects( 'term', $term_ids );
6031
+		$lazyloader->queue_objects('term', $term_ids);
6032 6032
 	}
6033 6033
 }
6034 6034
 
@@ -6045,11 +6045,11 @@  discard block
 block discarded – undo
6045 6045
  * @param string  $old_status Old post status.
6046 6046
  * @param WP_Post $post       Post object.
6047 6047
  */
6048
-function _update_term_count_on_transition_post_status( $new_status, $old_status, $post ) {
6048
+function _update_term_count_on_transition_post_status($new_status, $old_status, $post) {
6049 6049
 	// Update counts for the post's terms.
6050
-	foreach ( (array) get_object_taxonomies( $post->post_type ) as $taxonomy ) {
6051
-		$tt_ids = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'tt_ids' ) );
6052
-		wp_update_term_count( $tt_ids, $taxonomy );
6050
+	foreach ((array) get_object_taxonomies($post->post_type) as $taxonomy) {
6051
+		$tt_ids = wp_get_object_terms($post->ID, $taxonomy, array('fields' => 'tt_ids'));
6052
+		wp_update_term_count($tt_ids, $taxonomy);
6053 6053
 	}
6054 6054
 }
6055 6055
 
@@ -6067,14 +6067,14 @@  discard block
 block discarded – undo
6067 6067
  * @param bool  $update_term_cache Optional. Whether to update the term cache. Default true.
6068 6068
  * @param bool  $update_meta_cache Optional. Whether to update the meta cache. Default true.
6069 6069
  */
6070
-function _prime_post_caches( $ids, $update_term_cache = true, $update_meta_cache = true ) {
6070
+function _prime_post_caches($ids, $update_term_cache = true, $update_meta_cache = true) {
6071 6071
 	global $wpdb;
6072 6072
 
6073
-	$non_cached_ids = _get_non_cached_ids( $ids, 'posts' );
6074
-	if ( !empty( $non_cached_ids ) ) {
6075
-		$fresh_posts = $wpdb->get_results( sprintf( "SELECT $wpdb->posts.* FROM $wpdb->posts WHERE ID IN (%s)", join( ",", $non_cached_ids ) ) );
6073
+	$non_cached_ids = _get_non_cached_ids($ids, 'posts');
6074
+	if ( ! empty($non_cached_ids)) {
6075
+		$fresh_posts = $wpdb->get_results(sprintf("SELECT $wpdb->posts.* FROM $wpdb->posts WHERE ID IN (%s)", join(",", $non_cached_ids)));
6076 6076
 
6077
-		update_post_caches( $fresh_posts, 'any', $update_term_cache, $update_meta_cache );
6077
+		update_post_caches($fresh_posts, 'any', $update_term_cache, $update_meta_cache);
6078 6078
 	}
6079 6079
 }
6080 6080
 
@@ -6092,18 +6092,18 @@  discard block
 block discarded – undo
6092 6092
  * @param string $post_name Slug.
6093 6093
  * @param string $post_ID   Optional. Post ID that should be ignored. Default 0.
6094 6094
  */
6095
-function wp_add_trashed_suffix_to_post_name_for_trashed_posts( $post_name, $post_ID = 0 ) {
6096
-	$trashed_posts_with_desired_slug = get_posts( array(
6095
+function wp_add_trashed_suffix_to_post_name_for_trashed_posts($post_name, $post_ID = 0) {
6096
+	$trashed_posts_with_desired_slug = get_posts(array(
6097 6097
 		'name' => $post_name,
6098 6098
 		'post_status' => 'trash',
6099 6099
 		'post_type' => 'any',
6100 6100
 		'nopaging' => true,
6101
-		'post__not_in' => array( $post_ID )
6102
-	) );
6101
+		'post__not_in' => array($post_ID)
6102
+	));
6103 6103
 
6104
-	if ( ! empty( $trashed_posts_with_desired_slug ) ) {
6105
-		foreach ( $trashed_posts_with_desired_slug as $_post ) {
6106
-			wp_add_trashed_suffix_to_post_name_for_post( $_post );
6104
+	if ( ! empty($trashed_posts_with_desired_slug)) {
6105
+		foreach ($trashed_posts_with_desired_slug as $_post) {
6106
+			wp_add_trashed_suffix_to_post_name_for_post($_post);
6107 6107
 		}
6108 6108
 	}
6109 6109
 }
@@ -6121,17 +6121,17 @@  discard block
 block discarded – undo
6121 6121
  *
6122 6122
  * @param WP_Post $post The post.
6123 6123
  */
6124
-function wp_add_trashed_suffix_to_post_name_for_post( $post ) {
6124
+function wp_add_trashed_suffix_to_post_name_for_post($post) {
6125 6125
 	global $wpdb;
6126 6126
 
6127
-	$post = get_post( $post );
6127
+	$post = get_post($post);
6128 6128
 
6129
-	if ( strpos( $post->post_name, '-%trashed%' ) ) {
6129
+	if (strpos($post->post_name, '-%trashed%')) {
6130 6130
 		return $post->post_name;
6131 6131
 	}
6132
-	add_post_meta( $post->ID, '_wp_desired_post_slug', $post->post_name );
6133
-	$post_name = _truncate_post_slug( $post->post_name, 190 ) . '-%trashed%';
6134
-	$wpdb->update( $wpdb->posts, array( 'post_name' => $post_name ), array( 'ID' => $post->ID ) );
6135
-	clean_post_cache( $post->ID );
6132
+	add_post_meta($post->ID, '_wp_desired_post_slug', $post->post_name);
6133
+	$post_name = _truncate_post_slug($post->post_name, 190).'-%trashed%';
6134
+	$wpdb->update($wpdb->posts, array('post_name' => $post_name), array('ID' => $post->ID));
6135
+	clean_post_cache($post->ID);
6136 6136
 	return $post_name;
6137 6137
 }
Please login to merge, or discard this patch.
Braces   +590 added lines, -405 removed lines patch added patch discarded remove patch
@@ -220,8 +220,9 @@  discard block
 block discarded – undo
220 220
  * @return bool True on success, false on failure.
221 221
  */
222 222
 function update_attached_file( $attachment_id, $file ) {
223
-	if ( !get_post( $attachment_id ) )
224
-		return false;
223
+	if ( !get_post( $attachment_id ) ) {
224
+			return false;
225
+	}
225 226
 
226 227
 	/**
227 228
 	 * Filter the path to the attached file to update.
@@ -233,11 +234,12 @@  discard block
 block discarded – undo
233 234
 	 */
234 235
 	$file = apply_filters( 'update_attached_file', $file, $attachment_id );
235 236
 
236
-	if ( $file = _wp_relative_upload_path( $file ) )
237
-		return update_post_meta( $attachment_id, '_wp_attached_file', $file );
238
-	else
239
-		return delete_post_meta( $attachment_id, '_wp_attached_file' );
240
-}
237
+	if ( $file = _wp_relative_upload_path( $file ) ) {
238
+			return update_post_meta( $attachment_id, '_wp_attached_file', $file );
239
+	} else {
240
+			return delete_post_meta( $attachment_id, '_wp_attached_file' );
241
+	}
242
+	}
241 243
 
242 244
 /**
243 245
  * Return relative path to an uploaded file.
@@ -344,16 +346,19 @@  discard block
 block discarded – undo
344 346
 
345 347
 	$children = get_posts( $r );
346 348
 
347
-	if ( ! $children )
348
-		return $kids;
349
+	if ( ! $children ) {
350
+			return $kids;
351
+	}
349 352
 
350
-	if ( ! empty( $r['fields'] ) )
351
-		return $children;
353
+	if ( ! empty( $r['fields'] ) ) {
354
+			return $children;
355
+	}
352 356
 
353 357
 	update_post_cache($children);
354 358
 
355
-	foreach ( $children as $key => $child )
356
-		$kids[$child->ID] = $children[$key];
359
+	foreach ( $children as $key => $child ) {
360
+			$kids[$child->ID] = $children[$key];
361
+	}
357 362
 
358 363
 	if ( $output == OBJECT ) {
359 364
 		return $kids;
@@ -428,8 +433,9 @@  discard block
 block discarded – undo
428 433
  *                            When $output is OBJECT, a `WP_Post` instance is returned.
429 434
  */
430 435
 function get_post( $post = null, $output = OBJECT, $filter = 'raw' ) {
431
-	if ( empty( $post ) && isset( $GLOBALS['post'] ) )
432
-		$post = $GLOBALS['post'];
436
+	if ( empty( $post ) && isset( $GLOBALS['post'] ) ) {
437
+			$post = $GLOBALS['post'];
438
+	}
433 439
 
434 440
 	if ( $post instanceof WP_Post ) {
435 441
 		$_post = $post;
@@ -446,15 +452,17 @@  discard block
 block discarded – undo
446 452
 		$_post = WP_Post::get_instance( $post );
447 453
 	}
448 454
 
449
-	if ( ! $_post )
450
-		return null;
455
+	if ( ! $_post ) {
456
+			return null;
457
+	}
451 458
 
452 459
 	$_post = $_post->filter( $filter );
453 460
 
454
-	if ( $output == ARRAY_A )
455
-		return $_post->to_array();
456
-	elseif ( $output == ARRAY_N )
457
-		return array_values( $_post->to_array() );
461
+	if ( $output == ARRAY_A ) {
462
+			return $_post->to_array();
463
+	} elseif ( $output == ARRAY_N ) {
464
+			return array_values( $_post->to_array() );
465
+	}
458 466
 
459 467
 	return $_post;
460 468
 }
@@ -470,8 +478,9 @@  discard block
 block discarded – undo
470 478
 function get_post_ancestors( $post ) {
471 479
 	$post = get_post( $post );
472 480
 
473
-	if ( ! $post || empty( $post->post_parent ) || $post->post_parent == $post->ID )
474
-		return array();
481
+	if ( ! $post || empty( $post->post_parent ) || $post->post_parent == $post->ID ) {
482
+			return array();
483
+	}
475 484
 
476 485
 	$ancestors = array();
477 486
 
@@ -479,8 +488,9 @@  discard block
 block discarded – undo
479 488
 
480 489
 	while ( $ancestor = get_post( $id ) ) {
481 490
 		// Loop detection: If the ancestor has been seen before, break.
482
-		if ( empty( $ancestor->post_parent ) || ( $ancestor->post_parent == $post->ID ) || in_array( $ancestor->post_parent, $ancestors ) )
483
-			break;
491
+		if ( empty( $ancestor->post_parent ) || ( $ancestor->post_parent == $post->ID ) || in_array( $ancestor->post_parent, $ancestors ) ) {
492
+					break;
493
+		}
484 494
 
485 495
 		$id = $ancestors[] = $ancestor->post_parent;
486 496
 	}
@@ -511,11 +521,13 @@  discard block
 block discarded – undo
511 521
 function get_post_field( $field, $post = null, $context = 'display' ) {
512 522
 	$post = get_post( $post );
513 523
 
514
-	if ( !$post )
515
-		return '';
524
+	if ( !$post ) {
525
+			return '';
526
+	}
516 527
 
517
-	if ( !isset($post->$field) )
518
-		return '';
528
+	if ( !isset($post->$field) ) {
529
+			return '';
530
+	}
519 531
 
520 532
 	return sanitize_post_field($field, $post->$field, $post->ID, $context);
521 533
 }
@@ -534,8 +546,9 @@  discard block
 block discarded – undo
534 546
 function get_post_mime_type( $ID = '' ) {
535 547
 	$post = get_post($ID);
536 548
 
537
-	if ( is_object($post) )
538
-		return $post->post_mime_type;
549
+	if ( is_object($post) ) {
550
+			return $post->post_mime_type;
551
+	}
539 552
 
540 553
 	return false;
541 554
 }
@@ -554,16 +567,19 @@  discard block
 block discarded – undo
554 567
 function get_post_status( $ID = '' ) {
555 568
 	$post = get_post($ID);
556 569
 
557
-	if ( !is_object($post) )
558
-		return false;
570
+	if ( !is_object($post) ) {
571
+			return false;
572
+	}
559 573
 
560 574
 	if ( 'attachment' == $post->post_type ) {
561
-		if ( 'private' == $post->post_status )
562
-			return 'private';
575
+		if ( 'private' == $post->post_status ) {
576
+					return 'private';
577
+		}
563 578
 
564 579
 		// Unattached attachments are assumed to be published.
565
-		if ( ( 'inherit' == $post->post_status ) && ( 0 == $post->post_parent) )
566
-			return 'publish';
580
+		if ( ( 'inherit' == $post->post_status ) && ( 0 == $post->post_parent) ) {
581
+					return 'publish';
582
+		}
567 583
 
568 584
 		// Inherit status from the parent.
569 585
 		if ( $post->post_parent && ( $post->ID != $post->post_parent ) ) {
@@ -675,8 +691,9 @@  discard block
 block discarded – undo
675 691
 function register_post_status( $post_status, $args = array() ) {
676 692
 	global $wp_post_statuses;
677 693
 
678
-	if (!is_array($wp_post_statuses))
679
-		$wp_post_statuses = array();
694
+	if (!is_array($wp_post_statuses)) {
695
+			$wp_post_statuses = array();
696
+	}
680 697
 
681 698
 	// Args prefixed with an underscore are reserved for internal use.
682 699
 	$defaults = array(
@@ -699,38 +716,49 @@  discard block
 block discarded – undo
699 716
 	$args->name = $post_status;
700 717
 
701 718
 	// Set various defaults.
702
-	if ( null === $args->public && null === $args->internal && null === $args->protected && null === $args->private )
703
-		$args->internal = true;
719
+	if ( null === $args->public && null === $args->internal && null === $args->protected && null === $args->private ) {
720
+			$args->internal = true;
721
+	}
704 722
 
705
-	if ( null === $args->public  )
706
-		$args->public = false;
723
+	if ( null === $args->public  ) {
724
+			$args->public = false;
725
+	}
707 726
 
708
-	if ( null === $args->private  )
709
-		$args->private = false;
727
+	if ( null === $args->private  ) {
728
+			$args->private = false;
729
+	}
710 730
 
711
-	if ( null === $args->protected  )
712
-		$args->protected = false;
731
+	if ( null === $args->protected  ) {
732
+			$args->protected = false;
733
+	}
713 734
 
714
-	if ( null === $args->internal  )
715
-		$args->internal = false;
735
+	if ( null === $args->internal  ) {
736
+			$args->internal = false;
737
+	}
716 738
 
717
-	if ( null === $args->publicly_queryable )
718
-		$args->publicly_queryable = $args->public;
739
+	if ( null === $args->publicly_queryable ) {
740
+			$args->publicly_queryable = $args->public;
741
+	}
719 742
 
720
-	if ( null === $args->exclude_from_search )
721
-		$args->exclude_from_search = $args->internal;
743
+	if ( null === $args->exclude_from_search ) {
744
+			$args->exclude_from_search = $args->internal;
745
+	}
722 746
 
723
-	if ( null === $args->show_in_admin_all_list )
724
-		$args->show_in_admin_all_list = !$args->internal;
747
+	if ( null === $args->show_in_admin_all_list ) {
748
+			$args->show_in_admin_all_list = !$args->internal;
749
+	}
725 750
 
726
-	if ( null === $args->show_in_admin_status_list )
727
-		$args->show_in_admin_status_list = !$args->internal;
751
+	if ( null === $args->show_in_admin_status_list ) {
752
+			$args->show_in_admin_status_list = !$args->internal;
753
+	}
728 754
 
729
-	if ( false === $args->label )
730
-		$args->label = $post_status;
755
+	if ( false === $args->label ) {
756
+			$args->label = $post_status;
757
+	}
731 758
 
732
-	if ( false === $args->label_count )
733
-		$args->label_count = array( $args->label, $args->label );
759
+	if ( false === $args->label_count ) {
760
+			$args->label_count = array( $args->label, $args->label );
761
+	}
734 762
 
735 763
 	$wp_post_statuses[$post_status] = $args;
736 764
 
@@ -752,8 +780,9 @@  discard block
 block discarded – undo
752 780
 function get_post_status_object( $post_status ) {
753 781
 	global $wp_post_statuses;
754 782
 
755
-	if ( empty($wp_post_statuses[$post_status]) )
756
-		return null;
783
+	if ( empty($wp_post_statuses[$post_status]) ) {
784
+			return null;
785
+	}
757 786
 
758 787
 	return $wp_post_statuses[$post_status];
759 788
 }
@@ -796,8 +825,9 @@  discard block
 block discarded – undo
796 825
  * @return bool Whether post type is hierarchical.
797 826
  */
798 827
 function is_post_type_hierarchical( $post_type ) {
799
-	if ( ! post_type_exists( $post_type ) )
800
-		return false;
828
+	if ( ! post_type_exists( $post_type ) ) {
829
+			return false;
830
+	}
801 831
 
802 832
 	$post_type = get_post_type_object( $post_type );
803 833
 	return $post_type->hierarchical;
@@ -826,8 +856,9 @@  discard block
 block discarded – undo
826 856
  * @return string|false          Post type on success, false on failure.
827 857
  */
828 858
 function get_post_type( $post = null ) {
829
-	if ( $post = get_post( $post ) )
830
-		return $post->post_type;
859
+	if ( $post = get_post( $post ) ) {
860
+			return $post->post_type;
861
+	}
831 862
 
832 863
 	return false;
833 864
 }
@@ -1057,36 +1088,44 @@  discard block
 block discarded – undo
1057 1088
 	}
1058 1089
 
1059 1090
 	// If not set, default to the setting for public.
1060
-	if ( null === $args->publicly_queryable )
1061
-		$args->publicly_queryable = $args->public;
1091
+	if ( null === $args->publicly_queryable ) {
1092
+			$args->publicly_queryable = $args->public;
1093
+	}
1062 1094
 
1063 1095
 	// If not set, default to the setting for public.
1064
-	if ( null === $args->show_ui )
1065
-		$args->show_ui = $args->public;
1096
+	if ( null === $args->show_ui ) {
1097
+			$args->show_ui = $args->public;
1098
+	}
1066 1099
 
1067 1100
 	// If not set, default to the setting for show_ui.
1068
-	if ( null === $args->show_in_menu || ! $args->show_ui )
1069
-		$args->show_in_menu = $args->show_ui;
1101
+	if ( null === $args->show_in_menu || ! $args->show_ui ) {
1102
+			$args->show_in_menu = $args->show_ui;
1103
+	}
1070 1104
 
1071 1105
 	// If not set, default to the whether the full UI is shown.
1072
-	if ( null === $args->show_in_admin_bar )
1073
-		$args->show_in_admin_bar = (bool) $args->show_in_menu;
1106
+	if ( null === $args->show_in_admin_bar ) {
1107
+			$args->show_in_admin_bar = (bool) $args->show_in_menu;
1108
+	}
1074 1109
 
1075 1110
 	// If not set, default to the setting for public.
1076
-	if ( null === $args->show_in_nav_menus )
1077
-		$args->show_in_nav_menus = $args->public;
1111
+	if ( null === $args->show_in_nav_menus ) {
1112
+			$args->show_in_nav_menus = $args->public;
1113
+	}
1078 1114
 
1079 1115
 	// If not set, default to true if not public, false if public.
1080
-	if ( null === $args->exclude_from_search )
1081
-		$args->exclude_from_search = !$args->public;
1116
+	if ( null === $args->exclude_from_search ) {
1117
+			$args->exclude_from_search = !$args->public;
1118
+	}
1082 1119
 
1083 1120
 	// Back compat with quirky handling in version 3.0. #14122.
1084
-	if ( empty( $args->capabilities ) && null === $args->map_meta_cap && in_array( $args->capability_type, array( 'post', 'page' ) ) )
1085
-		$args->map_meta_cap = true;
1121
+	if ( empty( $args->capabilities ) && null === $args->map_meta_cap && in_array( $args->capability_type, array( 'post', 'page' ) ) ) {
1122
+			$args->map_meta_cap = true;
1123
+	}
1086 1124
 
1087 1125
 	// If not set, default to false.
1088
-	if ( null === $args->map_meta_cap )
1089
-		$args->map_meta_cap = false;
1126
+	if ( null === $args->map_meta_cap ) {
1127
+			$args->map_meta_cap = false;
1128
+	}
1090 1129
 
1091 1130
 	// If there's no specified edit link and no UI, remove the edit link.
1092 1131
 	if ( ! $args->show_ui && ! $has_edit_link ) {
@@ -1096,8 +1135,9 @@  discard block
 block discarded – undo
1096 1135
 	$args->cap = get_post_type_capabilities( $args );
1097 1136
 	unset( $args->capabilities );
1098 1137
 
1099
-	if ( is_array( $args->capability_type ) )
1100
-		$args->capability_type = $args->capability_type[0];
1138
+	if ( is_array( $args->capability_type ) ) {
1139
+			$args->capability_type = $args->capability_type[0];
1140
+	}
1101 1141
 
1102 1142
 	if ( ! empty( $args->supports ) ) {
1103 1143
 		add_post_type_support( $post_type, $args->supports );
@@ -1108,10 +1148,11 @@  discard block
 block discarded – undo
1108 1148
 	}
1109 1149
 
1110 1150
 	if ( false !== $args->query_var ) {
1111
-		if ( true === $args->query_var )
1112
-			$args->query_var = $post_type;
1113
-		else
1114
-			$args->query_var = sanitize_title_with_dashes( $args->query_var );
1151
+		if ( true === $args->query_var ) {
1152
+					$args->query_var = $post_type;
1153
+		} else {
1154
+					$args->query_var = sanitize_title_with_dashes( $args->query_var );
1155
+		}
1115 1156
 
1116 1157
 		if ( $wp && is_post_type_viewable( $args ) ) {
1117 1158
 			$wp->add_query_var( $args->query_var );
@@ -1119,34 +1160,42 @@  discard block
 block discarded – undo
1119 1160
 	}
1120 1161
 
1121 1162
 	if ( false !== $args->rewrite && ( is_admin() || '' != get_option( 'permalink_structure' ) ) ) {
1122
-		if ( ! is_array( $args->rewrite ) )
1123
-			$args->rewrite = array();
1124
-		if ( empty( $args->rewrite['slug'] ) )
1125
-			$args->rewrite['slug'] = $post_type;
1126
-		if ( ! isset( $args->rewrite['with_front'] ) )
1127
-			$args->rewrite['with_front'] = true;
1128
-		if ( ! isset( $args->rewrite['pages'] ) )
1129
-			$args->rewrite['pages'] = true;
1130
-		if ( ! isset( $args->rewrite['feeds'] ) || ! $args->has_archive )
1131
-			$args->rewrite['feeds'] = (bool) $args->has_archive;
1163
+		if ( ! is_array( $args->rewrite ) ) {
1164
+					$args->rewrite = array();
1165
+		}
1166
+		if ( empty( $args->rewrite['slug'] ) ) {
1167
+					$args->rewrite['slug'] = $post_type;
1168
+		}
1169
+		if ( ! isset( $args->rewrite['with_front'] ) ) {
1170
+					$args->rewrite['with_front'] = true;
1171
+		}
1172
+		if ( ! isset( $args->rewrite['pages'] ) ) {
1173
+					$args->rewrite['pages'] = true;
1174
+		}
1175
+		if ( ! isset( $args->rewrite['feeds'] ) || ! $args->has_archive ) {
1176
+					$args->rewrite['feeds'] = (bool) $args->has_archive;
1177
+		}
1132 1178
 		if ( ! isset( $args->rewrite['ep_mask'] ) ) {
1133
-			if ( isset( $args->permalink_epmask ) )
1134
-				$args->rewrite['ep_mask'] = $args->permalink_epmask;
1135
-			else
1136
-				$args->rewrite['ep_mask'] = EP_PERMALINK;
1179
+			if ( isset( $args->permalink_epmask ) ) {
1180
+							$args->rewrite['ep_mask'] = $args->permalink_epmask;
1181
+			} else {
1182
+							$args->rewrite['ep_mask'] = EP_PERMALINK;
1183
+			}
1137 1184
 		}
1138 1185
 
1139
-		if ( $args->hierarchical )
1140
-			add_rewrite_tag( "%$post_type%", '(.+?)', $args->query_var ? "{$args->query_var}=" : "post_type=$post_type&pagename=" );
1141
-		else
1142
-			add_rewrite_tag( "%$post_type%", '([^/]+)', $args->query_var ? "{$args->query_var}=" : "post_type=$post_type&name=" );
1186
+		if ( $args->hierarchical ) {
1187
+					add_rewrite_tag( "%$post_type%", '(.+?)', $args->query_var ? "{$args->query_var}=" : "post_type=$post_type&pagename=" );
1188
+		} else {
1189
+					add_rewrite_tag( "%$post_type%", '([^/]+)', $args->query_var ? "{$args->query_var}=" : "post_type=$post_type&name=" );
1190
+		}
1143 1191
 
1144 1192
 		if ( $args->has_archive ) {
1145 1193
 			$archive_slug = $args->has_archive === true ? $args->rewrite['slug'] : $args->has_archive;
1146
-			if ( $args->rewrite['with_front'] )
1147
-				$archive_slug = substr( $wp_rewrite->front, 1 ) . $archive_slug;
1148
-			else
1149
-				$archive_slug = $wp_rewrite->root . $archive_slug;
1194
+			if ( $args->rewrite['with_front'] ) {
1195
+							$archive_slug = substr( $wp_rewrite->front, 1 ) . $archive_slug;
1196
+			} else {
1197
+							$archive_slug = $wp_rewrite->root . $archive_slug;
1198
+			}
1150 1199
 
1151 1200
 			add_rewrite_rule( "{$archive_slug}/?$", "index.php?post_type=$post_type", 'top' );
1152 1201
 			if ( $args->rewrite['feeds'] && $wp_rewrite->feeds ) {
@@ -1154,8 +1203,9 @@  discard block
 block discarded – undo
1154 1203
 				add_rewrite_rule( "{$archive_slug}/feed/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' );
1155 1204
 				add_rewrite_rule( "{$archive_slug}/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' );
1156 1205
 			}
1157
-			if ( $args->rewrite['pages'] )
1158
-				add_rewrite_rule( "{$archive_slug}/{$wp_rewrite->pagination_base}/([0-9]{1,})/?$", "index.php?post_type=$post_type" . '&paged=$matches[1]', 'top' );
1206
+			if ( $args->rewrite['pages'] ) {
1207
+							add_rewrite_rule( "{$archive_slug}/{$wp_rewrite->pagination_base}/([0-9]{1,})/?$", "index.php?post_type=$post_type" . '&paged=$matches[1]', 'top' );
1208
+			}
1159 1209
 		}
1160 1210
 
1161 1211
 		$permastruct_args = $args->rewrite;
@@ -1164,8 +1214,9 @@  discard block
 block discarded – undo
1164 1214
 	}
1165 1215
 
1166 1216
 	// Register the post type meta box if a custom callback was specified.
1167
-	if ( $args->register_meta_box_cb )
1168
-		add_action( 'add_meta_boxes_' . $post_type, $args->register_meta_box_cb, 10, 1 );
1217
+	if ( $args->register_meta_box_cb ) {
1218
+			add_action( 'add_meta_boxes_' . $post_type, $args->register_meta_box_cb, 10, 1 );
1219
+	}
1169 1220
 
1170 1221
 	$args->labels = get_post_type_labels( $args );
1171 1222
 	$args->label = $args->labels->name;
@@ -1329,8 +1380,9 @@  discard block
 block discarded – undo
1329 1380
  * @return object object with all the capabilities as member variables.
1330 1381
  */
1331 1382
 function get_post_type_capabilities( $args ) {
1332
-	if ( ! is_array( $args->capability_type ) )
1333
-		$args->capability_type = array( $args->capability_type, $args->capability_type . 's' );
1383
+	if ( ! is_array( $args->capability_type ) ) {
1384
+			$args->capability_type = array( $args->capability_type, $args->capability_type . 's' );
1385
+	}
1334 1386
 
1335 1387
 	// Singular base for meta capabilities, plural base for primitive capabilities.
1336 1388
 	list( $singular_base, $plural_base ) = $args->capability_type;
@@ -1364,12 +1416,14 @@  discard block
 block discarded – undo
1364 1416
 	$capabilities = array_merge( $default_capabilities, $args->capabilities );
1365 1417
 
1366 1418
 	// Post creation capability simply maps to edit_posts by default:
1367
-	if ( ! isset( $capabilities['create_posts'] ) )
1368
-		$capabilities['create_posts'] = $capabilities['edit_posts'];
1419
+	if ( ! isset( $capabilities['create_posts'] ) ) {
1420
+			$capabilities['create_posts'] = $capabilities['edit_posts'];
1421
+	}
1369 1422
 
1370 1423
 	// Remember meta capabilities for future reference.
1371
-	if ( $args->map_meta_cap )
1372
-		_post_type_meta_capabilities( $capabilities );
1424
+	if ( $args->map_meta_cap ) {
1425
+			_post_type_meta_capabilities( $capabilities );
1426
+	}
1373 1427
 
1374 1428
 	return (object) $capabilities;
1375 1429
 }
@@ -1509,20 +1563,25 @@  discard block
 block discarded – undo
1509 1563
 function _get_custom_object_labels( $object, $nohier_vs_hier_defaults ) {
1510 1564
 	$object->labels = (array) $object->labels;
1511 1565
 
1512
-	if ( isset( $object->label ) && empty( $object->labels['name'] ) )
1513
-		$object->labels['name'] = $object->label;
1566
+	if ( isset( $object->label ) && empty( $object->labels['name'] ) ) {
1567
+			$object->labels['name'] = $object->label;
1568
+	}
1514 1569
 
1515
-	if ( !isset( $object->labels['singular_name'] ) && isset( $object->labels['name'] ) )
1516
-		$object->labels['singular_name'] = $object->labels['name'];
1570
+	if ( !isset( $object->labels['singular_name'] ) && isset( $object->labels['name'] ) ) {
1571
+			$object->labels['singular_name'] = $object->labels['name'];
1572
+	}
1517 1573
 
1518
-	if ( ! isset( $object->labels['name_admin_bar'] ) )
1519
-		$object->labels['name_admin_bar'] = isset( $object->labels['singular_name'] ) ? $object->labels['singular_name'] : $object->name;
1574
+	if ( ! isset( $object->labels['name_admin_bar'] ) ) {
1575
+			$object->labels['name_admin_bar'] = isset( $object->labels['singular_name'] ) ? $object->labels['singular_name'] : $object->name;
1576
+	}
1520 1577
 
1521
-	if ( !isset( $object->labels['menu_name'] ) && isset( $object->labels['name'] ) )
1522
-		$object->labels['menu_name'] = $object->labels['name'];
1578
+	if ( !isset( $object->labels['menu_name'] ) && isset( $object->labels['name'] ) ) {
1579
+			$object->labels['menu_name'] = $object->labels['name'];
1580
+	}
1523 1581
 
1524
-	if ( !isset( $object->labels['all_items'] ) && isset( $object->labels['menu_name'] ) )
1525
-		$object->labels['all_items'] = $object->labels['menu_name'];
1582
+	if ( !isset( $object->labels['all_items'] ) && isset( $object->labels['menu_name'] ) ) {
1583
+			$object->labels['all_items'] = $object->labels['menu_name'];
1584
+	}
1526 1585
 
1527 1586
 	if ( !isset( $object->labels['archives'] ) && isset( $object->labels['all_items'] ) ) {
1528 1587
 		$object->labels['archives'] = $object->labels['all_items'];
@@ -1548,8 +1607,9 @@  discard block
 block discarded – undo
1548 1607
 	foreach ( get_post_types( array( 'show_ui' => true ) ) as $ptype ) {
1549 1608
 		$ptype_obj = get_post_type_object( $ptype );
1550 1609
 		// Sub-menus only.
1551
-		if ( ! $ptype_obj->show_in_menu || $ptype_obj->show_in_menu === true )
1552
-			continue;
1610
+		if ( ! $ptype_obj->show_in_menu || $ptype_obj->show_in_menu === true ) {
1611
+					continue;
1612
+		}
1553 1613
 		add_submenu_page( $ptype_obj->show_in_menu, $ptype_obj->labels->name, $ptype_obj->labels->all_items, $ptype_obj->cap->edit_posts, "edit.php?post_type=$ptype" );
1554 1614
 	}
1555 1615
 }
@@ -1579,10 +1639,11 @@  discard block
 block discarded – undo
1579 1639
 
1580 1640
 	$features = (array) $feature;
1581 1641
 	foreach ($features as $feature) {
1582
-		if ( func_num_args() == 2 )
1583
-			$_wp_post_type_features[$post_type][$feature] = true;
1584
-		else
1585
-			$_wp_post_type_features[$post_type][$feature] = array_slice( func_get_args(), 2 );
1642
+		if ( func_num_args() == 2 ) {
1643
+					$_wp_post_type_features[$post_type][$feature] = true;
1644
+		} else {
1645
+					$_wp_post_type_features[$post_type][$feature] = array_slice( func_get_args(), 2 );
1646
+		}
1586 1647
 	}
1587 1648
 }
1588 1649
 
@@ -1615,8 +1676,9 @@  discard block
 block discarded – undo
1615 1676
 function get_all_post_type_supports( $post_type ) {
1616 1677
 	global $_wp_post_type_features;
1617 1678
 
1618
-	if ( isset( $_wp_post_type_features[$post_type] ) )
1619
-		return $_wp_post_type_features[$post_type];
1679
+	if ( isset( $_wp_post_type_features[$post_type] ) ) {
1680
+			return $_wp_post_type_features[$post_type];
1681
+	}
1620 1682
 
1621 1683
 	return array();
1622 1684
 }
@@ -1743,18 +1805,22 @@  discard block
 block discarded – undo
1743 1805
 	);
1744 1806
 
1745 1807
 	$r = wp_parse_args( $args, $defaults );
1746
-	if ( empty( $r['post_status'] ) )
1747
-		$r['post_status'] = ( 'attachment' == $r['post_type'] ) ? 'inherit' : 'publish';
1748
-	if ( ! empty($r['numberposts']) && empty($r['posts_per_page']) )
1749
-		$r['posts_per_page'] = $r['numberposts'];
1750
-	if ( ! empty($r['category']) )
1751
-		$r['cat'] = $r['category'];
1808
+	if ( empty( $r['post_status'] ) ) {
1809
+			$r['post_status'] = ( 'attachment' == $r['post_type'] ) ? 'inherit' : 'publish';
1810
+	}
1811
+	if ( ! empty($r['numberposts']) && empty($r['posts_per_page']) ) {
1812
+			$r['posts_per_page'] = $r['numberposts'];
1813
+	}
1814
+	if ( ! empty($r['category']) ) {
1815
+			$r['cat'] = $r['category'];
1816
+	}
1752 1817
 	if ( ! empty($r['include']) ) {
1753 1818
 		$incposts = wp_parse_id_list( $r['include'] );
1754 1819
 		$r['posts_per_page'] = count($incposts);  // only the number of posts included
1755 1820
 		$r['post__in'] = $incposts;
1756
-	} elseif ( ! empty($r['exclude']) )
1757
-		$r['post__not_in'] = wp_parse_id_list( $r['exclude'] );
1821
+	} elseif ( ! empty($r['exclude']) ) {
1822
+			$r['post__not_in'] = wp_parse_id_list( $r['exclude'] );
1823
+	}
1758 1824
 
1759 1825
 	$r['ignore_sticky_posts'] = true;
1760 1826
 	$r['no_found_rows'] = true;
@@ -1784,8 +1850,9 @@  discard block
 block discarded – undo
1784 1850
  */
1785 1851
 function add_post_meta( $post_id, $meta_key, $meta_value, $unique = false ) {
1786 1852
 	// Make sure meta is added to the post, not a revision.
1787
-	if ( $the_post = wp_is_post_revision($post_id) )
1788
-		$post_id = $the_post;
1853
+	if ( $the_post = wp_is_post_revision($post_id) ) {
1854
+			$post_id = $the_post;
1855
+	}
1789 1856
 
1790 1857
 	return add_metadata('post', $post_id, $meta_key, $meta_value, $unique);
1791 1858
 }
@@ -1807,8 +1874,9 @@  discard block
 block discarded – undo
1807 1874
  */
1808 1875
 function delete_post_meta( $post_id, $meta_key, $meta_value = '' ) {
1809 1876
 	// Make sure meta is added to the post, not a revision.
1810
-	if ( $the_post = wp_is_post_revision($post_id) )
1811
-		$post_id = $the_post;
1877
+	if ( $the_post = wp_is_post_revision($post_id) ) {
1878
+			$post_id = $the_post;
1879
+	}
1812 1880
 
1813 1881
 	return delete_metadata('post', $post_id, $meta_key, $meta_value);
1814 1882
 }
@@ -1849,8 +1917,9 @@  discard block
 block discarded – undo
1849 1917
  */
1850 1918
 function update_post_meta( $post_id, $meta_key, $meta_value, $prev_value = '' ) {
1851 1919
 	// Make sure meta is added to the post, not a revision.
1852
-	if ( $the_post = wp_is_post_revision($post_id) )
1853
-		$post_id = $the_post;
1920
+	if ( $the_post = wp_is_post_revision($post_id) ) {
1921
+			$post_id = $the_post;
1922
+	}
1854 1923
 
1855 1924
 	return update_metadata('post', $post_id, $meta_key, $meta_value, $prev_value);
1856 1925
 }
@@ -1880,8 +1949,9 @@  discard block
 block discarded – undo
1880 1949
  */
1881 1950
 function get_post_custom( $post_id = 0 ) {
1882 1951
 	$post_id = absint( $post_id );
1883
-	if ( ! $post_id )
1884
-		$post_id = get_the_ID();
1952
+	if ( ! $post_id ) {
1953
+			$post_id = get_the_ID();
1954
+	}
1885 1955
 
1886 1956
 	return get_post_meta( $post_id );
1887 1957
 }
@@ -1899,12 +1969,14 @@  discard block
 block discarded – undo
1899 1969
 function get_post_custom_keys( $post_id = 0 ) {
1900 1970
 	$custom = get_post_custom( $post_id );
1901 1971
 
1902
-	if ( !is_array($custom) )
1903
-		return;
1972
+	if ( !is_array($custom) ) {
1973
+			return;
1974
+	}
1904 1975
 
1905
-	if ( $keys = array_keys($custom) )
1906
-		return $keys;
1907
-}
1976
+	if ( $keys = array_keys($custom) ) {
1977
+			return $keys;
1978
+	}
1979
+	}
1908 1980
 
1909 1981
 /**
1910 1982
  * Retrieve values for a custom post field.
@@ -1919,8 +1991,9 @@  discard block
 block discarded – undo
1919 1991
  * @return array|null Meta field values.
1920 1992
  */
1921 1993
 function get_post_custom_values( $key = '', $post_id = 0 ) {
1922
-	if ( !$key )
1923
-		return null;
1994
+	if ( !$key ) {
1995
+			return null;
1996
+	}
1924 1997
 
1925 1998
 	$custom = get_post_custom($post_id);
1926 1999
 
@@ -1941,16 +2014,19 @@  discard block
 block discarded – undo
1941 2014
 function is_sticky( $post_id = 0 ) {
1942 2015
 	$post_id = absint( $post_id );
1943 2016
 
1944
-	if ( ! $post_id )
1945
-		$post_id = get_the_ID();
2017
+	if ( ! $post_id ) {
2018
+			$post_id = get_the_ID();
2019
+	}
1946 2020
 
1947 2021
 	$stickies = get_option( 'sticky_posts' );
1948 2022
 
1949
-	if ( ! is_array( $stickies ) )
1950
-		return false;
2023
+	if ( ! is_array( $stickies ) ) {
2024
+			return false;
2025
+	}
1951 2026
 
1952
-	if ( in_array( $post_id, $stickies ) )
1953
-		return true;
2027
+	if ( in_array( $post_id, $stickies ) ) {
2028
+			return true;
2029
+	}
1954 2030
 
1955 2031
 	return false;
1956 2032
 }
@@ -1975,21 +2051,27 @@  discard block
 block discarded – undo
1975 2051
 function sanitize_post( $post, $context = 'display' ) {
1976 2052
 	if ( is_object($post) ) {
1977 2053
 		// Check if post already filtered for this context.
1978
-		if ( isset($post->filter) && $context == $post->filter )
1979
-			return $post;
1980
-		if ( !isset($post->ID) )
1981
-			$post->ID = 0;
1982
-		foreach ( array_keys(get_object_vars($post)) as $field )
1983
-			$post->$field = sanitize_post_field($field, $post->$field, $post->ID, $context);
2054
+		if ( isset($post->filter) && $context == $post->filter ) {
2055
+					return $post;
2056
+		}
2057
+		if ( !isset($post->ID) ) {
2058
+					$post->ID = 0;
2059
+		}
2060
+		foreach ( array_keys(get_object_vars($post)) as $field ) {
2061
+					$post->$field = sanitize_post_field($field, $post->$field, $post->ID, $context);
2062
+		}
1984 2063
 		$post->filter = $context;
1985 2064
 	} elseif ( is_array( $post ) ) {
1986 2065
 		// Check if post already filtered for this context.
1987
-		if ( isset($post['filter']) && $context == $post['filter'] )
1988
-			return $post;
1989
-		if ( !isset($post['ID']) )
1990
-			$post['ID'] = 0;
1991
-		foreach ( array_keys($post) as $field )
1992
-			$post[$field] = sanitize_post_field($field, $post[$field], $post['ID'], $context);
2066
+		if ( isset($post['filter']) && $context == $post['filter'] ) {
2067
+					return $post;
2068
+		}
2069
+		if ( !isset($post['ID']) ) {
2070
+					$post['ID'] = 0;
2071
+		}
2072
+		foreach ( array_keys($post) as $field ) {
2073
+					$post[$field] = sanitize_post_field($field, $post[$field], $post['ID'], $context);
2074
+		}
1993 2075
 		$post['filter'] = $context;
1994 2076
 	}
1995 2077
 	return $post;
@@ -2014,8 +2096,9 @@  discard block
 block discarded – undo
2014 2096
  */
2015 2097
 function sanitize_post_field( $field, $value, $post_id, $context = 'display' ) {
2016 2098
 	$int_fields = array('ID', 'post_parent', 'menu_order');
2017
-	if ( in_array($field, $int_fields) )
2018
-		$value = (int) $value;
2099
+	if ( in_array($field, $int_fields) ) {
2100
+			$value = (int) $value;
2101
+	}
2019 2102
 
2020 2103
 	// Fields which contain arrays of integers.
2021 2104
 	$array_int_fields = array( 'ancestors' );
@@ -2024,8 +2107,9 @@  discard block
 block discarded – undo
2024 2107
 		return $value;
2025 2108
 	}
2026 2109
 
2027
-	if ( 'raw' == $context )
2028
-		return $value;
2110
+	if ( 'raw' == $context ) {
2111
+			return $value;
2112
+	}
2029 2113
 
2030 2114
 	$prefixed = false;
2031 2115
 	if ( false !== strpos($field, 'post_') ) {
@@ -2068,10 +2152,11 @@  discard block
 block discarded – undo
2068 2152
 		}
2069 2153
 
2070 2154
 		if ( in_array($field, $format_to_edit) ) {
2071
-			if ( 'post_content' == $field )
2072
-				$value = format_to_edit($value, user_can_richedit());
2073
-			else
2074
-				$value = format_to_edit($value);
2155
+			if ( 'post_content' == $field ) {
2156
+							$value = format_to_edit($value, user_can_richedit());
2157
+			} else {
2158
+							$value = format_to_edit($value);
2159
+			}
2075 2160
 		} else {
2076 2161
 			$value = esc_attr($value);
2077 2162
 		}
@@ -2141,10 +2226,11 @@  discard block
 block discarded – undo
2141 2226
 		}
2142 2227
 	}
2143 2228
 
2144
-	if ( 'attribute' == $context )
2145
-		$value = esc_attr($value);
2146
-	elseif ( 'js' == $context )
2147
-		$value = esc_js($value);
2229
+	if ( 'attribute' == $context ) {
2230
+			$value = esc_attr($value);
2231
+	} elseif ( 'js' == $context ) {
2232
+			$value = esc_js($value);
2233
+	}
2148 2234
 
2149 2235
 	return $value;
2150 2236
 }
@@ -2161,11 +2247,13 @@  discard block
 block discarded – undo
2161 2247
 function stick_post( $post_id ) {
2162 2248
 	$stickies = get_option('sticky_posts');
2163 2249
 
2164
-	if ( !is_array($stickies) )
2165
-		$stickies = array($post_id);
2250
+	if ( !is_array($stickies) ) {
2251
+			$stickies = array($post_id);
2252
+	}
2166 2253
 
2167
-	if ( ! in_array($post_id, $stickies) )
2168
-		$stickies[] = $post_id;
2254
+	if ( ! in_array($post_id, $stickies) ) {
2255
+			$stickies[] = $post_id;
2256
+	}
2169 2257
 
2170 2258
 	update_option('sticky_posts', $stickies);
2171 2259
 }
@@ -2182,15 +2270,18 @@  discard block
 block discarded – undo
2182 2270
 function unstick_post( $post_id ) {
2183 2271
 	$stickies = get_option('sticky_posts');
2184 2272
 
2185
-	if ( !is_array($stickies) )
2186
-		return;
2273
+	if ( !is_array($stickies) ) {
2274
+			return;
2275
+	}
2187 2276
 
2188
-	if ( ! in_array($post_id, $stickies) )
2189
-		return;
2277
+	if ( ! in_array($post_id, $stickies) ) {
2278
+			return;
2279
+	}
2190 2280
 
2191 2281
 	$offset = array_search($post_id, $stickies);
2192
-	if ( false === $offset )
2193
-		return;
2282
+	if ( false === $offset ) {
2283
+			return;
2284
+	}
2194 2285
 
2195 2286
 	array_splice($stickies, $offset, 1);
2196 2287
 
@@ -2239,8 +2330,9 @@  discard block
 block discarded – undo
2239 2330
 function wp_count_posts( $type = 'post', $perm = '' ) {
2240 2331
 	global $wpdb;
2241 2332
 
2242
-	if ( ! post_type_exists( $type ) )
2243
-		return new stdClass;
2333
+	if ( ! post_type_exists( $type ) ) {
2334
+			return new stdClass;
2335
+	}
2244 2336
 
2245 2337
 	$cache_key = _count_posts_cache_key( $type, $perm );
2246 2338
 
@@ -2415,8 +2507,9 @@  discard block
 block discarded – undo
2415 2507
 function wp_post_mime_type_where( $post_mime_types, $table_alias = '' ) {
2416 2508
 	$where = '';
2417 2509
 	$wildcards = array('', '%', '%/%');
2418
-	if ( is_string($post_mime_types) )
2419
-		$post_mime_types = array_map('trim', explode(',', $post_mime_types));
2510
+	if ( is_string($post_mime_types) ) {
2511
+			$post_mime_types = array_map('trim', explode(',', $post_mime_types));
2512
+	}
2420 2513
 
2421 2514
 	$wheres = array();
2422 2515
 
@@ -2426,29 +2519,34 @@  discard block
 block discarded – undo
2426 2519
 		if ( false !== $slashpos ) {
2427 2520
 			$mime_group = preg_replace('/[^-*.a-zA-Z0-9]/', '', substr($mime_type, 0, $slashpos));
2428 2521
 			$mime_subgroup = preg_replace('/[^-*.+a-zA-Z0-9]/', '', substr($mime_type, $slashpos + 1));
2429
-			if ( empty($mime_subgroup) )
2430
-				$mime_subgroup = '*';
2431
-			else
2432
-				$mime_subgroup = str_replace('/', '', $mime_subgroup);
2522
+			if ( empty($mime_subgroup) ) {
2523
+							$mime_subgroup = '*';
2524
+			} else {
2525
+							$mime_subgroup = str_replace('/', '', $mime_subgroup);
2526
+			}
2433 2527
 			$mime_pattern = "$mime_group/$mime_subgroup";
2434 2528
 		} else {
2435 2529
 			$mime_pattern = preg_replace('/[^-*.a-zA-Z0-9]/', '', $mime_type);
2436
-			if ( false === strpos($mime_pattern, '*') )
2437
-				$mime_pattern .= '/*';
2530
+			if ( false === strpos($mime_pattern, '*') ) {
2531
+							$mime_pattern .= '/*';
2532
+			}
2438 2533
 		}
2439 2534
 
2440 2535
 		$mime_pattern = preg_replace('/\*+/', '%', $mime_pattern);
2441 2536
 
2442
-		if ( in_array( $mime_type, $wildcards ) )
2443
-			return '';
2537
+		if ( in_array( $mime_type, $wildcards ) ) {
2538
+					return '';
2539
+		}
2444 2540
 
2445
-		if ( false !== strpos($mime_pattern, '%') )
2446
-			$wheres[] = empty($table_alias) ? "post_mime_type LIKE '$mime_pattern'" : "$table_alias.post_mime_type LIKE '$mime_pattern'";
2447
-		else
2448
-			$wheres[] = empty($table_alias) ? "post_mime_type = '$mime_pattern'" : "$table_alias.post_mime_type = '$mime_pattern'";
2541
+		if ( false !== strpos($mime_pattern, '%') ) {
2542
+					$wheres[] = empty($table_alias) ? "post_mime_type LIKE '$mime_pattern'" : "$table_alias.post_mime_type LIKE '$mime_pattern'";
2543
+		} else {
2544
+					$wheres[] = empty($table_alias) ? "post_mime_type = '$mime_pattern'" : "$table_alias.post_mime_type = '$mime_pattern'";
2545
+		}
2546
+	}
2547
+	if ( !empty($wheres) ) {
2548
+			$where = ' AND (' . join(' OR ', $wheres) . ') ';
2449 2549
 	}
2450
-	if ( !empty($wheres) )
2451
-		$where = ' AND (' . join(' OR ', $wheres) . ') ';
2452 2550
 	return $where;
2453 2551
 }
2454 2552
 
@@ -2476,14 +2574,17 @@  discard block
 block discarded – undo
2476 2574
 function wp_delete_post( $postid = 0, $force_delete = false ) {
2477 2575
 	global $wpdb;
2478 2576
 
2479
-	if ( !$post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $postid)) )
2480
-		return $post;
2577
+	if ( !$post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $postid)) ) {
2578
+			return $post;
2579
+	}
2481 2580
 
2482
-	if ( !$force_delete && ( $post->post_type == 'post' || $post->post_type == 'page') && get_post_status( $postid ) != 'trash' && EMPTY_TRASH_DAYS )
2483
-		return wp_trash_post( $postid );
2581
+	if ( !$force_delete && ( $post->post_type == 'post' || $post->post_type == 'page') && get_post_status( $postid ) != 'trash' && EMPTY_TRASH_DAYS ) {
2582
+			return wp_trash_post( $postid );
2583
+	}
2484 2584
 
2485
-	if ( $post->post_type == 'attachment' )
2486
-		return wp_delete_attachment( $postid, $force_delete );
2585
+	if ( $post->post_type == 'attachment' ) {
2586
+			return wp_delete_attachment( $postid, $force_delete );
2587
+	}
2487 2588
 
2488 2589
 	/**
2489 2590
 	 * Filter whether a post deletion should take place.
@@ -2530,8 +2631,9 @@  discard block
 block discarded – undo
2530 2631
 	// Do raw query. wp_get_post_revisions() is filtered.
2531 2632
 	$revision_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'revision'", $postid ) );
2532 2633
 	// Use wp_delete_post (via wp_delete_post_revision) again. Ensures any meta/misplaced data gets cleaned up.
2533
-	foreach ( $revision_ids as $revision_id )
2534
-		wp_delete_post_revision( $revision_id );
2634
+	foreach ( $revision_ids as $revision_id ) {
2635
+			wp_delete_post_revision( $revision_id );
2636
+	}
2535 2637
 
2536 2638
 	// Point all attachments to this post up one level.
2537 2639
 	$wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => 'attachment' ) );
@@ -2546,8 +2648,9 @@  discard block
 block discarded – undo
2546 2648
 	wp_defer_comment_counting( false );
2547 2649
 
2548 2650
 	$post_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $postid ));
2549
-	foreach ( $post_meta_ids as $mid )
2550
-		delete_metadata_by_mid( 'post', $mid );
2651
+	foreach ( $post_meta_ids as $mid ) {
2652
+			delete_metadata_by_mid( 'post', $mid );
2653
+	}
2551 2654
 
2552 2655
 	/**
2553 2656
 	 * Fires immediately before a post is deleted from the database.
@@ -2574,8 +2677,9 @@  discard block
 block discarded – undo
2574 2677
 	clean_post_cache( $post );
2575 2678
 
2576 2679
 	if ( is_post_type_hierarchical( $post->post_type ) && $children ) {
2577
-		foreach ( $children as $child )
2578
-			clean_post_cache( $child );
2680
+		foreach ( $children as $child ) {
2681
+					clean_post_cache( $child );
2682
+		}
2579 2683
 	}
2580 2684
 
2581 2685
 	wp_clear_scheduled_hook('publish_future_post', array( $postid ) );
@@ -2637,14 +2741,17 @@  discard block
 block discarded – undo
2637 2741
  * @return false|array|WP_Post|null Post data array, otherwise false.
2638 2742
  */
2639 2743
 function wp_trash_post( $post_id = 0 ) {
2640
-	if ( !EMPTY_TRASH_DAYS )
2641
-		return wp_delete_post($post_id, true);
2744
+	if ( !EMPTY_TRASH_DAYS ) {
2745
+			return wp_delete_post($post_id, true);
2746
+	}
2642 2747
 
2643
-	if ( !$post = get_post($post_id, ARRAY_A) )
2644
-		return $post;
2748
+	if ( !$post = get_post($post_id, ARRAY_A) ) {
2749
+			return $post;
2750
+	}
2645 2751
 
2646
-	if ( $post['post_status'] == 'trash' )
2647
-		return false;
2752
+	if ( $post['post_status'] == 'trash' ) {
2753
+			return false;
2754
+	}
2648 2755
 
2649 2756
 	/**
2650 2757
 	 * Fires before a post is sent to the trash.
@@ -2684,11 +2791,13 @@  discard block
 block discarded – undo
2684 2791
  * @return WP_Post|false WP_Post object. False on failure.
2685 2792
  */
2686 2793
 function wp_untrash_post( $post_id = 0 ) {
2687
-	if ( !$post = get_post($post_id, ARRAY_A) )
2688
-		return $post;
2794
+	if ( !$post = get_post($post_id, ARRAY_A) ) {
2795
+			return $post;
2796
+	}
2689 2797
 
2690
-	if ( $post['post_status'] != 'trash' )
2691
-		return false;
2798
+	if ( $post['post_status'] != 'trash' ) {
2799
+			return false;
2800
+	}
2692 2801
 
2693 2802
 	/**
2694 2803
 	 * Fires before a post is restored from the trash.
@@ -2736,8 +2845,9 @@  discard block
 block discarded – undo
2736 2845
 	global $wpdb;
2737 2846
 
2738 2847
 	$post = get_post($post);
2739
-	if ( empty($post) )
2740
-		return;
2848
+	if ( empty($post) ) {
2849
+			return;
2850
+	}
2741 2851
 
2742 2852
 	$post_id = $post->ID;
2743 2853
 
@@ -2751,13 +2861,15 @@  discard block
 block discarded – undo
2751 2861
 	do_action( 'trash_post_comments', $post_id );
2752 2862
 
2753 2863
 	$comments = $wpdb->get_results( $wpdb->prepare("SELECT comment_ID, comment_approved FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id) );
2754
-	if ( empty($comments) )
2755
-		return;
2864
+	if ( empty($comments) ) {
2865
+			return;
2866
+	}
2756 2867
 
2757 2868
 	// Cache current status for each comment.
2758 2869
 	$statuses = array();
2759
-	foreach ( $comments as $comment )
2760
-		$statuses[$comment->comment_ID] = $comment->comment_approved;
2870
+	foreach ( $comments as $comment ) {
2871
+			$statuses[$comment->comment_ID] = $comment->comment_approved;
2872
+	}
2761 2873
 	add_post_meta($post_id, '_wp_trash_meta_comments_status', $statuses);
2762 2874
 
2763 2875
 	// Set status for all comments to post-trashed.
@@ -2792,15 +2904,17 @@  discard block
 block discarded – undo
2792 2904
 	global $wpdb;
2793 2905
 
2794 2906
 	$post = get_post($post);
2795
-	if ( empty($post) )
2796
-		return;
2907
+	if ( empty($post) ) {
2908
+			return;
2909
+	}
2797 2910
 
2798 2911
 	$post_id = $post->ID;
2799 2912
 
2800 2913
 	$statuses = get_post_meta($post_id, '_wp_trash_meta_comments_status', true);
2801 2914
 
2802
-	if ( empty($statuses) )
2803
-		return true;
2915
+	if ( empty($statuses) ) {
2916
+			return true;
2917
+	}
2804 2918
 
2805 2919
 	/**
2806 2920
 	 * Fires before comments are restored for a post from the trash.
@@ -2813,8 +2927,9 @@  discard block
 block discarded – undo
2813 2927
 
2814 2928
 	// Restore each comment to its original status.
2815 2929
 	$group_by_status = array();
2816
-	foreach ( $statuses as $comment_id => $comment_status )
2817
-		$group_by_status[$comment_status][] = $comment_id;
2930
+	foreach ( $statuses as $comment_id => $comment_status ) {
2931
+			$group_by_status[$comment_status][] = $comment_id;
2932
+	}
2818 2933
 
2819 2934
 	foreach ( $group_by_status as $status => $comments ) {
2820 2935
 		// Sanity check. This shouldn't happen.
@@ -3566,8 +3681,9 @@  discard block
 block discarded – undo
3566 3681
 	$post = get_post($postarr['ID'], ARRAY_A);
3567 3682
 
3568 3683
 	if ( is_null( $post ) ) {
3569
-		if ( $wp_error )
3570
-			return new WP_Error( 'invalid_post', __( 'Invalid post ID.' ) );
3684
+		if ( $wp_error ) {
3685
+					return new WP_Error( 'invalid_post', __( 'Invalid post ID.' ) );
3686
+		}
3571 3687
 		return 0;
3572 3688
 	}
3573 3689
 
@@ -3576,17 +3692,19 @@  discard block
 block discarded – undo
3576 3692
 
3577 3693
 	// Passed post category list overwrites existing category list if not empty.
3578 3694
 	if ( isset($postarr['post_category']) && is_array($postarr['post_category'])
3579
-			 && 0 != count($postarr['post_category']) )
3580
-		$post_cats = $postarr['post_category'];
3581
-	else
3582
-		$post_cats = $post['post_category'];
3695
+			 && 0 != count($postarr['post_category']) ) {
3696
+			$post_cats = $postarr['post_category'];
3697
+	} else {
3698
+			$post_cats = $post['post_category'];
3699
+	}
3583 3700
 
3584 3701
 	// Drafts shouldn't be assigned a date unless explicitly done so by the user.
3585 3702
 	if ( isset( $post['post_status'] ) && in_array($post['post_status'], array('draft', 'pending', 'auto-draft')) && empty($postarr['edit_date']) &&
3586
-			 ('0000-00-00 00:00:00' == $post['post_date_gmt']) )
3587
-		$clear_date = true;
3588
-	else
3589
-		$clear_date = false;
3703
+			 ('0000-00-00 00:00:00' == $post['post_date_gmt']) ) {
3704
+			$clear_date = true;
3705
+	} else {
3706
+			$clear_date = false;
3707
+	}
3590 3708
 
3591 3709
 	// Merge old and new fields with new fields overwriting old ones.
3592 3710
 	$postarr = array_merge($post, $postarr);
@@ -3596,8 +3714,9 @@  discard block
 block discarded – undo
3596 3714
 		$postarr['post_date_gmt'] = '';
3597 3715
 	}
3598 3716
 
3599
-	if ($postarr['post_type'] == 'attachment')
3600
-		return wp_insert_attachment($postarr);
3717
+	if ($postarr['post_type'] == 'attachment') {
3718
+			return wp_insert_attachment($postarr);
3719
+	}
3601 3720
 
3602 3721
 	return wp_insert_post( $postarr, $wp_error );
3603 3722
 }
@@ -3614,11 +3733,13 @@  discard block
 block discarded – undo
3614 3733
 function wp_publish_post( $post ) {
3615 3734
 	global $wpdb;
3616 3735
 
3617
-	if ( ! $post = get_post( $post ) )
3618
-		return;
3736
+	if ( ! $post = get_post( $post ) ) {
3737
+			return;
3738
+	}
3619 3739
 
3620
-	if ( 'publish' == $post->post_status )
3621
-		return;
3740
+	if ( 'publish' == $post->post_status ) {
3741
+			return;
3742
+	}
3622 3743
 
3623 3744
 	$wpdb->update( $wpdb->posts, array( 'post_status' => 'publish' ), array( 'ID' => $post->ID ) );
3624 3745
 
@@ -3654,11 +3775,13 @@  discard block
 block discarded – undo
3654 3775
 function check_and_publish_future_post( $post_id ) {
3655 3776
 	$post = get_post($post_id);
3656 3777
 
3657
-	if ( empty($post) )
3658
-		return;
3778
+	if ( empty($post) ) {
3779
+			return;
3780
+	}
3659 3781
 
3660
-	if ( 'future' != $post->post_status )
3661
-		return;
3782
+	if ( 'future' != $post->post_status ) {
3783
+			return;
3784
+	}
3662 3785
 
3663 3786
 	$time = strtotime( $post->post_date_gmt . ' GMT' );
3664 3787
 
@@ -3689,16 +3812,18 @@  discard block
 block discarded – undo
3689 3812
  * @return string Unique slug for the post, based on $post_name (with a -1, -2, etc. suffix)
3690 3813
  */
3691 3814
 function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_parent ) {
3692
-	if ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) || ( 'inherit' == $post_status && 'revision' == $post_type ) )
3693
-		return $slug;
3815
+	if ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) || ( 'inherit' == $post_status && 'revision' == $post_type ) ) {
3816
+			return $slug;
3817
+	}
3694 3818
 
3695 3819
 	global $wpdb, $wp_rewrite;
3696 3820
 
3697 3821
 	$original_slug = $slug;
3698 3822
 
3699 3823
 	$feeds = $wp_rewrite->feeds;
3700
-	if ( ! is_array( $feeds ) )
3701
-		$feeds = array();
3824
+	if ( ! is_array( $feeds ) ) {
3825
+			$feeds = array();
3826
+	}
3702 3827
 
3703 3828
 	if ( 'attachment' == $post_type ) {
3704 3829
 		// Attachment slugs must be unique across all types.
@@ -3723,8 +3848,9 @@  discard block
 block discarded – undo
3723 3848
 			$slug = $alt_post_name;
3724 3849
 		}
3725 3850
 	} elseif ( is_post_type_hierarchical( $post_type ) ) {
3726
-		if ( 'nav_menu_item' == $post_type )
3727
-			return $slug;
3851
+		if ( 'nav_menu_item' == $post_type ) {
3852
+					return $slug;
3853
+		}
3728 3854
 
3729 3855
 		/*
3730 3856
 		 * Page slugs must be unique within their own trees. Pages are in a separate
@@ -3829,10 +3955,11 @@  discard block
 block discarded – undo
3829 3955
 function _truncate_post_slug( $slug, $length = 200 ) {
3830 3956
 	if ( strlen( $slug ) > $length ) {
3831 3957
 		$decoded_slug = urldecode( $slug );
3832
-		if ( $decoded_slug === $slug )
3833
-			$slug = substr( $slug, 0, $length );
3834
-		else
3835
-			$slug = utf8_uri_encode( $decoded_slug, $length );
3958
+		if ( $decoded_slug === $slug ) {
3959
+					$slug = substr( $slug, 0, $length );
3960
+		} else {
3961
+					$slug = utf8_uri_encode( $decoded_slug, $length );
3962
+		}
3836 3963
 	}
3837 3964
 
3838 3965
 	return rtrim( $slug, '-' );
@@ -3890,16 +4017,19 @@  discard block
 block discarded – undo
3890 4017
 function wp_set_post_terms( $post_id = 0, $tags = '', $taxonomy = 'post_tag', $append = false ) {
3891 4018
 	$post_id = (int) $post_id;
3892 4019
 
3893
-	if ( !$post_id )
3894
-		return false;
4020
+	if ( !$post_id ) {
4021
+			return false;
4022
+	}
3895 4023
 
3896
-	if ( empty($tags) )
3897
-		$tags = array();
4024
+	if ( empty($tags) ) {
4025
+			$tags = array();
4026
+	}
3898 4027
 
3899 4028
 	if ( ! is_array( $tags ) ) {
3900 4029
 		$comma = _x( ',', 'tag delimiter' );
3901
-		if ( ',' !== $comma )
3902
-			$tags = str_replace( $comma, ',', $tags );
4030
+		if ( ',' !== $comma ) {
4031
+					$tags = str_replace( $comma, ',', $tags );
4032
+		}
3903 4033
 		$tags = explode( ',', trim( $tags, " \n\t\r\0\x0B," ) );
3904 4034
 	}
3905 4035
 
@@ -4065,12 +4195,14 @@  discard block
 block discarded – undo
4065 4195
 function get_enclosed( $post_id ) {
4066 4196
 	$custom_fields = get_post_custom( $post_id );
4067 4197
 	$pung = array();
4068
-	if ( !is_array( $custom_fields ) )
4069
-		return $pung;
4198
+	if ( !is_array( $custom_fields ) ) {
4199
+			return $pung;
4200
+	}
4070 4201
 
4071 4202
 	foreach ( $custom_fields as $key => $val ) {
4072
-		if ( 'enclosure' != $key || !is_array( $val ) )
4073
-			continue;
4203
+		if ( 'enclosure' != $key || !is_array( $val ) ) {
4204
+					continue;
4205
+		}
4074 4206
 		foreach ( $val as $enc ) {
4075 4207
 			$enclosure = explode( "\n", $enc );
4076 4208
 			$pung[] = trim( $enclosure[ 0 ] );
@@ -4269,15 +4401,17 @@  discard block
 block discarded – undo
4269 4401
 			while ( $p->post_parent != 0 && isset( $pages[ $p->post_parent ] ) ) {
4270 4402
 				$count++;
4271 4403
 				$parent = $pages[ $p->post_parent ];
4272
-				if ( ! isset( $revparts[ $count ] ) || $parent->post_name != $revparts[ $count ] )
4273
-					break;
4404
+				if ( ! isset( $revparts[ $count ] ) || $parent->post_name != $revparts[ $count ] ) {
4405
+									break;
4406
+				}
4274 4407
 				$p = $parent;
4275 4408
 			}
4276 4409
 
4277 4410
 			if ( $p->post_parent == 0 && $count+1 == count( $revparts ) && $p->post_name == $revparts[ $count ] ) {
4278 4411
 				$foundid = $page->ID;
4279
-				if ( $page->post_type == $post_type )
4280
-					break;
4412
+				if ( $page->post_type == $post_type ) {
4413
+									break;
4414
+				}
4281 4415
 			}
4282 4416
 		}
4283 4417
 	}
@@ -4434,8 +4568,9 @@  discard block
 block discarded – undo
4434 4568
 		$page = get_post( $page );
4435 4569
 	}
4436 4570
 
4437
-	if ( ! $page )
4438
-		return false;
4571
+	if ( ! $page ) {
4572
+			return false;
4573
+	}
4439 4574
 
4440 4575
 	$uri = $page->post_name;
4441 4576
 
@@ -4765,14 +4900,17 @@  discard block
 block discarded – undo
4765 4900
  * @return bool True on success, false on failure.
4766 4901
  */
4767 4902
 function is_local_attachment($url) {
4768
-	if (strpos($url, home_url()) === false)
4769
-		return false;
4770
-	if (strpos($url, home_url('/?attachment_id=')) !== false)
4771
-		return true;
4903
+	if (strpos($url, home_url()) === false) {
4904
+			return false;
4905
+	}
4906
+	if (strpos($url, home_url('/?attachment_id=')) !== false) {
4907
+			return true;
4908
+	}
4772 4909
 	if ( $id = url_to_postid($url) ) {
4773 4910
 		$post = get_post($id);
4774
-		if ( 'attachment' == $post->post_type )
4775
-			return true;
4911
+		if ( 'attachment' == $post->post_type ) {
4912
+					return true;
4913
+		}
4776 4914
 	}
4777 4915
 	return false;
4778 4916
 }
@@ -4839,14 +4977,17 @@  discard block
 block discarded – undo
4839 4977
 function wp_delete_attachment( $post_id, $force_delete = false ) {
4840 4978
 	global $wpdb;
4841 4979
 
4842
-	if ( !$post = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $post_id) ) )
4843
-		return $post;
4980
+	if ( !$post = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $post_id) ) ) {
4981
+			return $post;
4982
+	}
4844 4983
 
4845
-	if ( 'attachment' != $post->post_type )
4846
-		return false;
4984
+	if ( 'attachment' != $post->post_type ) {
4985
+			return false;
4986
+	}
4847 4987
 
4848
-	if ( !$force_delete && EMPTY_TRASH_DAYS && MEDIA_TRASH && 'trash' != $post->post_status )
4849
-		return wp_trash_post( $post_id );
4988
+	if ( !$force_delete && EMPTY_TRASH_DAYS && MEDIA_TRASH && 'trash' != $post->post_status ) {
4989
+			return wp_trash_post( $post_id );
4990
+	}
4850 4991
 
4851 4992
 	delete_post_meta($post_id, '_wp_trash_meta_status');
4852 4993
 	delete_post_meta($post_id, '_wp_trash_meta_time');
@@ -4855,8 +4996,9 @@  discard block
 block discarded – undo
4855 4996
 	$backup_sizes = get_post_meta( $post->ID, '_wp_attachment_backup_sizes', true );
4856 4997
 	$file = get_attached_file( $post_id );
4857 4998
 
4858
-	if ( is_multisite() )
4859
-		delete_transient( 'dirsize_cache' );
4999
+	if ( is_multisite() ) {
5000
+			delete_transient( 'dirsize_cache' );
5001
+	}
4860 5002
 
4861 5003
 	/**
4862 5004
 	 * Fires before an attachment is deleted, at the start of wp_delete_attachment().
@@ -4883,8 +5025,9 @@  discard block
 block discarded – undo
4883 5025
 	wp_defer_comment_counting( false );
4884 5026
 
4885 5027
 	$post_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $post_id ));
4886
-	foreach ( $post_meta_ids as $mid )
4887
-		delete_metadata_by_mid( 'post', $mid );
5028
+	foreach ( $post_meta_ids as $mid ) {
5029
+			delete_metadata_by_mid( 'post', $mid );
5030
+	}
4888 5031
 
4889 5032
 	/** This action is documented in wp-includes/post.php */
4890 5033
 	do_action( 'delete_post', $post_id );
@@ -4944,13 +5087,15 @@  discard block
 block discarded – undo
4944 5087
  */
4945 5088
 function wp_get_attachment_metadata( $post_id = 0, $unfiltered = false ) {
4946 5089
 	$post_id = (int) $post_id;
4947
-	if ( !$post = get_post( $post_id ) )
4948
-		return false;
5090
+	if ( !$post = get_post( $post_id ) ) {
5091
+			return false;
5092
+	}
4949 5093
 
4950 5094
 	$data = get_post_meta( $post->ID, '_wp_attachment_metadata', true );
4951 5095
 
4952
-	if ( $unfiltered )
4953
-		return $data;
5096
+	if ( $unfiltered ) {
5097
+			return $data;
5098
+	}
4954 5099
 
4955 5100
 	/**
4956 5101
 	 * Filter the attachment meta data.
@@ -4975,8 +5120,9 @@  discard block
 block discarded – undo
4975 5120
  */
4976 5121
 function wp_update_attachment_metadata( $post_id, $data ) {
4977 5122
 	$post_id = (int) $post_id;
4978
-	if ( !$post = get_post( $post_id ) )
4979
-		return false;
5123
+	if ( !$post = get_post( $post_id ) ) {
5124
+			return false;
5125
+	}
4980 5126
 
4981 5127
 	/**
4982 5128
 	 * Filter the updated attachment meta data.
@@ -4986,11 +5132,12 @@  discard block
 block discarded – undo
4986 5132
 	 * @param array $data    Array of updated attachment meta data.
4987 5133
 	 * @param int   $post_id Attachment ID.
4988 5134
 	 */
4989
-	if ( $data = apply_filters( 'wp_update_attachment_metadata', $data, $post->ID ) )
4990
-		return update_post_meta( $post->ID, '_wp_attachment_metadata', $data );
4991
-	else
4992
-		return delete_post_meta( $post->ID, '_wp_attachment_metadata' );
4993
-}
5135
+	if ( $data = apply_filters( 'wp_update_attachment_metadata', $data, $post->ID ) ) {
5136
+			return update_post_meta( $post->ID, '_wp_attachment_metadata', $data );
5137
+	} else {
5138
+			return delete_post_meta( $post->ID, '_wp_attachment_metadata' );
5139
+	}
5140
+	}
4994 5141
 
4995 5142
 /**
4996 5143
  * Retrieve the URL for an attachment.
@@ -5004,11 +5151,13 @@  discard block
 block discarded – undo
5004 5151
  */
5005 5152
 function wp_get_attachment_url( $post_id = 0 ) {
5006 5153
 	$post_id = (int) $post_id;
5007
-	if ( !$post = get_post( $post_id ) )
5008
-		return false;
5154
+	if ( !$post = get_post( $post_id ) ) {
5155
+			return false;
5156
+	}
5009 5157
 
5010
-	if ( 'attachment' != $post->post_type )
5011
-		return false;
5158
+	if ( 'attachment' != $post->post_type ) {
5159
+			return false;
5160
+	}
5012 5161
 
5013 5162
 	$url = '';
5014 5163
 	// Get attached file.
@@ -5052,8 +5201,9 @@  discard block
 block discarded – undo
5052 5201
 	 */
5053 5202
 	$url = apply_filters( 'wp_get_attachment_url', $url, $post->ID );
5054 5203
 
5055
-	if ( empty( $url ) )
5056
-		return false;
5204
+	if ( empty( $url ) ) {
5205
+			return false;
5206
+	}
5057 5207
 
5058 5208
 	return $url;
5059 5209
 }
@@ -5068,10 +5218,12 @@  discard block
 block discarded – undo
5068 5218
  */
5069 5219
 function wp_get_attachment_thumb_file( $post_id = 0 ) {
5070 5220
 	$post_id = (int) $post_id;
5071
-	if ( !$post = get_post( $post_id ) )
5072
-		return false;
5073
-	if ( !is_array( $imagedata = wp_get_attachment_metadata( $post->ID ) ) )
5074
-		return false;
5221
+	if ( !$post = get_post( $post_id ) ) {
5222
+			return false;
5223
+	}
5224
+	if ( !is_array( $imagedata = wp_get_attachment_metadata( $post->ID ) ) ) {
5225
+			return false;
5226
+	}
5075 5227
 
5076 5228
 	$file = get_attached_file( $post->ID );
5077 5229
 
@@ -5099,17 +5251,21 @@  discard block
 block discarded – undo
5099 5251
  */
5100 5252
 function wp_get_attachment_thumb_url( $post_id = 0 ) {
5101 5253
 	$post_id = (int) $post_id;
5102
-	if ( !$post = get_post( $post_id ) )
5103
-		return false;
5104
-	if ( !$url = wp_get_attachment_url( $post->ID ) )
5105
-		return false;
5254
+	if ( !$post = get_post( $post_id ) ) {
5255
+			return false;
5256
+	}
5257
+	if ( !$url = wp_get_attachment_url( $post->ID ) ) {
5258
+			return false;
5259
+	}
5106 5260
 
5107 5261
 	$sized = image_downsize( $post_id, 'thumbnail' );
5108
-	if ( $sized )
5109
-		return $sized[0];
5262
+	if ( $sized ) {
5263
+			return $sized[0];
5264
+	}
5110 5265
 
5111
-	if ( !$thumb = wp_get_attachment_thumb_file( $post->ID ) )
5112
-		return false;
5266
+	if ( !$thumb = wp_get_attachment_thumb_file( $post->ID ) ) {
5267
+			return false;
5268
+	}
5113 5269
 
5114 5270
 	$url = str_replace(basename($url), basename($thumb), $url);
5115 5271
 
@@ -5196,8 +5352,9 @@  discard block
 block discarded – undo
5196 5352
  * @return string|false Icon, false otherwise.
5197 5353
  */
5198 5354
 function wp_mime_type_icon( $mime = 0 ) {
5199
-	if ( !is_numeric($mime) )
5200
-		$icon = wp_cache_get("mime_type_icon_$mime");
5355
+	if ( !is_numeric($mime) ) {
5356
+			$icon = wp_cache_get("mime_type_icon_$mime");
5357
+	}
5201 5358
 
5202 5359
 	$post_id = 0;
5203 5360
 	if ( empty($icon) ) {
@@ -5210,8 +5367,9 @@  discard block
 block discarded – undo
5210 5367
 				$ext = preg_replace('/^.+?\.([^.]+)$/', '$1', $file);
5211 5368
 				if ( !empty($ext) ) {
5212 5369
 					$post_mimes[] = $ext;
5213
-					if ( $ext_type = wp_ext2type( $ext ) )
5214
-						$post_mimes[] = $ext_type;
5370
+					if ( $ext_type = wp_ext2type( $ext ) ) {
5371
+											$post_mimes[] = $ext_type;
5372
+					}
5215 5373
 				}
5216 5374
 				$mime = $post->post_mime_type;
5217 5375
 			} else {
@@ -5258,11 +5416,13 @@  discard block
 block discarded – undo
5258 5416
 				if ( $dh = opendir($dir) ) {
5259 5417
 					while ( false !== $file = readdir($dh) ) {
5260 5418
 						$file = basename($file);
5261
-						if ( substr($file, 0, 1) == '.' )
5262
-							continue;
5419
+						if ( substr($file, 0, 1) == '.' ) {
5420
+													continue;
5421
+						}
5263 5422
 						if ( !in_array(strtolower(substr($file, -4)), array('.png', '.gif', '.jpg') ) ) {
5264
-							if ( is_dir("$dir/$file") )
5265
-								$dirs["$dir/$file"] = "$uri/$file";
5423
+							if ( is_dir("$dir/$file") ) {
5424
+															$dirs["$dir/$file"] = "$uri/$file";
5425
+							}
5266 5426
 							continue;
5267 5427
 						}
5268 5428
 						$icon_files["$dir/$file"] = "$uri/$file";
@@ -5275,8 +5435,9 @@  discard block
 block discarded – undo
5275 5435
 
5276 5436
 		$types = array();
5277 5437
 		// Icon basename - extension = MIME wildcard.
5278
-		foreach ( $icon_files as $file => $uri )
5279
-			$types[ preg_replace('/^([^.]*).*$/', '$1', basename($file)) ] =& $icon_files[$file];
5438
+		foreach ( $icon_files as $file => $uri ) {
5439
+					$types[ preg_replace('/^([^.]*).*$/', '$1', basename($file)) ] =& $icon_files[$file];
5440
+		}
5280 5441
 
5281 5442
 		if ( ! empty($mime) ) {
5282 5443
 			$post_mimes[] = substr($mime, 0, strpos($mime, '/'));
@@ -5611,12 +5772,14 @@  discard block
 block discarded – undo
5611 5772
  * @param array $posts Array of post objects, passed by reference.
5612 5773
  */
5613 5774
 function update_post_cache( &$posts ) {
5614
-	if ( ! $posts )
5615
-		return;
5775
+	if ( ! $posts ) {
5776
+			return;
5777
+	}
5616 5778
 
5617
-	foreach ( $posts as $post )
5618
-		wp_cache_add( $post->ID, $post, 'posts' );
5619
-}
5779
+	foreach ( $posts as $post ) {
5780
+			wp_cache_add( $post->ID, $post, 'posts' );
5781
+	}
5782
+	}
5620 5783
 
5621 5784
 /**
5622 5785
  * Will clean the post in the cache.
@@ -5636,12 +5799,14 @@  discard block
 block discarded – undo
5636 5799
 function clean_post_cache( $post ) {
5637 5800
 	global $_wp_suspend_cache_invalidation;
5638 5801
 
5639
-	if ( ! empty( $_wp_suspend_cache_invalidation ) )
5640
-		return;
5802
+	if ( ! empty( $_wp_suspend_cache_invalidation ) ) {
5803
+			return;
5804
+	}
5641 5805
 
5642 5806
 	$post = get_post( $post );
5643
-	if ( empty( $post ) )
5644
-		return;
5807
+	if ( empty( $post ) ) {
5808
+			return;
5809
+	}
5645 5810
 
5646 5811
 	wp_cache_delete( $post->ID, 'posts' );
5647 5812
 	wp_cache_delete( $post->ID, 'post_meta' );
@@ -5688,17 +5853,20 @@  discard block
 block discarded – undo
5688 5853
  */
5689 5854
 function update_post_caches( &$posts, $post_type = 'post', $update_term_cache = true, $update_meta_cache = true ) {
5690 5855
 	// No point in doing all this work if we didn't match any posts.
5691
-	if ( !$posts )
5692
-		return;
5856
+	if ( !$posts ) {
5857
+			return;
5858
+	}
5693 5859
 
5694 5860
 	update_post_cache($posts);
5695 5861
 
5696 5862
 	$post_ids = array();
5697
-	foreach ( $posts as $post )
5698
-		$post_ids[] = $post->ID;
5863
+	foreach ( $posts as $post ) {
5864
+			$post_ids[] = $post->ID;
5865
+	}
5699 5866
 
5700
-	if ( ! $post_type )
5701
-		$post_type = 'any';
5867
+	if ( ! $post_type ) {
5868
+			$post_type = 'any';
5869
+	}
5702 5870
 
5703 5871
 	if ( $update_term_cache ) {
5704 5872
 		if ( is_array($post_type) ) {
@@ -5714,13 +5882,15 @@  discard block
 block discarded – undo
5714 5882
 			$ptypes = array($post_type);
5715 5883
 		}
5716 5884
 
5717
-		if ( ! empty($ptypes) )
5718
-			update_object_term_cache($post_ids, $ptypes);
5885
+		if ( ! empty($ptypes) ) {
5886
+					update_object_term_cache($post_ids, $ptypes);
5887
+		}
5719 5888
 	}
5720 5889
 
5721
-	if ( $update_meta_cache )
5722
-		update_postmeta_cache($post_ids);
5723
-}
5890
+	if ( $update_meta_cache ) {
5891
+			update_postmeta_cache($post_ids);
5892
+	}
5893
+	}
5724 5894
 
5725 5895
 /**
5726 5896
  * Updates metadata cache for list of post IDs.
@@ -5757,16 +5927,18 @@  discard block
 block discarded – undo
5757 5927
 function clean_attachment_cache( $id, $clean_terms = false ) {
5758 5928
 	global $_wp_suspend_cache_invalidation;
5759 5929
 
5760
-	if ( !empty($_wp_suspend_cache_invalidation) )
5761
-		return;
5930
+	if ( !empty($_wp_suspend_cache_invalidation) ) {
5931
+			return;
5932
+	}
5762 5933
 
5763 5934
 	$id = (int) $id;
5764 5935
 
5765 5936
 	wp_cache_delete($id, 'posts');
5766 5937
 	wp_cache_delete($id, 'post_meta');
5767 5938
 
5768
-	if ( $clean_terms )
5769
-		clean_object_term_cache($id, 'attachment');
5939
+	if ( $clean_terms ) {
5940
+			clean_object_term_cache($id, 'attachment');
5941
+	}
5770 5942
 
5771 5943
 	/**
5772 5944
 	 * Fires after the given attachment's cache is cleaned.
@@ -5800,8 +5972,9 @@  discard block
 block discarded – undo
5800 5972
 
5801 5973
 	if ( $old_status != 'publish' && $new_status == 'publish' ) {
5802 5974
 		// Reset GUID if transitioning to publish and it is empty.
5803
-		if ( '' == get_the_guid($post->ID) )
5804
-			$wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post->ID ) ), array( 'ID' => $post->ID ) );
5975
+		if ( '' == get_the_guid($post->ID) ) {
5976
+					$wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post->ID ) ), array( 'ID' => $post->ID ) );
5977
+		}
5805 5978
 
5806 5979
 		/**
5807 5980
 		 * Fires when a post's status is transitioned from private to published.
@@ -5873,11 +6046,13 @@  discard block
 block discarded – undo
5873 6046
 		do_action( 'xmlrpc_publish_post', $post_id );
5874 6047
 	}
5875 6048
 
5876
-	if ( defined('WP_IMPORTING') )
5877
-		return;
6049
+	if ( defined('WP_IMPORTING') ) {
6050
+			return;
6051
+	}
5878 6052
 
5879
-	if ( get_option('default_pingback_flag') )
5880
-		add_post_meta( $post_id, '_pingme', '1' );
6053
+	if ( get_option('default_pingback_flag') ) {
6054
+			add_post_meta( $post_id, '_pingme', '1' );
6055
+	}
5881 6056
 	add_post_meta( $post_id, '_encloseme', '1' );
5882 6057
 
5883 6058
 	wp_schedule_single_event(time(), 'do_pings');
@@ -5894,8 +6069,9 @@  discard block
 block discarded – undo
5894 6069
  */
5895 6070
 function wp_get_post_parent_id( $post_ID ) {
5896 6071
 	$post = get_post( $post_ID );
5897
-	if ( !$post || is_wp_error( $post ) )
5898
-		return false;
6072
+	if ( !$post || is_wp_error( $post ) ) {
6073
+			return false;
6074
+	}
5899 6075
 	return (int) $post->post_parent;
5900 6076
 }
5901 6077
 
@@ -5915,28 +6091,35 @@  discard block
 block discarded – undo
5915 6091
  */
5916 6092
 function wp_check_post_hierarchy_for_loops( $post_parent, $post_ID ) {
5917 6093
 	// Nothing fancy here - bail.
5918
-	if ( !$post_parent )
5919
-		return 0;
6094
+	if ( !$post_parent ) {
6095
+			return 0;
6096
+	}
5920 6097
 
5921 6098
 	// New post can't cause a loop.
5922
-	if ( empty( $post_ID ) )
5923
-		return $post_parent;
6099
+	if ( empty( $post_ID ) ) {
6100
+			return $post_parent;
6101
+	}
5924 6102
 
5925 6103
 	// Can't be its own parent.
5926
-	if ( $post_parent == $post_ID )
5927
-		return 0;
6104
+	if ( $post_parent == $post_ID ) {
6105
+			return 0;
6106
+	}
5928 6107
 
5929 6108
 	// Now look for larger loops.
5930
-	if ( !$loop = wp_find_hierarchy_loop( 'wp_get_post_parent_id', $post_ID, $post_parent ) )
5931
-		return $post_parent; // No loop
6109
+	if ( !$loop = wp_find_hierarchy_loop( 'wp_get_post_parent_id', $post_ID, $post_parent ) ) {
6110
+			return $post_parent;
6111
+	}
6112
+	// No loop
5932 6113
 
5933 6114
 	// Setting $post_parent to the given value causes a loop.
5934
-	if ( isset( $loop[$post_ID] ) )
5935
-		return 0;
6115
+	if ( isset( $loop[$post_ID] ) ) {
6116
+			return 0;
6117
+	}
5936 6118
 
5937 6119
 	// There's a loop, but it doesn't contain $post_ID. Break the loop.
5938
-	foreach ( array_keys( $loop ) as $loop_member )
5939
-		wp_update_post( array( 'ID' => $loop_member, 'post_parent' => 0 ) );
6120
+	foreach ( array_keys( $loop ) as $loop_member ) {
6121
+			wp_update_post( array( 'ID' => $loop_member, 'post_parent' => 0 ) );
6122
+	}
5940 6123
 
5941 6124
 	return $post_parent;
5942 6125
 }
@@ -5954,10 +6137,11 @@  discard block
 block discarded – undo
5954 6137
 	$post = get_post( $post );
5955 6138
 	$thumbnail_id = absint( $thumbnail_id );
5956 6139
 	if ( $post && $thumbnail_id && get_post( $thumbnail_id ) ) {
5957
-		if ( wp_get_attachment_image( $thumbnail_id, 'thumbnail' ) )
5958
-			return update_post_meta( $post->ID, '_thumbnail_id', $thumbnail_id );
5959
-		else
5960
-			return delete_post_meta( $post->ID, '_thumbnail_id' );
6140
+		if ( wp_get_attachment_image( $thumbnail_id, 'thumbnail' ) ) {
6141
+					return update_post_meta( $post->ID, '_thumbnail_id', $thumbnail_id );
6142
+		} else {
6143
+					return delete_post_meta( $post->ID, '_thumbnail_id' );
6144
+		}
5961 6145
 	}
5962 6146
 	return false;
5963 6147
 }
@@ -5972,8 +6156,9 @@  discard block
 block discarded – undo
5972 6156
  */
5973 6157
 function delete_post_thumbnail( $post ) {
5974 6158
 	$post = get_post( $post );
5975
-	if ( $post )
5976
-		return delete_post_meta( $post->ID, '_thumbnail_id' );
6159
+	if ( $post ) {
6160
+			return delete_post_meta( $post->ID, '_thumbnail_id' );
6161
+	}
5977 6162
 	return false;
5978 6163
 }
5979 6164
 
Please login to merge, or discard this patch.
src/wp-includes/class-wp-ajax-response.php 3 patches
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
 	 *
23 23
 	 * @param string|array $args Optional. Will be passed to add() method.
24 24
 	 */
25
-	public function __construct( $args = '' ) {
26
-		if ( !empty($args) )
25
+	public function __construct($args = '') {
26
+		if ( ! empty($args))
27 27
 			$this->add($args);
28 28
 	}
29 29
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 * @param string|array $args Override defaults.
51 51
 	 * @return string XML response.
52 52
 	 */
53
-	public function add( $args = '' ) {
53
+	public function add($args = '') {
54 54
 		$defaults = array(
55 55
 			'what' => 'object', 'action' => false,
56 56
 			'id' => '0', 'old_id' => false,
@@ -58,39 +58,39 @@  discard block
 block discarded – undo
58 58
 			'data' => '', 'supplemental' => array()
59 59
 		);
60 60
 
61
-		$r = wp_parse_args( $args, $defaults );
61
+		$r = wp_parse_args($args, $defaults);
62 62
 
63
-		$position = preg_replace( '/[^a-z0-9:_-]/i', '', $r['position'] );
63
+		$position = preg_replace('/[^a-z0-9:_-]/i', '', $r['position']);
64 64
 		$id = $r['id'];
65 65
 		$what = $r['what'];
66 66
 		$action = $r['action'];
67 67
 		$old_id = $r['old_id'];
68 68
 		$data = $r['data'];
69 69
 
70
-		if ( is_wp_error( $id ) ) {
70
+		if (is_wp_error($id)) {
71 71
 			$data = $id;
72 72
 			$id = 0;
73 73
 		}
74 74
 
75 75
 		$response = '';
76
-		if ( is_wp_error( $data ) ) {
77
-			foreach ( (array) $data->get_error_codes() as $code ) {
78
-				$response .= "<wp_error code='$code'><![CDATA[" . $data->get_error_message( $code ) . "]]></wp_error>";
79
-				if ( ! $error_data = $data->get_error_data( $code ) ) {
76
+		if (is_wp_error($data)) {
77
+			foreach ((array) $data->get_error_codes() as $code) {
78
+				$response .= "<wp_error code='$code'><![CDATA[".$data->get_error_message($code)."]]></wp_error>";
79
+				if ( ! $error_data = $data->get_error_data($code)) {
80 80
 					continue;
81 81
 				}
82 82
 				$class = '';
83
-				if ( is_object( $error_data ) ) {
84
-					$class = ' class="' . get_class( $error_data ) . '"';
85
-					$error_data = get_object_vars( $error_data );
83
+				if (is_object($error_data)) {
84
+					$class = ' class="'.get_class($error_data).'"';
85
+					$error_data = get_object_vars($error_data);
86 86
 				}
87 87
 
88 88
 				$response .= "<wp_error_data code='$code'$class>";
89 89
 
90
-				if ( is_scalar( $error_data ) ) {
90
+				if (is_scalar($error_data)) {
91 91
 					$response .= "<![CDATA[$error_data]]>";
92
-				} elseif ( is_array( $error_data ) ) {
93
-					foreach ( $error_data as $k => $v ) {
92
+				} elseif (is_array($error_data)) {
93
+					foreach ($error_data as $k => $v) {
94 94
 						$response .= "<$k><![CDATA[$v]]></$k>";
95 95
 					}
96 96
 				}
@@ -102,22 +102,22 @@  discard block
 block discarded – undo
102 102
 		}
103 103
 
104 104
 		$s = '';
105
-		if ( is_array( $r['supplemental'] ) ) {
106
-			foreach ( $r['supplemental'] as $k => $v ) {
105
+		if (is_array($r['supplemental'])) {
106
+			foreach ($r['supplemental'] as $k => $v) {
107 107
 				$s .= "<$k><![CDATA[$v]]></$k>";
108 108
 			}
109 109
 			$s = "<supplemental>$s</supplemental>";
110 110
 		}
111 111
 
112
-		if ( false === $action ) {
112
+		if (false === $action) {
113 113
 			$action = $_POST['action'];
114 114
 		}
115 115
 		$x = '';
116 116
 		$x .= "<response action='{$action}_$id'>"; // The action attribute in the xml output is formatted like a nonce action
117
-		$x .=	"<$what id='$id' " . ( false === $old_id ? '' : "old_id='$old_id' " ) . "position='$position'>";
118
-		$x .=		$response;
119
-		$x .=		$s;
120
-		$x .=	"</$what>";
117
+		$x .= "<$what id='$id' ".(false === $old_id ? '' : "old_id='$old_id' ")."position='$position'>";
118
+		$x .= $response;
119
+		$x .= $s;
120
+		$x .= "</$what>";
121 121
 		$x .= "</response>";
122 122
 
123 123
 		$this->responses[] = $x;
@@ -132,12 +132,12 @@  discard block
 block discarded – undo
132 132
 	 * @since 2.1.0
133 133
 	 */
134 134
 	public function send() {
135
-		header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ) );
136
-		echo "<?xml version='1.0' encoding='" . get_option( 'blog_charset' ) . "' standalone='yes'?><wp_ajax>";
137
-		foreach ( (array) $this->responses as $response )
135
+		header('Content-Type: text/xml; charset='.get_option('blog_charset'));
136
+		echo "<?xml version='1.0' encoding='".get_option('blog_charset')."' standalone='yes'?><wp_ajax>";
137
+		foreach ((array) $this->responses as $response)
138 138
 			echo $response;
139 139
 		echo '</wp_ajax>';
140
-		if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
140
+		if (defined('DOING_AJAX') && DOING_AJAX)
141 141
 			wp_die();
142 142
 		else
143 143
 			die();
Please login to merge, or discard this patch.
Braces   +11 added lines, -8 removed lines patch added patch discarded remove patch
@@ -23,8 +23,9 @@  discard block
 block discarded – undo
23 23
 	 * @param string|array $args Optional. Will be passed to add() method.
24 24
 	 */
25 25
 	public function __construct( $args = '' ) {
26
-		if ( !empty($args) )
27
-			$this->add($args);
26
+		if ( !empty($args) ) {
27
+					$this->add($args);
28
+		}
28 29
 	}
29 30
 
30 31
 	/**
@@ -134,12 +135,14 @@  discard block
 block discarded – undo
134 135
 	public function send() {
135 136
 		header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ) );
136 137
 		echo "<?xml version='1.0' encoding='" . get_option( 'blog_charset' ) . "' standalone='yes'?><wp_ajax>";
137
-		foreach ( (array) $this->responses as $response )
138
-			echo $response;
138
+		foreach ( (array) $this->responses as $response ) {
139
+					echo $response;
140
+		}
139 141
 		echo '</wp_ajax>';
140
-		if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
141
-			wp_die();
142
-		else
143
-			die();
142
+		if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
143
+					wp_die();
144
+		} else {
145
+					die();
146
+		}
144 147
 	}
145 148
 }
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Send XML response back to AJAX request.
4
- *
5
- * @package WordPress
6
- * @since 2.1.0
7
- */
3
+	 * Send XML response back to AJAX request.
4
+	 *
5
+	 * @package WordPress
6
+	 * @since 2.1.0
7
+	 */
8 8
 class WP_Ajax_Response {
9 9
 	/**
10 10
 	 * Store XML responses to send.
Please login to merge, or discard this patch.
src/wp-includes/registration.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,4 +4,4 @@
 block discarded – undo
4 4
  *
5 5
  * @package WordPress
6 6
  */
7
-_deprecated_file( basename(__FILE__), '3.1', null, __( 'This file no longer needs to be included.' ) );
7
+_deprecated_file(basename(__FILE__), '3.1', null, __('This file no longer needs to be included.'));
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Deprecated. No longer needed.
4
- *
5
- * @package WordPress
6
- */
3
+	 * Deprecated. No longer needed.
4
+	 *
5
+	 * @package WordPress
6
+	 */
7 7
 _deprecated_file( basename(__FILE__), '3.1', null, __( 'This file no longer needs to be included.' ) );
Please login to merge, or discard this patch.
src/wp-includes/class-oembed.php 3 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * API for fetching the HTML to embed remote content based on a provided URL.
4
- * Used internally by the {@link WP_Embed} class, but is designed to be generic.
5
- *
6
- * @link https://codex.wordpress.org/oEmbed oEmbed Codex Article
7
- * @link http://oembed.com/ oEmbed Homepage
8
- *
9
- * @package WordPress
10
- * @subpackage oEmbed
11
- */
3
+	 * API for fetching the HTML to embed remote content based on a provided URL.
4
+	 * Used internally by the {@link WP_Embed} class, but is designed to be generic.
5
+	 *
6
+	 * @link https://codex.wordpress.org/oEmbed oEmbed Codex Article
7
+	 * @link http://oembed.com/ oEmbed Homepage
8
+	 *
9
+	 * @package WordPress
10
+	 * @subpackage oEmbed
11
+	 */
12 12
 
13 13
 /**
14 14
  * oEmbed class.
Please login to merge, or discard this patch.
Spacing   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	 */
26 26
 	public static $early_providers = array();
27 27
 
28
-	private $compat_methods = array( '_fetch_with_format', '_parse_json', '_parse_xml', '_parse_body' );
28
+	private $compat_methods = array('_fetch_with_format', '_parse_json', '_parse_xml', '_parse_body');
29 29
 
30 30
 	/**
31 31
 	 * Constructor
@@ -33,62 +33,62 @@  discard block
 block discarded – undo
33 33
 	 * @since 2.9.0
34 34
 	 */
35 35
 	public function __construct() {
36
-		$host = urlencode( home_url() );
36
+		$host = urlencode(home_url());
37 37
 		$providers = array(
38
-			'#http://((m|www)\.)?youtube\.com/watch.*#i'          => array( 'http://www.youtube.com/oembed',                             true  ),
39
-			'#https://((m|www)\.)?youtube\.com/watch.*#i'         => array( 'http://www.youtube.com/oembed?scheme=https',                true  ),
40
-			'#http://((m|www)\.)?youtube\.com/playlist.*#i'       => array( 'http://www.youtube.com/oembed',                             true  ),
41
-			'#https://((m|www)\.)?youtube\.com/playlist.*#i'      => array( 'http://www.youtube.com/oembed?scheme=https',                true  ),
42
-			'#http://youtu\.be/.*#i'                              => array( 'http://www.youtube.com/oembed',                             true  ),
43
-			'#https://youtu\.be/.*#i'                             => array( 'http://www.youtube.com/oembed?scheme=https',                true  ),
44
-			'#https?://(.+\.)?vimeo\.com/.*#i'                    => array( 'http://vimeo.com/api/oembed.{format}',                      true  ),
45
-			'#https?://(www\.)?dailymotion\.com/.*#i'             => array( 'https://www.dailymotion.com/services/oembed',               true  ),
46
-			'#https?://dai.ly/.*#i'                               => array( 'https://www.dailymotion.com/services/oembed',               true  ),
47
-			'#https?://(www\.)?flickr\.com/.*#i'                  => array( 'https://www.flickr.com/services/oembed/',                   true  ),
48
-			'#https?://flic\.kr/.*#i'                             => array( 'https://www.flickr.com/services/oembed/',                   true  ),
49
-			'#https?://(.+\.)?smugmug\.com/.*#i'                  => array( 'http://api.smugmug.com/services/oembed/',                   true  ),
50
-			'#https?://(www\.)?hulu\.com/watch/.*#i'              => array( 'http://www.hulu.com/api/oembed.{format}',                   true  ),
51
-			'http://i*.photobucket.com/albums/*'                  => array( 'http://api.photobucket.com/oembed',                         false ),
52
-			'http://gi*.photobucket.com/groups/*'                 => array( 'http://api.photobucket.com/oembed',                         false ),
53
-			'#https?://(www\.)?scribd\.com/doc/.*#i'              => array( 'http://www.scribd.com/services/oembed',                     true  ),
54
-			'#https?://wordpress.tv/.*#i'                         => array( 'http://wordpress.tv/oembed/',                               true  ),
55
-			'#https?://(.+\.)?polldaddy\.com/.*#i'                => array( 'https://polldaddy.com/oembed/',                             true  ),
56
-			'#https?://poll\.fm/.*#i'                             => array( 'https://polldaddy.com/oembed/',                             true  ),
57
-			'#https?://(www\.)?funnyordie\.com/videos/.*#i'       => array( 'http://www.funnyordie.com/oembed',                          true  ),
58
-			'#https?://(www\.)?twitter\.com/.+?/status(es)?/.*#i' => array( 'https://publish.twitter.com/oembed',                        true  ),
59
-			'#https?://(www\.)?twitter\.com/.+?/timelines/.*#i'   => array( 'https://publish.twitter.com/oembed',                        true  ),
60
-			'#https?://(www\.)?twitter\.com/i/moments/.*#i'       => array( 'https://publish.twitter.com/oembed',                        true  ),
61
-			'#https?://vine.co/v/.*#i'                            => array( 'https://vine.co/oembed.{format}',                           true  ),
62
-			'#https?://(www\.)?soundcloud\.com/.*#i'              => array( 'http://soundcloud.com/oembed',                              true  ),
63
-			'#https?://(.+?\.)?slideshare\.net/.*#i'              => array( 'https://www.slideshare.net/api/oembed/2',                   true  ),
64
-			'#https?://(www\.)?instagr(\.am|am\.com)/p/.*#i'      => array( 'https://api.instagram.com/oembed',                          true  ),
65
-			'#https?://(open|play)\.spotify\.com/.*#i'            => array( 'https://embed.spotify.com/oembed/',                         true  ),
66
-			'#https?://(.+\.)?imgur\.com/.*#i'                    => array( 'http://api.imgur.com/oembed',                               true  ),
67
-			'#https?://(www\.)?meetu(\.ps|p\.com)/.*#i'           => array( 'http://api.meetup.com/oembed',                              true  ),
68
-			'#https?://(www\.)?issuu\.com/.+/docs/.+#i'           => array( 'http://issuu.com/oembed_wp',                                true  ),
69
-			'#https?://(www\.)?collegehumor\.com/video/.*#i'      => array( 'http://www.collegehumor.com/oembed.{format}',               true  ),
70
-			'#https?://(www\.)?mixcloud\.com/.*#i'                => array( 'http://www.mixcloud.com/oembed',                            true  ),
71
-			'#https?://(www\.|embed\.)?ted\.com/talks/.*#i'       => array( 'http://www.ted.com/talks/oembed.{format}',                  true  ),
72
-			'#https?://(www\.)?(animoto|video214)\.com/play/.*#i' => array( 'https://animoto.com/oembeds/create',                        true  ),
73
-			'#https?://(.+)\.tumblr\.com/post/.*#i'               => array( 'https://www.tumblr.com/oembed/1.0',                         true  ),
74
-			'#https?://(www\.)?kickstarter\.com/projects/.*#i'    => array( 'https://www.kickstarter.com/services/oembed',               true  ),
75
-			'#https?://kck\.st/.*#i'                              => array( 'https://www.kickstarter.com/services/oembed',               true  ),
76
-			'#https?://cloudup\.com/.*#i'                         => array( 'https://cloudup.com/oembed',                                true  ),
77
-			'#https?://(www\.)?reverbnation\.com/.*#i'            => array( 'https://www.reverbnation.com/oembed',                       true  ),
78
-			'#https?://videopress.com/v/.*#'                      => array( 'https://public-api.wordpress.com/oembed/1.0/?for=' . $host, true  ),
79
-			'#https?://(www\.)?reddit\.com/r/[^/]+/comments/.*#i' => array( 'https://www.reddit.com/oembed',                             true  ),
80
-			'#https?://(www\.)?speakerdeck\.com/.*#i'             => array( 'https://speakerdeck.com/oembed.{format}',                   true  ),
38
+			'#http://((m|www)\.)?youtube\.com/watch.*#i'          => array('http://www.youtube.com/oembed', true),
39
+			'#https://((m|www)\.)?youtube\.com/watch.*#i'         => array('http://www.youtube.com/oembed?scheme=https', true),
40
+			'#http://((m|www)\.)?youtube\.com/playlist.*#i'       => array('http://www.youtube.com/oembed', true),
41
+			'#https://((m|www)\.)?youtube\.com/playlist.*#i'      => array('http://www.youtube.com/oembed?scheme=https', true),
42
+			'#http://youtu\.be/.*#i'                              => array('http://www.youtube.com/oembed', true),
43
+			'#https://youtu\.be/.*#i'                             => array('http://www.youtube.com/oembed?scheme=https', true),
44
+			'#https?://(.+\.)?vimeo\.com/.*#i'                    => array('http://vimeo.com/api/oembed.{format}', true),
45
+			'#https?://(www\.)?dailymotion\.com/.*#i'             => array('https://www.dailymotion.com/services/oembed', true),
46
+			'#https?://dai.ly/.*#i'                               => array('https://www.dailymotion.com/services/oembed', true),
47
+			'#https?://(www\.)?flickr\.com/.*#i'                  => array('https://www.flickr.com/services/oembed/', true),
48
+			'#https?://flic\.kr/.*#i'                             => array('https://www.flickr.com/services/oembed/', true),
49
+			'#https?://(.+\.)?smugmug\.com/.*#i'                  => array('http://api.smugmug.com/services/oembed/', true),
50
+			'#https?://(www\.)?hulu\.com/watch/.*#i'              => array('http://www.hulu.com/api/oembed.{format}', true),
51
+			'http://i*.photobucket.com/albums/*'                  => array('http://api.photobucket.com/oembed', false),
52
+			'http://gi*.photobucket.com/groups/*'                 => array('http://api.photobucket.com/oembed', false),
53
+			'#https?://(www\.)?scribd\.com/doc/.*#i'              => array('http://www.scribd.com/services/oembed', true),
54
+			'#https?://wordpress.tv/.*#i'                         => array('http://wordpress.tv/oembed/', true),
55
+			'#https?://(.+\.)?polldaddy\.com/.*#i'                => array('https://polldaddy.com/oembed/', true),
56
+			'#https?://poll\.fm/.*#i'                             => array('https://polldaddy.com/oembed/', true),
57
+			'#https?://(www\.)?funnyordie\.com/videos/.*#i'       => array('http://www.funnyordie.com/oembed', true),
58
+			'#https?://(www\.)?twitter\.com/.+?/status(es)?/.*#i' => array('https://publish.twitter.com/oembed', true),
59
+			'#https?://(www\.)?twitter\.com/.+?/timelines/.*#i'   => array('https://publish.twitter.com/oembed', true),
60
+			'#https?://(www\.)?twitter\.com/i/moments/.*#i'       => array('https://publish.twitter.com/oembed', true),
61
+			'#https?://vine.co/v/.*#i'                            => array('https://vine.co/oembed.{format}', true),
62
+			'#https?://(www\.)?soundcloud\.com/.*#i'              => array('http://soundcloud.com/oembed', true),
63
+			'#https?://(.+?\.)?slideshare\.net/.*#i'              => array('https://www.slideshare.net/api/oembed/2', true),
64
+			'#https?://(www\.)?instagr(\.am|am\.com)/p/.*#i'      => array('https://api.instagram.com/oembed', true),
65
+			'#https?://(open|play)\.spotify\.com/.*#i'            => array('https://embed.spotify.com/oembed/', true),
66
+			'#https?://(.+\.)?imgur\.com/.*#i'                    => array('http://api.imgur.com/oembed', true),
67
+			'#https?://(www\.)?meetu(\.ps|p\.com)/.*#i'           => array('http://api.meetup.com/oembed', true),
68
+			'#https?://(www\.)?issuu\.com/.+/docs/.+#i'           => array('http://issuu.com/oembed_wp', true),
69
+			'#https?://(www\.)?collegehumor\.com/video/.*#i'      => array('http://www.collegehumor.com/oembed.{format}', true),
70
+			'#https?://(www\.)?mixcloud\.com/.*#i'                => array('http://www.mixcloud.com/oembed', true),
71
+			'#https?://(www\.|embed\.)?ted\.com/talks/.*#i'       => array('http://www.ted.com/talks/oembed.{format}', true),
72
+			'#https?://(www\.)?(animoto|video214)\.com/play/.*#i' => array('https://animoto.com/oembeds/create', true),
73
+			'#https?://(.+)\.tumblr\.com/post/.*#i'               => array('https://www.tumblr.com/oembed/1.0', true),
74
+			'#https?://(www\.)?kickstarter\.com/projects/.*#i'    => array('https://www.kickstarter.com/services/oembed', true),
75
+			'#https?://kck\.st/.*#i'                              => array('https://www.kickstarter.com/services/oembed', true),
76
+			'#https?://cloudup\.com/.*#i'                         => array('https://cloudup.com/oembed', true),
77
+			'#https?://(www\.)?reverbnation\.com/.*#i'            => array('https://www.reverbnation.com/oembed', true),
78
+			'#https?://videopress.com/v/.*#'                      => array('https://public-api.wordpress.com/oembed/1.0/?for='.$host, true),
79
+			'#https?://(www\.)?reddit\.com/r/[^/]+/comments/.*#i' => array('https://www.reddit.com/oembed', true),
80
+			'#https?://(www\.)?speakerdeck\.com/.*#i'             => array('https://speakerdeck.com/oembed.{format}', true),
81 81
 		);
82 82
 
83
-		if ( ! empty( self::$early_providers['add'] ) ) {
84
-			foreach ( self::$early_providers['add'] as $format => $data ) {
85
-				$providers[ $format ] = $data;
83
+		if ( ! empty(self::$early_providers['add'])) {
84
+			foreach (self::$early_providers['add'] as $format => $data) {
85
+				$providers[$format] = $data;
86 86
 			}
87 87
 		}
88 88
 
89
-		if ( ! empty( self::$early_providers['remove'] ) ) {
90
-			foreach ( self::$early_providers['remove'] as $format ) {
91
-				unset( $providers[ $format ] );
89
+		if ( ! empty(self::$early_providers['remove'])) {
90
+			foreach (self::$early_providers['remove'] as $format) {
91
+				unset($providers[$format]);
92 92
 			}
93 93
 		}
94 94
 
@@ -163,10 +163,10 @@  discard block
 block discarded – undo
163 163
 		 *
164 164
 		 * @param array $providers An array of popular oEmbed providers.
165 165
 		 */
166
-		$this->providers = apply_filters( 'oembed_providers', $providers );
166
+		$this->providers = apply_filters('oembed_providers', $providers);
167 167
 
168 168
 		// Fix any embeds that contain new lines in the middle of the HTML which breaks wpautop().
169
-		add_filter( 'oembed_dataparse', array($this, '_strip_newlines'), 10, 3 );
169
+		add_filter('oembed_dataparse', array($this, '_strip_newlines'), 10, 3);
170 170
 	}
171 171
 
172 172
 	/**
@@ -179,9 +179,9 @@  discard block
 block discarded – undo
179 179
 	 * @param array    $arguments Arguments to pass when calling.
180 180
 	 * @return mixed|bool Return value of the callback, false otherwise.
181 181
 	 */
182
-	public function __call( $name, $arguments ) {
183
-		if ( in_array( $name, $this->compat_methods ) ) {
184
-			return call_user_func_array( array( $this, $name ), $arguments );
182
+	public function __call($name, $arguments) {
183
+		if (in_array($name, $this->compat_methods)) {
184
+			return call_user_func_array(array($this, $name), $arguments);
185 185
 		}
186 186
 		return false;
187 187
 	}
@@ -198,30 +198,30 @@  discard block
 block discarded – undo
198 198
 	 * @param string|array  $args Optional provider arguments.
199 199
 	 * @return false|string False on failure, otherwise the oEmbed provider URL.
200 200
 	 */
201
-	public function get_provider( $url, $args = '' ) {
201
+	public function get_provider($url, $args = '') {
202 202
 
203 203
 		$provider = false;
204 204
 
205
-		if ( !isset($args['discover']) )
205
+		if ( ! isset($args['discover']))
206 206
 			$args['discover'] = true;
207 207
 
208
-		foreach ( $this->providers as $matchmask => $data ) {
209
-			list( $providerurl, $regex ) = $data;
208
+		foreach ($this->providers as $matchmask => $data) {
209
+			list($providerurl, $regex) = $data;
210 210
 
211 211
 			// Turn the asterisk-type provider URLs into regex
212
-			if ( !$regex ) {
213
-				$matchmask = '#' . str_replace( '___wildcard___', '(.+)', preg_quote( str_replace( '*', '___wildcard___', $matchmask ), '#' ) ) . '#i';
214
-				$matchmask = preg_replace( '|^#http\\\://|', '#https?\://', $matchmask );
212
+			if ( ! $regex) {
213
+				$matchmask = '#'.str_replace('___wildcard___', '(.+)', preg_quote(str_replace('*', '___wildcard___', $matchmask), '#')).'#i';
214
+				$matchmask = preg_replace('|^#http\\\://|', '#https?\://', $matchmask);
215 215
 			}
216 216
 
217
-			if ( preg_match( $matchmask, $url ) ) {
218
-				$provider = str_replace( '{format}', 'json', $providerurl ); // JSON is easier to deal with than XML
217
+			if (preg_match($matchmask, $url)) {
218
+				$provider = str_replace('{format}', 'json', $providerurl); // JSON is easier to deal with than XML
219 219
 				break;
220 220
 			}
221 221
 		}
222 222
 
223
-		if ( !$provider && $args['discover'] )
224
-			$provider = $this->discover( $url );
223
+		if ( ! $provider && $args['discover'])
224
+			$provider = $this->discover($url);
225 225
 
226 226
 		return $provider;
227 227
 	}
@@ -244,12 +244,12 @@  discard block
 block discarded – undo
244 244
 	 * @param bool   $regex    Optional. Whether the $format parameter is in a regex format.
245 245
 	 *                         Default false.
246 246
 	 */
247
-	public static function _add_provider_early( $format, $provider, $regex = false ) {
248
-		if ( empty( self::$early_providers['add'] ) ) {
247
+	public static function _add_provider_early($format, $provider, $regex = false) {
248
+		if (empty(self::$early_providers['add'])) {
249 249
 			self::$early_providers['add'] = array();
250 250
 		}
251 251
 
252
-		self::$early_providers['add'][ $format ] = array( $provider, $regex );
252
+		self::$early_providers['add'][$format] = array($provider, $regex);
253 253
 	}
254 254
 
255 255
 	/**
@@ -267,8 +267,8 @@  discard block
 block discarded – undo
267 267
 	 * @param string $format The format of URL that this provider can handle. You can use
268 268
 	 *                       asterisks as wildcards.
269 269
 	 */
270
-	public static function _remove_provider_early( $format ) {
271
-		if ( empty( self::$early_providers['remove'] ) ) {
270
+	public static function _remove_provider_early($format) {
271
+		if (empty(self::$early_providers['remove'])) {
272 272
 			self::$early_providers['remove'] = array();
273 273
 		}
274 274
 
@@ -285,10 +285,10 @@  discard block
 block discarded – undo
285 285
 	 * @param array $args Optional arguments. Usually passed from a shortcode.
286 286
 	 * @return false|string False on failure, otherwise the UNSANITIZED (and potentially unsafe) HTML that should be used to embed.
287 287
 	 */
288
-	public function get_html( $url, $args = '' ) {
289
-		$provider = $this->get_provider( $url, $args );
288
+	public function get_html($url, $args = '') {
289
+		$provider = $this->get_provider($url, $args);
290 290
 
291
-		if ( !$provider || false === $data = $this->fetch( $provider, $url, $args ) )
291
+		if ( ! $provider || false === $data = $this->fetch($provider, $url, $args))
292 292
 			return false;
293 293
 
294 294
 		/**
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 		 * @param string $url  URL of the content to be embedded.
301 301
 		 * @param array  $args Optional arguments, usually passed from a shortcode.
302 302
 		 */
303
-		return apply_filters( 'oembed_result', $this->data2html( $data, $url ), $url, $args );
303
+		return apply_filters('oembed_result', $this->data2html($data, $url), $url, $args);
304 304
 	}
305 305
 
306 306
 	/**
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	 * @param string $url The URL that should be inspected for discovery `<link>` tags.
310 310
 	 * @return false|string False on failure, otherwise the oEmbed provider URL.
311 311
 	 */
312
-	public function discover( $url ) {
312
+	public function discover($url) {
313 313
 		$providers = array();
314 314
 		$args = array(
315 315
 			'limit_response_size' => 153600, // 150 KB
@@ -325,11 +325,11 @@  discard block
 block discarded – undo
325 325
 		 * @param array  $args oEmbed remote get arguments.
326 326
 		 * @param string $url  URL to be inspected.
327 327
 		 */
328
-		$args = apply_filters( 'oembed_remote_get_args', $args, $url );
328
+		$args = apply_filters('oembed_remote_get_args', $args, $url);
329 329
 
330 330
 		// Fetch URL content
331
-		$request = wp_safe_remote_get( $url, $args );
332
-		if ( $html = wp_remote_retrieve_body( $request ) ) {
331
+		$request = wp_safe_remote_get($url, $args);
332
+		if ($html = wp_remote_retrieve_body($request)) {
333 333
 
334 334
 			/**
335 335
 			 * Filter the link types that contain oEmbed provider URLs.
@@ -340,35 +340,35 @@  discard block
 block discarded – undo
340 340
 			 *                      'text/xml+oembed', and 'application/xml+oembed' (incorrect,
341 341
 			 *                      used by at least Vimeo).
342 342
 			 */
343
-			$linktypes = apply_filters( 'oembed_linktypes', array(
343
+			$linktypes = apply_filters('oembed_linktypes', array(
344 344
 				'application/json+oembed' => 'json',
345 345
 				'text/xml+oembed' => 'xml',
346 346
 				'application/xml+oembed' => 'xml',
347
-			) );
347
+			));
348 348
 
349 349
 			// Strip <body>
350
-			if ( $html_head_end = stripos( $html, '</head>' ) ) {
351
-				$html = substr( $html, 0, $html_head_end );
350
+			if ($html_head_end = stripos($html, '</head>')) {
351
+				$html = substr($html, 0, $html_head_end);
352 352
 			}
353 353
 
354 354
 			// Do a quick check
355 355
 			$tagfound = false;
356
-			foreach ( $linktypes as $linktype => $format ) {
357
-				if ( stripos($html, $linktype) ) {
356
+			foreach ($linktypes as $linktype => $format) {
357
+				if (stripos($html, $linktype)) {
358 358
 					$tagfound = true;
359 359
 					break;
360 360
 				}
361 361
 			}
362 362
 
363
-			if ( $tagfound && preg_match_all( '#<link([^<>]+)/?>#iU', $html, $links ) ) {
364
-				foreach ( $links[1] as $link ) {
365
-					$atts = shortcode_parse_atts( $link );
363
+			if ($tagfound && preg_match_all('#<link([^<>]+)/?>#iU', $html, $links)) {
364
+				foreach ($links[1] as $link) {
365
+					$atts = shortcode_parse_atts($link);
366 366
 
367
-					if ( !empty($atts['type']) && !empty($linktypes[$atts['type']]) && !empty($atts['href']) ) {
368
-						$providers[$linktypes[$atts['type']]] = htmlspecialchars_decode( $atts['href'] );
367
+					if ( ! empty($atts['type']) && ! empty($linktypes[$atts['type']]) && ! empty($atts['href'])) {
368
+						$providers[$linktypes[$atts['type']]] = htmlspecialchars_decode($atts['href']);
369 369
 
370 370
 						// Stop here if it's JSON (that's all we need)
371
-						if ( 'json' == $linktypes[$atts['type']] )
371
+						if ('json' == $linktypes[$atts['type']])
372 372
 							break;
373 373
 					}
374 374
 				}
@@ -376,9 +376,9 @@  discard block
 block discarded – undo
376 376
 		}
377 377
 
378 378
 		// JSON is preferred to XML
379
-		if ( !empty($providers['json']) )
379
+		if ( ! empty($providers['json']))
380 380
 			return $providers['json'];
381
-		elseif ( !empty($providers['xml']) )
381
+		elseif ( ! empty($providers['xml']))
382 382
 			return $providers['xml'];
383 383
 		else
384 384
 			return false;
@@ -392,12 +392,12 @@  discard block
 block discarded – undo
392 392
 	 * @param array $args Optional arguments. Usually passed from a shortcode.
393 393
 	 * @return false|object False on failure, otherwise the result in the form of an object.
394 394
 	 */
395
-	public function fetch( $provider, $url, $args = '' ) {
396
-		$args = wp_parse_args( $args, wp_embed_defaults( $url ) );
395
+	public function fetch($provider, $url, $args = '') {
396
+		$args = wp_parse_args($args, wp_embed_defaults($url));
397 397
 
398
-		$provider = add_query_arg( 'maxwidth', (int) $args['width'], $provider );
399
-		$provider = add_query_arg( 'maxheight', (int) $args['height'], $provider );
400
-		$provider = add_query_arg( 'url', urlencode($url), $provider );
398
+		$provider = add_query_arg('maxwidth', (int) $args['width'], $provider);
399
+		$provider = add_query_arg('maxheight', (int) $args['height'], $provider);
400
+		$provider = add_query_arg('url', urlencode($url), $provider);
401 401
 
402 402
 		/**
403 403
 		 * Filter the oEmbed URL to be fetched.
@@ -408,13 +408,13 @@  discard block
 block discarded – undo
408 408
 		 * @param string $url      URL of the content to be embedded.
409 409
 		 * @param array  $args     Optional arguments, usually passed from a shortcode.
410 410
 		 */
411
-		$provider = apply_filters( 'oembed_fetch_url', $provider, $url, $args );
411
+		$provider = apply_filters('oembed_fetch_url', $provider, $url, $args);
412 412
 
413
-		foreach ( array( 'json', 'xml' ) as $format ) {
414
-			$result = $this->_fetch_with_format( $provider, $format );
415
-			if ( is_wp_error( $result ) && 'not-implemented' == $result->get_error_code() )
413
+		foreach (array('json', 'xml') as $format) {
414
+			$result = $this->_fetch_with_format($provider, $format);
415
+			if (is_wp_error($result) && 'not-implemented' == $result->get_error_code())
416 416
 				continue;
417
-			return ( $result && ! is_wp_error( $result ) ) ? $result : false;
417
+			return ($result && ! is_wp_error($result)) ? $result : false;
418 418
 		}
419 419
 		return false;
420 420
 	}
@@ -428,19 +428,19 @@  discard block
 block discarded – undo
428 428
 	 * @param string $format Format to use
429 429
 	 * @return false|object|WP_Error False on failure, otherwise the result in the form of an object.
430 430
 	 */
431
-	private function _fetch_with_format( $provider_url_with_args, $format ) {
432
-		$provider_url_with_args = add_query_arg( 'format', $format, $provider_url_with_args );
431
+	private function _fetch_with_format($provider_url_with_args, $format) {
432
+		$provider_url_with_args = add_query_arg('format', $format, $provider_url_with_args);
433 433
 
434 434
 		/** This filter is documented in wp-includes/class-oembed.php */
435
-		$args = apply_filters( 'oembed_remote_get_args', array(), $provider_url_with_args );
435
+		$args = apply_filters('oembed_remote_get_args', array(), $provider_url_with_args);
436 436
 
437
-		$response = wp_safe_remote_get( $provider_url_with_args, $args );
438
-		if ( 501 == wp_remote_retrieve_response_code( $response ) )
439
-			return new WP_Error( 'not-implemented' );
440
-		if ( ! $body = wp_remote_retrieve_body( $response ) )
437
+		$response = wp_safe_remote_get($provider_url_with_args, $args);
438
+		if (501 == wp_remote_retrieve_response_code($response))
439
+			return new WP_Error('not-implemented');
440
+		if ( ! $body = wp_remote_retrieve_body($response))
441 441
 			return false;
442 442
 		$parse_method = "_parse_$format";
443
-		return $this->$parse_method( $body );
443
+		return $this->$parse_method($body);
444 444
 	}
445 445
 
446 446
 	/**
@@ -452,9 +452,9 @@  discard block
 block discarded – undo
452 452
 	 * @param string $response_body
453 453
 	 * @return object|false
454 454
 	 */
455
-	private function _parse_json( $response_body ) {
456
-		$data = json_decode( trim( $response_body ) );
457
-		return ( $data && is_object( $data ) ) ? $data : false;
455
+	private function _parse_json($response_body) {
456
+		$data = json_decode(trim($response_body));
457
+		return ($data && is_object($data)) ? $data : false;
458 458
 	}
459 459
 
460 460
 	/**
@@ -466,17 +466,17 @@  discard block
 block discarded – undo
466 466
 	 * @param string $response_body
467 467
 	 * @return object|false
468 468
 	 */
469
-	private function _parse_xml( $response_body ) {
470
-		if ( ! function_exists( 'libxml_disable_entity_loader' ) )
469
+	private function _parse_xml($response_body) {
470
+		if ( ! function_exists('libxml_disable_entity_loader'))
471 471
 			return false;
472 472
 
473
-		$loader = libxml_disable_entity_loader( true );
474
-		$errors = libxml_use_internal_errors( true );
473
+		$loader = libxml_disable_entity_loader(true);
474
+		$errors = libxml_use_internal_errors(true);
475 475
 
476
-		$return = $this->_parse_xml_body( $response_body );
476
+		$return = $this->_parse_xml_body($response_body);
477 477
 
478
-		libxml_use_internal_errors( $errors );
479
-		libxml_disable_entity_loader( $loader );
478
+		libxml_use_internal_errors($errors);
479
+		libxml_disable_entity_loader($loader);
480 480
 
481 481
 		return $return;
482 482
 	}
@@ -490,29 +490,29 @@  discard block
 block discarded – undo
490 490
 	 * @param string $response_body
491 491
 	 * @return object|false
492 492
 	 */
493
-	private function _parse_xml_body( $response_body ) {
494
-		if ( ! function_exists( 'simplexml_import_dom' ) || ! class_exists( 'DOMDocument', false ) )
493
+	private function _parse_xml_body($response_body) {
494
+		if ( ! function_exists('simplexml_import_dom') || ! class_exists('DOMDocument', false))
495 495
 			return false;
496 496
 
497 497
 		$dom = new DOMDocument;
498
-		$success = $dom->loadXML( $response_body );
499
-		if ( ! $success )
498
+		$success = $dom->loadXML($response_body);
499
+		if ( ! $success)
500 500
 			return false;
501 501
 
502
-		if ( isset( $dom->doctype ) )
502
+		if (isset($dom->doctype))
503 503
 			return false;
504 504
 
505
-		foreach ( $dom->childNodes as $child ) {
506
-			if ( XML_DOCUMENT_TYPE_NODE === $child->nodeType )
505
+		foreach ($dom->childNodes as $child) {
506
+			if (XML_DOCUMENT_TYPE_NODE === $child->nodeType)
507 507
 				return false;
508 508
 		}
509 509
 
510
-		$xml = simplexml_import_dom( $dom );
511
-		if ( ! $xml )
510
+		$xml = simplexml_import_dom($dom);
511
+		if ( ! $xml)
512 512
 			return false;
513 513
 
514 514
 		$return = new stdClass;
515
-		foreach ( $xml as $key => $value ) {
515
+		foreach ($xml as $key => $value) {
516 516
 			$return->$key = (string) $value;
517 517
 		}
518 518
 
@@ -526,32 +526,32 @@  discard block
 block discarded – undo
526 526
 	 * @param string $url The URL to the content that is desired to be embedded.
527 527
 	 * @return false|string False on error, otherwise the HTML needed to embed.
528 528
 	 */
529
-	public function data2html( $data, $url ) {
530
-		if ( ! is_object( $data ) || empty( $data->type ) )
529
+	public function data2html($data, $url) {
530
+		if ( ! is_object($data) || empty($data->type))
531 531
 			return false;
532 532
 
533 533
 		$return = false;
534 534
 
535
-		switch ( $data->type ) {
535
+		switch ($data->type) {
536 536
 			case 'photo':
537
-				if ( empty( $data->url ) || empty( $data->width ) || empty( $data->height ) )
537
+				if (empty($data->url) || empty($data->width) || empty($data->height))
538 538
 					break;
539
-				if ( ! is_string( $data->url ) || ! is_numeric( $data->width ) || ! is_numeric( $data->height ) )
539
+				if ( ! is_string($data->url) || ! is_numeric($data->width) || ! is_numeric($data->height))
540 540
 					break;
541 541
 
542
-				$title = ! empty( $data->title ) && is_string( $data->title ) ? $data->title : '';
543
-				$return = '<a href="' . esc_url( $url ) . '"><img src="' . esc_url( $data->url ) . '" alt="' . esc_attr($title) . '" width="' . esc_attr($data->width) . '" height="' . esc_attr($data->height) . '" /></a>';
542
+				$title = ! empty($data->title) && is_string($data->title) ? $data->title : '';
543
+				$return = '<a href="'.esc_url($url).'"><img src="'.esc_url($data->url).'" alt="'.esc_attr($title).'" width="'.esc_attr($data->width).'" height="'.esc_attr($data->height).'" /></a>';
544 544
 				break;
545 545
 
546 546
 			case 'video':
547 547
 			case 'rich':
548
-				if ( ! empty( $data->html ) && is_string( $data->html ) )
548
+				if ( ! empty($data->html) && is_string($data->html))
549 549
 					$return = $data->html;
550 550
 				break;
551 551
 
552 552
 			case 'link':
553
-				if ( ! empty( $data->title ) && is_string( $data->title ) )
554
-					$return = '<a href="' . esc_url( $url ) . '">' . esc_html( $data->title ) . '</a>';
553
+				if ( ! empty($data->title) && is_string($data->title))
554
+					$return = '<a href="'.esc_url($url).'">'.esc_html($data->title).'</a>';
555 555
 				break;
556 556
 
557 557
 			default:
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
 		 * @param object $data   A data object result from an oEmbed provider.
570 570
 		 * @param string $url    The URL of the content to be embedded.
571 571
 		 */
572
-		return apply_filters( 'oembed_dataparse', $return, $data, $url );
572
+		return apply_filters('oembed_dataparse', $return, $data, $url);
573 573
 	}
574 574
 
575 575
 	/**
@@ -581,33 +581,33 @@  discard block
 block discarded – undo
581 581
 	 * @param string $url The original URL passed to oEmbed.
582 582
 	 * @return string Possibly modified $html
583 583
 	 */
584
-	public function _strip_newlines( $html, $data, $url ) {
585
-		if ( false === strpos( $html, "\n" ) ) {
584
+	public function _strip_newlines($html, $data, $url) {
585
+		if (false === strpos($html, "\n")) {
586 586
 			return $html;
587 587
 		}
588 588
 
589 589
 		$count = 1;
590 590
 		$found = array();
591 591
 		$token = '__PRE__';
592
-		$search = array( "\t", "\n", "\r", ' ' );
593
-		$replace = array( '__TAB__', '__NL__', '__CR__', '__SPACE__' );
594
-		$tokenized = str_replace( $search, $replace, $html );
592
+		$search = array("\t", "\n", "\r", ' ');
593
+		$replace = array('__TAB__', '__NL__', '__CR__', '__SPACE__');
594
+		$tokenized = str_replace($search, $replace, $html);
595 595
 
596
-		preg_match_all( '#(<pre[^>]*>.+?</pre>)#i', $tokenized, $matches, PREG_SET_ORDER );
597
-		foreach ( $matches as $i => $match ) {
598
-			$tag_html = str_replace( $replace, $search, $match[0] );
599
-			$tag_token = $token . $i;
596
+		preg_match_all('#(<pre[^>]*>.+?</pre>)#i', $tokenized, $matches, PREG_SET_ORDER);
597
+		foreach ($matches as $i => $match) {
598
+			$tag_html = str_replace($replace, $search, $match[0]);
599
+			$tag_token = $token.$i;
600 600
 
601
-			$found[ $tag_token ] = $tag_html;
602
-			$html = str_replace( $tag_html, $tag_token, $html, $count );
601
+			$found[$tag_token] = $tag_html;
602
+			$html = str_replace($tag_html, $tag_token, $html, $count);
603 603
 		}
604 604
 
605
-		$replaced = str_replace( $replace, $search, $html );
606
-		$stripped = str_replace( array( "\r\n", "\n" ), '', $replaced );
607
-		$pre = array_values( $found );
608
-		$tokens = array_keys( $found );
605
+		$replaced = str_replace($replace, $search, $html);
606
+		$stripped = str_replace(array("\r\n", "\n"), '', $replaced);
607
+		$pre = array_values($found);
608
+		$tokens = array_keys($found);
609 609
 
610
-		return str_replace( $tokens, $pre, $stripped );
610
+		return str_replace($tokens, $pre, $stripped);
611 611
 	}
612 612
 }
613 613
 
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
 function _wp_oembed_get_object() {
625 625
 	static $wp_oembed = null;
626 626
 
627
-	if ( is_null( $wp_oembed ) ) {
627
+	if (is_null($wp_oembed)) {
628 628
 		$wp_oembed = new WP_oEmbed();
629 629
 	}
630 630
 	return $wp_oembed;
Please login to merge, or discard this patch.
Braces   +61 added lines, -42 removed lines patch added patch discarded remove patch
@@ -202,8 +202,9 @@  discard block
 block discarded – undo
202 202
 
203 203
 		$provider = false;
204 204
 
205
-		if ( !isset($args['discover']) )
206
-			$args['discover'] = true;
205
+		if ( !isset($args['discover']) ) {
206
+					$args['discover'] = true;
207
+		}
207 208
 
208 209
 		foreach ( $this->providers as $matchmask => $data ) {
209 210
 			list( $providerurl, $regex ) = $data;
@@ -220,8 +221,9 @@  discard block
 block discarded – undo
220 221
 			}
221 222
 		}
222 223
 
223
-		if ( !$provider && $args['discover'] )
224
-			$provider = $this->discover( $url );
224
+		if ( !$provider && $args['discover'] ) {
225
+					$provider = $this->discover( $url );
226
+		}
225 227
 
226 228
 		return $provider;
227 229
 	}
@@ -288,8 +290,9 @@  discard block
 block discarded – undo
288 290
 	public function get_html( $url, $args = '' ) {
289 291
 		$provider = $this->get_provider( $url, $args );
290 292
 
291
-		if ( !$provider || false === $data = $this->fetch( $provider, $url, $args ) )
292
-			return false;
293
+		if ( !$provider || false === $data = $this->fetch( $provider, $url, $args ) ) {
294
+					return false;
295
+		}
293 296
 
294 297
 		/**
295 298
 		 * Filter the HTML returned by the oEmbed provider.
@@ -368,20 +371,22 @@  discard block
 block discarded – undo
368 371
 						$providers[$linktypes[$atts['type']]] = htmlspecialchars_decode( $atts['href'] );
369 372
 
370 373
 						// Stop here if it's JSON (that's all we need)
371
-						if ( 'json' == $linktypes[$atts['type']] )
372
-							break;
374
+						if ( 'json' == $linktypes[$atts['type']] ) {
375
+													break;
376
+						}
373 377
 					}
374 378
 				}
375 379
 			}
376 380
 		}
377 381
 
378 382
 		// JSON is preferred to XML
379
-		if ( !empty($providers['json']) )
380
-			return $providers['json'];
381
-		elseif ( !empty($providers['xml']) )
382
-			return $providers['xml'];
383
-		else
384
-			return false;
383
+		if ( !empty($providers['json']) ) {
384
+					return $providers['json'];
385
+		} elseif ( !empty($providers['xml']) ) {
386
+					return $providers['xml'];
387
+		} else {
388
+					return false;
389
+		}
385 390
 	}
386 391
 
387 392
 	/**
@@ -412,8 +417,9 @@  discard block
 block discarded – undo
412 417
 
413 418
 		foreach ( array( 'json', 'xml' ) as $format ) {
414 419
 			$result = $this->_fetch_with_format( $provider, $format );
415
-			if ( is_wp_error( $result ) && 'not-implemented' == $result->get_error_code() )
416
-				continue;
420
+			if ( is_wp_error( $result ) && 'not-implemented' == $result->get_error_code() ) {
421
+							continue;
422
+			}
417 423
 			return ( $result && ! is_wp_error( $result ) ) ? $result : false;
418 424
 		}
419 425
 		return false;
@@ -435,10 +441,12 @@  discard block
 block discarded – undo
435 441
 		$args = apply_filters( 'oembed_remote_get_args', array(), $provider_url_with_args );
436 442
 
437 443
 		$response = wp_safe_remote_get( $provider_url_with_args, $args );
438
-		if ( 501 == wp_remote_retrieve_response_code( $response ) )
439
-			return new WP_Error( 'not-implemented' );
440
-		if ( ! $body = wp_remote_retrieve_body( $response ) )
441
-			return false;
444
+		if ( 501 == wp_remote_retrieve_response_code( $response ) ) {
445
+					return new WP_Error( 'not-implemented' );
446
+		}
447
+		if ( ! $body = wp_remote_retrieve_body( $response ) ) {
448
+					return false;
449
+		}
442 450
 		$parse_method = "_parse_$format";
443 451
 		return $this->$parse_method( $body );
444 452
 	}
@@ -467,8 +475,9 @@  discard block
 block discarded – undo
467 475
 	 * @return object|false
468 476
 	 */
469 477
 	private function _parse_xml( $response_body ) {
470
-		if ( ! function_exists( 'libxml_disable_entity_loader' ) )
471
-			return false;
478
+		if ( ! function_exists( 'libxml_disable_entity_loader' ) ) {
479
+					return false;
480
+		}
472 481
 
473 482
 		$loader = libxml_disable_entity_loader( true );
474 483
 		$errors = libxml_use_internal_errors( true );
@@ -491,25 +500,30 @@  discard block
 block discarded – undo
491 500
 	 * @return object|false
492 501
 	 */
493 502
 	private function _parse_xml_body( $response_body ) {
494
-		if ( ! function_exists( 'simplexml_import_dom' ) || ! class_exists( 'DOMDocument', false ) )
495
-			return false;
503
+		if ( ! function_exists( 'simplexml_import_dom' ) || ! class_exists( 'DOMDocument', false ) ) {
504
+					return false;
505
+		}
496 506
 
497 507
 		$dom = new DOMDocument;
498 508
 		$success = $dom->loadXML( $response_body );
499
-		if ( ! $success )
500
-			return false;
509
+		if ( ! $success ) {
510
+					return false;
511
+		}
501 512
 
502
-		if ( isset( $dom->doctype ) )
503
-			return false;
513
+		if ( isset( $dom->doctype ) ) {
514
+					return false;
515
+		}
504 516
 
505 517
 		foreach ( $dom->childNodes as $child ) {
506
-			if ( XML_DOCUMENT_TYPE_NODE === $child->nodeType )
507
-				return false;
518
+			if ( XML_DOCUMENT_TYPE_NODE === $child->nodeType ) {
519
+							return false;
520
+			}
508 521
 		}
509 522
 
510 523
 		$xml = simplexml_import_dom( $dom );
511
-		if ( ! $xml )
512
-			return false;
524
+		if ( ! $xml ) {
525
+					return false;
526
+		}
513 527
 
514 528
 		$return = new stdClass;
515 529
 		foreach ( $xml as $key => $value ) {
@@ -527,17 +541,20 @@  discard block
 block discarded – undo
527 541
 	 * @return false|string False on error, otherwise the HTML needed to embed.
528 542
 	 */
529 543
 	public function data2html( $data, $url ) {
530
-		if ( ! is_object( $data ) || empty( $data->type ) )
531
-			return false;
544
+		if ( ! is_object( $data ) || empty( $data->type ) ) {
545
+					return false;
546
+		}
532 547
 
533 548
 		$return = false;
534 549
 
535 550
 		switch ( $data->type ) {
536 551
 			case 'photo':
537
-				if ( empty( $data->url ) || empty( $data->width ) || empty( $data->height ) )
538
-					break;
539
-				if ( ! is_string( $data->url ) || ! is_numeric( $data->width ) || ! is_numeric( $data->height ) )
540
-					break;
552
+				if ( empty( $data->url ) || empty( $data->width ) || empty( $data->height ) ) {
553
+									break;
554
+				}
555
+				if ( ! is_string( $data->url ) || ! is_numeric( $data->width ) || ! is_numeric( $data->height ) ) {
556
+									break;
557
+				}
541 558
 
542 559
 				$title = ! empty( $data->title ) && is_string( $data->title ) ? $data->title : '';
543 560
 				$return = '<a href="' . esc_url( $url ) . '"><img src="' . esc_url( $data->url ) . '" alt="' . esc_attr($title) . '" width="' . esc_attr($data->width) . '" height="' . esc_attr($data->height) . '" /></a>';
@@ -545,13 +562,15 @@  discard block
 block discarded – undo
545 562
 
546 563
 			case 'video':
547 564
 			case 'rich':
548
-				if ( ! empty( $data->html ) && is_string( $data->html ) )
549
-					$return = $data->html;
565
+				if ( ! empty( $data->html ) && is_string( $data->html ) ) {
566
+									$return = $data->html;
567
+				}
550 568
 				break;
551 569
 
552 570
 			case 'link':
553
-				if ( ! empty( $data->title ) && is_string( $data->title ) )
554
-					$return = '<a href="' . esc_url( $url ) . '">' . esc_html( $data->title ) . '</a>';
571
+				if ( ! empty( $data->title ) && is_string( $data->title ) ) {
572
+									$return = '<a href="' . esc_url( $url ) . '">' . esc_html( $data->title ) . '</a>';
573
+				}
555 574
 				break;
556 575
 
557 576
 			default:
Please login to merge, or discard this patch.
src/wp-includes/ms-files.php 2 patches
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -8,75 +8,75 @@
 block discarded – undo
8 8
  * @subpackage Multisite
9 9
  */
10 10
 
11
-define( 'SHORTINIT', true );
12
-require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
11
+define('SHORTINIT', true);
12
+require_once(dirname(dirname(__FILE__)).'/wp-load.php');
13 13
 
14
-if ( !is_multisite() )
15
-	die( 'Multisite support not enabled' );
14
+if ( ! is_multisite())
15
+	die('Multisite support not enabled');
16 16
 
17 17
 ms_file_constants();
18 18
 
19
-error_reporting( 0 );
19
+error_reporting(0);
20 20
 
21
-if ( $current_blog->archived == '1' || $current_blog->spam == '1' || $current_blog->deleted == '1' ) {
22
-	status_header( 404 );
23
-	die( '404 &#8212; File not found.' );
21
+if ($current_blog->archived == '1' || $current_blog->spam == '1' || $current_blog->deleted == '1') {
22
+	status_header(404);
23
+	die('404 &#8212; File not found.');
24 24
 }
25 25
 
26
-$file = rtrim( BLOGUPLOADDIR, '/' ) . '/' . str_replace( '..', '', $_GET[ 'file' ] );
27
-if ( !is_file( $file ) ) {
28
-	status_header( 404 );
29
-	die( '404 &#8212; File not found.' );
26
+$file = rtrim(BLOGUPLOADDIR, '/').'/'.str_replace('..', '', $_GET['file']);
27
+if ( ! is_file($file)) {
28
+	status_header(404);
29
+	die('404 &#8212; File not found.');
30 30
 }
31 31
 
32
-$mime = wp_check_filetype( $file );
33
-if ( false === $mime[ 'type' ] && function_exists( 'mime_content_type' ) )
34
-	$mime[ 'type' ] = mime_content_type( $file );
32
+$mime = wp_check_filetype($file);
33
+if (false === $mime['type'] && function_exists('mime_content_type'))
34
+	$mime['type'] = mime_content_type($file);
35 35
 
36
-if ( $mime[ 'type' ] )
37
-	$mimetype = $mime[ 'type' ];
36
+if ($mime['type'])
37
+	$mimetype = $mime['type'];
38 38
 else
39
-	$mimetype = 'image/' . substr( $file, strrpos( $file, '.' ) + 1 );
39
+	$mimetype = 'image/'.substr($file, strrpos($file, '.') + 1);
40 40
 
41
-header( 'Content-Type: ' . $mimetype ); // always send this
42
-if ( false === strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS' ) )
43
-	header( 'Content-Length: ' . filesize( $file ) );
41
+header('Content-Type: '.$mimetype); // always send this
42
+if (false === strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS'))
43
+	header('Content-Length: '.filesize($file));
44 44
 
45 45
 // Optional support for X-Sendfile and X-Accel-Redirect
46
-if ( WPMU_ACCEL_REDIRECT ) {
47
-	header( 'X-Accel-Redirect: ' . str_replace( WP_CONTENT_DIR, '', $file ) );
46
+if (WPMU_ACCEL_REDIRECT) {
47
+	header('X-Accel-Redirect: '.str_replace(WP_CONTENT_DIR, '', $file));
48 48
 	exit;
49
-} elseif ( WPMU_SENDFILE ) {
50
-	header( 'X-Sendfile: ' . $file );
49
+} elseif (WPMU_SENDFILE) {
50
+	header('X-Sendfile: '.$file);
51 51
 	exit;
52 52
 }
53 53
 
54
-$last_modified = gmdate( 'D, d M Y H:i:s', filemtime( $file ) );
55
-$etag = '"' . md5( $last_modified ) . '"';
56
-header( "Last-Modified: $last_modified GMT" );
57
-header( 'ETag: ' . $etag );
58
-header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + 100000000 ) . ' GMT' );
54
+$last_modified = gmdate('D, d M Y H:i:s', filemtime($file));
55
+$etag = '"'.md5($last_modified).'"';
56
+header("Last-Modified: $last_modified GMT");
57
+header('ETag: '.$etag);
58
+header('Expires: '.gmdate('D, d M Y H:i:s', time() + 100000000).' GMT');
59 59
 
60 60
 // Support for Conditional GET - use stripslashes to avoid formatting.php dependency
61
-$client_etag = isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ? stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) : false;
61
+$client_etag = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : false;
62 62
 
63
-if ( ! isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) )
63
+if ( ! isset($_SERVER['HTTP_IF_MODIFIED_SINCE']))
64 64
 	$_SERVER['HTTP_IF_MODIFIED_SINCE'] = false;
65 65
 
66
-$client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] );
66
+$client_last_modified = trim($_SERVER['HTTP_IF_MODIFIED_SINCE']);
67 67
 // If string is empty, return 0. If not, attempt to parse into a timestamp
68
-$client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0;
68
+$client_modified_timestamp = $client_last_modified ? strtotime($client_last_modified) : 0;
69 69
 
70 70
 // Make a timestamp for our most recent modification...
71 71
 $modified_timestamp = strtotime($last_modified);
72 72
 
73
-if ( ( $client_last_modified && $client_etag )
74
-	? ( ( $client_modified_timestamp >= $modified_timestamp) && ( $client_etag == $etag ) )
75
-	: ( ( $client_modified_timestamp >= $modified_timestamp) || ( $client_etag == $etag ) )
73
+if (($client_last_modified && $client_etag)
74
+	? (($client_modified_timestamp >= $modified_timestamp) && ($client_etag == $etag))
75
+	: (($client_modified_timestamp >= $modified_timestamp) || ($client_etag == $etag))
76 76
 	) {
77
-	status_header( 304 );
77
+	status_header(304);
78 78
 	exit;
79 79
 }
80 80
 
81 81
 // If we made it this far, just serve the file
82
-readfile( $file );
82
+readfile($file);
Please login to merge, or discard this patch.
Braces   +11 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
 define( 'SHORTINIT', true );
12 12
 require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
13 13
 
14
-if ( !is_multisite() )
14
+if ( !is_multisite() ) {
15 15
 	die( 'Multisite support not enabled' );
16
+}
16 17
 
17 18
 ms_file_constants();
18 19
 
@@ -30,17 +31,20 @@  discard block
 block discarded – undo
30 31
 }
31 32
 
32 33
 $mime = wp_check_filetype( $file );
33
-if ( false === $mime[ 'type' ] && function_exists( 'mime_content_type' ) )
34
+if ( false === $mime[ 'type' ] && function_exists( 'mime_content_type' ) ) {
34 35
 	$mime[ 'type' ] = mime_content_type( $file );
36
+}
35 37
 
36
-if ( $mime[ 'type' ] )
38
+if ( $mime[ 'type' ] ) {
37 39
 	$mimetype = $mime[ 'type' ];
38
-else
40
+} else {
39 41
 	$mimetype = 'image/' . substr( $file, strrpos( $file, '.' ) + 1 );
42
+}
40 43
 
41 44
 header( 'Content-Type: ' . $mimetype ); // always send this
42
-if ( false === strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS' ) )
45
+if ( false === strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS' ) ) {
43 46
 	header( 'Content-Length: ' . filesize( $file ) );
47
+}
44 48
 
45 49
 // Optional support for X-Sendfile and X-Accel-Redirect
46 50
 if ( WPMU_ACCEL_REDIRECT ) {
@@ -60,8 +64,9 @@  discard block
 block discarded – undo
60 64
 // Support for Conditional GET - use stripslashes to avoid formatting.php dependency
61 65
 $client_etag = isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ? stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) : false;
62 66
 
63
-if ( ! isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) )
67
+if ( ! isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
64 68
 	$_SERVER['HTTP_IF_MODIFIED_SINCE'] = false;
69
+}
65 70
 
66 71
 $client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] );
67 72
 // If string is empty, return 0. If not, attempt to parse into a timestamp
Please login to merge, or discard this patch.
src/wp-includes/compat.php 3 patches
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -161,13 +161,15 @@  discard block
 block discarded – undo
161 161
 function _hash_hmac($algo, $data, $key, $raw_output = false) {
162 162
 	$packs = array('md5' => 'H32', 'sha1' => 'H40');
163 163
 
164
-	if ( !isset($packs[$algo]) )
165
-		return false;
164
+	if ( !isset($packs[$algo]) ) {
165
+			return false;
166
+	}
166 167
 
167 168
 	$pack = $packs[$algo];
168 169
 
169
-	if (strlen($key) > 64)
170
-		$key = pack($pack, $algo($key));
170
+	if (strlen($key) > 64) {
171
+			$key = pack($pack, $algo($key));
172
+	}
171 173
 
172 174
 	$key = str_pad($key, 64, chr(0));
173 175
 
@@ -176,8 +178,9 @@  discard block
 block discarded – undo
176 178
 
177 179
 	$hmac = $algo($opad . pack($pack, $algo($ipad . $data)));
178 180
 
179
-	if ( $raw_output )
180
-		return pack( $pack, $hmac );
181
+	if ( $raw_output ) {
182
+			return pack( $pack, $hmac );
183
+	}
181 184
 	return $hmac;
182 185
 }
183 186
 
@@ -210,8 +213,9 @@  discard block
 block discarded – undo
210 213
 		}
211 214
 
212 215
 		$res = $wp_json->decode( $string );
213
-		if ( $assoc_array )
214
-			$res = _json_decode_object_helper( $res );
216
+		if ( $assoc_array ) {
217
+					$res = _json_decode_object_helper( $res );
218
+		}
215 219
 		return $res;
216 220
 	}
217 221
 
@@ -220,8 +224,9 @@  discard block
 block discarded – undo
220 224
 	 * @return array
221 225
 	 */
222 226
 	function _json_decode_object_helper($data) {
223
-		if ( is_object($data) )
224
-			$data = get_object_vars($data);
227
+		if ( is_object($data) ) {
228
+					$data = get_object_vars($data);
229
+		}
225 230
 		return is_array($data) ? array_map(__FUNCTION__, $data) : $data;
226 231
 	}
227 232
 }
Please login to merge, or discard this patch.
Doc Comments   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,6 +8,10 @@  discard block
 block discarded – undo
8 8
 
9 9
 // If gettext isn't available
10 10
 if ( !function_exists('_') ) {
11
+
12
+	/**
13
+	 * @param string $string
14
+	 */
11 15
 	function _($string) {
12 16
 		return $string;
13 17
 	}
@@ -366,7 +370,7 @@  discard block
 block discarded – undo
366 370
 	 *
367 371
 	 * @internal This is a compatibility function for PHP <5.5
368 372
 	 *
369
-	 * @return bool|string Returns the error message on success, "No Error" if no error has occurred,
373
+	 * @return false|string Returns the error message on success, "No Error" if no error has occurred,
370 374
 	 *                     or false on failure.
371 375
 	 */
372 376
 	function json_last_error_msg() {
Please login to merge, or discard this patch.
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 // If gettext isn't available
10
-if ( !function_exists('_') ) {
10
+if ( ! function_exists('_')) {
11 11
 	function _($string) {
12 12
 		return $string;
13 13
 	}
@@ -27,21 +27,21 @@  discard block
 block discarded – undo
27 27
  *             false  : Used for testing - return false for future calls to this function
28 28
  *             'reset': Used for testing - restore default behavior of this function
29 29
  */
30
-function _wp_can_use_pcre_u( $set = null ) {
30
+function _wp_can_use_pcre_u($set = null) {
31 31
 	static $utf8_pcre = 'reset';
32 32
 
33
-	if ( null !== $set ) {
33
+	if (null !== $set) {
34 34
 		$utf8_pcre = $set;
35 35
 	}
36 36
 
37
-	if ( 'reset' === $utf8_pcre ) {
38
-		$utf8_pcre = @preg_match( '/^./u', 'a' );
37
+	if ('reset' === $utf8_pcre) {
38
+		$utf8_pcre = @preg_match('/^./u', 'a');
39 39
 	}
40 40
 
41 41
 	return $utf8_pcre;
42 42
 }
43 43
 
44
-if ( ! function_exists( 'mb_substr' ) ) :
44
+if ( ! function_exists('mb_substr')) :
45 45
 	/**
46 46
 	 * Compat function to mimic mb_substr().
47 47
 	 *
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
 	 * @param string|null $encoding Optional. Character encoding to use. Default null.
58 58
 	 * @return string Extracted substring.
59 59
 	 */
60
-	function mb_substr( $str, $start, $length = null, $encoding = null ) {
61
-		return _mb_substr( $str, $start, $length, $encoding );
60
+	function mb_substr($str, $start, $length = null, $encoding = null) {
61
+		return _mb_substr($str, $start, $length, $encoding);
62 62
 	}
63 63
 endif;
64 64
 
@@ -79,24 +79,24 @@  discard block
 block discarded – undo
79 79
  * @param string|null $encoding Optional. Character encoding to use. Default null.
80 80
  * @return string Extracted substring.
81 81
  */
82
-function _mb_substr( $str, $start, $length = null, $encoding = null ) {
83
-	if ( null === $encoding ) {
84
-		$encoding = get_option( 'blog_charset' );
82
+function _mb_substr($str, $start, $length = null, $encoding = null) {
83
+	if (null === $encoding) {
84
+		$encoding = get_option('blog_charset');
85 85
 	}
86 86
 
87 87
 	/*
88 88
 	 * The solution below works only for UTF-8, so in case of a different
89 89
 	 * charset just use built-in substr().
90 90
 	 */
91
-	if ( ! in_array( $encoding, array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) ) {
92
-		return is_null( $length ) ? substr( $str, $start ) : substr( $str, $start, $length );
91
+	if ( ! in_array($encoding, array('utf8', 'utf-8', 'UTF8', 'UTF-8'))) {
92
+		return is_null($length) ? substr($str, $start) : substr($str, $start, $length);
93 93
 	}
94 94
 
95
-	if ( _wp_can_use_pcre_u() ) {
95
+	if (_wp_can_use_pcre_u()) {
96 96
 		// Use the regex unicode support to separate the UTF-8 characters into an array.
97
-		preg_match_all( '/./us', $str, $match );
98
-		$chars = is_null( $length ) ? array_slice( $match[0], $start ) : array_slice( $match[0], $start, $length );
99
-		return implode( '', $chars );
97
+		preg_match_all('/./us', $str, $match);
98
+		$chars = is_null($length) ? array_slice($match[0], $start) : array_slice($match[0], $start, $length);
99
+		return implode('', $chars);
100 100
 	}
101 101
 
102 102
 	$regex = '/(
@@ -112,26 +112,26 @@  discard block
 block discarded – undo
112 112
 	)/x';
113 113
 
114 114
 	// Start with 1 element instead of 0 since the first thing we do is pop.
115
-	$chars = array( '' );
115
+	$chars = array('');
116 116
 	do {
117 117
 		// We had some string left over from the last round, but we counted it in that last round.
118
-		array_pop( $chars );
118
+		array_pop($chars);
119 119
 
120 120
 		/*
121 121
 		 * Split by UTF-8 character, limit to 1000 characters (last array element will contain
122 122
 		 * the rest of the string).
123 123
 		 */
124
-		$pieces = preg_split( $regex, $str, 1000, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
124
+		$pieces = preg_split($regex, $str, 1000, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
125 125
 
126
-		$chars = array_merge( $chars, $pieces );
126
+		$chars = array_merge($chars, $pieces);
127 127
 
128 128
 	// If there's anything left over, repeat the loop.
129
-	} while ( count( $pieces ) > 1 && $str = array_pop( $pieces ) );
129
+	} while (count($pieces) > 1 && $str = array_pop($pieces));
130 130
 
131
-	return join( '', array_slice( $chars, $start, $length ) );
131
+	return join('', array_slice($chars, $start, $length));
132 132
 }
133 133
 
134
-if ( ! function_exists( 'mb_strlen' ) ) :
134
+if ( ! function_exists('mb_strlen')) :
135 135
 	/**
136 136
 	 * Compat function to mimic mb_strlen().
137 137
 	 *
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
 	 * @param string|null $encoding Optional. Character encoding to use. Default null.
145 145
 	 * @return int String length of `$str`.
146 146
 	 */
147
-	function mb_strlen( $str, $encoding = null ) {
148
-		return _mb_strlen( $str, $encoding );
147
+	function mb_strlen($str, $encoding = null) {
148
+		return _mb_strlen($str, $encoding);
149 149
 	}
150 150
 endif;
151 151
 
@@ -163,23 +163,23 @@  discard block
 block discarded – undo
163 163
  * @param string|null $encoding Optional. Character encoding to use. Default null.
164 164
  * @return int String length of `$str`.
165 165
  */
166
-function _mb_strlen( $str, $encoding = null ) {
167
-	if ( null === $encoding ) {
168
-		$encoding = get_option( 'blog_charset' );
166
+function _mb_strlen($str, $encoding = null) {
167
+	if (null === $encoding) {
168
+		$encoding = get_option('blog_charset');
169 169
 	}
170 170
 
171 171
 	/*
172 172
 	 * The solution below works only for UTF-8, so in case of a different charset
173 173
 	 * just use built-in strlen().
174 174
 	 */
175
-	if ( ! in_array( $encoding, array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) ) {
176
-		return strlen( $str );
175
+	if ( ! in_array($encoding, array('utf8', 'utf-8', 'UTF8', 'UTF-8'))) {
176
+		return strlen($str);
177 177
 	}
178 178
 
179
-	if ( _wp_can_use_pcre_u() ) {
179
+	if (_wp_can_use_pcre_u()) {
180 180
 		// Use the regex unicode support to separate the UTF-8 characters into an array.
181
-		preg_match_all( '/./us', $str, $match );
182
-		return count( $match[0] );
181
+		preg_match_all('/./us', $str, $match);
182
+		return count($match[0]);
183 183
 	}
184 184
 
185 185
 	$regex = '/(?:
@@ -204,19 +204,19 @@  discard block
 block discarded – undo
204 204
 		 * Split by UTF-8 character, limit to 1000 characters (last array element will contain
205 205
 		 * the rest of the string).
206 206
 		 */
207
-		$pieces = preg_split( $regex, $str, 1000 );
207
+		$pieces = preg_split($regex, $str, 1000);
208 208
 
209 209
 		// Increment.
210
-		$count += count( $pieces );
210
+		$count += count($pieces);
211 211
 
212 212
 	// If there's anything left over, repeat the loop.
213
-	} while ( $str = array_pop( $pieces ) );
213
+	} while ($str = array_pop($pieces));
214 214
 
215 215
 	// Fencepost: preg_split() always returns one extra item in the array.
216 216
 	return --$count;
217 217
 }
218 218
 
219
-if ( !function_exists('hash_hmac') ):
219
+if ( ! function_exists('hash_hmac')):
220 220
 /**
221 221
  * Compat function to mimic hash_hmac().
222 222
  *
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 function _hash_hmac($algo, $data, $key, $raw_output = false) {
256 256
 	$packs = array('md5' => 'H32', 'sha1' => 'H40');
257 257
 
258
-	if ( !isset($packs[$algo]) )
258
+	if ( ! isset($packs[$algo]))
259 259
 		return false;
260 260
 
261 261
 	$pack = $packs[$algo];
@@ -268,44 +268,44 @@  discard block
 block discarded – undo
268 268
 	$ipad = (substr($key, 0, 64) ^ str_repeat(chr(0x36), 64));
269 269
 	$opad = (substr($key, 0, 64) ^ str_repeat(chr(0x5C), 64));
270 270
 
271
-	$hmac = $algo($opad . pack($pack, $algo($ipad . $data)));
271
+	$hmac = $algo($opad.pack($pack, $algo($ipad.$data)));
272 272
 
273
-	if ( $raw_output )
274
-		return pack( $pack, $hmac );
273
+	if ($raw_output)
274
+		return pack($pack, $hmac);
275 275
 	return $hmac;
276 276
 }
277 277
 
278
-if ( !function_exists('json_encode') ) {
279
-	function json_encode( $string ) {
278
+if ( ! function_exists('json_encode')) {
279
+	function json_encode($string) {
280 280
 		global $wp_json;
281 281
 
282
-		if ( ! ( $wp_json instanceof Services_JSON ) ) {
283
-			require_once( ABSPATH . WPINC . '/class-json.php' );
282
+		if ( ! ($wp_json instanceof Services_JSON)) {
283
+			require_once(ABSPATH.WPINC.'/class-json.php');
284 284
 			$wp_json = new Services_JSON();
285 285
 		}
286 286
 
287
-		return $wp_json->encodeUnsafe( $string );
287
+		return $wp_json->encodeUnsafe($string);
288 288
 	}
289 289
 }
290 290
 
291
-if ( !function_exists('json_decode') ) {
291
+if ( ! function_exists('json_decode')) {
292 292
 	/**
293 293
 	 * @global Services_JSON $wp_json
294 294
 	 * @param string $string
295 295
 	 * @param bool   $assoc_array
296 296
 	 * @return object|array
297 297
 	 */
298
-	function json_decode( $string, $assoc_array = false ) {
298
+	function json_decode($string, $assoc_array = false) {
299 299
 		global $wp_json;
300 300
 
301
-		if ( ! ($wp_json instanceof Services_JSON ) ) {
302
-			require_once( ABSPATH . WPINC . '/class-json.php' );
301
+		if ( ! ($wp_json instanceof Services_JSON)) {
302
+			require_once(ABSPATH.WPINC.'/class-json.php');
303 303
 			$wp_json = new Services_JSON();
304 304
 		}
305 305
 
306
-		$res = $wp_json->decode( $string );
307
-		if ( $assoc_array )
308
-			$res = _json_decode_object_helper( $res );
306
+		$res = $wp_json->decode($string);
307
+		if ($assoc_array)
308
+			$res = _json_decode_object_helper($res);
309 309
 		return $res;
310 310
 	}
311 311
 
@@ -314,13 +314,13 @@  discard block
 block discarded – undo
314 314
 	 * @return array
315 315
 	 */
316 316
 	function _json_decode_object_helper($data) {
317
-		if ( is_object($data) )
317
+		if (is_object($data))
318 318
 			$data = get_object_vars($data);
319 319
 		return is_array($data) ? array_map(__FUNCTION__, $data) : $data;
320 320
 	}
321 321
 }
322 322
 
323
-if ( ! function_exists( 'hash_equals' ) ) :
323
+if ( ! function_exists('hash_equals')) :
324 324
 /**
325 325
  * Timing attack safe string comparison
326 326
  *
@@ -336,16 +336,16 @@  discard block
 block discarded – undo
336 336
  * @param string $b Actual, user supplied, string.
337 337
  * @return bool Whether strings are equal.
338 338
  */
339
-function hash_equals( $a, $b ) {
340
-	$a_length = strlen( $a );
341
-	if ( $a_length !== strlen( $b ) ) {
339
+function hash_equals($a, $b) {
340
+	$a_length = strlen($a);
341
+	if ($a_length !== strlen($b)) {
342 342
 		return false;
343 343
 	}
344 344
 	$result = 0;
345 345
 
346 346
 	// Do not attempt to "optimize" this.
347
-	for ( $i = 0; $i < $a_length; $i++ ) {
348
-		$result |= ord( $a[ $i ] ) ^ ord( $b[ $i ] );
347
+	for ($i = 0; $i < $a_length; $i++) {
348
+		$result |= ord($a[$i]) ^ ord($b[$i]);
349 349
 	}
350 350
 
351 351
 	return $result === 0;
@@ -354,11 +354,11 @@  discard block
 block discarded – undo
354 354
 
355 355
 // JSON_PRETTY_PRINT was introduced in PHP 5.4
356 356
 // Defined here to prevent a notice when using it with wp_json_encode()
357
-if ( ! defined( 'JSON_PRETTY_PRINT' ) ) {
358
-	define( 'JSON_PRETTY_PRINT', 128 );
357
+if ( ! defined('JSON_PRETTY_PRINT')) {
358
+	define('JSON_PRETTY_PRINT', 128);
359 359
 }
360 360
 
361
-if ( ! function_exists( 'json_last_error_msg' ) ) :
361
+if ( ! function_exists('json_last_error_msg')) :
362 362
 	/**
363 363
 	 * Retrieves the error string of the last json_encode() or json_decode() call.
364 364
 	 *
@@ -371,41 +371,41 @@  discard block
 block discarded – undo
371 371
 	 */
372 372
 	function json_last_error_msg() {
373 373
 		// See https://core.trac.wordpress.org/ticket/27799.
374
-		if ( ! function_exists( 'json_last_error' ) ) {
374
+		if ( ! function_exists('json_last_error')) {
375 375
 			return false;
376 376
 		}
377 377
 
378 378
 		$last_error_code = json_last_error();
379 379
 
380 380
 		// Just in case JSON_ERROR_NONE is not defined.
381
-		$error_code_none = defined( 'JSON_ERROR_NONE' ) ? JSON_ERROR_NONE : 0;
381
+		$error_code_none = defined('JSON_ERROR_NONE') ? JSON_ERROR_NONE : 0;
382 382
 
383
-		switch ( true ) {
383
+		switch (true) {
384 384
 			case $last_error_code === $error_code_none:
385 385
 				return 'No error';
386 386
 
387
-			case defined( 'JSON_ERROR_DEPTH' ) && JSON_ERROR_DEPTH === $last_error_code:
387
+			case defined('JSON_ERROR_DEPTH') && JSON_ERROR_DEPTH === $last_error_code:
388 388
 				return 'Maximum stack depth exceeded';
389 389
 
390
-			case defined( 'JSON_ERROR_STATE_MISMATCH' ) && JSON_ERROR_STATE_MISMATCH === $last_error_code:
390
+			case defined('JSON_ERROR_STATE_MISMATCH') && JSON_ERROR_STATE_MISMATCH === $last_error_code:
391 391
 				return 'State mismatch (invalid or malformed JSON)';
392 392
 
393
-			case defined( 'JSON_ERROR_CTRL_CHAR' ) && JSON_ERROR_CTRL_CHAR === $last_error_code:
393
+			case defined('JSON_ERROR_CTRL_CHAR') && JSON_ERROR_CTRL_CHAR === $last_error_code:
394 394
 				return 'Control character error, possibly incorrectly encoded';
395 395
 
396
-			case defined( 'JSON_ERROR_SYNTAX' ) && JSON_ERROR_SYNTAX === $last_error_code:
396
+			case defined('JSON_ERROR_SYNTAX') && JSON_ERROR_SYNTAX === $last_error_code:
397 397
 				return 'Syntax error';
398 398
 
399
-			case defined( 'JSON_ERROR_UTF8' ) && JSON_ERROR_UTF8 === $last_error_code:
399
+			case defined('JSON_ERROR_UTF8') && JSON_ERROR_UTF8 === $last_error_code:
400 400
 				return 'Malformed UTF-8 characters, possibly incorrectly encoded';
401 401
 
402
-			case defined( 'JSON_ERROR_RECURSION' ) && JSON_ERROR_RECURSION === $last_error_code:
402
+			case defined('JSON_ERROR_RECURSION') && JSON_ERROR_RECURSION === $last_error_code:
403 403
 				return 'Recursion detected';
404 404
 
405
-			case defined( 'JSON_ERROR_INF_OR_NAN' ) && JSON_ERROR_INF_OR_NAN === $last_error_code:
405
+			case defined('JSON_ERROR_INF_OR_NAN') && JSON_ERROR_INF_OR_NAN === $last_error_code:
406 406
 				return 'Inf and NaN cannot be JSON encoded';
407 407
 
408
-			case defined( 'JSON_ERROR_UNSUPPORTED_TYPE' ) && JSON_ERROR_UNSUPPORTED_TYPE === $last_error_code:
408
+			case defined('JSON_ERROR_UNSUPPORTED_TYPE') && JSON_ERROR_UNSUPPORTED_TYPE === $last_error_code:
409 409
 				return 'Type is not supported';
410 410
 
411 411
 			default:
@@ -414,8 +414,8 @@  discard block
 block discarded – undo
414 414
 	}
415 415
 endif;
416 416
 
417
-if ( ! interface_exists( 'JsonSerializable' ) ) {
418
-	define( 'WP_JSON_SERIALIZE_COMPATIBLE', true );
417
+if ( ! interface_exists('JsonSerializable')) {
418
+	define('WP_JSON_SERIALIZE_COMPATIBLE', true);
419 419
 	/**
420 420
 	 * JsonSerializable interface.
421 421
 	 *
@@ -431,6 +431,6 @@  discard block
 block discarded – undo
431 431
 }
432 432
 
433 433
 // random_int was introduced in PHP 7.0
434
-if ( ! function_exists( 'random_int' ) ) {
435
-	require ABSPATH . WPINC . '/random_compat/random.php';
434
+if ( ! function_exists('random_int')) {
435
+	require ABSPATH.WPINC.'/random_compat/random.php';
436 436
 }
Please login to merge, or discard this patch.
src/wp-includes/wp-db.php 4 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * WordPress DB Class
4
- *
5
- * Original code from {@link http://php.justinvincent.com Justin Vincent ([email protected])}
6
- *
7
- * @package WordPress
8
- * @subpackage Database
9
- * @since 0.71
10
- */
3
+	 * WordPress DB Class
4
+	 *
5
+	 * Original code from {@link http://php.justinvincent.com Justin Vincent ([email protected])}
6
+	 *
7
+	 * @package WordPress
8
+	 * @subpackage Database
9
+	 * @since 0.71
10
+	 */
11 11
 
12 12
 /**
13 13
  * @since 0.71
Please login to merge, or discard this patch.
Doc Comments   +5 added lines, -7 removed lines patch added patch discarded remove patch
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
 	 *
664 664
 	 * @see wpdb::__construct()
665 665
 	 * @since 2.0.8
666
-	 * @return true
666
+	 * @return boolean
667 667
 	 */
668 668
 	public function __destruct() {
669 669
 		return true;
@@ -1239,8 +1239,6 @@  discard block
 block discarded – undo
1239 1239
 	 * @param array|mixed $args     The array of variables to substitute into the query's placeholders if being called like
1240 1240
 	 *                              {@link http://php.net/vsprintf vsprintf()}, or the first variable to substitute into the query's placeholders if
1241 1241
 	 *                              being called like {@link http://php.net/sprintf sprintf()}.
1242
-	 * @param mixed       $args,... further variables to substitute into the query's placeholders if being called like
1243
-	 *                              {@link http://php.net/sprintf sprintf()}.
1244 1242
 	 * @return string|void Sanitized query string, if there is a query to prepare.
1245 1243
 	 */
1246 1244
 	public function prepare( $query, $args ) {
@@ -1449,7 +1447,7 @@  discard block
 block discarded – undo
1449 1447
 	 * @since 3.9.0 $allow_bail parameter added.
1450 1448
 	 *
1451 1449
 	 * @param bool $allow_bail Optional. Allows the function to bail. Default true.
1452
-	 * @return bool True with a successful connection, false on failure.
1450
+	 * @return boolean|null True with a successful connection, false on failure.
1453 1451
 	 */
1454 1452
 	public function db_connect( $allow_bail = true ) {
1455 1453
 		$this->is_mysql = true;
@@ -3052,7 +3050,7 @@  discard block
 block discarded – undo
3052 3050
 	 *
3053 3051
 	 * @since 1.5.0
3054 3052
 	 *
3055
-	 * @return true
3053
+	 * @return boolean
3056 3054
 	 */
3057 3055
 	public function timer_start() {
3058 3056
 		$this->time_start = microtime( true );
@@ -3186,7 +3184,7 @@  discard block
 block discarded – undo
3186 3184
 	 * @param string $db_cap The feature to check for. Accepts 'collation',
3187 3185
 	 *                       'group_concat', 'subqueries', 'set_charset',
3188 3186
 	 *                       or 'utf8mb4'.
3189
-	 * @return int|false Whether the database feature is supported, false otherwise.
3187
+	 * @return boolean Whether the database feature is supported, false otherwise.
3190 3188
 	 */
3191 3189
 	public function has_cap( $db_cap ) {
3192 3190
 		$version = $this->db_version();
@@ -3242,7 +3240,7 @@  discard block
 block discarded – undo
3242 3240
 	 *
3243 3241
 	 * @since 2.7.0
3244 3242
 	 *
3245
-	 * @return null|string Null on failure, version number on success.
3243
+	 * @return string Null on failure, version number on success.
3246 3244
 	 */
3247 3245
 	public function db_version() {
3248 3246
 		if ( $this->use_mysqli ) {
Please login to merge, or discard this patch.
Spacing   +628 added lines, -628 removed lines patch added patch discarded remove patch
@@ -12,28 +12,28 @@  discard block
 block discarded – undo
12 12
 /**
13 13
  * @since 0.71
14 14
  */
15
-define( 'EZSQL_VERSION', 'WP1.25' );
15
+define('EZSQL_VERSION', 'WP1.25');
16 16
 
17 17
 /**
18 18
  * @since 0.71
19 19
  */
20
-define( 'OBJECT', 'OBJECT' );
21
-define( 'object', 'OBJECT' ); // Back compat.
20
+define('OBJECT', 'OBJECT');
21
+define('object', 'OBJECT'); // Back compat.
22 22
 
23 23
 /**
24 24
  * @since 2.5.0
25 25
  */
26
-define( 'OBJECT_K', 'OBJECT_K' );
26
+define('OBJECT_K', 'OBJECT_K');
27 27
 
28 28
 /**
29 29
  * @since 0.71
30 30
  */
31
-define( 'ARRAY_A', 'ARRAY_A' );
31
+define('ARRAY_A', 'ARRAY_A');
32 32
 
33 33
 /**
34 34
  * @since 0.71
35 35
  */
36
-define( 'ARRAY_N', 'ARRAY_N' );
36
+define('ARRAY_N', 'ARRAY_N');
37 37
 
38 38
 /**
39 39
  * WordPress Database Access Abstraction Object
@@ -265,8 +265,8 @@  discard block
 block discarded – undo
265 265
 	 * @see wpdb::tables()
266 266
 	 * @var array
267 267
 	 */
268
-	var $tables = array( 'posts', 'comments', 'links', 'options', 'postmeta',
269
-		'terms', 'term_taxonomy', 'term_relationships', 'termmeta', 'commentmeta' );
268
+	var $tables = array('posts', 'comments', 'links', 'options', 'postmeta',
269
+		'terms', 'term_taxonomy', 'term_relationships', 'termmeta', 'commentmeta');
270 270
 
271 271
 	/**
272 272
 	 * List of deprecated WordPress tables
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	 * @see wpdb::tables()
279 279
 	 * @var array
280 280
 	 */
281
-	var $old_tables = array( 'categories', 'post2cat', 'link2cat' );
281
+	var $old_tables = array('categories', 'post2cat', 'link2cat');
282 282
 
283 283
 	/**
284 284
 	 * List of WordPress global tables
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 	 * @see wpdb::tables()
289 289
 	 * @var array
290 290
 	 */
291
-	var $global_tables = array( 'users', 'usermeta' );
291
+	var $global_tables = array('users', 'usermeta');
292 292
 
293 293
 	/**
294 294
 	 * List of Multisite global tables
@@ -298,8 +298,8 @@  discard block
 block discarded – undo
298 298
 	 * @see wpdb::tables()
299 299
 	 * @var array
300 300
 	 */
301
-	var $ms_global_tables = array( 'blogs', 'signups', 'site', 'sitemeta',
302
-		'sitecategories', 'registration_log', 'blog_versions' );
301
+	var $ms_global_tables = array('blogs', 'signups', 'site', 'sitemeta',
302
+		'sitecategories', 'registration_log', 'blog_versions');
303 303
 
304 304
 	/**
305 305
 	 * WordPress Comments table
@@ -585,8 +585,8 @@  discard block
 block discarded – undo
585 585
 	 * @access protected
586 586
 	 * @var array
587 587
 	 */
588
-	protected $incompatible_modes = array( 'NO_ZERO_DATE', 'ONLY_FULL_GROUP_BY',
589
-		'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'TRADITIONAL' );
588
+	protected $incompatible_modes = array('NO_ZERO_DATE', 'ONLY_FULL_GROUP_BY',
589
+		'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'TRADITIONAL');
590 590
 
591 591
 	/**
592 592
 	 * Whether to use mysqli over mysql.
@@ -623,10 +623,10 @@  discard block
 block discarded – undo
623 623
 	 * @param string $dbname     MySQL database name
624 624
 	 * @param string $dbhost     MySQL database host
625 625
 	 */
626
-	public function __construct( $dbuser, $dbpassword, $dbname, $dbhost ) {
627
-		register_shutdown_function( array( $this, '__destruct' ) );
626
+	public function __construct($dbuser, $dbpassword, $dbname, $dbhost) {
627
+		register_shutdown_function(array($this, '__destruct'));
628 628
 
629
-		if ( WP_DEBUG && WP_DEBUG_DISPLAY )
629
+		if (WP_DEBUG && WP_DEBUG_DISPLAY)
630 630
 			$this->show_errors();
631 631
 
632 632
 		/* Use ext/mysqli if it exists and:
@@ -635,12 +635,12 @@  discard block
 block discarded – undo
635 635
 		 *  - We are running PHP 5.5 or greater, or
636 636
 		 *  - ext/mysql is not loaded.
637 637
 		 */
638
-		if ( function_exists( 'mysqli_connect' ) ) {
639
-			if ( defined( 'WP_USE_EXT_MYSQL' ) ) {
638
+		if (function_exists('mysqli_connect')) {
639
+			if (defined('WP_USE_EXT_MYSQL')) {
640 640
 				$this->use_mysqli = ! WP_USE_EXT_MYSQL;
641
-			} elseif ( version_compare( phpversion(), '5.5', '>=' ) || ! function_exists( 'mysql_connect' ) ) {
641
+			} elseif (version_compare(phpversion(), '5.5', '>=') || ! function_exists('mysql_connect')) {
642 642
 				$this->use_mysqli = true;
643
-			} elseif ( false !== strpos( $GLOBALS['wp_version'], '-' ) ) {
643
+			} elseif (false !== strpos($GLOBALS['wp_version'], '-')) {
644 644
 				$this->use_mysqli = true;
645 645
 			}
646 646
 		}
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
 		$this->dbhost = $dbhost;
652 652
 
653 653
 		// wp-config.php creation will manually connect when ready.
654
-		if ( defined( 'WP_SETUP_CONFIG' ) ) {
654
+		if (defined('WP_SETUP_CONFIG')) {
655 655
 			return;
656 656
 		}
657 657
 
@@ -677,8 +677,8 @@  discard block
 block discarded – undo
677 677
 	 * @param string $name The private member to get, and optionally process
678 678
 	 * @return mixed The private member
679 679
 	 */
680
-	public function __get( $name ) {
681
-		if ( 'col_info' === $name )
680
+	public function __get($name) {
681
+		if ('col_info' === $name)
682 682
 			$this->load_col_info();
683 683
 
684 684
 		return $this->$name;
@@ -692,13 +692,13 @@  discard block
 block discarded – undo
692 692
 	 * @param string $name  The private member to set
693 693
 	 * @param mixed  $value The value to set
694 694
 	 */
695
-	public function __set( $name, $value ) {
695
+	public function __set($name, $value) {
696 696
 		$protected_members = array(
697 697
 			'col_meta',
698 698
 			'table_charset',
699 699
 			'check_current_query',
700 700
 		);
701
-		if (  in_array( $name, $protected_members, true ) ) {
701
+		if (in_array($name, $protected_members, true)) {
702 702
 			return;
703 703
 		}
704 704
 		$this->$name = $value;
@@ -713,8 +713,8 @@  discard block
 block discarded – undo
713 713
 	 *
714 714
 	 * @return bool If the member is set or not
715 715
 	 */
716
-	public function __isset( $name ) {
717
-		return isset( $this->$name );
716
+	public function __isset($name) {
717
+		return isset($this->$name);
718 718
 	}
719 719
 
720 720
 	/**
@@ -724,8 +724,8 @@  discard block
 block discarded – undo
724 724
 	 *
725 725
 	 * @param string $name  The private member to unset
726 726
 	 */
727
-	public function __unset( $name ) {
728
-		unset( $this->$name );
727
+	public function __unset($name) {
728
+		unset($this->$name);
729 729
 	}
730 730
 
731 731
 	/**
@@ -734,30 +734,30 @@  discard block
 block discarded – undo
734 734
 	 * @since 3.1.0
735 735
 	 */
736 736
 	public function init_charset() {
737
-		if ( function_exists('is_multisite') && is_multisite() ) {
737
+		if (function_exists('is_multisite') && is_multisite()) {
738 738
 			$this->charset = 'utf8';
739
-			if ( defined( 'DB_COLLATE' ) && DB_COLLATE ) {
739
+			if (defined('DB_COLLATE') && DB_COLLATE) {
740 740
 				$this->collate = DB_COLLATE;
741 741
 			} else {
742 742
 				$this->collate = 'utf8_general_ci';
743 743
 			}
744
-		} elseif ( defined( 'DB_COLLATE' ) ) {
744
+		} elseif (defined('DB_COLLATE')) {
745 745
 			$this->collate = DB_COLLATE;
746 746
 		}
747 747
 
748
-		if ( defined( 'DB_CHARSET' ) ) {
748
+		if (defined('DB_CHARSET')) {
749 749
 			$this->charset = DB_CHARSET;
750 750
 		}
751 751
 
752
-		if ( ( $this->use_mysqli && ! ( $this->dbh instanceof mysqli ) ) || empty( $this->dbh ) ) {
752
+		if (($this->use_mysqli && ! ($this->dbh instanceof mysqli)) || empty($this->dbh)) {
753 753
 			return;
754 754
 		}
755 755
 
756
-		if ( 'utf8' === $this->charset && $this->has_cap( 'utf8mb4' ) ) {
756
+		if ('utf8' === $this->charset && $this->has_cap('utf8mb4')) {
757 757
 			$this->charset = 'utf8mb4';
758 758
 		}
759 759
 
760
-		if ( 'utf8mb4' === $this->charset && ( ! $this->collate || stripos( $this->collate, 'utf8_' ) === 0 ) ) {
760
+		if ('utf8mb4' === $this->charset && ( ! $this->collate || stripos($this->collate, 'utf8_') === 0)) {
761 761
 			$this->collate = 'utf8mb4_unicode_ci';
762 762
 		}
763 763
 	}
@@ -771,29 +771,29 @@  discard block
 block discarded – undo
771 771
 	 * @param string   $charset Optional. The character set. Default null.
772 772
 	 * @param string   $collate Optional. The collation. Default null.
773 773
 	 */
774
-	public function set_charset( $dbh, $charset = null, $collate = null ) {
775
-		if ( ! isset( $charset ) )
774
+	public function set_charset($dbh, $charset = null, $collate = null) {
775
+		if ( ! isset($charset))
776 776
 			$charset = $this->charset;
777
-		if ( ! isset( $collate ) )
777
+		if ( ! isset($collate))
778 778
 			$collate = $this->collate;
779
-		if ( $this->has_cap( 'collation' ) && ! empty( $charset ) ) {
780
-			if ( $this->use_mysqli ) {
781
-				if ( function_exists( 'mysqli_set_charset' ) && $this->has_cap( 'set_charset' ) ) {
782
-					mysqli_set_charset( $dbh, $charset );
779
+		if ($this->has_cap('collation') && ! empty($charset)) {
780
+			if ($this->use_mysqli) {
781
+				if (function_exists('mysqli_set_charset') && $this->has_cap('set_charset')) {
782
+					mysqli_set_charset($dbh, $charset);
783 783
 				} else {
784
-					$query = $this->prepare( 'SET NAMES %s', $charset );
785
-					if ( ! empty( $collate ) )
786
-						$query .= $this->prepare( ' COLLATE %s', $collate );
787
-					mysqli_query( $dbh, $query );
784
+					$query = $this->prepare('SET NAMES %s', $charset);
785
+					if ( ! empty($collate))
786
+						$query .= $this->prepare(' COLLATE %s', $collate);
787
+					mysqli_query($dbh, $query);
788 788
 				}
789 789
 			} else {
790
-				if ( function_exists( 'mysql_set_charset' ) && $this->has_cap( 'set_charset' ) ) {
791
-					mysql_set_charset( $charset, $dbh );
790
+				if (function_exists('mysql_set_charset') && $this->has_cap('set_charset')) {
791
+					mysql_set_charset($charset, $dbh);
792 792
 				} else {
793
-					$query = $this->prepare( 'SET NAMES %s', $charset );
794
-					if ( ! empty( $collate ) )
795
-						$query .= $this->prepare( ' COLLATE %s', $collate );
796
-					mysql_query( $query, $dbh );
793
+					$query = $this->prepare('SET NAMES %s', $charset);
794
+					if ( ! empty($collate))
795
+						$query .= $this->prepare(' COLLATE %s', $collate);
796
+					mysql_query($query, $dbh);
797 797
 				}
798 798
 			}
799 799
 		}
@@ -809,36 +809,36 @@  discard block
 block discarded – undo
809 809
 	 *
810 810
 	 * @param array $modes Optional. A list of SQL modes to set.
811 811
 	 */
812
-	public function set_sql_mode( $modes = array() ) {
813
-		if ( empty( $modes ) ) {
814
-			if ( $this->use_mysqli ) {
815
-				$res = mysqli_query( $this->dbh, 'SELECT @@SESSION.sql_mode' );
812
+	public function set_sql_mode($modes = array()) {
813
+		if (empty($modes)) {
814
+			if ($this->use_mysqli) {
815
+				$res = mysqli_query($this->dbh, 'SELECT @@SESSION.sql_mode');
816 816
 			} else {
817
-				$res = mysql_query( 'SELECT @@SESSION.sql_mode', $this->dbh );
817
+				$res = mysql_query('SELECT @@SESSION.sql_mode', $this->dbh);
818 818
 			}
819 819
 
820
-			if ( empty( $res ) ) {
820
+			if (empty($res)) {
821 821
 				return;
822 822
 			}
823 823
 
824
-			if ( $this->use_mysqli ) {
825
-				$modes_array = mysqli_fetch_array( $res );
826
-				if ( empty( $modes_array[0] ) ) {
824
+			if ($this->use_mysqli) {
825
+				$modes_array = mysqli_fetch_array($res);
826
+				if (empty($modes_array[0])) {
827 827
 					return;
828 828
 				}
829 829
 				$modes_str = $modes_array[0];
830 830
 			} else {
831
-				$modes_str = mysql_result( $res, 0 );
831
+				$modes_str = mysql_result($res, 0);
832 832
 			}
833 833
 
834
-			if ( empty( $modes_str ) ) {
834
+			if (empty($modes_str)) {
835 835
 				return;
836 836
 			}
837 837
 
838
-			$modes = explode( ',', $modes_str );
838
+			$modes = explode(',', $modes_str);
839 839
 		}
840 840
 
841
-		$modes = array_change_key_case( $modes, CASE_UPPER );
841
+		$modes = array_change_key_case($modes, CASE_UPPER);
842 842
 
843 843
 		/**
844 844
 		 * Filter the list of incompatible SQL modes to exclude.
@@ -847,20 +847,20 @@  discard block
 block discarded – undo
847 847
 		 *
848 848
 		 * @param array $incompatible_modes An array of incompatible modes.
849 849
 		 */
850
-		$incompatible_modes = (array) apply_filters( 'incompatible_sql_modes', $this->incompatible_modes );
850
+		$incompatible_modes = (array) apply_filters('incompatible_sql_modes', $this->incompatible_modes);
851 851
 
852
-		foreach ( $modes as $i => $mode ) {
853
-			if ( in_array( $mode, $incompatible_modes ) ) {
854
-				unset( $modes[ $i ] );
852
+		foreach ($modes as $i => $mode) {
853
+			if (in_array($mode, $incompatible_modes)) {
854
+				unset($modes[$i]);
855 855
 			}
856 856
 		}
857 857
 
858
-		$modes_str = implode( ',', $modes );
858
+		$modes_str = implode(',', $modes);
859 859
 
860
-		if ( $this->use_mysqli ) {
861
-			mysqli_query( $this->dbh, "SET SESSION sql_mode='$modes_str'" );
860
+		if ($this->use_mysqli) {
861
+			mysqli_query($this->dbh, "SET SESSION sql_mode='$modes_str'");
862 862
 		} else {
863
-			mysql_query( "SET SESSION sql_mode='$modes_str'", $this->dbh );
863
+			mysql_query("SET SESSION sql_mode='$modes_str'", $this->dbh);
864 864
 		}
865 865
 	}
866 866
 
@@ -873,31 +873,31 @@  discard block
 block discarded – undo
873 873
 	 * @param bool   $set_table_names Optional. Whether the table names, e.g. wpdb::$posts, should be updated or not.
874 874
 	 * @return string|WP_Error Old prefix or WP_Error on error
875 875
 	 */
876
-	public function set_prefix( $prefix, $set_table_names = true ) {
876
+	public function set_prefix($prefix, $set_table_names = true) {
877 877
 
878
-		if ( preg_match( '|[^a-z0-9_]|i', $prefix ) )
879
-			return new WP_Error('invalid_db_prefix', 'Invalid database prefix' );
878
+		if (preg_match('|[^a-z0-9_]|i', $prefix))
879
+			return new WP_Error('invalid_db_prefix', 'Invalid database prefix');
880 880
 
881 881
 		$old_prefix = is_multisite() ? '' : $prefix;
882 882
 
883
-		if ( isset( $this->base_prefix ) )
883
+		if (isset($this->base_prefix))
884 884
 			$old_prefix = $this->base_prefix;
885 885
 
886 886
 		$this->base_prefix = $prefix;
887 887
 
888
-		if ( $set_table_names ) {
889
-			foreach ( $this->tables( 'global' ) as $table => $prefixed_table )
888
+		if ($set_table_names) {
889
+			foreach ($this->tables('global') as $table => $prefixed_table)
890 890
 				$this->$table = $prefixed_table;
891 891
 
892
-			if ( is_multisite() && empty( $this->blogid ) )
892
+			if (is_multisite() && empty($this->blogid))
893 893
 				return $old_prefix;
894 894
 
895 895
 			$this->prefix = $this->get_blog_prefix();
896 896
 
897
-			foreach ( $this->tables( 'blog' ) as $table => $prefixed_table )
897
+			foreach ($this->tables('blog') as $table => $prefixed_table)
898 898
 				$this->$table = $prefixed_table;
899 899
 
900
-			foreach ( $this->tables( 'old' ) as $table => $prefixed_table )
900
+			foreach ($this->tables('old') as $table => $prefixed_table)
901 901
 				$this->$table = $prefixed_table;
902 902
 		}
903 903
 		return $old_prefix;
@@ -913,8 +913,8 @@  discard block
 block discarded – undo
913 913
 	 * @param int $site_id Optional.
914 914
 	 * @return int previous blog id
915 915
 	 */
916
-	public function set_blog_id( $blog_id, $site_id = 0 ) {
917
-		if ( ! empty( $site_id ) )
916
+	public function set_blog_id($blog_id, $site_id = 0) {
917
+		if ( ! empty($site_id))
918 918
 			$this->siteid = $site_id;
919 919
 
920 920
 		$old_blog_id  = $this->blogid;
@@ -922,10 +922,10 @@  discard block
 block discarded – undo
922 922
 
923 923
 		$this->prefix = $this->get_blog_prefix();
924 924
 
925
-		foreach ( $this->tables( 'blog' ) as $table => $prefixed_table )
925
+		foreach ($this->tables('blog') as $table => $prefixed_table)
926 926
 			$this->$table = $prefixed_table;
927 927
 
928
-		foreach ( $this->tables( 'old' ) as $table => $prefixed_table )
928
+		foreach ($this->tables('old') as $table => $prefixed_table)
929 929
 			$this->$table = $prefixed_table;
930 930
 
931 931
 		return $old_blog_id;
@@ -938,15 +938,15 @@  discard block
 block discarded – undo
938 938
 	 * @param int $blog_id Optional.
939 939
 	 * @return string Blog prefix.
940 940
 	 */
941
-	public function get_blog_prefix( $blog_id = null ) {
942
-		if ( is_multisite() ) {
943
-			if ( null === $blog_id )
941
+	public function get_blog_prefix($blog_id = null) {
942
+		if (is_multisite()) {
943
+			if (null === $blog_id)
944 944
 				$blog_id = $this->blogid;
945 945
 			$blog_id = (int) $blog_id;
946
-			if ( defined( 'MULTISITE' ) && ( 0 == $blog_id || 1 == $blog_id ) )
946
+			if (defined('MULTISITE') && (0 == $blog_id || 1 == $blog_id))
947 947
 				return $this->base_prefix;
948 948
 			else
949
-				return $this->base_prefix . $blog_id . '_';
949
+				return $this->base_prefix.$blog_id.'_';
950 950
 		} else {
951 951
 			return $this->base_prefix;
952 952
 		}
@@ -979,20 +979,20 @@  discard block
 block discarded – undo
979 979
 	 * @param int    $blog_id Optional. The blog_id to prefix. Defaults to wpdb::$blogid. Used only when prefix is requested.
980 980
 	 * @return array Table names. When a prefix is requested, the key is the unprefixed table name.
981 981
 	 */
982
-	public function tables( $scope = 'all', $prefix = true, $blog_id = 0 ) {
983
-		switch ( $scope ) {
982
+	public function tables($scope = 'all', $prefix = true, $blog_id = 0) {
983
+		switch ($scope) {
984 984
 			case 'all' :
985
-				$tables = array_merge( $this->global_tables, $this->tables );
986
-				if ( is_multisite() )
987
-					$tables = array_merge( $tables, $this->ms_global_tables );
985
+				$tables = array_merge($this->global_tables, $this->tables);
986
+				if (is_multisite())
987
+					$tables = array_merge($tables, $this->ms_global_tables);
988 988
 				break;
989 989
 			case 'blog' :
990 990
 				$tables = $this->tables;
991 991
 				break;
992 992
 			case 'global' :
993 993
 				$tables = $this->global_tables;
994
-				if ( is_multisite() )
995
-					$tables = array_merge( $tables, $this->ms_global_tables );
994
+				if (is_multisite())
995
+					$tables = array_merge($tables, $this->ms_global_tables);
996 996
 				break;
997 997
 			case 'ms_global' :
998 998
 				$tables = $this->ms_global_tables;
@@ -1004,24 +1004,24 @@  discard block
 block discarded – undo
1004 1004
 				return array();
1005 1005
 		}
1006 1006
 
1007
-		if ( $prefix ) {
1008
-			if ( ! $blog_id )
1007
+		if ($prefix) {
1008
+			if ( ! $blog_id)
1009 1009
 				$blog_id = $this->blogid;
1010
-			$blog_prefix = $this->get_blog_prefix( $blog_id );
1010
+			$blog_prefix = $this->get_blog_prefix($blog_id);
1011 1011
 			$base_prefix = $this->base_prefix;
1012
-			$global_tables = array_merge( $this->global_tables, $this->ms_global_tables );
1013
-			foreach ( $tables as $k => $table ) {
1014
-				if ( in_array( $table, $global_tables ) )
1015
-					$tables[ $table ] = $base_prefix . $table;
1012
+			$global_tables = array_merge($this->global_tables, $this->ms_global_tables);
1013
+			foreach ($tables as $k => $table) {
1014
+				if (in_array($table, $global_tables))
1015
+					$tables[$table] = $base_prefix.$table;
1016 1016
 				else
1017
-					$tables[ $table ] = $blog_prefix . $table;
1018
-				unset( $tables[ $k ] );
1017
+					$tables[$table] = $blog_prefix.$table;
1018
+				unset($tables[$k]);
1019 1019
 			}
1020 1020
 
1021
-			if ( isset( $tables['users'] ) && defined( 'CUSTOM_USER_TABLE' ) )
1021
+			if (isset($tables['users']) && defined('CUSTOM_USER_TABLE'))
1022 1022
 				$tables['users'] = CUSTOM_USER_TABLE;
1023 1023
 
1024
-			if ( isset( $tables['usermeta'] ) && defined( 'CUSTOM_USER_META_TABLE' ) )
1024
+			if (isset($tables['usermeta']) && defined('CUSTOM_USER_META_TABLE'))
1025 1025
 				$tables['usermeta'] = CUSTOM_USER_META_TABLE;
1026 1026
 		}
1027 1027
 
@@ -1039,53 +1039,53 @@  discard block
 block discarded – undo
1039 1039
 	 * @param string        $db  MySQL database name
1040 1040
 	 * @param resource|null $dbh Optional link identifier.
1041 1041
 	 */
1042
-	public function select( $db, $dbh = null ) {
1043
-		if ( is_null($dbh) )
1042
+	public function select($db, $dbh = null) {
1043
+		if (is_null($dbh))
1044 1044
 			$dbh = $this->dbh;
1045 1045
 
1046
-		if ( $this->use_mysqli ) {
1047
-			$success = mysqli_select_db( $dbh, $db );
1046
+		if ($this->use_mysqli) {
1047
+			$success = mysqli_select_db($dbh, $db);
1048 1048
 		} else {
1049
-			$success = mysql_select_db( $db, $dbh );
1049
+			$success = mysql_select_db($db, $dbh);
1050 1050
 		}
1051
-		if ( ! $success ) {
1051
+		if ( ! $success) {
1052 1052
 			$this->ready = false;
1053
-			if ( ! did_action( 'template_redirect' ) ) {
1053
+			if ( ! did_action('template_redirect')) {
1054 1054
 				wp_load_translations_early();
1055 1055
 
1056
-				$message = '<h1>' . __( 'Can&#8217;t select database' ) . "</h1>\n";
1056
+				$message = '<h1>'.__('Can&#8217;t select database')."</h1>\n";
1057 1057
 
1058
-				$message .= '<p>' . sprintf(
1058
+				$message .= '<p>'.sprintf(
1059 1059
 					/* translators: %s: database name */
1060
-					__( 'We were able to connect to the database server (which means your username and password is okay) but not able to select the %s database.' ),
1061
-					'<code>' . htmlspecialchars( $db, ENT_QUOTES ) . '</code>'
1062
-				) . "</p>\n";
1060
+					__('We were able to connect to the database server (which means your username and password is okay) but not able to select the %s database.'),
1061
+					'<code>'.htmlspecialchars($db, ENT_QUOTES).'</code>'
1062
+				)."</p>\n";
1063 1063
 
1064 1064
 				$message .= "<ul>\n";
1065
-				$message .= '<li>' . __( 'Are you sure it exists?' ) . "</li>\n";
1065
+				$message .= '<li>'.__('Are you sure it exists?')."</li>\n";
1066 1066
 
1067
-				$message .= '<li>' . sprintf(
1067
+				$message .= '<li>'.sprintf(
1068 1068
 					/* translators: 1: database user, 2: database name */
1069
-					__( 'Does the user %1$s have permission to use the %2$s database?' ),
1070
-					'<code>' . htmlspecialchars( $this->dbuser, ENT_QUOTES )  . '</code>',
1071
-					'<code>' . htmlspecialchars( $db, ENT_QUOTES ) . '</code>'
1072
-				) . "</li>\n";
1069
+					__('Does the user %1$s have permission to use the %2$s database?'),
1070
+					'<code>'.htmlspecialchars($this->dbuser, ENT_QUOTES).'</code>',
1071
+					'<code>'.htmlspecialchars($db, ENT_QUOTES).'</code>'
1072
+				)."</li>\n";
1073 1073
 
1074
-				$message .= '<li>' . sprintf(
1074
+				$message .= '<li>'.sprintf(
1075 1075
 					/* translators: %s: database name */
1076
-					__( 'On some systems the name of your database is prefixed with your username, so it would be like <code>username_%1$s</code>. Could that be the problem?' ),
1077
-					htmlspecialchars( $db, ENT_QUOTES )
1078
-				). "</li>\n";
1076
+					__('On some systems the name of your database is prefixed with your username, so it would be like <code>username_%1$s</code>. Could that be the problem?'),
1077
+					htmlspecialchars($db, ENT_QUOTES)
1078
+				)."</li>\n";
1079 1079
 
1080 1080
 				$message .= "</ul>\n";
1081 1081
 
1082
-				$message .= '<p>' . sprintf(
1082
+				$message .= '<p>'.sprintf(
1083 1083
 					/* translators: %s: support forums URL */
1084
-					__( 'If you don&#8217;t know how to set up a database you should <strong>contact your host</strong>. If all else fails you may find help at the <a href="%s">WordPress Support Forums</a>.' ),
1085
-					__( 'https://wordpress.org/support/' )
1086
-				) . "</p>\n";
1084
+					__('If you don&#8217;t know how to set up a database you should <strong>contact your host</strong>. If all else fails you may find help at the <a href="%s">WordPress Support Forums</a>.'),
1085
+					__('https://wordpress.org/support/')
1086
+				)."</p>\n";
1087 1087
 
1088
-				$this->bail( $message, 'db_select_fail' );
1088
+				$this->bail($message, 'db_select_fail');
1089 1089
 			}
1090 1090
 		}
1091 1091
 	}
@@ -1104,10 +1104,10 @@  discard block
 block discarded – undo
1104 1104
 	 * @param string $string
1105 1105
 	 * @return string
1106 1106
 	 */
1107
-	function _weak_escape( $string ) {
1108
-		if ( func_num_args() === 1 && function_exists( '_deprecated_function' ) )
1109
-			_deprecated_function( __METHOD__, '3.6', 'wpdb::prepare() or esc_sql()' );
1110
-		return addslashes( $string );
1107
+	function _weak_escape($string) {
1108
+		if (func_num_args() === 1 && function_exists('_deprecated_function'))
1109
+			_deprecated_function(__METHOD__, '3.6', 'wpdb::prepare() or esc_sql()');
1110
+		return addslashes($string);
1111 1111
 	}
1112 1112
 
1113 1113
 	/**
@@ -1121,23 +1121,23 @@  discard block
 block discarded – undo
1121 1121
 	 * @param  string $string to escape
1122 1122
 	 * @return string escaped
1123 1123
 	 */
1124
-	function _real_escape( $string ) {
1125
-		if ( $this->dbh ) {
1126
-			if ( $this->use_mysqli ) {
1127
-				return mysqli_real_escape_string( $this->dbh, $string );
1124
+	function _real_escape($string) {
1125
+		if ($this->dbh) {
1126
+			if ($this->use_mysqli) {
1127
+				return mysqli_real_escape_string($this->dbh, $string);
1128 1128
 			} else {
1129
-				return mysql_real_escape_string( $string, $this->dbh );
1129
+				return mysql_real_escape_string($string, $this->dbh);
1130 1130
 			}
1131 1131
 		}
1132 1132
 
1133
-		$class = get_class( $this );
1134
-		if ( function_exists( '__' ) ) {
1133
+		$class = get_class($this);
1134
+		if (function_exists('__')) {
1135 1135
 			/* translators: %s: database access abstraction class, usually wpdb or a class extending wpdb */
1136
-			_doing_it_wrong( $class, sprintf( __( '%s must set a database connection for use with escaping.' ), $class ), E_USER_NOTICE );
1136
+			_doing_it_wrong($class, sprintf(__('%s must set a database connection for use with escaping.'), $class), E_USER_NOTICE);
1137 1137
 		} else {
1138
-			_doing_it_wrong( $class, sprintf( '%s must set a database connection for use with escaping.', $class ), E_USER_NOTICE );
1138
+			_doing_it_wrong($class, sprintf('%s must set a database connection for use with escaping.', $class), E_USER_NOTICE);
1139 1139
 		}
1140
-		return addslashes( $string );
1140
+		return addslashes($string);
1141 1141
 	}
1142 1142
 
1143 1143
 	/**
@@ -1150,16 +1150,16 @@  discard block
 block discarded – undo
1150 1150
 	 * @param  string|array $data
1151 1151
 	 * @return string|array escaped
1152 1152
 	 */
1153
-	function _escape( $data ) {
1154
-		if ( is_array( $data ) ) {
1155
-			foreach ( $data as $k => $v ) {
1156
-				if ( is_array($v) )
1157
-					$data[$k] = $this->_escape( $v );
1153
+	function _escape($data) {
1154
+		if (is_array($data)) {
1155
+			foreach ($data as $k => $v) {
1156
+				if (is_array($v))
1157
+					$data[$k] = $this->_escape($v);
1158 1158
 				else
1159
-					$data[$k] = $this->_real_escape( $v );
1159
+					$data[$k] = $this->_real_escape($v);
1160 1160
 			}
1161 1161
 		} else {
1162
-			$data = $this->_real_escape( $data );
1162
+			$data = $this->_real_escape($data);
1163 1163
 		}
1164 1164
 
1165 1165
 		return $data;
@@ -1178,18 +1178,18 @@  discard block
 block discarded – undo
1178 1178
 	 * @param mixed $data
1179 1179
 	 * @return mixed
1180 1180
 	 */
1181
-	public function escape( $data ) {
1182
-		if ( func_num_args() === 1 && function_exists( '_deprecated_function' ) )
1183
-			_deprecated_function( __METHOD__, '3.6', 'wpdb::prepare() or esc_sql()' );
1184
-		if ( is_array( $data ) ) {
1185
-			foreach ( $data as $k => $v ) {
1186
-				if ( is_array( $v ) )
1187
-					$data[$k] = $this->escape( $v, 'recursive' );
1181
+	public function escape($data) {
1182
+		if (func_num_args() === 1 && function_exists('_deprecated_function'))
1183
+			_deprecated_function(__METHOD__, '3.6', 'wpdb::prepare() or esc_sql()');
1184
+		if (is_array($data)) {
1185
+			foreach ($data as $k => $v) {
1186
+				if (is_array($v))
1187
+					$data[$k] = $this->escape($v, 'recursive');
1188 1188
 				else
1189
-					$data[$k] = $this->_weak_escape( $v, 'internal' );
1189
+					$data[$k] = $this->_weak_escape($v, 'internal');
1190 1190
 			}
1191 1191
 		} else {
1192
-			$data = $this->_weak_escape( $data, 'internal' );
1192
+			$data = $this->_weak_escape($data, 'internal');
1193 1193
 		}
1194 1194
 
1195 1195
 		return $data;
@@ -1204,9 +1204,9 @@  discard block
 block discarded – undo
1204 1204
 	 *
1205 1205
 	 * @param string $string to escape
1206 1206
 	 */
1207
-	public function escape_by_ref( &$string ) {
1208
-		if ( ! is_float( $string ) )
1209
-			$string = $this->_real_escape( $string );
1207
+	public function escape_by_ref(&$string) {
1208
+		if ( ! is_float($string))
1209
+			$string = $this->_real_escape($string);
1210 1210
 	}
1211 1211
 
1212 1212
 	/**
@@ -1243,26 +1243,26 @@  discard block
 block discarded – undo
1243 1243
 	 *                              {@link http://php.net/sprintf sprintf()}.
1244 1244
 	 * @return string|void Sanitized query string, if there is a query to prepare.
1245 1245
 	 */
1246
-	public function prepare( $query, $args ) {
1247
-		if ( is_null( $query ) )
1246
+	public function prepare($query, $args) {
1247
+		if (is_null($query))
1248 1248
 			return;
1249 1249
 
1250 1250
 		// This is not meant to be foolproof -- but it will catch obviously incorrect usage.
1251
-		if ( strpos( $query, '%' ) === false ) {
1252
-			_doing_it_wrong( 'wpdb::prepare', sprintf( __( 'The query argument of %s must have a placeholder.' ), 'wpdb::prepare()' ), '3.9' );
1251
+		if (strpos($query, '%') === false) {
1252
+			_doing_it_wrong('wpdb::prepare', sprintf(__('The query argument of %s must have a placeholder.'), 'wpdb::prepare()'), '3.9');
1253 1253
 		}
1254 1254
 
1255 1255
 		$args = func_get_args();
1256
-		array_shift( $args );
1256
+		array_shift($args);
1257 1257
 		// If args were passed as an array (as in vsprintf), move them up
1258
-		if ( isset( $args[0] ) && is_array($args[0]) )
1258
+		if (isset($args[0]) && is_array($args[0]))
1259 1259
 			$args = $args[0];
1260
-		$query = str_replace( "'%s'", '%s', $query ); // in case someone mistakenly already singlequoted it
1261
-		$query = str_replace( '"%s"', '%s', $query ); // doublequote unquoting
1262
-		$query = preg_replace( '|(?<!%)%f|' , '%F', $query ); // Force floats to be locale unaware
1263
-		$query = preg_replace( '|(?<!%)%s|', "'%s'", $query ); // quote the strings, avoiding escaped strings like %%s
1264
-		array_walk( $args, array( $this, 'escape_by_ref' ) );
1265
-		return @vsprintf( $query, $args );
1260
+		$query = str_replace("'%s'", '%s', $query); // in case someone mistakenly already singlequoted it
1261
+		$query = str_replace('"%s"', '%s', $query); // doublequote unquoting
1262
+		$query = preg_replace('|(?<!%)%f|', '%F', $query); // Force floats to be locale unaware
1263
+		$query = preg_replace('|(?<!%)%s|', "'%s'", $query); // quote the strings, avoiding escaped strings like %%s
1264
+		array_walk($args, array($this, 'escape_by_ref'));
1265
+		return @vsprintf($query, $args);
1266 1266
 	}
1267 1267
 
1268 1268
 	/**
@@ -1287,8 +1287,8 @@  discard block
 block discarded – undo
1287 1287
 	 * @return string Text in the form of a LIKE phrase. The output is not SQL safe. Call $wpdb::prepare()
1288 1288
 	 *                or real_escape next.
1289 1289
 	 */
1290
-	public function esc_like( $text ) {
1291
-		return addcslashes( $text, '_%\\' );
1290
+	public function esc_like($text) {
1291
+		return addcslashes($text, '_%\\');
1292 1292
 	}
1293 1293
 
1294 1294
 	/**
@@ -1300,56 +1300,56 @@  discard block
 block discarded – undo
1300 1300
 	 * @param string $str The error to display
1301 1301
 	 * @return false|void False if the showing of errors is disabled.
1302 1302
 	 */
1303
-	public function print_error( $str = '' ) {
1303
+	public function print_error($str = '') {
1304 1304
 		global $EZSQL_ERROR;
1305 1305
 
1306
-		if ( !$str ) {
1307
-			if ( $this->use_mysqli ) {
1308
-				$str = mysqli_error( $this->dbh );
1306
+		if ( ! $str) {
1307
+			if ($this->use_mysqli) {
1308
+				$str = mysqli_error($this->dbh);
1309 1309
 			} else {
1310
-				$str = mysql_error( $this->dbh );
1310
+				$str = mysql_error($this->dbh);
1311 1311
 			}
1312 1312
 		}
1313
-		$EZSQL_ERROR[] = array( 'query' => $this->last_query, 'error_str' => $str );
1313
+		$EZSQL_ERROR[] = array('query' => $this->last_query, 'error_str' => $str);
1314 1314
 
1315
-		if ( $this->suppress_errors )
1315
+		if ($this->suppress_errors)
1316 1316
 			return false;
1317 1317
 
1318 1318
 		wp_load_translations_early();
1319 1319
 
1320
-		if ( $caller = $this->get_caller() )
1321
-			$error_str = sprintf( __( 'WordPress database error %1$s for query %2$s made by %3$s' ), $str, $this->last_query, $caller );
1320
+		if ($caller = $this->get_caller())
1321
+			$error_str = sprintf(__('WordPress database error %1$s for query %2$s made by %3$s'), $str, $this->last_query, $caller);
1322 1322
 		else
1323
-			$error_str = sprintf( __( 'WordPress database error %1$s for query %2$s' ), $str, $this->last_query );
1323
+			$error_str = sprintf(__('WordPress database error %1$s for query %2$s'), $str, $this->last_query);
1324 1324
 
1325
-		error_log( $error_str );
1325
+		error_log($error_str);
1326 1326
 
1327 1327
 		// Are we showing errors?
1328
-		if ( ! $this->show_errors )
1328
+		if ( ! $this->show_errors)
1329 1329
 			return false;
1330 1330
 
1331 1331
 		// If there is an error then take note of it
1332
-		if ( is_multisite() ) {
1332
+		if (is_multisite()) {
1333 1333
 			$msg = sprintf(
1334 1334
 				"%s [%s]\n%s\n",
1335
-				__( 'WordPress database error:' ),
1335
+				__('WordPress database error:'),
1336 1336
 				$str,
1337 1337
 				$this->last_query
1338 1338
 			);
1339 1339
 
1340
-			if ( defined( 'ERRORLOGFILE' ) ) {
1341
-				error_log( $msg, 3, ERRORLOGFILE );
1340
+			if (defined('ERRORLOGFILE')) {
1341
+				error_log($msg, 3, ERRORLOGFILE);
1342 1342
 			}
1343
-			if ( defined( 'DIEONDBERROR' ) ) {
1344
-				wp_die( $msg );
1343
+			if (defined('DIEONDBERROR')) {
1344
+				wp_die($msg);
1345 1345
 			}
1346 1346
 		} else {
1347
-			$str   = htmlspecialchars( $str, ENT_QUOTES );
1348
-			$query = htmlspecialchars( $this->last_query, ENT_QUOTES );
1347
+			$str   = htmlspecialchars($str, ENT_QUOTES);
1348
+			$query = htmlspecialchars($this->last_query, ENT_QUOTES);
1349 1349
 
1350 1350
 			printf(
1351 1351
 				'<div id="error"><p class="wpdberror"><strong>%s</strong> [%s]<br /><code>%s</code></p></div>',
1352
-				__( 'WordPress database error:' ),
1352
+				__('WordPress database error:'),
1353 1353
 				$str,
1354 1354
 				$query
1355 1355
 			);
@@ -1370,7 +1370,7 @@  discard block
 block discarded – undo
1370 1370
 	 * @param bool $show Whether to show or hide errors
1371 1371
 	 * @return bool Old value for showing errors.
1372 1372
 	 */
1373
-	public function show_errors( $show = true ) {
1373
+	public function show_errors($show = true) {
1374 1374
 		$errors = $this->show_errors;
1375 1375
 		$this->show_errors = $show;
1376 1376
 		return $errors;
@@ -1403,7 +1403,7 @@  discard block
 block discarded – undo
1403 1403
 	 * @param bool $suppress Optional. New value. Defaults to true.
1404 1404
 	 * @return bool Old value
1405 1405
 	 */
1406
-	public function suppress_errors( $suppress = true ) {
1406
+	public function suppress_errors($suppress = true) {
1407 1407
 		$errors = $this->suppress_errors;
1408 1408
 		$this->suppress_errors = (bool) $suppress;
1409 1409
 		return $errors;
@@ -1421,21 +1421,21 @@  discard block
 block discarded – undo
1421 1421
 		$this->rows_affected = $this->num_rows = 0;
1422 1422
 		$this->last_error  = '';
1423 1423
 
1424
-		if ( $this->use_mysqli && $this->result instanceof mysqli_result ) {
1425
-			mysqli_free_result( $this->result );
1424
+		if ($this->use_mysqli && $this->result instanceof mysqli_result) {
1425
+			mysqli_free_result($this->result);
1426 1426
 			$this->result = null;
1427 1427
 
1428 1428
 			// Sanity check before using the handle
1429
-			if ( empty( $this->dbh ) || !( $this->dbh instanceof mysqli ) ) {
1429
+			if (empty($this->dbh) || ! ($this->dbh instanceof mysqli)) {
1430 1430
 				return;
1431 1431
 			}
1432 1432
 
1433 1433
 			// Clear out any results from a multi-query
1434
-			while ( mysqli_more_results( $this->dbh ) ) {
1435
-				mysqli_next_result( $this->dbh );
1434
+			while (mysqli_more_results($this->dbh)) {
1435
+				mysqli_next_result($this->dbh);
1436 1436
 			}
1437
-		} elseif ( is_resource( $this->result ) ) {
1438
-			mysql_free_result( $this->result );
1437
+		} elseif (is_resource($this->result)) {
1438
+			mysql_free_result($this->result);
1439 1439
 		}
1440 1440
 	}
1441 1441
 
@@ -1451,17 +1451,17 @@  discard block
 block discarded – undo
1451 1451
 	 * @param bool $allow_bail Optional. Allows the function to bail. Default true.
1452 1452
 	 * @return bool True with a successful connection, false on failure.
1453 1453
 	 */
1454
-	public function db_connect( $allow_bail = true ) {
1454
+	public function db_connect($allow_bail = true) {
1455 1455
 		$this->is_mysql = true;
1456 1456
 
1457 1457
 		/*
1458 1458
 		 * Deprecated in 3.9+ when using MySQLi. No equivalent
1459 1459
 		 * $new_link parameter exists for mysqli_* functions.
1460 1460
 		 */
1461
-		$new_link = defined( 'MYSQL_NEW_LINK' ) ? MYSQL_NEW_LINK : true;
1462
-		$client_flags = defined( 'MYSQL_CLIENT_FLAGS' ) ? MYSQL_CLIENT_FLAGS : 0;
1461
+		$new_link = defined('MYSQL_NEW_LINK') ? MYSQL_NEW_LINK : true;
1462
+		$client_flags = defined('MYSQL_CLIENT_FLAGS') ? MYSQL_CLIENT_FLAGS : 0;
1463 1463
 
1464
-		if ( $this->use_mysqli ) {
1464
+		if ($this->use_mysqli) {
1465 1465
 			$this->dbh = mysqli_init();
1466 1466
 
1467 1467
 			// mysqli_real_connect doesn't support the host param including a port or socket
@@ -1469,24 +1469,24 @@  discard block
 block discarded – undo
1469 1469
 			$port = null;
1470 1470
 			$socket = null;
1471 1471
 			$host = $this->dbhost;
1472
-			$port_or_socket = strstr( $host, ':' );
1473
-			if ( ! empty( $port_or_socket ) ) {
1474
-				$host = substr( $host, 0, strpos( $host, ':' ) );
1475
-				$port_or_socket = substr( $port_or_socket, 1 );
1476
-				if ( 0 !== strpos( $port_or_socket, '/' ) ) {
1477
-					$port = intval( $port_or_socket );
1478
-					$maybe_socket = strstr( $port_or_socket, ':' );
1479
-					if ( ! empty( $maybe_socket ) ) {
1480
-						$socket = substr( $maybe_socket, 1 );
1472
+			$port_or_socket = strstr($host, ':');
1473
+			if ( ! empty($port_or_socket)) {
1474
+				$host = substr($host, 0, strpos($host, ':'));
1475
+				$port_or_socket = substr($port_or_socket, 1);
1476
+				if (0 !== strpos($port_or_socket, '/')) {
1477
+					$port = intval($port_or_socket);
1478
+					$maybe_socket = strstr($port_or_socket, ':');
1479
+					if ( ! empty($maybe_socket)) {
1480
+						$socket = substr($maybe_socket, 1);
1481 1481
 					}
1482 1482
 				} else {
1483 1483
 					$socket = $port_or_socket;
1484 1484
 				}
1485 1485
 			}
1486 1486
 
1487
-			mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
1487
+			mysqli_real_connect($this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags);
1488 1488
 
1489
-			if ( $this->dbh->connect_errno ) {
1489
+			if ($this->dbh->connect_errno) {
1490 1490
 				$this->dbh = null;
1491 1491
 
1492 1492
 				/* It's possible ext/mysqli is misconfigured. Fall back to ext/mysql if:
@@ -1496,68 +1496,68 @@  discard block
 block discarded – undo
1496 1496
 		 		 */
1497 1497
 				$attempt_fallback = true;
1498 1498
 
1499
-				if ( $this->has_connected ) {
1499
+				if ($this->has_connected) {
1500 1500
 					$attempt_fallback = false;
1501
-				} elseif ( defined( 'WP_USE_EXT_MYSQL' ) && ! WP_USE_EXT_MYSQL ) {
1501
+				} elseif (defined('WP_USE_EXT_MYSQL') && ! WP_USE_EXT_MYSQL) {
1502 1502
 					$attempt_fallback = false;
1503
-				} elseif ( ! function_exists( 'mysql_connect' ) ) {
1503
+				} elseif ( ! function_exists('mysql_connect')) {
1504 1504
 					$attempt_fallback = false;
1505 1505
 				}
1506 1506
 
1507
-				if ( $attempt_fallback ) {
1507
+				if ($attempt_fallback) {
1508 1508
 					$this->use_mysqli = false;
1509
-					return $this->db_connect( $allow_bail );
1509
+					return $this->db_connect($allow_bail);
1510 1510
 				}
1511 1511
 			}
1512 1512
 		} else {
1513
-			$this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags );
1513
+			$this->dbh = mysql_connect($this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags);
1514 1514
 		}
1515 1515
 
1516
-		if ( ! $this->dbh && $allow_bail ) {
1516
+		if ( ! $this->dbh && $allow_bail) {
1517 1517
 			wp_load_translations_early();
1518 1518
 
1519 1519
 			// Load custom DB error template, if present.
1520
-			if ( file_exists( WP_CONTENT_DIR . '/db-error.php' ) ) {
1521
-				require_once( WP_CONTENT_DIR . '/db-error.php' );
1520
+			if (file_exists(WP_CONTENT_DIR.'/db-error.php')) {
1521
+				require_once(WP_CONTENT_DIR.'/db-error.php');
1522 1522
 				die();
1523 1523
 			}
1524 1524
 
1525
-			$message = '<h1>' . __( 'Error establishing a database connection' ) . "</h1>\n";
1525
+			$message = '<h1>'.__('Error establishing a database connection')."</h1>\n";
1526 1526
 
1527
-			$message .= '<p>' . sprintf(
1527
+			$message .= '<p>'.sprintf(
1528 1528
 				/* translators: 1: wp-config.php. 2: database host */
1529
-				__( 'This either means that the username and password information in your %1$s file is incorrect or we can&#8217;t contact the database server at %2$s. This could mean your host&#8217;s database server is down.' ),
1529
+				__('This either means that the username and password information in your %1$s file is incorrect or we can&#8217;t contact the database server at %2$s. This could mean your host&#8217;s database server is down.'),
1530 1530
 				'<code>wp-config.php</code>',
1531
-				'<code>' . htmlspecialchars( $this->dbhost, ENT_QUOTES ) . '</code>'
1532
-			) . "</p>\n";
1531
+				'<code>'.htmlspecialchars($this->dbhost, ENT_QUOTES).'</code>'
1532
+			)."</p>\n";
1533 1533
 
1534 1534
 			$message .= "<ul>\n";
1535
-			$message .= '<li>' . __( 'Are you sure you have the correct username and password?' ) . "</li>\n";
1536
-			$message .= '<li>' . __( 'Are you sure that you have typed the correct hostname?' ) . "</li>\n";
1537
-			$message .= '<li>' . __( 'Are you sure that the database server is running?' ) . "</li>\n";
1535
+			$message .= '<li>'.__('Are you sure you have the correct username and password?')."</li>\n";
1536
+			$message .= '<li>'.__('Are you sure that you have typed the correct hostname?')."</li>\n";
1537
+			$message .= '<li>'.__('Are you sure that the database server is running?')."</li>\n";
1538 1538
 			$message .= "</ul>\n";
1539 1539
 
1540
-			$message .= '<p>' . sprintf(
1540
+			$message .= '<p>'.sprintf(
1541 1541
 				/* translators: %s: support forums URL */
1542
-				__( 'If you&#8217;re unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href="%s">WordPress Support Forums</a>.' ),
1543
-				__( 'https://wordpress.org/support/' )
1544
-			) . "</p>\n";
1542
+				__('If you&#8217;re unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href="%s">WordPress Support Forums</a>.'),
1543
+				__('https://wordpress.org/support/')
1544
+			)."</p>\n";
1545 1545
 
1546
-			$this->bail( $message, 'db_connect_fail' );
1546
+			$this->bail($message, 'db_connect_fail');
1547 1547
 
1548 1548
 			return false;
1549
-		} elseif ( $this->dbh ) {
1550
-			if ( ! $this->has_connected ) {
1549
+		} elseif ($this->dbh) {
1550
+			if ( ! $this->has_connected) {
1551 1551
 				$this->init_charset();
1552 1552
 			}
1553 1553
 
1554 1554
 			$this->has_connected = true;
1555 1555
 
1556
-			$this->set_charset( $this->dbh );
1556
+			$this->set_charset($this->dbh);
1557 1557
 
1558 1558
 			$this->ready = true;
1559 1559
 			$this->set_sql_mode();
1560
-			$this->select( $this->dbname, $this->dbh );
1560
+			$this->select($this->dbname, $this->dbh);
1561 1561
 
1562 1562
 			return true;
1563 1563
 		}
@@ -1579,13 +1579,13 @@  discard block
 block discarded – undo
1579 1579
 	 * @param bool $allow_bail Optional. Allows the function to bail. Default true.
1580 1580
 	 * @return bool|void True if the connection is up.
1581 1581
 	 */
1582
-	public function check_connection( $allow_bail = true ) {
1583
-		if ( $this->use_mysqli ) {
1584
-			if ( ! empty( $this->dbh ) && mysqli_ping( $this->dbh ) ) {
1582
+	public function check_connection($allow_bail = true) {
1583
+		if ($this->use_mysqli) {
1584
+			if ( ! empty($this->dbh) && mysqli_ping($this->dbh)) {
1585 1585
 				return true;
1586 1586
 			}
1587 1587
 		} else {
1588
-			if ( ! empty( $this->dbh ) && mysql_ping( $this->dbh ) ) {
1588
+			if ( ! empty($this->dbh) && mysql_ping($this->dbh)) {
1589 1589
 				return true;
1590 1590
 			}
1591 1591
 		}
@@ -1593,62 +1593,62 @@  discard block
 block discarded – undo
1593 1593
 		$error_reporting = false;
1594 1594
 
1595 1595
 		// Disable warnings, as we don't want to see a multitude of "unable to connect" messages
1596
-		if ( WP_DEBUG ) {
1596
+		if (WP_DEBUG) {
1597 1597
 			$error_reporting = error_reporting();
1598
-			error_reporting( $error_reporting & ~E_WARNING );
1598
+			error_reporting($error_reporting & ~E_WARNING);
1599 1599
 		}
1600 1600
 
1601
-		for ( $tries = 1; $tries <= $this->reconnect_retries; $tries++ ) {
1601
+		for ($tries = 1; $tries <= $this->reconnect_retries; $tries++) {
1602 1602
 			// On the last try, re-enable warnings. We want to see a single instance of the
1603 1603
 			// "unable to connect" message on the bail() screen, if it appears.
1604
-			if ( $this->reconnect_retries === $tries && WP_DEBUG ) {
1605
-				error_reporting( $error_reporting );
1604
+			if ($this->reconnect_retries === $tries && WP_DEBUG) {
1605
+				error_reporting($error_reporting);
1606 1606
 			}
1607 1607
 
1608
-			if ( $this->db_connect( false ) ) {
1609
-				if ( $error_reporting ) {
1610
-					error_reporting( $error_reporting );
1608
+			if ($this->db_connect(false)) {
1609
+				if ($error_reporting) {
1610
+					error_reporting($error_reporting);
1611 1611
 				}
1612 1612
 
1613 1613
 				return true;
1614 1614
 			}
1615 1615
 
1616
-			sleep( 1 );
1616
+			sleep(1);
1617 1617
 		}
1618 1618
 
1619 1619
 		// If template_redirect has already happened, it's too late for wp_die()/dead_db().
1620 1620
 		// Let's just return and hope for the best.
1621
-		if ( did_action( 'template_redirect' ) ) {
1621
+		if (did_action('template_redirect')) {
1622 1622
 			return false;
1623 1623
 		}
1624 1624
 
1625
-		if ( ! $allow_bail ) {
1625
+		if ( ! $allow_bail) {
1626 1626
 			return false;
1627 1627
 		}
1628 1628
 
1629 1629
 		wp_load_translations_early();
1630 1630
 
1631
-		$message = '<h1>' . __( 'Error reconnecting to the database' ) . "</h1>\n";
1631
+		$message = '<h1>'.__('Error reconnecting to the database')."</h1>\n";
1632 1632
 
1633
-		$message .= '<p>' . sprintf(
1633
+		$message .= '<p>'.sprintf(
1634 1634
 			/* translators: %s: database host */
1635
-			__( 'This means that we lost contact with the database server at %s. This could mean your host&#8217;s database server is down.' ),
1636
-			'<code>' . htmlspecialchars( $this->dbhost, ENT_QUOTES ) . '</code>'
1637
-		) . "</p>\n";
1635
+			__('This means that we lost contact with the database server at %s. This could mean your host&#8217;s database server is down.'),
1636
+			'<code>'.htmlspecialchars($this->dbhost, ENT_QUOTES).'</code>'
1637
+		)."</p>\n";
1638 1638
 
1639 1639
 		$message .= "<ul>\n";
1640
-		$message .= '<li>' . __( 'Are you sure that the database server is running?' ) . "</li>\n";
1641
-		$message .= '<li>' . __( 'Are you sure that the database server is not under particularly heavy load?' ) . "</li>\n";
1640
+		$message .= '<li>'.__('Are you sure that the database server is running?')."</li>\n";
1641
+		$message .= '<li>'.__('Are you sure that the database server is not under particularly heavy load?')."</li>\n";
1642 1642
 		$message .= "</ul>\n";
1643 1643
 
1644
-		$message .= '<p>' . sprintf(
1644
+		$message .= '<p>'.sprintf(
1645 1645
 			/* translators: %s: support forums URL */
1646
-			__( 'If you&#8217;re unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href="%s">WordPress Support Forums</a>.' ),
1647
-			__( 'https://wordpress.org/support/' )
1648
-		) . "</p>\n";
1646
+			__('If you&#8217;re unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href="%s">WordPress Support Forums</a>.'),
1647
+			__('https://wordpress.org/support/')
1648
+		)."</p>\n";
1649 1649
 
1650 1650
 		// We weren't able to reconnect, so we better bail.
1651
-		$this->bail( $message, 'db_connect_fail' );
1651
+		$this->bail($message, 'db_connect_fail');
1652 1652
 
1653 1653
 		// Call dead_db() if bail didn't die, because this database is no more. It has ceased to be (at least temporarily).
1654 1654
 		dead_db();
@@ -1664,8 +1664,8 @@  discard block
 block discarded – undo
1664 1664
 	 * @param string $query Database query
1665 1665
 	 * @return int|false Number of rows affected/selected or false on error
1666 1666
 	 */
1667
-	public function query( $query ) {
1668
-		if ( ! $this->ready ) {
1667
+	public function query($query) {
1668
+		if ( ! $this->ready) {
1669 1669
 			$this->check_current_query = true;
1670 1670
 			return false;
1671 1671
 		}
@@ -1680,7 +1680,7 @@  discard block
 block discarded – undo
1680 1680
 		 *
1681 1681
 		 * @param string $query Database query.
1682 1682
 		 */
1683
-		$query = apply_filters( 'query', $query );
1683
+		$query = apply_filters('query', $query);
1684 1684
 
1685 1685
 		$this->flush();
1686 1686
 
@@ -1688,12 +1688,12 @@  discard block
 block discarded – undo
1688 1688
 		$this->func_call = "\$db->query(\"$query\")";
1689 1689
 
1690 1690
 		// If we're writing to the database, make sure the query will write safely.
1691
-		if ( $this->check_current_query && ! $this->check_ascii( $query ) ) {
1692
-			$stripped_query = $this->strip_invalid_text_from_query( $query );
1691
+		if ($this->check_current_query && ! $this->check_ascii($query)) {
1692
+			$stripped_query = $this->strip_invalid_text_from_query($query);
1693 1693
 			// strip_invalid_text_from_query() can perform queries, so we need
1694 1694
 			// to flush again, just to make sure everything is clear.
1695 1695
 			$this->flush();
1696
-			if ( $stripped_query !== $query ) {
1696
+			if ($stripped_query !== $query) {
1697 1697
 				$this->insert_id = 0;
1698 1698
 				return false;
1699 1699
 			}
@@ -1704,21 +1704,21 @@  discard block
 block discarded – undo
1704 1704
 		// Keep track of the last query for debug..
1705 1705
 		$this->last_query = $query;
1706 1706
 
1707
-		$this->_do_query( $query );
1707
+		$this->_do_query($query);
1708 1708
 
1709 1709
 		// MySQL server has gone away, try to reconnect
1710 1710
 		$mysql_errno = 0;
1711
-		if ( ! empty( $this->dbh ) ) {
1712
-			if ( $this->use_mysqli ) {
1713
-				$mysql_errno = mysqli_errno( $this->dbh );
1711
+		if ( ! empty($this->dbh)) {
1712
+			if ($this->use_mysqli) {
1713
+				$mysql_errno = mysqli_errno($this->dbh);
1714 1714
 			} else {
1715
-				$mysql_errno = mysql_errno( $this->dbh );
1715
+				$mysql_errno = mysql_errno($this->dbh);
1716 1716
 			}
1717 1717
 		}
1718 1718
 
1719
-		if ( empty( $this->dbh ) || 2006 == $mysql_errno ) {
1720
-			if ( $this->check_connection() ) {
1721
-				$this->_do_query( $query );
1719
+		if (empty($this->dbh) || 2006 == $mysql_errno) {
1720
+			if ($this->check_connection()) {
1721
+				$this->_do_query($query);
1722 1722
 			} else {
1723 1723
 				$this->insert_id = 0;
1724 1724
 				return false;
@@ -1726,48 +1726,48 @@  discard block
 block discarded – undo
1726 1726
 		}
1727 1727
 
1728 1728
 		// If there is an error then take note of it..
1729
-		if ( $this->use_mysqli ) {
1730
-			$this->last_error = mysqli_error( $this->dbh );
1729
+		if ($this->use_mysqli) {
1730
+			$this->last_error = mysqli_error($this->dbh);
1731 1731
 		} else {
1732
-			$this->last_error = mysql_error( $this->dbh );
1732
+			$this->last_error = mysql_error($this->dbh);
1733 1733
 		}
1734 1734
 
1735
-		if ( $this->last_error ) {
1735
+		if ($this->last_error) {
1736 1736
 			// Clear insert_id on a subsequent failed insert.
1737
-			if ( $this->insert_id && preg_match( '/^\s*(insert|replace)\s/i', $query ) )
1737
+			if ($this->insert_id && preg_match('/^\s*(insert|replace)\s/i', $query))
1738 1738
 				$this->insert_id = 0;
1739 1739
 
1740 1740
 			$this->print_error();
1741 1741
 			return false;
1742 1742
 		}
1743 1743
 
1744
-		if ( preg_match( '/^\s*(create|alter|truncate|drop)\s/i', $query ) ) {
1744
+		if (preg_match('/^\s*(create|alter|truncate|drop)\s/i', $query)) {
1745 1745
 			$return_val = $this->result;
1746
-		} elseif ( preg_match( '/^\s*(insert|delete|update|replace)\s/i', $query ) ) {
1747
-			if ( $this->use_mysqli ) {
1748
-				$this->rows_affected = mysqli_affected_rows( $this->dbh );
1746
+		} elseif (preg_match('/^\s*(insert|delete|update|replace)\s/i', $query)) {
1747
+			if ($this->use_mysqli) {
1748
+				$this->rows_affected = mysqli_affected_rows($this->dbh);
1749 1749
 			} else {
1750
-				$this->rows_affected = mysql_affected_rows( $this->dbh );
1750
+				$this->rows_affected = mysql_affected_rows($this->dbh);
1751 1751
 			}
1752 1752
 			// Take note of the insert_id
1753
-			if ( preg_match( '/^\s*(insert|replace)\s/i', $query ) ) {
1754
-				if ( $this->use_mysqli ) {
1755
-					$this->insert_id = mysqli_insert_id( $this->dbh );
1753
+			if (preg_match('/^\s*(insert|replace)\s/i', $query)) {
1754
+				if ($this->use_mysqli) {
1755
+					$this->insert_id = mysqli_insert_id($this->dbh);
1756 1756
 				} else {
1757
-					$this->insert_id = mysql_insert_id( $this->dbh );
1757
+					$this->insert_id = mysql_insert_id($this->dbh);
1758 1758
 				}
1759 1759
 			}
1760 1760
 			// Return number of rows affected
1761 1761
 			$return_val = $this->rows_affected;
1762 1762
 		} else {
1763 1763
 			$num_rows = 0;
1764
-			if ( $this->use_mysqli && $this->result instanceof mysqli_result ) {
1765
-				while ( $row = mysqli_fetch_object( $this->result ) ) {
1764
+			if ($this->use_mysqli && $this->result instanceof mysqli_result) {
1765
+				while ($row = mysqli_fetch_object($this->result)) {
1766 1766
 					$this->last_result[$num_rows] = $row;
1767 1767
 					$num_rows++;
1768 1768
 				}
1769
-			} elseif ( is_resource( $this->result ) ) {
1770
-				while ( $row = mysql_fetch_object( $this->result ) ) {
1769
+			} elseif (is_resource($this->result)) {
1770
+				while ($row = mysql_fetch_object($this->result)) {
1771 1771
 					$this->last_result[$num_rows] = $row;
1772 1772
 					$num_rows++;
1773 1773
 				}
@@ -1792,20 +1792,20 @@  discard block
 block discarded – undo
1792 1792
 	 *
1793 1793
 	 * @param string $query The query to run.
1794 1794
 	 */
1795
-	private function _do_query( $query ) {
1796
-		if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) {
1795
+	private function _do_query($query) {
1796
+		if (defined('SAVEQUERIES') && SAVEQUERIES) {
1797 1797
 			$this->timer_start();
1798 1798
 		}
1799 1799
 
1800
-		if ( ! empty( $this->dbh ) && $this->use_mysqli ) {
1801
-			$this->result = mysqli_query( $this->dbh, $query );
1802
-		} elseif ( ! empty( $this->dbh ) ) {
1803
-			$this->result = mysql_query( $query, $this->dbh );
1800
+		if ( ! empty($this->dbh) && $this->use_mysqli) {
1801
+			$this->result = mysqli_query($this->dbh, $query);
1802
+		} elseif ( ! empty($this->dbh)) {
1803
+			$this->result = mysql_query($query, $this->dbh);
1804 1804
 		}
1805 1805
 		$this->num_queries++;
1806 1806
 
1807
-		if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) {
1808
-			$this->queries[] = array( $query, $this->timer_stop(), $this->get_caller() );
1807
+		if (defined('SAVEQUERIES') && SAVEQUERIES) {
1808
+			$this->queries[] = array($query, $this->timer_stop(), $this->get_caller());
1809 1809
 		}
1810 1810
 	}
1811 1811
 
@@ -1830,8 +1830,8 @@  discard block
 block discarded – undo
1830 1830
 	 *                             If omitted, all values in $data will be treated as strings unless otherwise specified in wpdb::$field_types.
1831 1831
 	 * @return int|false The number of rows inserted, or false on error.
1832 1832
 	 */
1833
-	public function insert( $table, $data, $format = null ) {
1834
-		return $this->_insert_replace_helper( $table, $data, $format, 'INSERT' );
1833
+	public function insert($table, $data, $format = null) {
1834
+		return $this->_insert_replace_helper($table, $data, $format, 'INSERT');
1835 1835
 	}
1836 1836
 
1837 1837
 	/**
@@ -1855,8 +1855,8 @@  discard block
 block discarded – undo
1855 1855
 	 *                             If omitted, all values in $data will be treated as strings unless otherwise specified in wpdb::$field_types.
1856 1856
 	 * @return int|false The number of rows affected, or false on error.
1857 1857
 	 */
1858
-	public function replace( $table, $data, $format = null ) {
1859
-		return $this->_insert_replace_helper( $table, $data, $format, 'REPLACE' );
1858
+	public function replace($table, $data, $format = null) {
1859
+		return $this->_insert_replace_helper($table, $data, $format, 'REPLACE');
1860 1860
 	}
1861 1861
 
1862 1862
 	/**
@@ -1881,21 +1881,21 @@  discard block
 block discarded – undo
1881 1881
 	 * @param string $type         Optional. What type of operation is this? INSERT or REPLACE. Defaults to INSERT.
1882 1882
 	 * @return int|false The number of rows affected, or false on error.
1883 1883
 	 */
1884
-	function _insert_replace_helper( $table, $data, $format = null, $type = 'INSERT' ) {
1884
+	function _insert_replace_helper($table, $data, $format = null, $type = 'INSERT') {
1885 1885
 		$this->insert_id = 0;
1886 1886
 
1887
-		if ( ! in_array( strtoupper( $type ), array( 'REPLACE', 'INSERT' ) ) ) {
1887
+		if ( ! in_array(strtoupper($type), array('REPLACE', 'INSERT'))) {
1888 1888
 			return false;
1889 1889
 		}
1890 1890
 
1891
-		$data = $this->process_fields( $table, $data, $format );
1892
-		if ( false === $data ) {
1891
+		$data = $this->process_fields($table, $data, $format);
1892
+		if (false === $data) {
1893 1893
 			return false;
1894 1894
 		}
1895 1895
 
1896 1896
 		$formats = $values = array();
1897
-		foreach ( $data as $value ) {
1898
-			if ( is_null( $value['value'] ) ) {
1897
+		foreach ($data as $value) {
1898
+			if (is_null($value['value'])) {
1899 1899
 				$formats[] = 'NULL';
1900 1900
 				continue;
1901 1901
 			}
@@ -1904,13 +1904,13 @@  discard block
 block discarded – undo
1904 1904
 			$values[]  = $value['value'];
1905 1905
 		}
1906 1906
 
1907
-		$fields  = '`' . implode( '`, `', array_keys( $data ) ) . '`';
1908
-		$formats = implode( ', ', $formats );
1907
+		$fields  = '`'.implode('`, `', array_keys($data)).'`';
1908
+		$formats = implode(', ', $formats);
1909 1909
 
1910 1910
 		$sql = "$type INTO `$table` ($fields) VALUES ($formats)";
1911 1911
 
1912 1912
 		$this->check_current_query = false;
1913
-		return $this->query( $this->prepare( $sql, $values ) );
1913
+		return $this->query($this->prepare($sql, $values));
1914 1914
 	}
1915 1915
 
1916 1916
 	/**
@@ -1943,47 +1943,47 @@  discard block
 block discarded – undo
1943 1943
 	 *                                   If omitted, all values in $where will be treated as strings.
1944 1944
 	 * @return int|false The number of rows updated, or false on error.
1945 1945
 	 */
1946
-	public function update( $table, $data, $where, $format = null, $where_format = null ) {
1947
-		if ( ! is_array( $data ) || ! is_array( $where ) ) {
1946
+	public function update($table, $data, $where, $format = null, $where_format = null) {
1947
+		if ( ! is_array($data) || ! is_array($where)) {
1948 1948
 			return false;
1949 1949
 		}
1950 1950
 
1951
-		$data = $this->process_fields( $table, $data, $format );
1952
-		if ( false === $data ) {
1951
+		$data = $this->process_fields($table, $data, $format);
1952
+		if (false === $data) {
1953 1953
 			return false;
1954 1954
 		}
1955
-		$where = $this->process_fields( $table, $where, $where_format );
1956
-		if ( false === $where ) {
1955
+		$where = $this->process_fields($table, $where, $where_format);
1956
+		if (false === $where) {
1957 1957
 			return false;
1958 1958
 		}
1959 1959
 
1960 1960
 		$fields = $conditions = $values = array();
1961
-		foreach ( $data as $field => $value ) {
1962
-			if ( is_null( $value['value'] ) ) {
1961
+		foreach ($data as $field => $value) {
1962
+			if (is_null($value['value'])) {
1963 1963
 				$fields[] = "`$field` = NULL";
1964 1964
 				continue;
1965 1965
 			}
1966 1966
 
1967
-			$fields[] = "`$field` = " . $value['format'];
1967
+			$fields[] = "`$field` = ".$value['format'];
1968 1968
 			$values[] = $value['value'];
1969 1969
 		}
1970
-		foreach ( $where as $field => $value ) {
1971
-			if ( is_null( $value['value'] ) ) {
1970
+		foreach ($where as $field => $value) {
1971
+			if (is_null($value['value'])) {
1972 1972
 				$conditions[] = "`$field` IS NULL";
1973 1973
 				continue;
1974 1974
 			}
1975 1975
 
1976
-			$conditions[] = "`$field` = " . $value['format'];
1976
+			$conditions[] = "`$field` = ".$value['format'];
1977 1977
 			$values[] = $value['value'];
1978 1978
 		}
1979 1979
 
1980
-		$fields = implode( ', ', $fields );
1981
-		$conditions = implode( ' AND ', $conditions );
1980
+		$fields = implode(', ', $fields);
1981
+		$conditions = implode(' AND ', $conditions);
1982 1982
 
1983 1983
 		$sql = "UPDATE `$table` SET $fields WHERE $conditions";
1984 1984
 
1985 1985
 		$this->check_current_query = false;
1986
-		return $this->query( $this->prepare( $sql, $values ) );
1986
+		return $this->query($this->prepare($sql, $values));
1987 1987
 	}
1988 1988
 
1989 1989
 	/**
@@ -2008,33 +2008,33 @@  discard block
 block discarded – undo
2008 2008
 	 *                                   If omitted, all values in $where will be treated as strings unless otherwise specified in wpdb::$field_types.
2009 2009
 	 * @return int|false The number of rows updated, or false on error.
2010 2010
 	 */
2011
-	public function delete( $table, $where, $where_format = null ) {
2012
-		if ( ! is_array( $where ) ) {
2011
+	public function delete($table, $where, $where_format = null) {
2012
+		if ( ! is_array($where)) {
2013 2013
 			return false;
2014 2014
 		}
2015 2015
 
2016
-		$where = $this->process_fields( $table, $where, $where_format );
2017
-		if ( false === $where ) {
2016
+		$where = $this->process_fields($table, $where, $where_format);
2017
+		if (false === $where) {
2018 2018
 			return false;
2019 2019
 		}
2020 2020
 
2021 2021
 		$conditions = $values = array();
2022
-		foreach ( $where as $field => $value ) {
2023
-			if ( is_null( $value['value'] ) ) {
2022
+		foreach ($where as $field => $value) {
2023
+			if (is_null($value['value'])) {
2024 2024
 				$conditions[] = "`$field` IS NULL";
2025 2025
 				continue;
2026 2026
 			}
2027 2027
 
2028
-			$conditions[] = "`$field` = " . $value['format'];
2028
+			$conditions[] = "`$field` = ".$value['format'];
2029 2029
 			$values[] = $value['value'];
2030 2030
 		}
2031 2031
 
2032
-		$conditions = implode( ' AND ', $conditions );
2032
+		$conditions = implode(' AND ', $conditions);
2033 2033
 
2034 2034
 		$sql = "DELETE FROM `$table` WHERE $conditions";
2035 2035
 
2036 2036
 		$this->check_current_query = false;
2037
-		return $this->query( $this->prepare( $sql, $values ) );
2037
+		return $this->query($this->prepare($sql, $values));
2038 2038
 	}
2039 2039
 
2040 2040
 	/**
@@ -2055,25 +2055,25 @@  discard block
 block discarded – undo
2055 2055
 	 * @return array|false Returns an array of fields that contain paired values
2056 2056
 	 *                    and formats. Returns false for invalid values.
2057 2057
 	 */
2058
-	protected function process_fields( $table, $data, $format ) {
2059
-		$data = $this->process_field_formats( $data, $format );
2060
-		if ( false === $data ) {
2058
+	protected function process_fields($table, $data, $format) {
2059
+		$data = $this->process_field_formats($data, $format);
2060
+		if (false === $data) {
2061 2061
 			return false;
2062 2062
 		}
2063 2063
 
2064
-		$data = $this->process_field_charsets( $data, $table );
2065
-		if ( false === $data ) {
2064
+		$data = $this->process_field_charsets($data, $table);
2065
+		if (false === $data) {
2066 2066
 			return false;
2067 2067
 		}
2068 2068
 
2069
-		$data = $this->process_field_lengths( $data, $table );
2070
-		if ( false === $data ) {
2069
+		$data = $this->process_field_lengths($data, $table);
2070
+		if (false === $data) {
2071 2071
 			return false;
2072 2072
 		}
2073 2073
 
2074
-		$converted_data = $this->strip_invalid_text( $data );
2074
+		$converted_data = $this->strip_invalid_text($data);
2075 2075
 
2076
-		if ( $data !== $converted_data ) {
2076
+		if ($data !== $converted_data) {
2077 2077
 			return false;
2078 2078
 		}
2079 2079
 
@@ -2091,25 +2091,25 @@  discard block
 block discarded – undo
2091 2091
 	 * @return array Array, keyed by field names with values being an array
2092 2092
 	 *               of 'value' and 'format' keys.
2093 2093
 	 */
2094
-	protected function process_field_formats( $data, $format ) {
2094
+	protected function process_field_formats($data, $format) {
2095 2095
 		$formats = $original_formats = (array) $format;
2096 2096
 
2097
-		foreach ( $data as $field => $value ) {
2097
+		foreach ($data as $field => $value) {
2098 2098
 			$value = array(
2099 2099
 				'value'  => $value,
2100 2100
 				'format' => '%s',
2101 2101
 			);
2102 2102
 
2103
-			if ( ! empty( $format ) ) {
2104
-				$value['format'] = array_shift( $formats );
2105
-				if ( ! $value['format'] ) {
2106
-					$value['format'] = reset( $original_formats );
2103
+			if ( ! empty($format)) {
2104
+				$value['format'] = array_shift($formats);
2105
+				if ( ! $value['format']) {
2106
+					$value['format'] = reset($original_formats);
2107 2107
 				}
2108
-			} elseif ( isset( $this->field_types[ $field ] ) ) {
2109
-				$value['format'] = $this->field_types[ $field ];
2108
+			} elseif (isset($this->field_types[$field])) {
2109
+				$value['format'] = $this->field_types[$field];
2110 2110
 			}
2111 2111
 
2112
-			$data[ $field ] = $value;
2112
+			$data[$field] = $value;
2113 2113
 		}
2114 2114
 
2115 2115
 		return $data;
@@ -2126,22 +2126,22 @@  discard block
 block discarded – undo
2126 2126
 	 * @param string $table Table name.
2127 2127
 	 * @return array|false The same array as $data with additional 'charset' keys.
2128 2128
 	 */
2129
-	protected function process_field_charsets( $data, $table ) {
2130
-		foreach ( $data as $field => $value ) {
2131
-			if ( '%d' === $value['format'] || '%f' === $value['format'] ) {
2129
+	protected function process_field_charsets($data, $table) {
2130
+		foreach ($data as $field => $value) {
2131
+			if ('%d' === $value['format'] || '%f' === $value['format']) {
2132 2132
 				/*
2133 2133
 				 * We can skip this field if we know it isn't a string.
2134 2134
 				 * This checks %d/%f versus ! %s because its sprintf() could take more.
2135 2135
 				 */
2136 2136
 				$value['charset'] = false;
2137 2137
 			} else {
2138
-				$value['charset'] = $this->get_col_charset( $table, $field );
2139
-				if ( is_wp_error( $value['charset'] ) ) {
2138
+				$value['charset'] = $this->get_col_charset($table, $field);
2139
+				if (is_wp_error($value['charset'])) {
2140 2140
 					return false;
2141 2141
 				}
2142 2142
 			}
2143 2143
 
2144
-			$data[ $field ] = $value;
2144
+			$data[$field] = $value;
2145 2145
 		}
2146 2146
 
2147 2147
 		return $data;
@@ -2158,22 +2158,22 @@  discard block
 block discarded – undo
2158 2158
 	 * @return array|false The same array as $data with additional 'length' keys, or false if
2159 2159
 	 *                     any of the values were too long for their corresponding field.
2160 2160
 	 */
2161
-	protected function process_field_lengths( $data, $table ) {
2162
-		foreach ( $data as $field => $value ) {
2163
-			if ( '%d' === $value['format'] || '%f' === $value['format'] ) {
2161
+	protected function process_field_lengths($data, $table) {
2162
+		foreach ($data as $field => $value) {
2163
+			if ('%d' === $value['format'] || '%f' === $value['format']) {
2164 2164
 				/*
2165 2165
 				 * We can skip this field if we know it isn't a string.
2166 2166
 				 * This checks %d/%f versus ! %s because its sprintf() could take more.
2167 2167
 				 */
2168 2168
 				$value['length'] = false;
2169 2169
 			} else {
2170
-				$value['length'] = $this->get_col_length( $table, $field );
2171
-				if ( is_wp_error( $value['length'] ) ) {
2170
+				$value['length'] = $this->get_col_length($table, $field);
2171
+				if (is_wp_error($value['length'])) {
2172 2172
 					return false;
2173 2173
 				}
2174 2174
 			}
2175 2175
 
2176
-			$data[ $field ] = $value;
2176
+			$data[$field] = $value;
2177 2177
 		}
2178 2178
 
2179 2179
 		return $data;
@@ -2193,24 +2193,24 @@  discard block
 block discarded – undo
2193 2193
 	 * @param int         $y     Optional. Row of value to return. Indexed from 0.
2194 2194
 	 * @return string|null Database query result (as string), or null on failure
2195 2195
 	 */
2196
-	public function get_var( $query = null, $x = 0, $y = 0 ) {
2196
+	public function get_var($query = null, $x = 0, $y = 0) {
2197 2197
 		$this->func_call = "\$db->get_var(\"$query\", $x, $y)";
2198 2198
 
2199
-		if ( $this->check_current_query && $this->check_safe_collation( $query ) ) {
2199
+		if ($this->check_current_query && $this->check_safe_collation($query)) {
2200 2200
 			$this->check_current_query = false;
2201 2201
 		}
2202 2202
 
2203
-		if ( $query ) {
2204
-			$this->query( $query );
2203
+		if ($query) {
2204
+			$this->query($query);
2205 2205
 		}
2206 2206
 
2207 2207
 		// Extract var out of cached results based x,y vals
2208
-		if ( !empty( $this->last_result[$y] ) ) {
2209
-			$values = array_values( get_object_vars( $this->last_result[$y] ) );
2208
+		if ( ! empty($this->last_result[$y])) {
2209
+			$values = array_values(get_object_vars($this->last_result[$y]));
2210 2210
 		}
2211 2211
 
2212 2212
 		// If there is a value return it else return null
2213
-		return ( isset( $values[$x] ) && $values[$x] !== '' ) ? $values[$x] : null;
2213
+		return (isset($values[$x]) && $values[$x] !== '') ? $values[$x] : null;
2214 2214
 	}
2215 2215
 
2216 2216
 	/**
@@ -2228,33 +2228,33 @@  discard block
 block discarded – undo
2228 2228
 	 * @param int         $y      Optional. Row to return. Indexed from 0.
2229 2229
 	 * @return array|object|null|void Database query result in format specified by $output or null on failure
2230 2230
 	 */
2231
-	public function get_row( $query = null, $output = OBJECT, $y = 0 ) {
2231
+	public function get_row($query = null, $output = OBJECT, $y = 0) {
2232 2232
 		$this->func_call = "\$db->get_row(\"$query\",$output,$y)";
2233 2233
 
2234
-		if ( $this->check_current_query && $this->check_safe_collation( $query ) ) {
2234
+		if ($this->check_current_query && $this->check_safe_collation($query)) {
2235 2235
 			$this->check_current_query = false;
2236 2236
 		}
2237 2237
 
2238
-		if ( $query ) {
2239
-			$this->query( $query );
2238
+		if ($query) {
2239
+			$this->query($query);
2240 2240
 		} else {
2241 2241
 			return null;
2242 2242
 		}
2243 2243
 
2244
-		if ( !isset( $this->last_result[$y] ) )
2244
+		if ( ! isset($this->last_result[$y]))
2245 2245
 			return null;
2246 2246
 
2247
-		if ( $output == OBJECT ) {
2247
+		if ($output == OBJECT) {
2248 2248
 			return $this->last_result[$y] ? $this->last_result[$y] : null;
2249
-		} elseif ( $output == ARRAY_A ) {
2250
-			return $this->last_result[$y] ? get_object_vars( $this->last_result[$y] ) : null;
2251
-		} elseif ( $output == ARRAY_N ) {
2252
-			return $this->last_result[$y] ? array_values( get_object_vars( $this->last_result[$y] ) ) : null;
2253
-		} elseif ( strtoupper( $output ) === OBJECT ) {
2249
+		} elseif ($output == ARRAY_A) {
2250
+			return $this->last_result[$y] ? get_object_vars($this->last_result[$y]) : null;
2251
+		} elseif ($output == ARRAY_N) {
2252
+			return $this->last_result[$y] ? array_values(get_object_vars($this->last_result[$y])) : null;
2253
+		} elseif (strtoupper($output) === OBJECT) {
2254 2254
 			// Back compat for OBJECT being previously case insensitive.
2255 2255
 			return $this->last_result[$y] ? $this->last_result[$y] : null;
2256 2256
 		} else {
2257
-			$this->print_error( " \$db->get_row(string query, output type, int offset) -- Output type must be one of: OBJECT, ARRAY_A, ARRAY_N" );
2257
+			$this->print_error(" \$db->get_row(string query, output type, int offset) -- Output type must be one of: OBJECT, ARRAY_A, ARRAY_N");
2258 2258
 		}
2259 2259
 	}
2260 2260
 
@@ -2271,19 +2271,19 @@  discard block
 block discarded – undo
2271 2271
 	 * @param int         $x     Optional. Column to return. Indexed from 0.
2272 2272
 	 * @return array Database query result. Array indexed from 0 by SQL result row number.
2273 2273
 	 */
2274
-	public function get_col( $query = null , $x = 0 ) {
2275
-		if ( $this->check_current_query && $this->check_safe_collation( $query ) ) {
2274
+	public function get_col($query = null, $x = 0) {
2275
+		if ($this->check_current_query && $this->check_safe_collation($query)) {
2276 2276
 			$this->check_current_query = false;
2277 2277
 		}
2278 2278
 
2279
-		if ( $query ) {
2280
-			$this->query( $query );
2279
+		if ($query) {
2280
+			$this->query($query);
2281 2281
 		}
2282 2282
 
2283 2283
 		$new_array = array();
2284 2284
 		// Extract the column values
2285
-		for ( $i = 0, $j = count( $this->last_result ); $i < $j; $i++ ) {
2286
-			$new_array[$i] = $this->get_var( null, $x, $i );
2285
+		for ($i = 0, $j = count($this->last_result); $i < $j; $i++) {
2286
+			$new_array[$i] = $this->get_var(null, $x, $i);
2287 2287
 		}
2288 2288
 		return $new_array;
2289 2289
 	}
@@ -2303,48 +2303,48 @@  discard block
 block discarded – undo
2303 2303
 	 *                       Duplicate keys are discarded.
2304 2304
 	 * @return array|object|null Database query results
2305 2305
 	 */
2306
-	public function get_results( $query = null, $output = OBJECT ) {
2306
+	public function get_results($query = null, $output = OBJECT) {
2307 2307
 		$this->func_call = "\$db->get_results(\"$query\", $output)";
2308 2308
 
2309
-		if ( $this->check_current_query && $this->check_safe_collation( $query ) ) {
2309
+		if ($this->check_current_query && $this->check_safe_collation($query)) {
2310 2310
 			$this->check_current_query = false;
2311 2311
 		}
2312 2312
 
2313
-		if ( $query ) {
2314
-			$this->query( $query );
2313
+		if ($query) {
2314
+			$this->query($query);
2315 2315
 		} else {
2316 2316
 			return null;
2317 2317
 		}
2318 2318
 
2319 2319
 		$new_array = array();
2320
-		if ( $output == OBJECT ) {
2320
+		if ($output == OBJECT) {
2321 2321
 			// Return an integer-keyed array of row objects
2322 2322
 			return $this->last_result;
2323
-		} elseif ( $output == OBJECT_K ) {
2323
+		} elseif ($output == OBJECT_K) {
2324 2324
 			// Return an array of row objects with keys from column 1
2325 2325
 			// (Duplicates are discarded)
2326
-			foreach ( $this->last_result as $row ) {
2327
-				$var_by_ref = get_object_vars( $row );
2328
-				$key = array_shift( $var_by_ref );
2329
-				if ( ! isset( $new_array[ $key ] ) )
2330
-					$new_array[ $key ] = $row;
2326
+			foreach ($this->last_result as $row) {
2327
+				$var_by_ref = get_object_vars($row);
2328
+				$key = array_shift($var_by_ref);
2329
+				if ( ! isset($new_array[$key]))
2330
+					$new_array[$key] = $row;
2331 2331
 			}
2332 2332
 			return $new_array;
2333
-		} elseif ( $output == ARRAY_A || $output == ARRAY_N ) {
2333
+		} elseif ($output == ARRAY_A || $output == ARRAY_N) {
2334 2334
 			// Return an integer-keyed array of...
2335
-			if ( $this->last_result ) {
2336
-				foreach ( (array) $this->last_result as $row ) {
2337
-					if ( $output == ARRAY_N ) {
2335
+			if ($this->last_result) {
2336
+				foreach ((array) $this->last_result as $row) {
2337
+					if ($output == ARRAY_N) {
2338 2338
 						// ...integer-keyed row arrays
2339
-						$new_array[] = array_values( get_object_vars( $row ) );
2339
+						$new_array[] = array_values(get_object_vars($row));
2340 2340
 					} else {
2341 2341
 						// ...column name-keyed row arrays
2342
-						$new_array[] = get_object_vars( $row );
2342
+						$new_array[] = get_object_vars($row);
2343 2343
 					}
2344 2344
 				}
2345 2345
 			}
2346 2346
 			return $new_array;
2347
-		} elseif ( strtoupper( $output ) === OBJECT ) {
2347
+		} elseif (strtoupper($output) === OBJECT) {
2348 2348
 			// Back compat for OBJECT being previously case insensitive.
2349 2349
 			return $this->last_result;
2350 2350
 		}
@@ -2360,8 +2360,8 @@  discard block
 block discarded – undo
2360 2360
 	 * @param string $table Table name.
2361 2361
 	 * @return string|WP_Error Table character set, WP_Error object if it couldn't be found.
2362 2362
 	 */
2363
-	protected function get_table_charset( $table ) {
2364
-		$tablekey = strtolower( $table );
2363
+	protected function get_table_charset($table) {
2364
+		$tablekey = strtolower($table);
2365 2365
 
2366 2366
 		/**
2367 2367
 		 * Filter the table charset value before the DB is checked.
@@ -2374,72 +2374,72 @@  discard block
 block discarded – undo
2374 2374
 		 * @param string $charset The character set to use. Default null.
2375 2375
 		 * @param string $table   The name of the table being checked.
2376 2376
 		 */
2377
-		$charset = apply_filters( 'pre_get_table_charset', null, $table );
2378
-		if ( null !== $charset ) {
2377
+		$charset = apply_filters('pre_get_table_charset', null, $table);
2378
+		if (null !== $charset) {
2379 2379
 			return $charset;
2380 2380
 		}
2381 2381
 
2382
-		if ( isset( $this->table_charset[ $tablekey ] ) ) {
2383
-			return $this->table_charset[ $tablekey ];
2382
+		if (isset($this->table_charset[$tablekey])) {
2383
+			return $this->table_charset[$tablekey];
2384 2384
 		}
2385 2385
 
2386 2386
 		$charsets = $columns = array();
2387 2387
 
2388
-		$table_parts = explode( '.', $table );
2389
-		$table = '`' . implode( '`.`', $table_parts ) . '`';
2390
-		$results = $this->get_results( "SHOW FULL COLUMNS FROM $table" );
2391
-		if ( ! $results ) {
2392
-			return new WP_Error( 'wpdb_get_table_charset_failure' );
2388
+		$table_parts = explode('.', $table);
2389
+		$table = '`'.implode('`.`', $table_parts).'`';
2390
+		$results = $this->get_results("SHOW FULL COLUMNS FROM $table");
2391
+		if ( ! $results) {
2392
+			return new WP_Error('wpdb_get_table_charset_failure');
2393 2393
 		}
2394 2394
 
2395
-		foreach ( $results as $column ) {
2396
-			$columns[ strtolower( $column->Field ) ] = $column;
2395
+		foreach ($results as $column) {
2396
+			$columns[strtolower($column->Field)] = $column;
2397 2397
 		}
2398 2398
 
2399
-		$this->col_meta[ $tablekey ] = $columns;
2399
+		$this->col_meta[$tablekey] = $columns;
2400 2400
 
2401
-		foreach ( $columns as $column ) {
2402
-			if ( ! empty( $column->Collation ) ) {
2403
-				list( $charset ) = explode( '_', $column->Collation );
2401
+		foreach ($columns as $column) {
2402
+			if ( ! empty($column->Collation)) {
2403
+				list($charset) = explode('_', $column->Collation);
2404 2404
 
2405 2405
 				// If the current connection can't support utf8mb4 characters, let's only send 3-byte utf8 characters.
2406
-				if ( 'utf8mb4' === $charset && ! $this->has_cap( 'utf8mb4' ) ) {
2406
+				if ('utf8mb4' === $charset && ! $this->has_cap('utf8mb4')) {
2407 2407
 					$charset = 'utf8';
2408 2408
 				}
2409 2409
 
2410
-				$charsets[ strtolower( $charset ) ] = true;
2410
+				$charsets[strtolower($charset)] = true;
2411 2411
 			}
2412 2412
 
2413
-			list( $type ) = explode( '(', $column->Type );
2413
+			list($type) = explode('(', $column->Type);
2414 2414
 
2415 2415
 			// A binary/blob means the whole query gets treated like this.
2416
-			if ( in_array( strtoupper( $type ), array( 'BINARY', 'VARBINARY', 'TINYBLOB', 'MEDIUMBLOB', 'BLOB', 'LONGBLOB' ) ) ) {
2417
-				$this->table_charset[ $tablekey ] = 'binary';
2416
+			if (in_array(strtoupper($type), array('BINARY', 'VARBINARY', 'TINYBLOB', 'MEDIUMBLOB', 'BLOB', 'LONGBLOB'))) {
2417
+				$this->table_charset[$tablekey] = 'binary';
2418 2418
 				return 'binary';
2419 2419
 			}
2420 2420
 		}
2421 2421
 
2422 2422
 		// utf8mb3 is an alias for utf8.
2423
-		if ( isset( $charsets['utf8mb3'] ) ) {
2423
+		if (isset($charsets['utf8mb3'])) {
2424 2424
 			$charsets['utf8'] = true;
2425
-			unset( $charsets['utf8mb3'] );
2425
+			unset($charsets['utf8mb3']);
2426 2426
 		}
2427 2427
 
2428 2428
 		// Check if we have more than one charset in play.
2429
-		$count = count( $charsets );
2430
-		if ( 1 === $count ) {
2431
-			$charset = key( $charsets );
2432
-		} elseif ( 0 === $count ) {
2429
+		$count = count($charsets);
2430
+		if (1 === $count) {
2431
+			$charset = key($charsets);
2432
+		} elseif (0 === $count) {
2433 2433
 			// No charsets, assume this table can store whatever.
2434 2434
 			$charset = false;
2435 2435
 		} else {
2436 2436
 			// More than one charset. Remove latin1 if present and recalculate.
2437
-			unset( $charsets['latin1'] );
2438
-			$count = count( $charsets );
2439
-			if ( 1 === $count ) {
2437
+			unset($charsets['latin1']);
2438
+			$count = count($charsets);
2439
+			if (1 === $count) {
2440 2440
 				// Only one charset (besides latin1).
2441
-				$charset = key( $charsets );
2442
-			} elseif ( 2 === $count && isset( $charsets['utf8'], $charsets['utf8mb4'] ) ) {
2441
+				$charset = key($charsets);
2442
+			} elseif (2 === $count && isset($charsets['utf8'], $charsets['utf8mb4'])) {
2443 2443
 				// Two charsets, but they're utf8 and utf8mb4, use utf8.
2444 2444
 				$charset = 'utf8';
2445 2445
 			} else {
@@ -2448,7 +2448,7 @@  discard block
 block discarded – undo
2448 2448
 			}
2449 2449
 		}
2450 2450
 
2451
-		$this->table_charset[ $tablekey ] = $charset;
2451
+		$this->table_charset[$tablekey] = $charset;
2452 2452
 		return $charset;
2453 2453
 	}
2454 2454
 
@@ -2463,9 +2463,9 @@  discard block
 block discarded – undo
2463 2463
 	 * @return string|false|WP_Error Column character set as a string. False if the column has no
2464 2464
 	 *                               character set. WP_Error object if there was an error.
2465 2465
 	 */
2466
-	public function get_col_charset( $table, $column ) {
2467
-		$tablekey = strtolower( $table );
2468
-		$columnkey = strtolower( $column );
2466
+	public function get_col_charset($table, $column) {
2467
+		$tablekey = strtolower($table);
2468
+		$columnkey = strtolower($column);
2469 2469
 
2470 2470
 		/**
2471 2471
 		 * Filter the column charset value before the DB is checked.
@@ -2479,40 +2479,40 @@  discard block
 block discarded – undo
2479 2479
 		 * @param string $table   The name of the table being checked.
2480 2480
 		 * @param string $column  The name of the column being checked.
2481 2481
 		 */
2482
-		$charset = apply_filters( 'pre_get_col_charset', null, $table, $column );
2483
-		if ( null !== $charset ) {
2482
+		$charset = apply_filters('pre_get_col_charset', null, $table, $column);
2483
+		if (null !== $charset) {
2484 2484
 			return $charset;
2485 2485
 		}
2486 2486
 
2487 2487
 		// Skip this entirely if this isn't a MySQL database.
2488
-		if ( empty( $this->is_mysql ) ) {
2488
+		if (empty($this->is_mysql)) {
2489 2489
 			return false;
2490 2490
 		}
2491 2491
 
2492
-		if ( empty( $this->table_charset[ $tablekey ] ) ) {
2492
+		if (empty($this->table_charset[$tablekey])) {
2493 2493
 			// This primes column information for us.
2494
-			$table_charset = $this->get_table_charset( $table );
2495
-			if ( is_wp_error( $table_charset ) ) {
2494
+			$table_charset = $this->get_table_charset($table);
2495
+			if (is_wp_error($table_charset)) {
2496 2496
 				return $table_charset;
2497 2497
 			}
2498 2498
 		}
2499 2499
 
2500 2500
 		// If still no column information, return the table charset.
2501
-		if ( empty( $this->col_meta[ $tablekey ] ) ) {
2502
-			return $this->table_charset[ $tablekey ];
2501
+		if (empty($this->col_meta[$tablekey])) {
2502
+			return $this->table_charset[$tablekey];
2503 2503
 		}
2504 2504
 
2505 2505
 		// If this column doesn't exist, return the table charset.
2506
-		if ( empty( $this->col_meta[ $tablekey ][ $columnkey ] ) ) {
2507
-			return $this->table_charset[ $tablekey ];
2506
+		if (empty($this->col_meta[$tablekey][$columnkey])) {
2507
+			return $this->table_charset[$tablekey];
2508 2508
 		}
2509 2509
 
2510 2510
 		// Return false when it's not a string column.
2511
-		if ( empty( $this->col_meta[ $tablekey ][ $columnkey ]->Collation ) ) {
2511
+		if (empty($this->col_meta[$tablekey][$columnkey]->Collation)) {
2512 2512
 			return false;
2513 2513
 		}
2514 2514
 
2515
-		list( $charset ) = explode( '_', $this->col_meta[ $tablekey ][ $columnkey ]->Collation );
2515
+		list($charset) = explode('_', $this->col_meta[$tablekey][$columnkey]->Collation);
2516 2516
 		return $charset;
2517 2517
 	}
2518 2518
 
@@ -2529,37 +2529,37 @@  discard block
 block discarded – undo
2529 2529
 	 *                              false if the column has no length (for example, numeric column)
2530 2530
 	 *                              WP_Error object if there was an error.
2531 2531
 	 */
2532
-	public function get_col_length( $table, $column ) {
2533
-		$tablekey = strtolower( $table );
2534
-		$columnkey = strtolower( $column );
2532
+	public function get_col_length($table, $column) {
2533
+		$tablekey = strtolower($table);
2534
+		$columnkey = strtolower($column);
2535 2535
 
2536 2536
 		// Skip this entirely if this isn't a MySQL database.
2537
-		if ( empty( $this->is_mysql ) ) {
2537
+		if (empty($this->is_mysql)) {
2538 2538
 			return false;
2539 2539
 		}
2540 2540
 
2541
-		if ( empty( $this->col_meta[ $tablekey ] ) ) {
2541
+		if (empty($this->col_meta[$tablekey])) {
2542 2542
 			// This primes column information for us.
2543
-			$table_charset = $this->get_table_charset( $table );
2544
-			if ( is_wp_error( $table_charset ) ) {
2543
+			$table_charset = $this->get_table_charset($table);
2544
+			if (is_wp_error($table_charset)) {
2545 2545
 				return $table_charset;
2546 2546
 			}
2547 2547
 		}
2548 2548
 
2549
-		if ( empty( $this->col_meta[ $tablekey ][ $columnkey ] ) ) {
2549
+		if (empty($this->col_meta[$tablekey][$columnkey])) {
2550 2550
 			return false;
2551 2551
 		}
2552 2552
 
2553
-		$typeinfo = explode( '(', $this->col_meta[ $tablekey ][ $columnkey ]->Type );
2553
+		$typeinfo = explode('(', $this->col_meta[$tablekey][$columnkey]->Type);
2554 2554
 
2555
-		$type = strtolower( $typeinfo[0] );
2556
-		if ( ! empty( $typeinfo[1] ) ) {
2557
-			$length = trim( $typeinfo[1], ')' );
2555
+		$type = strtolower($typeinfo[0]);
2556
+		if ( ! empty($typeinfo[1])) {
2557
+			$length = trim($typeinfo[1], ')');
2558 2558
 		} else {
2559 2559
 			$length = false;
2560 2560
 		}
2561 2561
 
2562
-		switch( $type ) {
2562
+		switch ($type) {
2563 2563
 			case 'char':
2564 2564
 			case 'varchar':
2565 2565
 				return array(
@@ -2578,21 +2578,21 @@  discard block
 block discarded – undo
2578 2578
 			case 'tinytext':
2579 2579
 				return array(
2580 2580
 					'type'   => 'byte',
2581
-					'length' => 255,        // 2^8 - 1
2581
+					'length' => 255, // 2^8 - 1
2582 2582
 				);
2583 2583
 
2584 2584
 			case 'blob':
2585 2585
 			case 'text':
2586 2586
 				return array(
2587 2587
 					'type'   => 'byte',
2588
-					'length' => 65535,      // 2^16 - 1
2588
+					'length' => 65535, // 2^16 - 1
2589 2589
 				);
2590 2590
 
2591 2591
 			case 'mediumblob':
2592 2592
 			case 'mediumtext':
2593 2593
 				return array(
2594 2594
 					'type'   => 'byte',
2595
-					'length' => 16777215,   // 2^24 - 1
2595
+					'length' => 16777215, // 2^24 - 1
2596 2596
 				);
2597 2597
 
2598 2598
 			case 'longblob':
@@ -2619,12 +2619,12 @@  discard block
 block discarded – undo
2619 2619
 	 * @param string $string String to check.
2620 2620
 	 * @return bool True if ASCII, false if not.
2621 2621
 	 */
2622
-	protected function check_ascii( $string ) {
2623
-		if ( function_exists( 'mb_check_encoding' ) ) {
2624
-			if ( mb_check_encoding( $string, 'ASCII' ) ) {
2622
+	protected function check_ascii($string) {
2623
+		if (function_exists('mb_check_encoding')) {
2624
+			if (mb_check_encoding($string, 'ASCII')) {
2625 2625
 				return true;
2626 2626
 			}
2627
-		} elseif ( ! preg_match( '/[^\x00-\x7F]/', $string ) ) {
2627
+		} elseif ( ! preg_match('/[^\x00-\x7F]/', $string)) {
2628 2628
 			return true;
2629 2629
 		}
2630 2630
 
@@ -2640,48 +2640,48 @@  discard block
 block discarded – undo
2640 2640
 	 * @param string $query The query to check.
2641 2641
 	 * @return bool True if the collation is safe, false if it isn't.
2642 2642
 	 */
2643
-	protected function check_safe_collation( $query ) {
2644
-		if ( $this->checking_collation ) {
2643
+	protected function check_safe_collation($query) {
2644
+		if ($this->checking_collation) {
2645 2645
 			return true;
2646 2646
 		}
2647 2647
 
2648 2648
 		// We don't need to check the collation for queries that don't read data.
2649
-		$query = ltrim( $query, "\r\n\t (" );
2650
-		if ( preg_match( '/^(?:SHOW|DESCRIBE|DESC|EXPLAIN|CREATE)\s/i', $query ) ) {
2649
+		$query = ltrim($query, "\r\n\t (");
2650
+		if (preg_match('/^(?:SHOW|DESCRIBE|DESC|EXPLAIN|CREATE)\s/i', $query)) {
2651 2651
 			return true;
2652 2652
 		}
2653 2653
 
2654 2654
 		// All-ASCII queries don't need extra checking.
2655
-		if ( $this->check_ascii( $query ) ) {
2655
+		if ($this->check_ascii($query)) {
2656 2656
 			return true;
2657 2657
 		}
2658 2658
 
2659
-		$table = $this->get_table_from_query( $query );
2660
-		if ( ! $table ) {
2659
+		$table = $this->get_table_from_query($query);
2660
+		if ( ! $table) {
2661 2661
 			return false;
2662 2662
 		}
2663 2663
 
2664 2664
 		$this->checking_collation = true;
2665
-		$collation = $this->get_table_charset( $table );
2665
+		$collation = $this->get_table_charset($table);
2666 2666
 		$this->checking_collation = false;
2667 2667
 
2668 2668
 		// Tables with no collation, or latin1 only, don't need extra checking.
2669
-		if ( false === $collation || 'latin1' === $collation ) {
2669
+		if (false === $collation || 'latin1' === $collation) {
2670 2670
 			return true;
2671 2671
 		}
2672 2672
 
2673
-		$table = strtolower( $table );
2674
-		if ( empty( $this->col_meta[ $table ] ) ) {
2673
+		$table = strtolower($table);
2674
+		if (empty($this->col_meta[$table])) {
2675 2675
 			return false;
2676 2676
 		}
2677 2677
 
2678 2678
 		// If any of the columns don't have one of these collations, it needs more sanity checking.
2679
-		foreach ( $this->col_meta[ $table ] as $col ) {
2680
-			if ( empty( $col->Collation ) ) {
2679
+		foreach ($this->col_meta[$table] as $col) {
2680
+			if (empty($col->Collation)) {
2681 2681
 				continue;
2682 2682
 			}
2683 2683
 
2684
-			if ( ! in_array( $col->Collation, array( 'utf8_general_ci', 'utf8_bin', 'utf8mb4_general_ci', 'utf8mb4_bin' ), true ) ) {
2684
+			if ( ! in_array($col->Collation, array('utf8_general_ci', 'utf8_bin', 'utf8mb4_general_ci', 'utf8mb4_bin'), true)) {
2685 2685
 				return false;
2686 2686
 			}
2687 2687
 		}
@@ -2703,13 +2703,13 @@  discard block
 block discarded – undo
2703 2703
 	 *                        such as 'field' are retained in each value array. If we cannot
2704 2704
 	 *                        remove invalid characters, a WP_Error object is returned.
2705 2705
 	 */
2706
-	protected function strip_invalid_text( $data ) {
2706
+	protected function strip_invalid_text($data) {
2707 2707
 		$db_check_string = false;
2708 2708
 
2709
-		foreach ( $data as &$value ) {
2709
+		foreach ($data as &$value) {
2710 2710
 			$charset = $value['charset'];
2711 2711
 
2712
-			if ( is_array( $value['length'] ) ) {
2712
+			if (is_array($value['length'])) {
2713 2713
 				$length = $value['length']['length'];
2714 2714
 				$truncate_by_byte_length = 'byte' === $value['length']['type'];
2715 2715
 			} else {
@@ -2721,12 +2721,12 @@  discard block
 block discarded – undo
2721 2721
 			}
2722 2722
 
2723 2723
 			// There's no charset to work with.
2724
-			if ( false === $charset ) {
2724
+			if (false === $charset) {
2725 2725
 				continue;
2726 2726
 			}
2727 2727
 
2728 2728
 			// Column isn't a string.
2729
-			if ( ! is_string( $value['value'] ) ) {
2729
+			if ( ! is_string($value['value'])) {
2730 2730
 				continue;
2731 2731
 			}
2732 2732
 
@@ -2736,26 +2736,26 @@  discard block
 block discarded – undo
2736 2736
 				'latin1' === $charset
2737 2737
 			||
2738 2738
 				// ASCII is always OK.
2739
-				( ! isset( $value['ascii'] ) && $this->check_ascii( $value['value'] ) )
2739
+				( ! isset($value['ascii']) && $this->check_ascii($value['value']))
2740 2740
 			) {
2741 2741
 				$truncate_by_byte_length = true;
2742 2742
 				$needs_validation = false;
2743 2743
 			}
2744 2744
 
2745
-			if ( $truncate_by_byte_length ) {
2745
+			if ($truncate_by_byte_length) {
2746 2746
 				mbstring_binary_safe_encoding();
2747
-				if ( false !== $length && strlen( $value['value'] ) > $length ) {
2748
-					$value['value'] = substr( $value['value'], 0, $length );
2747
+				if (false !== $length && strlen($value['value']) > $length) {
2748
+					$value['value'] = substr($value['value'], 0, $length);
2749 2749
 				}
2750 2750
 				reset_mbstring_encoding();
2751 2751
 
2752
-				if ( ! $needs_validation ) {
2752
+				if ( ! $needs_validation) {
2753 2753
 					continue;
2754 2754
 				}
2755 2755
 			}
2756 2756
 
2757 2757
 			// utf8 can be handled by regex, which is a bunch faster than a DB lookup.
2758
-			if ( ( 'utf8' === $charset || 'utf8mb3' === $charset || 'utf8mb4' === $charset ) && function_exists( 'mb_strlen' ) ) {
2758
+			if (('utf8' === $charset || 'utf8mb3' === $charset || 'utf8mb4' === $charset) && function_exists('mb_strlen')) {
2759 2759
 				$regex = '/
2760 2760
 					(
2761 2761
 						(?: [\x00-\x7F]                  # single-byte sequences   0xxxxxxx
@@ -2765,7 +2765,7 @@  discard block
 block discarded – undo
2765 2765
 						|   \xED[\x80-\x9F][\x80-\xBF]
2766 2766
 						|   [\xEE-\xEF][\x80-\xBF]{2}';
2767 2767
 
2768
-				if ( 'utf8mb4' === $charset ) {
2768
+				if ('utf8mb4' === $charset) {
2769 2769
 					$regex .= '
2770 2770
 						|    \xF0[\x90-\xBF][\x80-\xBF]{2} # four-byte sequences   11110xxx 10xxxxxx * 3
2771 2771
 						|    [\xF1-\xF3][\x80-\xBF]{3}
@@ -2777,11 +2777,11 @@  discard block
 block discarded – undo
2777 2777
 					)
2778 2778
 					| .                                  # anything else
2779 2779
 					/x';
2780
-				$value['value'] = preg_replace( $regex, '$1', $value['value'] );
2780
+				$value['value'] = preg_replace($regex, '$1', $value['value']);
2781 2781
 
2782 2782
 
2783
-				if ( false !== $length && mb_strlen( $value['value'], 'UTF-8' ) > $length ) {
2784
-					$value['value'] = mb_substr( $value['value'], 0, $length, 'UTF-8' );
2783
+				if (false !== $length && mb_strlen($value['value'], 'UTF-8') > $length) {
2784
+					$value['value'] = mb_substr($value['value'], 0, $length, 'UTF-8');
2785 2785
 				}
2786 2786
 				continue;
2787 2787
 			}
@@ -2789,59 +2789,59 @@  discard block
 block discarded – undo
2789 2789
 			// We couldn't use any local conversions, send it to the DB.
2790 2790
 			$value['db'] = $db_check_string = true;
2791 2791
 		}
2792
-		unset( $value ); // Remove by reference.
2792
+		unset($value); // Remove by reference.
2793 2793
 
2794
-		if ( $db_check_string ) {
2794
+		if ($db_check_string) {
2795 2795
 			$queries = array();
2796
-			foreach ( $data as $col => $value ) {
2797
-				if ( ! empty( $value['db'] ) ) {
2796
+			foreach ($data as $col => $value) {
2797
+				if ( ! empty($value['db'])) {
2798 2798
 					// We're going to need to truncate by characters or bytes, depending on the length value we have.
2799
-					if ( 'byte' === $value['length']['type'] ) {
2799
+					if ('byte' === $value['length']['type']) {
2800 2800
 						// Using binary causes LEFT() to truncate by bytes.
2801 2801
 						$charset = 'binary';
2802 2802
 					} else {
2803 2803
 						$charset = $value['charset'];
2804 2804
 					}
2805 2805
 
2806
-					if ( $this->charset ) {
2806
+					if ($this->charset) {
2807 2807
 						$connection_charset = $this->charset;
2808 2808
 					} else {
2809
-						if ( $this->use_mysqli ) {
2810
-							$connection_charset = mysqli_character_set_name( $this->dbh );
2809
+						if ($this->use_mysqli) {
2810
+							$connection_charset = mysqli_character_set_name($this->dbh);
2811 2811
 						} else {
2812 2812
 							$connection_charset = mysql_client_encoding();
2813 2813
 						}
2814 2814
 					}
2815 2815
 
2816
-					if ( is_array( $value['length'] ) ) {
2817
-						$queries[ $col ] = $this->prepare( "CONVERT( LEFT( CONVERT( %s USING $charset ), %.0f ) USING $connection_charset )", $value['value'], $value['length']['length'] );
2818
-					} else if ( 'binary' !== $charset ) {
2816
+					if (is_array($value['length'])) {
2817
+						$queries[$col] = $this->prepare("CONVERT( LEFT( CONVERT( %s USING $charset ), %.0f ) USING $connection_charset )", $value['value'], $value['length']['length']);
2818
+					} else if ('binary' !== $charset) {
2819 2819
 						// If we don't have a length, there's no need to convert binary - it will always return the same result.
2820
-						$queries[ $col ] = $this->prepare( "CONVERT( CONVERT( %s USING $charset ) USING $connection_charset )", $value['value'] );
2820
+						$queries[$col] = $this->prepare("CONVERT( CONVERT( %s USING $charset ) USING $connection_charset )", $value['value']);
2821 2821
 					}
2822 2822
 
2823
-					unset( $data[ $col ]['db'] );
2823
+					unset($data[$col]['db']);
2824 2824
 				}
2825 2825
 			}
2826 2826
 
2827 2827
 			$sql = array();
2828
-			foreach ( $queries as $column => $query ) {
2829
-				if ( ! $query ) {
2828
+			foreach ($queries as $column => $query) {
2829
+				if ( ! $query) {
2830 2830
 					continue;
2831 2831
 				}
2832 2832
 
2833
-				$sql[] = $query . " AS x_$column";
2833
+				$sql[] = $query." AS x_$column";
2834 2834
 			}
2835 2835
 
2836 2836
 			$this->check_current_query = false;
2837
-			$row = $this->get_row( "SELECT " . implode( ', ', $sql ), ARRAY_A );
2838
-			if ( ! $row ) {
2839
-				return new WP_Error( 'wpdb_strip_invalid_text_failure' );
2837
+			$row = $this->get_row("SELECT ".implode(', ', $sql), ARRAY_A);
2838
+			if ( ! $row) {
2839
+				return new WP_Error('wpdb_strip_invalid_text_failure');
2840 2840
 			}
2841 2841
 
2842
-			foreach ( array_keys( $data ) as $column ) {
2843
-				if ( isset( $row["x_$column"] ) ) {
2844
-					$data[ $column ]['value'] = $row["x_$column"];
2842
+			foreach (array_keys($data) as $column) {
2843
+				if (isset($row["x_$column"])) {
2844
+					$data[$column]['value'] = $row["x_$column"];
2845 2845
 				}
2846 2846
 			}
2847 2847
 		}
@@ -2858,22 +2858,22 @@  discard block
 block discarded – undo
2858 2858
 	 * @param string $query Query to convert.
2859 2859
 	 * @return string|WP_Error The converted query, or a WP_Error object if the conversion fails.
2860 2860
 	 */
2861
-	protected function strip_invalid_text_from_query( $query ) {
2861
+	protected function strip_invalid_text_from_query($query) {
2862 2862
 		// We don't need to check the collation for queries that don't read data.
2863
-		$trimmed_query = ltrim( $query, "\r\n\t (" );
2864
-		if ( preg_match( '/^(?:SHOW|DESCRIBE|DESC|EXPLAIN|CREATE)\s/i', $trimmed_query ) ) {
2863
+		$trimmed_query = ltrim($query, "\r\n\t (");
2864
+		if (preg_match('/^(?:SHOW|DESCRIBE|DESC|EXPLAIN|CREATE)\s/i', $trimmed_query)) {
2865 2865
 			return $query;
2866 2866
 		}
2867 2867
 
2868
-		$table = $this->get_table_from_query( $query );
2869
-		if ( $table ) {
2870
-			$charset = $this->get_table_charset( $table );
2871
-			if ( is_wp_error( $charset ) ) {
2868
+		$table = $this->get_table_from_query($query);
2869
+		if ($table) {
2870
+			$charset = $this->get_table_charset($table);
2871
+			if (is_wp_error($charset)) {
2872 2872
 				return $charset;
2873 2873
 			}
2874 2874
 
2875 2875
 			// We can't reliably strip text from tables containing binary/blob columns
2876
-			if ( 'binary' === $charset ) {
2876
+			if ('binary' === $charset) {
2877 2877
 				return $query;
2878 2878
 			}
2879 2879
 		} else {
@@ -2887,8 +2887,8 @@  discard block
 block discarded – undo
2887 2887
 			'length'  => false,
2888 2888
 		);
2889 2889
 
2890
-		$data = $this->strip_invalid_text( array( $data ) );
2891
-		if ( is_wp_error( $data ) ) {
2890
+		$data = $this->strip_invalid_text(array($data));
2891
+		if (is_wp_error($data)) {
2892 2892
 			return $data;
2893 2893
 		}
2894 2894
 
@@ -2906,16 +2906,16 @@  discard block
 block discarded – undo
2906 2906
 	 * @param string $value  The text to check.
2907 2907
 	 * @return string|WP_Error The converted string, or a WP_Error object if the conversion fails.
2908 2908
 	 */
2909
-	public function strip_invalid_text_for_column( $table, $column, $value ) {
2910
-		if ( ! is_string( $value ) ) {
2909
+	public function strip_invalid_text_for_column($table, $column, $value) {
2910
+		if ( ! is_string($value)) {
2911 2911
 			return $value;
2912 2912
 		}
2913 2913
 
2914
-		$charset = $this->get_col_charset( $table, $column );
2915
-		if ( ! $charset ) {
2914
+		$charset = $this->get_col_charset($table, $column);
2915
+		if ( ! $charset) {
2916 2916
 			// Not a string column.
2917 2917
 			return $value;
2918
-		} elseif ( is_wp_error( $charset ) ) {
2918
+		} elseif (is_wp_error($charset)) {
2919 2919
 			// Bail on real errors.
2920 2920
 			return $charset;
2921 2921
 		}
@@ -2924,16 +2924,16 @@  discard block
 block discarded – undo
2924 2924
 			$column => array(
2925 2925
 				'value'   => $value,
2926 2926
 				'charset' => $charset,
2927
-				'length'  => $this->get_col_length( $table, $column ),
2927
+				'length'  => $this->get_col_length($table, $column),
2928 2928
 			)
2929 2929
 		);
2930 2930
 
2931
-		$data = $this->strip_invalid_text( $data );
2932
-		if ( is_wp_error( $data ) ) {
2931
+		$data = $this->strip_invalid_text($data);
2932
+		if (is_wp_error($data)) {
2933 2933
 			return $data;
2934 2934
 		}
2935 2935
 
2936
-		return $data[ $column ]['value'];
2936
+		return $data[$column]['value'];
2937 2937
 	}
2938 2938
 
2939 2939
 	/**
@@ -2945,37 +2945,37 @@  discard block
 block discarded – undo
2945 2945
 	 * @param string $query The query to search.
2946 2946
 	 * @return string|false $table The table name found, or false if a table couldn't be found.
2947 2947
 	 */
2948
-	protected function get_table_from_query( $query ) {
2948
+	protected function get_table_from_query($query) {
2949 2949
 		// Remove characters that can legally trail the table name.
2950
-		$query = rtrim( $query, ';/-#' );
2950
+		$query = rtrim($query, ';/-#');
2951 2951
 
2952 2952
 		// Allow (select...) union [...] style queries. Use the first query's table name.
2953
-		$query = ltrim( $query, "\r\n\t (" );
2953
+		$query = ltrim($query, "\r\n\t (");
2954 2954
 
2955 2955
 		// Strip everything between parentheses except nested selects.
2956
-		$query = preg_replace( '/\((?!\s*select)[^(]*?\)/is', '()', $query );
2956
+		$query = preg_replace('/\((?!\s*select)[^(]*?\)/is', '()', $query);
2957 2957
 
2958 2958
 		// Quickly match most common queries.
2959
-		if ( preg_match( '/^\s*(?:'
2959
+		if (preg_match('/^\s*(?:'
2960 2960
 				. 'SELECT.*?\s+FROM'
2961 2961
 				. '|INSERT(?:\s+LOW_PRIORITY|\s+DELAYED|\s+HIGH_PRIORITY)?(?:\s+IGNORE)?(?:\s+INTO)?'
2962 2962
 				. '|REPLACE(?:\s+LOW_PRIORITY|\s+DELAYED)?(?:\s+INTO)?'
2963 2963
 				. '|UPDATE(?:\s+LOW_PRIORITY)?(?:\s+IGNORE)?'
2964 2964
 				. '|DELETE(?:\s+LOW_PRIORITY|\s+QUICK|\s+IGNORE)*(?:\s+FROM)?'
2965
-				. ')\s+((?:[0-9a-zA-Z$_.`-]|[\xC2-\xDF][\x80-\xBF])+)/is', $query, $maybe ) ) {
2966
-			return str_replace( '`', '', $maybe[1] );
2965
+				. ')\s+((?:[0-9a-zA-Z$_.`-]|[\xC2-\xDF][\x80-\xBF])+)/is', $query, $maybe)) {
2966
+			return str_replace('`', '', $maybe[1]);
2967 2967
 		}
2968 2968
 
2969 2969
 		// SHOW TABLE STATUS and SHOW TABLES
2970
-		if ( preg_match( '/^\s*(?:'
2970
+		if (preg_match('/^\s*(?:'
2971 2971
 				. 'SHOW\s+TABLE\s+STATUS.+(?:LIKE\s+|WHERE\s+Name\s*=\s*)'
2972 2972
 				. '|SHOW\s+(?:FULL\s+)?TABLES.+(?:LIKE\s+|WHERE\s+Name\s*=\s*)'
2973
-				. ')\W((?:[0-9a-zA-Z$_.`-]|[\xC2-\xDF][\x80-\xBF])+)\W/is', $query, $maybe ) ) {
2974
-			return str_replace( '`', '', $maybe[1] );
2973
+				. ')\W((?:[0-9a-zA-Z$_.`-]|[\xC2-\xDF][\x80-\xBF])+)\W/is', $query, $maybe)) {
2974
+			return str_replace('`', '', $maybe[1]);
2975 2975
 		}
2976 2976
 
2977 2977
 		// Big pattern for the rest of the table-related queries.
2978
-		if ( preg_match( '/^\s*(?:'
2978
+		if (preg_match('/^\s*(?:'
2979 2979
 				. '(?:EXPLAIN\s+(?:EXTENDED\s+)?)?SELECT.*?\s+FROM'
2980 2980
 				. '|DESCRIBE|DESC|EXPLAIN|HANDLER'
2981 2981
 				. '|(?:LOCK|UNLOCK)\s+TABLE(?:S)?'
@@ -2989,8 +2989,8 @@  discard block
 block discarded – undo
2989 2989
 				. '|LOAD\s+DATA.*INFILE.*INTO\s+TABLE'
2990 2990
 				. '|(?:GRANT|REVOKE).*ON\s+TABLE'
2991 2991
 				. '|SHOW\s+(?:.*FROM|.*TABLE)'
2992
-				. ')\s+\(*\s*((?:[0-9a-zA-Z$_.`-]|[\xC2-\xDF][\x80-\xBF])+)\s*\)*/is', $query, $maybe ) ) {
2993
-			return str_replace( '`', '', $maybe[1] );
2992
+				. ')\s+\(*\s*((?:[0-9a-zA-Z$_.`-]|[\xC2-\xDF][\x80-\xBF])+)\s*\)*/is', $query, $maybe)) {
2993
+			return str_replace('`', '', $maybe[1]);
2994 2994
 		}
2995 2995
 
2996 2996
 		return false;
@@ -3004,18 +3004,18 @@  discard block
 block discarded – undo
3004 3004
 	 * @access protected
3005 3005
 	 */
3006 3006
 	protected function load_col_info() {
3007
-		if ( $this->col_info )
3007
+		if ($this->col_info)
3008 3008
 			return;
3009 3009
 
3010
-		if ( $this->use_mysqli ) {
3011
-			$num_fields = mysqli_num_fields( $this->result );
3012
-			for ( $i = 0; $i < $num_fields; $i++ ) {
3013
-				$this->col_info[ $i ] = mysqli_fetch_field( $this->result );
3010
+		if ($this->use_mysqli) {
3011
+			$num_fields = mysqli_num_fields($this->result);
3012
+			for ($i = 0; $i < $num_fields; $i++) {
3013
+				$this->col_info[$i] = mysqli_fetch_field($this->result);
3014 3014
 			}
3015 3015
 		} else {
3016
-			$num_fields = mysql_num_fields( $this->result );
3017
-			for ( $i = 0; $i < $num_fields; $i++ ) {
3018
-				$this->col_info[ $i ] = mysql_fetch_field( $this->result, $i );
3016
+			$num_fields = mysql_num_fields($this->result);
3017
+			for ($i = 0; $i < $num_fields; $i++) {
3018
+				$this->col_info[$i] = mysql_fetch_field($this->result, $i);
3019 3019
 			}
3020 3020
 		}
3021 3021
 	}
@@ -3029,14 +3029,14 @@  discard block
 block discarded – undo
3029 3029
 	 * @param int    $col_offset Optional. 0: col name. 1: which table the col's in. 2: col's max length. 3: if the col is numeric. 4: col's type
3030 3030
 	 * @return mixed Column Results
3031 3031
 	 */
3032
-	public function get_col_info( $info_type = 'name', $col_offset = -1 ) {
3032
+	public function get_col_info($info_type = 'name', $col_offset = -1) {
3033 3033
 		$this->load_col_info();
3034 3034
 
3035
-		if ( $this->col_info ) {
3036
-			if ( $col_offset == -1 ) {
3035
+		if ($this->col_info) {
3036
+			if ($col_offset == -1) {
3037 3037
 				$i = 0;
3038 3038
 				$new_array = array();
3039
-				foreach ( (array) $this->col_info as $col ) {
3039
+				foreach ((array) $this->col_info as $col) {
3040 3040
 					$new_array[$i] = $col->{$info_type};
3041 3041
 					$i++;
3042 3042
 				}
@@ -3055,7 +3055,7 @@  discard block
 block discarded – undo
3055 3055
 	 * @return true
3056 3056
 	 */
3057 3057
 	public function timer_start() {
3058
-		$this->time_start = microtime( true );
3058
+		$this->time_start = microtime(true);
3059 3059
 		return true;
3060 3060
 	}
3061 3061
 
@@ -3067,7 +3067,7 @@  discard block
 block discarded – undo
3067 3067
 	 * @return float Total time spent on the query, in seconds
3068 3068
 	 */
3069 3069
 	public function timer_stop() {
3070
-		return ( microtime( true ) - $this->time_start );
3070
+		return (microtime(true) - $this->time_start);
3071 3071
 	}
3072 3072
 
3073 3073
 	/**
@@ -3081,9 +3081,9 @@  discard block
 block discarded – undo
3081 3081
 	 * @param string $error_code Optional. A Computer readable string to identify the error.
3082 3082
 	 * @return false|void
3083 3083
 	 */
3084
-	public function bail( $message, $error_code = '500' ) {
3085
-		if ( !$this->show_errors ) {
3086
-			if ( class_exists( 'WP_Error', false ) ) {
3084
+	public function bail($message, $error_code = '500') {
3085
+		if ( ! $this->show_errors) {
3086
+			if (class_exists('WP_Error', false)) {
3087 3087
 				$this->error = new WP_Error($error_code, $message);
3088 3088
 			} else {
3089 3089
 				$this->error = $message;
@@ -3104,17 +3104,17 @@  discard block
 block discarded – undo
3104 3104
 	 *              or the connection doesn't exist.
3105 3105
 	 */
3106 3106
 	public function close() {
3107
-		if ( ! $this->dbh ) {
3107
+		if ( ! $this->dbh) {
3108 3108
 			return false;
3109 3109
 		}
3110 3110
 
3111
-		if ( $this->use_mysqli ) {
3112
-			$closed = mysqli_close( $this->dbh );
3111
+		if ($this->use_mysqli) {
3112
+			$closed = mysqli_close($this->dbh);
3113 3113
 		} else {
3114
-			$closed = mysql_close( $this->dbh );
3114
+			$closed = mysql_close($this->dbh);
3115 3115
 		}
3116 3116
 
3117
-		if ( $closed ) {
3117
+		if ($closed) {
3118 3118
 			$this->dbh = null;
3119 3119
 			$this->ready = false;
3120 3120
 			$this->has_connected = false;
@@ -3136,8 +3136,8 @@  discard block
 block discarded – undo
3136 3136
 	public function check_database_version() {
3137 3137
 		global $wp_version, $required_mysql_version;
3138 3138
 		// Make sure the server has the required MySQL version
3139
-		if ( version_compare($this->db_version(), $required_mysql_version, '<') )
3140
-			return new WP_Error('database_version', sprintf( __( '<strong>ERROR</strong>: WordPress %1$s requires MySQL %2$s or higher' ), $wp_version, $required_mysql_version ));
3139
+		if (version_compare($this->db_version(), $required_mysql_version, '<'))
3140
+			return new WP_Error('database_version', sprintf(__('<strong>ERROR</strong>: WordPress %1$s requires MySQL %2$s or higher'), $wp_version, $required_mysql_version));
3141 3141
 	}
3142 3142
 
3143 3143
 	/**
@@ -3153,8 +3153,8 @@  discard block
 block discarded – undo
3153 3153
 	 * @return bool True if collation is supported, false if version does not
3154 3154
 	 */
3155 3155
 	public function supports_collation() {
3156
-		_deprecated_function( __FUNCTION__, '3.5', 'wpdb::has_cap( \'collation\' )' );
3157
-		return $this->has_cap( 'collation' );
3156
+		_deprecated_function(__FUNCTION__, '3.5', 'wpdb::has_cap( \'collation\' )');
3157
+		return $this->has_cap('collation');
3158 3158
 	}
3159 3159
 
3160 3160
 	/**
@@ -3167,9 +3167,9 @@  discard block
 block discarded – undo
3167 3167
 	public function get_charset_collate() {
3168 3168
 		$charset_collate = '';
3169 3169
 
3170
-		if ( ! empty( $this->charset ) )
3170
+		if ( ! empty($this->charset))
3171 3171
 			$charset_collate = "DEFAULT CHARACTER SET $this->charset";
3172
-		if ( ! empty( $this->collate ) )
3172
+		if ( ! empty($this->collate))
3173 3173
 			$charset_collate .= " COLLATE $this->collate";
3174 3174
 
3175 3175
 		return $charset_collate;
@@ -3188,21 +3188,21 @@  discard block
 block discarded – undo
3188 3188
 	 *                       or 'utf8mb4'.
3189 3189
 	 * @return int|false Whether the database feature is supported, false otherwise.
3190 3190
 	 */
3191
-	public function has_cap( $db_cap ) {
3191
+	public function has_cap($db_cap) {
3192 3192
 		$version = $this->db_version();
3193 3193
 
3194
-		switch ( strtolower( $db_cap ) ) {
3194
+		switch (strtolower($db_cap)) {
3195 3195
 			case 'collation' :    // @since 2.5.0
3196 3196
 			case 'group_concat' : // @since 2.7.0
3197 3197
 			case 'subqueries' :   // @since 2.7.0
3198
-				return version_compare( $version, '4.1', '>=' );
3198
+				return version_compare($version, '4.1', '>=');
3199 3199
 			case 'set_charset' :
3200
-				return version_compare( $version, '5.0.7', '>=' );
3200
+				return version_compare($version, '5.0.7', '>=');
3201 3201
 			case 'utf8mb4' :      // @since 4.1.0
3202
-				if ( version_compare( $version, '5.5.3', '<' ) ) {
3202
+				if (version_compare($version, '5.5.3', '<')) {
3203 3203
 					return false;
3204 3204
 				}
3205
-				if ( $this->use_mysqli ) {
3205
+				if ($this->use_mysqli) {
3206 3206
 					$client_version = mysqli_get_client_info();
3207 3207
 				} else {
3208 3208
 					$client_version = mysql_get_client_info();
@@ -3212,11 +3212,11 @@  discard block
 block discarded – undo
3212 3212
 				 * libmysql has supported utf8mb4 since 5.5.3, same as the MySQL server.
3213 3213
 				 * mysqlnd has supported utf8mb4 since 5.0.9.
3214 3214
 				 */
3215
-				if ( false !== strpos( $client_version, 'mysqlnd' ) ) {
3216
-					$client_version = preg_replace( '/^\D+([\d.]+).*/', '$1', $client_version );
3217
-					return version_compare( $client_version, '5.0.9', '>=' );
3215
+				if (false !== strpos($client_version, 'mysqlnd')) {
3216
+					$client_version = preg_replace('/^\D+([\d.]+).*/', '$1', $client_version);
3217
+					return version_compare($client_version, '5.0.9', '>=');
3218 3218
 				} else {
3219
-					return version_compare( $client_version, '5.5.3', '>=' );
3219
+					return version_compare($client_version, '5.5.3', '>=');
3220 3220
 				}
3221 3221
 		}
3222 3222
 
@@ -3234,7 +3234,7 @@  discard block
 block discarded – undo
3234 3234
 	 * @return string|array The name of the calling function
3235 3235
 	 */
3236 3236
 	public function get_caller() {
3237
-		return wp_debug_backtrace_summary( __CLASS__ );
3237
+		return wp_debug_backtrace_summary(__CLASS__);
3238 3238
 	}
3239 3239
 
3240 3240
 	/**
@@ -3245,11 +3245,11 @@  discard block
 block discarded – undo
3245 3245
 	 * @return null|string Null on failure, version number on success.
3246 3246
 	 */
3247 3247
 	public function db_version() {
3248
-		if ( $this->use_mysqli ) {
3249
-			$server_info = mysqli_get_server_info( $this->dbh );
3248
+		if ($this->use_mysqli) {
3249
+			$server_info = mysqli_get_server_info($this->dbh);
3250 3250
 		} else {
3251
-			$server_info = mysql_get_server_info( $this->dbh );
3251
+			$server_info = mysql_get_server_info($this->dbh);
3252 3252
 		}
3253
-		return preg_replace( '/[^0-9.].*/', '', $server_info );
3253
+		return preg_replace('/[^0-9.].*/', '', $server_info);
3254 3254
 	}
3255 3255
 }
Please login to merge, or discard this patch.
Braces   +133 added lines, -92 removed lines patch added patch discarded remove patch
@@ -626,8 +626,9 @@  discard block
 block discarded – undo
626 626
 	public function __construct( $dbuser, $dbpassword, $dbname, $dbhost ) {
627 627
 		register_shutdown_function( array( $this, '__destruct' ) );
628 628
 
629
-		if ( WP_DEBUG && WP_DEBUG_DISPLAY )
630
-			$this->show_errors();
629
+		if ( WP_DEBUG && WP_DEBUG_DISPLAY ) {
630
+					$this->show_errors();
631
+		}
631 632
 
632 633
 		/* Use ext/mysqli if it exists and:
633 634
 		 *  - WP_USE_EXT_MYSQL is defined as false, or
@@ -678,8 +679,9 @@  discard block
 block discarded – undo
678 679
 	 * @return mixed The private member
679 680
 	 */
680 681
 	public function __get( $name ) {
681
-		if ( 'col_info' === $name )
682
-			$this->load_col_info();
682
+		if ( 'col_info' === $name ) {
683
+					$this->load_col_info();
684
+		}
683 685
 
684 686
 		return $this->$name;
685 687
 	}
@@ -772,18 +774,21 @@  discard block
 block discarded – undo
772 774
 	 * @param string   $collate Optional. The collation. Default null.
773 775
 	 */
774 776
 	public function set_charset( $dbh, $charset = null, $collate = null ) {
775
-		if ( ! isset( $charset ) )
776
-			$charset = $this->charset;
777
-		if ( ! isset( $collate ) )
778
-			$collate = $this->collate;
777
+		if ( ! isset( $charset ) ) {
778
+					$charset = $this->charset;
779
+		}
780
+		if ( ! isset( $collate ) ) {
781
+					$collate = $this->collate;
782
+		}
779 783
 		if ( $this->has_cap( 'collation' ) && ! empty( $charset ) ) {
780 784
 			if ( $this->use_mysqli ) {
781 785
 				if ( function_exists( 'mysqli_set_charset' ) && $this->has_cap( 'set_charset' ) ) {
782 786
 					mysqli_set_charset( $dbh, $charset );
783 787
 				} else {
784 788
 					$query = $this->prepare( 'SET NAMES %s', $charset );
785
-					if ( ! empty( $collate ) )
786
-						$query .= $this->prepare( ' COLLATE %s', $collate );
789
+					if ( ! empty( $collate ) ) {
790
+											$query .= $this->prepare( ' COLLATE %s', $collate );
791
+					}
787 792
 					mysqli_query( $dbh, $query );
788 793
 				}
789 794
 			} else {
@@ -791,8 +796,9 @@  discard block
 block discarded – undo
791 796
 					mysql_set_charset( $charset, $dbh );
792 797
 				} else {
793 798
 					$query = $this->prepare( 'SET NAMES %s', $charset );
794
-					if ( ! empty( $collate ) )
795
-						$query .= $this->prepare( ' COLLATE %s', $collate );
799
+					if ( ! empty( $collate ) ) {
800
+											$query .= $this->prepare( ' COLLATE %s', $collate );
801
+					}
796 802
 					mysql_query( $query, $dbh );
797 803
 				}
798 804
 			}
@@ -875,30 +881,36 @@  discard block
 block discarded – undo
875 881
 	 */
876 882
 	public function set_prefix( $prefix, $set_table_names = true ) {
877 883
 
878
-		if ( preg_match( '|[^a-z0-9_]|i', $prefix ) )
879
-			return new WP_Error('invalid_db_prefix', 'Invalid database prefix' );
884
+		if ( preg_match( '|[^a-z0-9_]|i', $prefix ) ) {
885
+					return new WP_Error('invalid_db_prefix', 'Invalid database prefix' );
886
+		}
880 887
 
881 888
 		$old_prefix = is_multisite() ? '' : $prefix;
882 889
 
883
-		if ( isset( $this->base_prefix ) )
884
-			$old_prefix = $this->base_prefix;
890
+		if ( isset( $this->base_prefix ) ) {
891
+					$old_prefix = $this->base_prefix;
892
+		}
885 893
 
886 894
 		$this->base_prefix = $prefix;
887 895
 
888 896
 		if ( $set_table_names ) {
889
-			foreach ( $this->tables( 'global' ) as $table => $prefixed_table )
890
-				$this->$table = $prefixed_table;
897
+			foreach ( $this->tables( 'global' ) as $table => $prefixed_table ) {
898
+							$this->$table = $prefixed_table;
899
+			}
891 900
 
892
-			if ( is_multisite() && empty( $this->blogid ) )
893
-				return $old_prefix;
901
+			if ( is_multisite() && empty( $this->blogid ) ) {
902
+							return $old_prefix;
903
+			}
894 904
 
895 905
 			$this->prefix = $this->get_blog_prefix();
896 906
 
897
-			foreach ( $this->tables( 'blog' ) as $table => $prefixed_table )
898
-				$this->$table = $prefixed_table;
907
+			foreach ( $this->tables( 'blog' ) as $table => $prefixed_table ) {
908
+							$this->$table = $prefixed_table;
909
+			}
899 910
 
900
-			foreach ( $this->tables( 'old' ) as $table => $prefixed_table )
901
-				$this->$table = $prefixed_table;
911
+			foreach ( $this->tables( 'old' ) as $table => $prefixed_table ) {
912
+							$this->$table = $prefixed_table;
913
+			}
902 914
 		}
903 915
 		return $old_prefix;
904 916
 	}
@@ -914,19 +926,22 @@  discard block
 block discarded – undo
914 926
 	 * @return int previous blog id
915 927
 	 */
916 928
 	public function set_blog_id( $blog_id, $site_id = 0 ) {
917
-		if ( ! empty( $site_id ) )
918
-			$this->siteid = $site_id;
929
+		if ( ! empty( $site_id ) ) {
930
+					$this->siteid = $site_id;
931
+		}
919 932
 
920 933
 		$old_blog_id  = $this->blogid;
921 934
 		$this->blogid = $blog_id;
922 935
 
923 936
 		$this->prefix = $this->get_blog_prefix();
924 937
 
925
-		foreach ( $this->tables( 'blog' ) as $table => $prefixed_table )
926
-			$this->$table = $prefixed_table;
938
+		foreach ( $this->tables( 'blog' ) as $table => $prefixed_table ) {
939
+					$this->$table = $prefixed_table;
940
+		}
927 941
 
928
-		foreach ( $this->tables( 'old' ) as $table => $prefixed_table )
929
-			$this->$table = $prefixed_table;
942
+		foreach ( $this->tables( 'old' ) as $table => $prefixed_table ) {
943
+					$this->$table = $prefixed_table;
944
+		}
930 945
 
931 946
 		return $old_blog_id;
932 947
 	}
@@ -940,13 +955,15 @@  discard block
 block discarded – undo
940 955
 	 */
941 956
 	public function get_blog_prefix( $blog_id = null ) {
942 957
 		if ( is_multisite() ) {
943
-			if ( null === $blog_id )
944
-				$blog_id = $this->blogid;
958
+			if ( null === $blog_id ) {
959
+							$blog_id = $this->blogid;
960
+			}
945 961
 			$blog_id = (int) $blog_id;
946
-			if ( defined( 'MULTISITE' ) && ( 0 == $blog_id || 1 == $blog_id ) )
947
-				return $this->base_prefix;
948
-			else
949
-				return $this->base_prefix . $blog_id . '_';
962
+			if ( defined( 'MULTISITE' ) && ( 0 == $blog_id || 1 == $blog_id ) ) {
963
+							return $this->base_prefix;
964
+			} else {
965
+							return $this->base_prefix . $blog_id . '_';
966
+			}
950 967
 		} else {
951 968
 			return $this->base_prefix;
952 969
 		}
@@ -983,16 +1000,18 @@  discard block
 block discarded – undo
983 1000
 		switch ( $scope ) {
984 1001
 			case 'all' :
985 1002
 				$tables = array_merge( $this->global_tables, $this->tables );
986
-				if ( is_multisite() )
987
-					$tables = array_merge( $tables, $this->ms_global_tables );
1003
+				if ( is_multisite() ) {
1004
+									$tables = array_merge( $tables, $this->ms_global_tables );
1005
+				}
988 1006
 				break;
989 1007
 			case 'blog' :
990 1008
 				$tables = $this->tables;
991 1009
 				break;
992 1010
 			case 'global' :
993 1011
 				$tables = $this->global_tables;
994
-				if ( is_multisite() )
995
-					$tables = array_merge( $tables, $this->ms_global_tables );
1012
+				if ( is_multisite() ) {
1013
+									$tables = array_merge( $tables, $this->ms_global_tables );
1014
+				}
996 1015
 				break;
997 1016
 			case 'ms_global' :
998 1017
 				$tables = $this->ms_global_tables;
@@ -1005,24 +1024,28 @@  discard block
 block discarded – undo
1005 1024
 		}
1006 1025
 
1007 1026
 		if ( $prefix ) {
1008
-			if ( ! $blog_id )
1009
-				$blog_id = $this->blogid;
1027
+			if ( ! $blog_id ) {
1028
+							$blog_id = $this->blogid;
1029
+			}
1010 1030
 			$blog_prefix = $this->get_blog_prefix( $blog_id );
1011 1031
 			$base_prefix = $this->base_prefix;
1012 1032
 			$global_tables = array_merge( $this->global_tables, $this->ms_global_tables );
1013 1033
 			foreach ( $tables as $k => $table ) {
1014
-				if ( in_array( $table, $global_tables ) )
1015
-					$tables[ $table ] = $base_prefix . $table;
1016
-				else
1017
-					$tables[ $table ] = $blog_prefix . $table;
1034
+				if ( in_array( $table, $global_tables ) ) {
1035
+									$tables[ $table ] = $base_prefix . $table;
1036
+				} else {
1037
+									$tables[ $table ] = $blog_prefix . $table;
1038
+				}
1018 1039
 				unset( $tables[ $k ] );
1019 1040
 			}
1020 1041
 
1021
-			if ( isset( $tables['users'] ) && defined( 'CUSTOM_USER_TABLE' ) )
1022
-				$tables['users'] = CUSTOM_USER_TABLE;
1042
+			if ( isset( $tables['users'] ) && defined( 'CUSTOM_USER_TABLE' ) ) {
1043
+							$tables['users'] = CUSTOM_USER_TABLE;
1044
+			}
1023 1045
 
1024
-			if ( isset( $tables['usermeta'] ) && defined( 'CUSTOM_USER_META_TABLE' ) )
1025
-				$tables['usermeta'] = CUSTOM_USER_META_TABLE;
1046
+			if ( isset( $tables['usermeta'] ) && defined( 'CUSTOM_USER_META_TABLE' ) ) {
1047
+							$tables['usermeta'] = CUSTOM_USER_META_TABLE;
1048
+			}
1026 1049
 		}
1027 1050
 
1028 1051
 		return $tables;
@@ -1040,8 +1063,9 @@  discard block
 block discarded – undo
1040 1063
 	 * @param resource|null $dbh Optional link identifier.
1041 1064
 	 */
1042 1065
 	public function select( $db, $dbh = null ) {
1043
-		if ( is_null($dbh) )
1044
-			$dbh = $this->dbh;
1066
+		if ( is_null($dbh) ) {
1067
+					$dbh = $this->dbh;
1068
+		}
1045 1069
 
1046 1070
 		if ( $this->use_mysqli ) {
1047 1071
 			$success = mysqli_select_db( $dbh, $db );
@@ -1105,8 +1129,9 @@  discard block
 block discarded – undo
1105 1129
 	 * @return string
1106 1130
 	 */
1107 1131
 	function _weak_escape( $string ) {
1108
-		if ( func_num_args() === 1 && function_exists( '_deprecated_function' ) )
1109
-			_deprecated_function( __METHOD__, '3.6', 'wpdb::prepare() or esc_sql()' );
1132
+		if ( func_num_args() === 1 && function_exists( '_deprecated_function' ) ) {
1133
+					_deprecated_function( __METHOD__, '3.6', 'wpdb::prepare() or esc_sql()' );
1134
+		}
1110 1135
 		return addslashes( $string );
1111 1136
 	}
1112 1137
 
@@ -1153,10 +1178,11 @@  discard block
 block discarded – undo
1153 1178
 	function _escape( $data ) {
1154 1179
 		if ( is_array( $data ) ) {
1155 1180
 			foreach ( $data as $k => $v ) {
1156
-				if ( is_array($v) )
1157
-					$data[$k] = $this->_escape( $v );
1158
-				else
1159
-					$data[$k] = $this->_real_escape( $v );
1181
+				if ( is_array($v) ) {
1182
+									$data[$k] = $this->_escape( $v );
1183
+				} else {
1184
+									$data[$k] = $this->_real_escape( $v );
1185
+				}
1160 1186
 			}
1161 1187
 		} else {
1162 1188
 			$data = $this->_real_escape( $data );
@@ -1179,14 +1205,16 @@  discard block
 block discarded – undo
1179 1205
 	 * @return mixed
1180 1206
 	 */
1181 1207
 	public function escape( $data ) {
1182
-		if ( func_num_args() === 1 && function_exists( '_deprecated_function' ) )
1183
-			_deprecated_function( __METHOD__, '3.6', 'wpdb::prepare() or esc_sql()' );
1208
+		if ( func_num_args() === 1 && function_exists( '_deprecated_function' ) ) {
1209
+					_deprecated_function( __METHOD__, '3.6', 'wpdb::prepare() or esc_sql()' );
1210
+		}
1184 1211
 		if ( is_array( $data ) ) {
1185 1212
 			foreach ( $data as $k => $v ) {
1186
-				if ( is_array( $v ) )
1187
-					$data[$k] = $this->escape( $v, 'recursive' );
1188
-				else
1189
-					$data[$k] = $this->_weak_escape( $v, 'internal' );
1213
+				if ( is_array( $v ) ) {
1214
+									$data[$k] = $this->escape( $v, 'recursive' );
1215
+				} else {
1216
+									$data[$k] = $this->_weak_escape( $v, 'internal' );
1217
+				}
1190 1218
 			}
1191 1219
 		} else {
1192 1220
 			$data = $this->_weak_escape( $data, 'internal' );
@@ -1205,8 +1233,9 @@  discard block
 block discarded – undo
1205 1233
 	 * @param string $string to escape
1206 1234
 	 */
1207 1235
 	public function escape_by_ref( &$string ) {
1208
-		if ( ! is_float( $string ) )
1209
-			$string = $this->_real_escape( $string );
1236
+		if ( ! is_float( $string ) ) {
1237
+					$string = $this->_real_escape( $string );
1238
+		}
1210 1239
 	}
1211 1240
 
1212 1241
 	/**
@@ -1244,8 +1273,9 @@  discard block
 block discarded – undo
1244 1273
 	 * @return string|void Sanitized query string, if there is a query to prepare.
1245 1274
 	 */
1246 1275
 	public function prepare( $query, $args ) {
1247
-		if ( is_null( $query ) )
1248
-			return;
1276
+		if ( is_null( $query ) ) {
1277
+					return;
1278
+		}
1249 1279
 
1250 1280
 		// This is not meant to be foolproof -- but it will catch obviously incorrect usage.
1251 1281
 		if ( strpos( $query, '%' ) === false ) {
@@ -1255,8 +1285,9 @@  discard block
 block discarded – undo
1255 1285
 		$args = func_get_args();
1256 1286
 		array_shift( $args );
1257 1287
 		// If args were passed as an array (as in vsprintf), move them up
1258
-		if ( isset( $args[0] ) && is_array($args[0]) )
1259
-			$args = $args[0];
1288
+		if ( isset( $args[0] ) && is_array($args[0]) ) {
1289
+					$args = $args[0];
1290
+		}
1260 1291
 		$query = str_replace( "'%s'", '%s', $query ); // in case someone mistakenly already singlequoted it
1261 1292
 		$query = str_replace( '"%s"', '%s', $query ); // doublequote unquoting
1262 1293
 		$query = preg_replace( '|(?<!%)%f|' , '%F', $query ); // Force floats to be locale unaware
@@ -1312,21 +1343,24 @@  discard block
 block discarded – undo
1312 1343
 		}
1313 1344
 		$EZSQL_ERROR[] = array( 'query' => $this->last_query, 'error_str' => $str );
1314 1345
 
1315
-		if ( $this->suppress_errors )
1316
-			return false;
1346
+		if ( $this->suppress_errors ) {
1347
+					return false;
1348
+		}
1317 1349
 
1318 1350
 		wp_load_translations_early();
1319 1351
 
1320
-		if ( $caller = $this->get_caller() )
1321
-			$error_str = sprintf( __( 'WordPress database error %1$s for query %2$s made by %3$s' ), $str, $this->last_query, $caller );
1322
-		else
1323
-			$error_str = sprintf( __( 'WordPress database error %1$s for query %2$s' ), $str, $this->last_query );
1352
+		if ( $caller = $this->get_caller() ) {
1353
+					$error_str = sprintf( __( 'WordPress database error %1$s for query %2$s made by %3$s' ), $str, $this->last_query, $caller );
1354
+		} else {
1355
+					$error_str = sprintf( __( 'WordPress database error %1$s for query %2$s' ), $str, $this->last_query );
1356
+		}
1324 1357
 
1325 1358
 		error_log( $error_str );
1326 1359
 
1327 1360
 		// Are we showing errors?
1328
-		if ( ! $this->show_errors )
1329
-			return false;
1361
+		if ( ! $this->show_errors ) {
1362
+					return false;
1363
+		}
1330 1364
 
1331 1365
 		// If there is an error then take note of it
1332 1366
 		if ( is_multisite() ) {
@@ -1734,8 +1768,9 @@  discard block
 block discarded – undo
1734 1768
 
1735 1769
 		if ( $this->last_error ) {
1736 1770
 			// Clear insert_id on a subsequent failed insert.
1737
-			if ( $this->insert_id && preg_match( '/^\s*(insert|replace)\s/i', $query ) )
1738
-				$this->insert_id = 0;
1771
+			if ( $this->insert_id && preg_match( '/^\s*(insert|replace)\s/i', $query ) ) {
1772
+							$this->insert_id = 0;
1773
+			}
1739 1774
 
1740 1775
 			$this->print_error();
1741 1776
 			return false;
@@ -2241,8 +2276,9 @@  discard block
 block discarded – undo
2241 2276
 			return null;
2242 2277
 		}
2243 2278
 
2244
-		if ( !isset( $this->last_result[$y] ) )
2245
-			return null;
2279
+		if ( !isset( $this->last_result[$y] ) ) {
2280
+					return null;
2281
+		}
2246 2282
 
2247 2283
 		if ( $output == OBJECT ) {
2248 2284
 			return $this->last_result[$y] ? $this->last_result[$y] : null;
@@ -2326,8 +2362,9 @@  discard block
 block discarded – undo
2326 2362
 			foreach ( $this->last_result as $row ) {
2327 2363
 				$var_by_ref = get_object_vars( $row );
2328 2364
 				$key = array_shift( $var_by_ref );
2329
-				if ( ! isset( $new_array[ $key ] ) )
2330
-					$new_array[ $key ] = $row;
2365
+				if ( ! isset( $new_array[ $key ] ) ) {
2366
+									$new_array[ $key ] = $row;
2367
+				}
2331 2368
 			}
2332 2369
 			return $new_array;
2333 2370
 		} elseif ( $output == ARRAY_A || $output == ARRAY_N ) {
@@ -3004,8 +3041,9 @@  discard block
 block discarded – undo
3004 3041
 	 * @access protected
3005 3042
 	 */
3006 3043
 	protected function load_col_info() {
3007
-		if ( $this->col_info )
3008
-			return;
3044
+		if ( $this->col_info ) {
3045
+					return;
3046
+		}
3009 3047
 
3010 3048
 		if ( $this->use_mysqli ) {
3011 3049
 			$num_fields = mysqli_num_fields( $this->result );
@@ -3136,8 +3174,9 @@  discard block
 block discarded – undo
3136 3174
 	public function check_database_version() {
3137 3175
 		global $wp_version, $required_mysql_version;
3138 3176
 		// Make sure the server has the required MySQL version
3139
-		if ( version_compare($this->db_version(), $required_mysql_version, '<') )
3140
-			return new WP_Error('database_version', sprintf( __( '<strong>ERROR</strong>: WordPress %1$s requires MySQL %2$s or higher' ), $wp_version, $required_mysql_version ));
3177
+		if ( version_compare($this->db_version(), $required_mysql_version, '<') ) {
3178
+					return new WP_Error('database_version', sprintf( __( '<strong>ERROR</strong>: WordPress %1$s requires MySQL %2$s or higher' ), $wp_version, $required_mysql_version ));
3179
+		}
3141 3180
 	}
3142 3181
 
3143 3182
 	/**
@@ -3167,10 +3206,12 @@  discard block
 block discarded – undo
3167 3206
 	public function get_charset_collate() {
3168 3207
 		$charset_collate = '';
3169 3208
 
3170
-		if ( ! empty( $this->charset ) )
3171
-			$charset_collate = "DEFAULT CHARACTER SET $this->charset";
3172
-		if ( ! empty( $this->collate ) )
3173
-			$charset_collate .= " COLLATE $this->collate";
3209
+		if ( ! empty( $this->charset ) ) {
3210
+					$charset_collate = "DEFAULT CHARACTER SET $this->charset";
3211
+		}
3212
+		if ( ! empty( $this->collate ) ) {
3213
+					$charset_collate .= " COLLATE $this->collate";
3214
+		}
3174 3215
 
3175 3216
 		return $charset_collate;
3176 3217
 	}
Please login to merge, or discard this patch.
src/wp-includes/Text/Diff/Engine/shell.php 3 patches
Indentation   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -16,147 +16,147 @@
 block discarded – undo
16 16
  */
17 17
 class Text_Diff_Engine_shell {
18 18
 
19
-    /**
20
-     * Path to the diff executable
21
-     *
22
-     * @var string
23
-     */
24
-    var $_diffCommand = 'diff';
25
-
26
-    /**
27
-     * Returns the array of differences.
28
-     *
29
-     * @param array $from_lines lines of text from old file
30
-     * @param array $to_lines   lines of text from new file
31
-     *
32
-     * @return array all changes made (array with Text_Diff_Op_* objects)
33
-     */
34
-    function diff($from_lines, $to_lines)
35
-    {
36
-        array_walk($from_lines, array('Text_Diff', 'trimNewlines'));
37
-        array_walk($to_lines, array('Text_Diff', 'trimNewlines'));
38
-
39
-        $temp_dir = Text_Diff::_getTempDir();
40
-
41
-        // Execute gnu diff or similar to get a standard diff file.
42
-        $from_file = tempnam($temp_dir, 'Text_Diff');
43
-        $to_file = tempnam($temp_dir, 'Text_Diff');
44
-        $fp = fopen($from_file, 'w');
45
-        fwrite($fp, implode("\n", $from_lines));
46
-        fclose($fp);
47
-        $fp = fopen($to_file, 'w');
48
-        fwrite($fp, implode("\n", $to_lines));
49
-        fclose($fp);
50
-        $diff = shell_exec($this->_diffCommand . ' ' . $from_file . ' ' . $to_file);
51
-        unlink($from_file);
52
-        unlink($to_file);
53
-
54
-        if (is_null($diff)) {
55
-            // No changes were made
56
-            return array(new Text_Diff_Op_copy($from_lines));
57
-        }
58
-
59
-        $from_line_no = 1;
60
-        $to_line_no = 1;
61
-        $edits = array();
62
-
63
-        // Get changed lines by parsing something like:
64
-        // 0a1,2
65
-        // 1,2c4,6
66
-        // 1,5d6
67
-        preg_match_all('#^(\d+)(?:,(\d+))?([adc])(\d+)(?:,(\d+))?$#m', $diff,
68
-            $matches, PREG_SET_ORDER);
69
-
70
-        foreach ($matches as $match) {
71
-            if (!isset($match[5])) {
72
-                // This paren is not set every time (see regex).
73
-                $match[5] = false;
74
-            }
75
-
76
-            if ($match[3] == 'a') {
77
-                $from_line_no--;
78
-            }
79
-
80
-            if ($match[3] == 'd') {
81
-                $to_line_no--;
82
-            }
83
-
84
-            if ($from_line_no < $match[1] || $to_line_no < $match[4]) {
85
-                // copied lines
86
-                assert('$match[1] - $from_line_no == $match[4] - $to_line_no');
87
-                array_push($edits,
88
-                    new Text_Diff_Op_copy(
89
-                        $this->_getLines($from_lines, $from_line_no, $match[1] - 1),
90
-                        $this->_getLines($to_lines, $to_line_no, $match[4] - 1)));
91
-            }
92
-
93
-            switch ($match[3]) {
94
-            case 'd':
95
-                // deleted lines
96
-                array_push($edits,
97
-                    new Text_Diff_Op_delete(
98
-                        $this->_getLines($from_lines, $from_line_no, $match[2])));
99
-                $to_line_no++;
100
-                break;
101
-
102
-            case 'c':
103
-                // changed lines
104
-                array_push($edits,
105
-                    new Text_Diff_Op_change(
106
-                        $this->_getLines($from_lines, $from_line_no, $match[2]),
107
-                        $this->_getLines($to_lines, $to_line_no, $match[5])));
108
-                break;
109
-
110
-            case 'a':
111
-                // added lines
112
-                array_push($edits,
113
-                    new Text_Diff_Op_add(
114
-                        $this->_getLines($to_lines, $to_line_no, $match[5])));
115
-                $from_line_no++;
116
-                break;
117
-            }
118
-        }
119
-
120
-        if (!empty($from_lines)) {
121
-            // Some lines might still be pending. Add them as copied
122
-            array_push($edits,
123
-                new Text_Diff_Op_copy(
124
-                    $this->_getLines($from_lines, $from_line_no,
125
-                                     $from_line_no + count($from_lines) - 1),
126
-                    $this->_getLines($to_lines, $to_line_no,
127
-                                     $to_line_no + count($to_lines) - 1)));
128
-        }
129
-
130
-        return $edits;
131
-    }
132
-
133
-    /**
134
-     * Get lines from either the old or new text
135
-     *
136
-     * @access private
137
-     *
138
-     * @param array &$text_lines Either $from_lines or $to_lines
139
-     * @param int   &$line_no    Current line number
140
-     * @param int   $end         Optional end line, when we want to chop more
141
-     *                           than one line.
142
-     *
143
-     * @return array The chopped lines
144
-     */
145
-    function _getLines(&$text_lines, &$line_no, $end = false)
146
-    {
147
-        if (!empty($end)) {
148
-            $lines = array();
149
-            // We can shift even more
150
-            while ($line_no <= $end) {
151
-                array_push($lines, array_shift($text_lines));
152
-                $line_no++;
153
-            }
154
-        } else {
155
-            $lines = array(array_shift($text_lines));
156
-            $line_no++;
157
-        }
158
-
159
-        return $lines;
160
-    }
19
+	/**
20
+	 * Path to the diff executable
21
+	 *
22
+	 * @var string
23
+	 */
24
+	var $_diffCommand = 'diff';
25
+
26
+	/**
27
+	 * Returns the array of differences.
28
+	 *
29
+	 * @param array $from_lines lines of text from old file
30
+	 * @param array $to_lines   lines of text from new file
31
+	 *
32
+	 * @return array all changes made (array with Text_Diff_Op_* objects)
33
+	 */
34
+	function diff($from_lines, $to_lines)
35
+	{
36
+		array_walk($from_lines, array('Text_Diff', 'trimNewlines'));
37
+		array_walk($to_lines, array('Text_Diff', 'trimNewlines'));
38
+
39
+		$temp_dir = Text_Diff::_getTempDir();
40
+
41
+		// Execute gnu diff or similar to get a standard diff file.
42
+		$from_file = tempnam($temp_dir, 'Text_Diff');
43
+		$to_file = tempnam($temp_dir, 'Text_Diff');
44
+		$fp = fopen($from_file, 'w');
45
+		fwrite($fp, implode("\n", $from_lines));
46
+		fclose($fp);
47
+		$fp = fopen($to_file, 'w');
48
+		fwrite($fp, implode("\n", $to_lines));
49
+		fclose($fp);
50
+		$diff = shell_exec($this->_diffCommand . ' ' . $from_file . ' ' . $to_file);
51
+		unlink($from_file);
52
+		unlink($to_file);
53
+
54
+		if (is_null($diff)) {
55
+			// No changes were made
56
+			return array(new Text_Diff_Op_copy($from_lines));
57
+		}
58
+
59
+		$from_line_no = 1;
60
+		$to_line_no = 1;
61
+		$edits = array();
62
+
63
+		// Get changed lines by parsing something like:
64
+		// 0a1,2
65
+		// 1,2c4,6
66
+		// 1,5d6
67
+		preg_match_all('#^(\d+)(?:,(\d+))?([adc])(\d+)(?:,(\d+))?$#m', $diff,
68
+			$matches, PREG_SET_ORDER);
69
+
70
+		foreach ($matches as $match) {
71
+			if (!isset($match[5])) {
72
+				// This paren is not set every time (see regex).
73
+				$match[5] = false;
74
+			}
75
+
76
+			if ($match[3] == 'a') {
77
+				$from_line_no--;
78
+			}
79
+
80
+			if ($match[3] == 'd') {
81
+				$to_line_no--;
82
+			}
83
+
84
+			if ($from_line_no < $match[1] || $to_line_no < $match[4]) {
85
+				// copied lines
86
+				assert('$match[1] - $from_line_no == $match[4] - $to_line_no');
87
+				array_push($edits,
88
+					new Text_Diff_Op_copy(
89
+						$this->_getLines($from_lines, $from_line_no, $match[1] - 1),
90
+						$this->_getLines($to_lines, $to_line_no, $match[4] - 1)));
91
+			}
92
+
93
+			switch ($match[3]) {
94
+			case 'd':
95
+				// deleted lines
96
+				array_push($edits,
97
+					new Text_Diff_Op_delete(
98
+						$this->_getLines($from_lines, $from_line_no, $match[2])));
99
+				$to_line_no++;
100
+				break;
101
+
102
+			case 'c':
103
+				// changed lines
104
+				array_push($edits,
105
+					new Text_Diff_Op_change(
106
+						$this->_getLines($from_lines, $from_line_no, $match[2]),
107
+						$this->_getLines($to_lines, $to_line_no, $match[5])));
108
+				break;
109
+
110
+			case 'a':
111
+				// added lines
112
+				array_push($edits,
113
+					new Text_Diff_Op_add(
114
+						$this->_getLines($to_lines, $to_line_no, $match[5])));
115
+				$from_line_no++;
116
+				break;
117
+			}
118
+		}
119
+
120
+		if (!empty($from_lines)) {
121
+			// Some lines might still be pending. Add them as copied
122
+			array_push($edits,
123
+				new Text_Diff_Op_copy(
124
+					$this->_getLines($from_lines, $from_line_no,
125
+									 $from_line_no + count($from_lines) - 1),
126
+					$this->_getLines($to_lines, $to_line_no,
127
+									 $to_line_no + count($to_lines) - 1)));
128
+		}
129
+
130
+		return $edits;
131
+	}
132
+
133
+	/**
134
+	 * Get lines from either the old or new text
135
+	 *
136
+	 * @access private
137
+	 *
138
+	 * @param array &$text_lines Either $from_lines or $to_lines
139
+	 * @param int   &$line_no    Current line number
140
+	 * @param int   $end         Optional end line, when we want to chop more
141
+	 *                           than one line.
142
+	 *
143
+	 * @return array The chopped lines
144
+	 */
145
+	function _getLines(&$text_lines, &$line_no, $end = false)
146
+	{
147
+		if (!empty($end)) {
148
+			$lines = array();
149
+			// We can shift even more
150
+			while ($line_no <= $end) {
151
+				array_push($lines, array_shift($text_lines));
152
+				$line_no++;
153
+			}
154
+		} else {
155
+			$lines = array(array_shift($text_lines));
156
+			$line_no++;
157
+		}
158
+
159
+		return $lines;
160
+	}
161 161
 
162 162
 }
Please login to merge, or discard this patch.
Switch Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -91,29 +91,29 @@
 block discarded – undo
91 91
             }
92 92
 
93 93
             switch ($match[3]) {
94
-            case 'd':
95
-                // deleted lines
96
-                array_push($edits,
97
-                    new Text_Diff_Op_delete(
98
-                        $this->_getLines($from_lines, $from_line_no, $match[2])));
99
-                $to_line_no++;
100
-                break;
101
-
102
-            case 'c':
103
-                // changed lines
104
-                array_push($edits,
105
-                    new Text_Diff_Op_change(
106
-                        $this->_getLines($from_lines, $from_line_no, $match[2]),
107
-                        $this->_getLines($to_lines, $to_line_no, $match[5])));
108
-                break;
109
-
110
-            case 'a':
111
-                // added lines
112
-                array_push($edits,
113
-                    new Text_Diff_Op_add(
114
-                        $this->_getLines($to_lines, $to_line_no, $match[5])));
115
-                $from_line_no++;
116
-                break;
94
+            	case 'd':
95
+                	// deleted lines
96
+                	array_push($edits,
97
+                    	new Text_Diff_Op_delete(
98
+                        	$this->_getLines($from_lines, $from_line_no, $match[2])));
99
+                	$to_line_no++;
100
+                	break;
101
+
102
+            	case 'c':
103
+                	// changed lines
104
+                	array_push($edits,
105
+                    	new Text_Diff_Op_change(
106
+                        	$this->_getLines($from_lines, $from_line_no, $match[2]),
107
+                        	$this->_getLines($to_lines, $to_line_no, $match[5])));
108
+                	break;
109
+
110
+            	case 'a':
111
+                	// added lines
112
+                	array_push($edits,
113
+                    	new Text_Diff_Op_add(
114
+                        	$this->_getLines($to_lines, $to_line_no, $match[5])));
115
+                	$from_line_no++;
116
+                	break;
117 117
             }
118 118
         }
119 119
 
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         $fp = fopen($to_file, 'w');
48 48
         fwrite($fp, implode("\n", $to_lines));
49 49
         fclose($fp);
50
-        $diff = shell_exec($this->_diffCommand . ' ' . $from_file . ' ' . $to_file);
50
+        $diff = shell_exec($this->_diffCommand.' '.$from_file.' '.$to_file);
51 51
         unlink($from_file);
52 52
         unlink($to_file);
53 53
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
             $matches, PREG_SET_ORDER);
69 69
 
70 70
         foreach ($matches as $match) {
71
-            if (!isset($match[5])) {
71
+            if ( ! isset($match[5])) {
72 72
                 // This paren is not set every time (see regex).
73 73
                 $match[5] = false;
74 74
             }
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
             }
118 118
         }
119 119
 
120
-        if (!empty($from_lines)) {
120
+        if ( ! empty($from_lines)) {
121 121
             // Some lines might still be pending. Add them as copied
122 122
             array_push($edits,
123 123
                 new Text_Diff_Op_copy(
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
      */
145 145
     function _getLines(&$text_lines, &$line_no, $end = false)
146 146
     {
147
-        if (!empty($end)) {
147
+        if ( ! empty($end)) {
148 148
             $lines = array();
149 149
             // We can shift even more
150 150
             while ($line_no <= $end) {
Please login to merge, or discard this patch.
src/wp-includes/Text/Diff/Engine/xdiff.php 3 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -15,22 +15,22 @@  discard block
 block discarded – undo
15 15
  */
16 16
 class Text_Diff_Engine_xdiff {
17 17
 
18
-    /**
19
-     */
20
-    function diff($from_lines, $to_lines)
21
-    {
22
-        array_walk($from_lines, array('Text_Diff', 'trimNewlines'));
23
-        array_walk($to_lines, array('Text_Diff', 'trimNewlines'));
18
+	/**
19
+	 */
20
+	function diff($from_lines, $to_lines)
21
+	{
22
+		array_walk($from_lines, array('Text_Diff', 'trimNewlines'));
23
+		array_walk($to_lines, array('Text_Diff', 'trimNewlines'));
24 24
 
25
-        /* Convert the two input arrays into strings for xdiff processing. */
26
-        $from_string = implode("\n", $from_lines);
27
-        $to_string = implode("\n", $to_lines);
25
+		/* Convert the two input arrays into strings for xdiff processing. */
26
+		$from_string = implode("\n", $from_lines);
27
+		$to_string = implode("\n", $to_lines);
28 28
 
29
-        /* Diff the two strings and convert the result to an array. */
30
-        $diff = xdiff_string_diff($from_string, $to_string, count($to_lines));
31
-        $diff = explode("\n", $diff);
29
+		/* Diff the two strings and convert the result to an array. */
30
+		$diff = xdiff_string_diff($from_string, $to_string, count($to_lines));
31
+		$diff = explode("\n", $diff);
32 32
 
33
-        /* Walk through the diff one line at a time.  We build the $edits
33
+		/* Walk through the diff one line at a time.  We build the $edits
34 34
          * array of diff operations by reading the first character of the
35 35
          * xdiff output (which is in the "unified diff" format).
36 36
          *
@@ -38,27 +38,27 @@  discard block
 block discarded – undo
38 38
          * lines using this approach, so we can't add Text_Diff_Op_changed
39 39
          * instances to the $edits array.  The result is still perfectly
40 40
          * valid, albeit a little less descriptive and efficient. */
41
-        $edits = array();
42
-        foreach ($diff as $line) {
43
-            if (!strlen($line)) {
44
-                continue;
45
-            }
46
-            switch ($line[0]) {
47
-            case ' ':
48
-                $edits[] = new Text_Diff_Op_copy(array(substr($line, 1)));
49
-                break;
41
+		$edits = array();
42
+		foreach ($diff as $line) {
43
+			if (!strlen($line)) {
44
+				continue;
45
+			}
46
+			switch ($line[0]) {
47
+			case ' ':
48
+				$edits[] = new Text_Diff_Op_copy(array(substr($line, 1)));
49
+				break;
50 50
 
51
-            case '+':
52
-                $edits[] = new Text_Diff_Op_add(array(substr($line, 1)));
53
-                break;
51
+			case '+':
52
+				$edits[] = new Text_Diff_Op_add(array(substr($line, 1)));
53
+				break;
54 54
 
55
-            case '-':
56
-                $edits[] = new Text_Diff_Op_delete(array(substr($line, 1)));
57
-                break;
58
-            }
59
-        }
55
+			case '-':
56
+				$edits[] = new Text_Diff_Op_delete(array(substr($line, 1)));
57
+				break;
58
+			}
59
+		}
60 60
 
61
-        return $edits;
62
-    }
61
+		return $edits;
62
+	}
63 63
 
64 64
 }
Please login to merge, or discard this patch.
Switch Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -44,17 +44,17 @@
 block discarded – undo
44 44
                 continue;
45 45
             }
46 46
             switch ($line[0]) {
47
-            case ' ':
48
-                $edits[] = new Text_Diff_Op_copy(array(substr($line, 1)));
49
-                break;
47
+            	case ' ':
48
+                	$edits[] = new Text_Diff_Op_copy(array(substr($line, 1)));
49
+                	break;
50 50
 
51
-            case '+':
52
-                $edits[] = new Text_Diff_Op_add(array(substr($line, 1)));
53
-                break;
51
+            	case '+':
52
+                	$edits[] = new Text_Diff_Op_add(array(substr($line, 1)));
53
+                	break;
54 54
 
55
-            case '-':
56
-                $edits[] = new Text_Diff_Op_delete(array(substr($line, 1)));
57
-                break;
55
+            	case '-':
56
+                	$edits[] = new Text_Diff_Op_delete(array(substr($line, 1)));
57
+                	break;
58 58
             }
59 59
         }
60 60
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
          * valid, albeit a little less descriptive and efficient. */
41 41
         $edits = array();
42 42
         foreach ($diff as $line) {
43
-            if (!strlen($line)) {
43
+            if ( ! strlen($line)) {
44 44
                 continue;
45 45
             }
46 46
             switch ($line[0]) {
Please login to merge, or discard this patch.