Completed
Push — master ( c0c536...fdb3a7 )
by Stephen
20:33
created
src/wp-admin/includes/image-edit.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
  * @ignore
342 342
  * @param int $w Image width in pixels.
343 343
  * @param int $h Image height in pixels.
344
- * @return float|int Image preview ratio.
344
+ * @return integer Image preview ratio.
345 345
  */
346 346
 function _image_get_preview_ratio($w, $h) {
347 347
 	$max = max($w, $h);
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
  * @ignore
357 357
  * @param resource  $img   Image resource.
358 358
  * @param float|int $angle Image rotation angle, in degrees.
359
- * @return resource|false GD image resource, false otherwise.
359
+ * @return resource GD image resource, false otherwise.
360 360
  */
361 361
 function _rotate_image_resource($img, $angle) {
362 362
 	_deprecated_function( __FUNCTION__, '3.5', __( 'Use WP_Image_Editor::rotate' ) );
Please login to merge, or discard this patch.
Spacing   +220 added lines, -220 removed lines patch added patch discarded remove patch
@@ -20,22 +20,22 @@  discard block
 block discarded – undo
20 20
 	$sub_sizes = isset($meta['sizes']) && is_array($meta['sizes']);
21 21
 	$note = '';
22 22
 
23
-	if ( isset( $meta['width'], $meta['height'] ) )
24
-		$big = max( $meta['width'], $meta['height'] );
23
+	if (isset($meta['width'], $meta['height']))
24
+		$big = max($meta['width'], $meta['height']);
25 25
 	else
26
-		die( __('Image data does not exist. Please re-upload the image.') );
26
+		die(__('Image data does not exist. Please re-upload the image.'));
27 27
 
28 28
 	$sizer = $big > 400 ? 400 / $big : 1;
29 29
 
30
-	$backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true );
30
+	$backup_sizes = get_post_meta($post_id, '_wp_attachment_backup_sizes', true);
31 31
 	$can_restore = false;
32
-	if ( ! empty( $backup_sizes ) && isset( $backup_sizes['full-orig'], $meta['file'] ) )
33
-		$can_restore = $backup_sizes['full-orig']['file'] != basename( $meta['file'] );
32
+	if ( ! empty($backup_sizes) && isset($backup_sizes['full-orig'], $meta['file']))
33
+		$can_restore = $backup_sizes['full-orig']['file'] != basename($meta['file']);
34 34
 
35
-	if ( $msg ) {
36
-		if ( isset($msg->error) )
35
+	if ($msg) {
36
+		if (isset($msg->error))
37 37
 			$note = "<div class='error'><p>$msg->error</p></div>";
38
-		elseif ( isset($msg->msg) )
38
+		elseif (isset($msg->msg))
39 39
 			$note = "<div class='updated'><p>$msg->msg</p></div>";
40 40
 	}
41 41
 
@@ -46,28 +46,28 @@  discard block
 block discarded – undo
46 46
 	<div class="imgedit-settings">
47 47
 	<div class="imgedit-group">
48 48
 	<div class="imgedit-group-top">
49
-		<h2><?php _e( 'Scale Image' ); ?></h2>
50
-		<button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" aria-expanded="false"><span class="screen-reader-text"><?php esc_html_e( 'Scale Image Help' ); ?></span></button>
49
+		<h2><?php _e('Scale Image'); ?></h2>
50
+		<button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" aria-expanded="false"><span class="screen-reader-text"><?php esc_html_e('Scale Image Help'); ?></span></button>
51 51
 		<div class="imgedit-help">
52 52
 		<p><?php _e('You can proportionally scale the original image. For best results, scaling should be done before you crop, flip, or rotate. Images can only be scaled down, not up.'); ?></p>
53 53
 		</div>
54
-		<?php if ( isset( $meta['width'], $meta['height'] ) ): ?>
55
-		<p><?php printf( __('Original dimensions %s'), $meta['width'] . ' &times; ' . $meta['height'] ); ?></p>
54
+		<?php if (isset($meta['width'], $meta['height'])): ?>
55
+		<p><?php printf(__('Original dimensions %s'), $meta['width'].' &times; '.$meta['height']); ?></p>
56 56
 		<?php endif ?>
57 57
 		<div class="imgedit-submit">
58 58
 
59 59
 		<fieldset class="imgedit-scale">
60
-		<legend><?php _e( 'New dimensions:' ); ?></legend>
60
+		<legend><?php _e('New dimensions:'); ?></legend>
61 61
 		<div class="nowrap">
62
-		<label><span class="screen-reader-text"><?php _e( 'scale width' ); ?></span>
63
-		<input type="text" id="imgedit-scale-width-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1)" value="<?php echo isset( $meta['width'] ) ? $meta['width'] : 0; ?>" />
62
+		<label><span class="screen-reader-text"><?php _e('scale width'); ?></span>
63
+		<input type="text" id="imgedit-scale-width-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1)" value="<?php echo isset($meta['width']) ? $meta['width'] : 0; ?>" />
64 64
 		</label>
65 65
 		<span class="imgedit-separator">&times;</span>
66
-		<label><span class="screen-reader-text"><?php _e( 'scale height' ); ?></span>
67
-		<input type="text" id="imgedit-scale-height-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0)" value="<?php echo isset( $meta['height'] ) ? $meta['height'] : 0; ?>" />
66
+		<label><span class="screen-reader-text"><?php _e('scale height'); ?></span>
67
+		<input type="text" id="imgedit-scale-height-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0)" value="<?php echo isset($meta['height']) ? $meta['height'] : 0; ?>" />
68 68
 		</label>
69 69
 		<span class="imgedit-scale-warn" id="imgedit-scale-warn-<?php echo $post_id; ?>">!</span>
70
-		<input id="imgedit-scale-button" type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'scale')" class="button button-primary" value="<?php esc_attr_e( 'Scale' ); ?>" />
70
+		<input id="imgedit-scale-button" type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'scale')" class="button button-primary" value="<?php esc_attr_e('Scale'); ?>" />
71 71
  		</div>
72 72
 		</fieldset>
73 73
 
@@ -75,20 +75,20 @@  discard block
 block discarded – undo
75 75
 	</div>
76 76
 	</div>
77 77
 
78
-<?php if ( $can_restore ) { ?>
78
+<?php if ($can_restore) { ?>
79 79
 
80 80
 	<div class="imgedit-group">
81 81
 	<div class="imgedit-group-top">
82
-		<h2><button type="button" onclick="imageEdit.toggleHelp(this);" class="button-link"><?php _e( 'Restore Original Image' ); ?> <span class="dashicons dashicons-arrow-down imgedit-help-toggle"></span></button></h2>
82
+		<h2><button type="button" onclick="imageEdit.toggleHelp(this);" class="button-link"><?php _e('Restore Original Image'); ?> <span class="dashicons dashicons-arrow-down imgedit-help-toggle"></span></button></h2>
83 83
 		<div class="imgedit-help">
84 84
 		<p><?php _e('Discard any changes and restore the original image.');
85 85
 
86
-		if ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE )
86
+		if ( ! defined('IMAGE_EDIT_OVERWRITE') || ! IMAGE_EDIT_OVERWRITE)
87 87
 			echo ' '.__('Previously edited copies of the image will not be deleted.');
88 88
 
89 89
 		?></p>
90 90
 		<div class="imgedit-submit">
91
-		<input type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'restore')" class="button button-primary" value="<?php esc_attr_e( 'Restore image' ); ?>" <?php echo $can_restore; ?> />
91
+		<input type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'restore')" class="button button-primary" value="<?php esc_attr_e('Restore image'); ?>" <?php echo $can_restore; ?> />
92 92
 		</div>
93 93
 		</div>
94 94
 	</div>
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
 
99 99
 	<div class="imgedit-group">
100 100
 	<div class="imgedit-group-top">
101
-		<h2><?php _e( 'Image Crop' ); ?></h2>
102
-		<button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" aria-expanded="false"><span class="screen-reader-text"><?php esc_html_e( 'Image Crop Help' ); ?></span></button>
101
+		<h2><?php _e('Image Crop'); ?></h2>
102
+		<button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" aria-expanded="false"><span class="screen-reader-text"><?php esc_html_e('Image Crop Help'); ?></span></button>
103 103
 
104 104
 		<div class="imgedit-help">
105 105
 		<p><?php _e('To crop the image, click on it and drag to make your selection.'); ?></p>
@@ -113,26 +113,26 @@  discard block
 block discarded – undo
113 113
 	</div>
114 114
 
115 115
 	<fieldset class="imgedit-crop-ratio">
116
-		<legend><?php _e( 'Aspect ratio:' ); ?></legend>
116
+		<legend><?php _e('Aspect ratio:'); ?></legend>
117 117
 		<div class="nowrap">
118
-		<label><span class="screen-reader-text"><?php _e( 'crop ratio width' ); ?></span>
118
+		<label><span class="screen-reader-text"><?php _e('crop ratio width'); ?></span>
119 119
 		<input type="text" id="imgedit-crop-width-<?php echo $post_id; ?>" onkeyup="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 0, this)" />
120 120
 		</label>
121 121
 		<span class="imgedit-separator">:</span>
122
-		<label><span class="screen-reader-text"><?php _e( 'crop ratio height' ); ?></span>
122
+		<label><span class="screen-reader-text"><?php _e('crop ratio height'); ?></span>
123 123
 		<input type="text" id="imgedit-crop-height-<?php echo $post_id; ?>" onkeyup="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 1, this)" />
124 124
 		</label>
125 125
 		</div>
126 126
 	</fieldset>
127 127
 
128 128
 	<fieldset id="imgedit-crop-sel-<?php echo $post_id; ?>" class="imgedit-crop-sel">
129
-		<legend><?php _e( 'Selection:' ); ?></legend>
129
+		<legend><?php _e('Selection:'); ?></legend>
130 130
 		<div class="nowrap">
131
-		<label><span class="screen-reader-text"><?php _e( 'selection width' ); ?></span>
131
+		<label><span class="screen-reader-text"><?php _e('selection width'); ?></span>
132 132
 		<input type="text" id="imgedit-sel-width-<?php echo $post_id; ?>" onkeyup="imageEdit.setNumSelection(<?php echo $post_id; ?>)" />
133 133
 		</label>
134 134
 		<span class="imgedit-separator">&times;</span>
135
-		<label><span class="screen-reader-text"><?php _e( 'selection height' ); ?></span>
135
+		<label><span class="screen-reader-text"><?php _e('selection height'); ?></span>
136 136
 		<input type="text" id="imgedit-sel-height-<?php echo $post_id; ?>" onkeyup="imageEdit.setNumSelection(<?php echo $post_id; ?>)" />
137 137
 		</label>
138 138
 		</div>
@@ -140,25 +140,25 @@  discard block
 block discarded – undo
140 140
 
141 141
 	</div>
142 142
 
143
-	<?php if ( $thumb && $sub_sizes ) {
144
-		$thumb_img = wp_constrain_dimensions( $thumb['width'], $thumb['height'], 160, 120 );
143
+	<?php if ($thumb && $sub_sizes) {
144
+		$thumb_img = wp_constrain_dimensions($thumb['width'], $thumb['height'], 160, 120);
145 145
 	?>
146 146
 
147 147
 	<div class="imgedit-group imgedit-applyto">
148 148
 	<div class="imgedit-group-top">
149
-		<h2><?php _e( 'Thumbnail Settings' ); ?></h2>
150
-		<button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" aria-expanded="false"><span class="screen-reader-text"><?php esc_html_e( 'Thumbnail Settings Help' ); ?></span></button>
149
+		<h2><?php _e('Thumbnail Settings'); ?></h2>
150
+		<button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" aria-expanded="false"><span class="screen-reader-text"><?php esc_html_e('Thumbnail Settings Help'); ?></span></button>
151 151
 		<p class="imgedit-help"><?php _e('You can edit the image while preserving the thumbnail. For example, you may wish to have a square thumbnail that displays just a section of the image.'); ?></p>
152 152
 	</div>
153 153
 
154 154
 	<figure class="imgedit-thumbnail-preview">
155 155
 		<img src="<?php echo $thumb['url']; ?>" width="<?php echo $thumb_img[0]; ?>" height="<?php echo $thumb_img[1]; ?>" class="imgedit-size-preview" alt="" draggable="false" />
156
-		<figcaption class="imgedit-thumbnail-preview-caption"><?php _e( 'Current thumbnail' ); ?></figcaption>
156
+		<figcaption class="imgedit-thumbnail-preview-caption"><?php _e('Current thumbnail'); ?></figcaption>
157 157
 	</figure>
158 158
 
159 159
 	<div id="imgedit-save-target-<?php echo $post_id; ?>" class="imgedit-save-target">
160 160
 	<fieldset>
161
-		<legend><strong><?php _e( 'Apply changes to:' ); ?></strong></legend>
161
+		<legend><strong><?php _e('Apply changes to:'); ?></strong></legend>
162 162
 
163 163
 		<label class="imgedit-label">
164 164
 		<input type="radio" name="imgedit-target-<?php echo $post_id; ?>" value="all" checked="checked" />
@@ -182,26 +182,26 @@  discard block
 block discarded – undo
182 182
 	<div class="imgedit-panel-content wp-clearfix">
183 183
 		<?php echo $note; ?>
184 184
 		<div class="imgedit-menu wp-clearfix">
185
-			<button type="button" onclick="imageEdit.crop(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-crop button disabled" disabled><span class="screen-reader-text"><?php esc_html_e( 'Crop' ); ?></span></button><?php
185
+			<button type="button" onclick="imageEdit.crop(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-crop button disabled" disabled><span class="screen-reader-text"><?php esc_html_e('Crop'); ?></span></button><?php
186 186
 
187 187
 		// On some setups GD library does not provide imagerotate() - Ticket #11536
188
-		if ( wp_image_editor_supports( array( 'mime_type' => get_post_mime_type( $post_id ), 'methods' => array( 'rotate' ) ) ) ) {
188
+		if (wp_image_editor_supports(array('mime_type' => get_post_mime_type($post_id), 'methods' => array('rotate')))) {
189 189
 			$note_no_rotate = '';
190 190
 	?>
191
-			<button type="button" class="imgedit-rleft button" onclick="imageEdit.rotate( 90, <?php echo "$post_id, '$nonce'"; ?>, this)"><span class="screen-reader-text"><?php esc_html_e( 'Rotate counter-clockwise' ); ?></span></button>
192
-			<button type="button" class="imgedit-rright button" onclick="imageEdit.rotate(-90, <?php echo "$post_id, '$nonce'"; ?>, this)"><span class="screen-reader-text"><?php esc_html_e( 'Rotate clockwise' ); ?></span></button>
191
+			<button type="button" class="imgedit-rleft button" onclick="imageEdit.rotate( 90, <?php echo "$post_id, '$nonce'"; ?>, this)"><span class="screen-reader-text"><?php esc_html_e('Rotate counter-clockwise'); ?></span></button>
192
+			<button type="button" class="imgedit-rright button" onclick="imageEdit.rotate(-90, <?php echo "$post_id, '$nonce'"; ?>, this)"><span class="screen-reader-text"><?php esc_html_e('Rotate clockwise'); ?></span></button>
193 193
 	<?php } else {
194
-			$note_no_rotate = '<p class="note-no-rotate"><em>' . __( 'Image rotation is not supported by your web host.' ) . '</em></p>';
194
+			$note_no_rotate = '<p class="note-no-rotate"><em>'.__('Image rotation is not supported by your web host.').'</em></p>';
195 195
 	?>
196 196
 			<button type="button" class="imgedit-rleft button disabled" disabled></button>
197 197
 			<button type="button" class="imgedit-rright button disabled" disabled></button>
198 198
 	<?php } ?>
199 199
 
200
-			<button type="button" onclick="imageEdit.flip(1, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-flipv button"><span class="screen-reader-text"><?php esc_html_e( 'Flip vertically' ); ?></span></button>
201
-			<button type="button" onclick="imageEdit.flip(2, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-fliph button"><span class="screen-reader-text"><?php esc_html_e( 'Flip horizontally' ); ?></span></button>
200
+			<button type="button" onclick="imageEdit.flip(1, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-flipv button"><span class="screen-reader-text"><?php esc_html_e('Flip vertically'); ?></span></button>
201
+			<button type="button" onclick="imageEdit.flip(2, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-fliph button"><span class="screen-reader-text"><?php esc_html_e('Flip horizontally'); ?></span></button>
202 202
 
203
-			<button type="button" id="image-undo-<?php echo $post_id; ?>" onclick="imageEdit.undo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-undo button disabled" disabled><span class="screen-reader-text"><?php esc_html_e( 'Undo' ); ?></span></button>
204
-			<button type="button" id="image-redo-<?php echo $post_id; ?>" onclick="imageEdit.redo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-redo button disabled" disabled><span class="screen-reader-text"><?php esc_html_e( 'Redo' ); ?></span></button>
203
+			<button type="button" id="image-undo-<?php echo $post_id; ?>" onclick="imageEdit.undo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-undo button disabled" disabled><span class="screen-reader-text"><?php esc_html_e('Undo'); ?></span></button>
204
+			<button type="button" id="image-redo-<?php echo $post_id; ?>" onclick="imageEdit.redo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-redo button disabled" disabled><span class="screen-reader-text"><?php esc_html_e('Redo'); ?></span></button>
205 205
 			<?php echo $note_no_rotate; ?>
206 206
 		</div>
207 207
 
@@ -209,16 +209,16 @@  discard block
 block discarded – undo
209 209
 		<input type="hidden" id="imgedit-history-<?php echo $post_id; ?>" value="" />
210 210
 		<input type="hidden" id="imgedit-undone-<?php echo $post_id; ?>" value="0" />
211 211
 		<input type="hidden" id="imgedit-selection-<?php echo $post_id; ?>" value="" />
212
-		<input type="hidden" id="imgedit-x-<?php echo $post_id; ?>" value="<?php echo isset( $meta['width'] ) ? $meta['width'] : 0; ?>" />
213
-		<input type="hidden" id="imgedit-y-<?php echo $post_id; ?>" value="<?php echo isset( $meta['height'] ) ? $meta['height'] : 0; ?>" />
212
+		<input type="hidden" id="imgedit-x-<?php echo $post_id; ?>" value="<?php echo isset($meta['width']) ? $meta['width'] : 0; ?>" />
213
+		<input type="hidden" id="imgedit-y-<?php echo $post_id; ?>" value="<?php echo isset($meta['height']) ? $meta['height'] : 0; ?>" />
214 214
 
215 215
 		<div id="imgedit-crop-<?php echo $post_id; ?>" class="imgedit-crop-wrap">
216
-		<img id="image-preview-<?php echo $post_id; ?>" onload="imageEdit.imgLoaded('<?php echo $post_id; ?>')" src="<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>?action=imgedit-preview&amp;_ajax_nonce=<?php echo $nonce; ?>&amp;postid=<?php echo $post_id; ?>&amp;rand=<?php echo rand(1, 99999); ?>" alt="" />
216
+		<img id="image-preview-<?php echo $post_id; ?>" onload="imageEdit.imgLoaded('<?php echo $post_id; ?>')" src="<?php echo admin_url('admin-ajax.php', 'relative'); ?>?action=imgedit-preview&amp;_ajax_nonce=<?php echo $nonce; ?>&amp;postid=<?php echo $post_id; ?>&amp;rand=<?php echo rand(1, 99999); ?>" alt="" />
217 217
 		</div>
218 218
 
219 219
 		<div class="imgedit-submit">
220
-			<input type="button" onclick="imageEdit.close(<?php echo $post_id; ?>, 1)" class="button imgedit-cancel-btn" value="<?php esc_attr_e( 'Cancel' ); ?>" />
221
-			<input type="button" onclick="imageEdit.save(<?php echo "$post_id, '$nonce'"; ?>)" disabled="disabled" class="button button-primary imgedit-submit-btn" value="<?php esc_attr_e( 'Save' ); ?>" />
220
+			<input type="button" onclick="imageEdit.close(<?php echo $post_id; ?>, 1)" class="button imgedit-cancel-btn" value="<?php esc_attr_e('Cancel'); ?>" />
221
+			<input type="button" onclick="imageEdit.save(<?php echo "$post_id, '$nonce'"; ?>)" disabled="disabled" class="button button-primary imgedit-submit-btn" value="<?php esc_attr_e('Save'); ?>" />
222 222
 		</div>
223 223
 	</div>
224 224
 
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
  * @param int $post_id
240 240
  * @return bool
241 241
  */
242
-function wp_stream_image( $image, $mime_type, $post_id ) {
243
-	if ( $image instanceof WP_Image_Editor ) {
242
+function wp_stream_image($image, $mime_type, $post_id) {
243
+	if ($image instanceof WP_Image_Editor) {
244 244
 
245 245
 		/**
246 246
 		 * Filter the WP_Image_Editor instance for the image to be streamed to the browser.
@@ -250,14 +250,14 @@  discard block
 block discarded – undo
250 250
 		 * @param WP_Image_Editor $image   WP_Image_Editor instance.
251 251
 		 * @param int             $post_id Post ID.
252 252
 		 */
253
-		$image = apply_filters( 'image_editor_save_pre', $image, $post_id );
253
+		$image = apply_filters('image_editor_save_pre', $image, $post_id);
254 254
 
255
-		if ( is_wp_error( $image->stream( $mime_type ) ) )
255
+		if (is_wp_error($image->stream($mime_type)))
256 256
 			return false;
257 257
 
258 258
 		return true;
259 259
 	} else {
260
-		_deprecated_argument( __FUNCTION__, '3.5', __( '$image needs to be an WP_Image_Editor object' ) );
260
+		_deprecated_argument(__FUNCTION__, '3.5', __('$image needs to be an WP_Image_Editor object'));
261 261
 
262 262
 		/**
263 263
 		 * Filter the GD image resource to be streamed to the browser.
@@ -268,18 +268,18 @@  discard block
 block discarded – undo
268 268
 		 * @param resource $image   Image resource to be streamed.
269 269
 		 * @param int      $post_id Post ID.
270 270
 		 */
271
-		$image = apply_filters( 'image_save_pre', $image, $post_id );
271
+		$image = apply_filters('image_save_pre', $image, $post_id);
272 272
 
273
-		switch ( $mime_type ) {
273
+		switch ($mime_type) {
274 274
 			case 'image/jpeg':
275
-				header( 'Content-Type: image/jpeg' );
276
-				return imagejpeg( $image, null, 90 );
275
+				header('Content-Type: image/jpeg');
276
+				return imagejpeg($image, null, 90);
277 277
 			case 'image/png':
278
-				header( 'Content-Type: image/png' );
279
-				return imagepng( $image );
278
+				header('Content-Type: image/png');
279
+				return imagepng($image);
280 280
 			case 'image/gif':
281
-				header( 'Content-Type: image/gif' );
282
-				return imagegif( $image );
281
+				header('Content-Type: image/gif');
282
+				return imagegif($image);
283 283
 			default:
284 284
 				return false;
285 285
 		}
@@ -295,11 +295,11 @@  discard block
 block discarded – undo
295 295
  * @param int $post_id
296 296
  * @return bool
297 297
  */
298
-function wp_save_image_file( $filename, $image, $mime_type, $post_id ) {
299
-	if ( $image instanceof WP_Image_Editor ) {
298
+function wp_save_image_file($filename, $image, $mime_type, $post_id) {
299
+	if ($image instanceof WP_Image_Editor) {
300 300
 
301 301
 		/** This filter is documented in wp-admin/includes/image-edit.php */
302
-		$image = apply_filters( 'image_editor_save_pre', $image, $post_id );
302
+		$image = apply_filters('image_editor_save_pre', $image, $post_id);
303 303
 
304 304
 		/**
305 305
 		 * Filter whether to skip saving the image file.
@@ -315,17 +315,17 @@  discard block
 block discarded – undo
315 315
 		 * @param string          $mime_type Image mime type.
316 316
 		 * @param int             $post_id   Post ID.
317 317
 		 */
318
-		$saved = apply_filters( 'wp_save_image_editor_file', null, $filename, $image, $mime_type, $post_id );
318
+		$saved = apply_filters('wp_save_image_editor_file', null, $filename, $image, $mime_type, $post_id);
319 319
 
320
-		if ( null !== $saved )
320
+		if (null !== $saved)
321 321
 			return $saved;
322 322
 
323
-		return $image->save( $filename, $mime_type );
323
+		return $image->save($filename, $mime_type);
324 324
 	} else {
325
-		_deprecated_argument( __FUNCTION__, '3.5', __( '$image needs to be an WP_Image_Editor object' ) );
325
+		_deprecated_argument(__FUNCTION__, '3.5', __('$image needs to be an WP_Image_Editor object'));
326 326
 
327 327
 		/** This filter is documented in wp-admin/includes/image-edit.php */
328
-		$image = apply_filters( 'image_save_pre', $image, $post_id );
328
+		$image = apply_filters('image_save_pre', $image, $post_id);
329 329
 
330 330
 		/**
331 331
 		 * Filter whether to skip saving the image file.
@@ -342,20 +342,20 @@  discard block
 block discarded – undo
342 342
 		 * @param string          $mime_type Image mime type.
343 343
 		 * @param int             $post_id   Post ID.
344 344
 		 */
345
-		$saved = apply_filters( 'wp_save_image_file', null, $filename, $image, $mime_type, $post_id );
345
+		$saved = apply_filters('wp_save_image_file', null, $filename, $image, $mime_type, $post_id);
346 346
 
347
-		if ( null !== $saved )
347
+		if (null !== $saved)
348 348
 			return $saved;
349 349
 
350
-		switch ( $mime_type ) {
350
+		switch ($mime_type) {
351 351
 			case 'image/jpeg':
352 352
 
353 353
 				/** This filter is documented in wp-includes/class-wp-image-editor.php */
354
-				return imagejpeg( $image, $filename, apply_filters( 'jpeg_quality', 90, 'edit_image' ) );
354
+				return imagejpeg($image, $filename, apply_filters('jpeg_quality', 90, 'edit_image'));
355 355
 			case 'image/png':
356
-				return imagepng( $image, $filename );
356
+				return imagepng($image, $filename);
357 357
 			case 'image/gif':
358
-				return imagegif( $image, $filename );
358
+				return imagegif($image, $filename);
359 359
 			default:
360 360
 				return false;
361 361
 		}
@@ -388,10 +388,10 @@  discard block
 block discarded – undo
388 388
  * @return resource|false GD image resource, false otherwise.
389 389
  */
390 390
 function _rotate_image_resource($img, $angle) {
391
-	_deprecated_function( __FUNCTION__, '3.5', __( 'Use WP_Image_Editor::rotate' ) );
392
-	if ( function_exists('imagerotate') ) {
391
+	_deprecated_function(__FUNCTION__, '3.5', __('Use WP_Image_Editor::rotate'));
392
+	if (function_exists('imagerotate')) {
393 393
 		$rotated = imagerotate($img, $angle, 0);
394
-		if ( is_resource($rotated) ) {
394
+		if (is_resource($rotated)) {
395 395
 			imagedestroy($img);
396 396
 			$img = $rotated;
397 397
 		}
@@ -411,17 +411,17 @@  discard block
 block discarded – undo
411 411
  * @return resource (maybe) flipped image resource.
412 412
  */
413 413
 function _flip_image_resource($img, $horz, $vert) {
414
-	_deprecated_function( __FUNCTION__, '3.5', __( 'Use WP_Image_Editor::flip' ) );
414
+	_deprecated_function(__FUNCTION__, '3.5', __('Use WP_Image_Editor::flip'));
415 415
 	$w = imagesx($img);
416 416
 	$h = imagesy($img);
417 417
 	$dst = wp_imagecreatetruecolor($w, $h);
418
-	if ( is_resource($dst) ) {
418
+	if (is_resource($dst)) {
419 419
 		$sx = $vert ? ($w - 1) : 0;
420 420
 		$sy = $horz ? ($h - 1) : 0;
421 421
 		$sw = $vert ? -$w : $w;
422 422
 		$sh = $horz ? -$h : $h;
423 423
 
424
-		if ( imagecopyresampled($dst, $img, 0, 0, $sx, $sy, $w, $h, $sw, $sh) ) {
424
+		if (imagecopyresampled($dst, $img, 0, 0, $sx, $sy, $w, $h, $sw, $sh)) {
425 425
 			imagedestroy($img);
426 426
 			$img = $dst;
427 427
 		}
@@ -444,8 +444,8 @@  discard block
 block discarded – undo
444 444
  */
445 445
 function _crop_image_resource($img, $x, $y, $w, $h) {
446 446
 	$dst = wp_imagecreatetruecolor($w, $h);
447
-	if ( is_resource($dst) ) {
448
-		if ( imagecopy($dst, $img, 0, 0, $x, $y, $w, $h) ) {
447
+	if (is_resource($dst)) {
448
+		if (imagecopy($dst, $img, 0, 0, $x, $y, $w, $h)) {
449 449
 			imagedestroy($img);
450 450
 			$img = $dst;
451 451
 		}
@@ -462,24 +462,24 @@  discard block
 block discarded – undo
462 462
  * @param array           $changes Array of change operations.
463 463
  * @return WP_Image_Editor {@see WP_Image_Editor} instance with changes applied.
464 464
  */
465
-function image_edit_apply_changes( $image, $changes ) {
466
-	if ( is_resource( $image ) )
467
-		_deprecated_argument( __FUNCTION__, '3.5', __( '$image needs to be an WP_Image_Editor object' ) );
465
+function image_edit_apply_changes($image, $changes) {
466
+	if (is_resource($image))
467
+		_deprecated_argument(__FUNCTION__, '3.5', __('$image needs to be an WP_Image_Editor object'));
468 468
 
469
-	if ( !is_array($changes) )
469
+	if ( ! is_array($changes))
470 470
 		return $image;
471 471
 
472 472
 	// Expand change operations.
473
-	foreach ( $changes as $key => $obj ) {
474
-		if ( isset($obj->r) ) {
473
+	foreach ($changes as $key => $obj) {
474
+		if (isset($obj->r)) {
475 475
 			$obj->type = 'rotate';
476 476
 			$obj->angle = $obj->r;
477 477
 			unset($obj->r);
478
-		} elseif ( isset($obj->f) ) {
478
+		} elseif (isset($obj->f)) {
479 479
 			$obj->type = 'flip';
480 480
 			$obj->axis = $obj->f;
481 481
 			unset($obj->f);
482
-		} elseif ( isset($obj->c) ) {
482
+		} elseif (isset($obj->c)) {
483 483
 			$obj->type = 'crop';
484 484
 			$obj->sel = $obj->c;
485 485
 			unset($obj->c);
@@ -488,12 +488,12 @@  discard block
 block discarded – undo
488 488
 	}
489 489
 
490 490
 	// Combine operations.
491
-	if ( count($changes) > 1 ) {
491
+	if (count($changes) > 1) {
492 492
 		$filtered = array($changes[0]);
493
-		for ( $i = 0, $j = 1, $c = count( $changes ); $j < $c; $j++ ) {
493
+		for ($i = 0, $j = 1, $c = count($changes); $j < $c; $j++) {
494 494
 			$combined = false;
495
-			if ( $filtered[$i]->type == $changes[$j]->type ) {
496
-				switch ( $filtered[$i]->type ) {
495
+			if ($filtered[$i]->type == $changes[$j]->type) {
496
+				switch ($filtered[$i]->type) {
497 497
 					case 'rotate':
498 498
 						$filtered[$i]->angle += $changes[$j]->angle;
499 499
 						$combined = true;
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
 						break;
505 505
 				}
506 506
 			}
507
-			if ( !$combined )
507
+			if ( ! $combined)
508 508
 				$filtered[++$i] = $changes[$j];
509 509
 		}
510 510
 		$changes = $filtered;
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 	}
513 513
 
514 514
 	// Image resource before applying the changes.
515
-	if ( $image instanceof WP_Image_Editor ) {
515
+	if ($image instanceof WP_Image_Editor) {
516 516
 
517 517
 		/**
518 518
 		 * Filter the WP_Image_Editor instance before applying changes to the image.
@@ -522,8 +522,8 @@  discard block
 block discarded – undo
522 522
 		 * @param WP_Image_Editor $image   WP_Image_Editor instance.
523 523
  		 * @param array           $changes Array of change operations.
524 524
 		 */
525
-		$image = apply_filters( 'wp_image_editor_before_change', $image, $changes );
526
-	} elseif ( is_resource( $image ) ) {
525
+		$image = apply_filters('wp_image_editor_before_change', $image, $changes);
526
+	} elseif (is_resource($image)) {
527 527
 
528 528
 		/**
529 529
 		 * Filter the GD image resource before applying changes to the image.
@@ -534,39 +534,39 @@  discard block
 block discarded – undo
534 534
 		 * @param resource $image   GD image resource.
535 535
  		 * @param array    $changes Array of change operations.
536 536
 		 */
537
-		$image = apply_filters( 'image_edit_before_change', $image, $changes );
537
+		$image = apply_filters('image_edit_before_change', $image, $changes);
538 538
 	}
539 539
 
540
-	foreach ( $changes as $operation ) {
541
-		switch ( $operation->type ) {
540
+	foreach ($changes as $operation) {
541
+		switch ($operation->type) {
542 542
 			case 'rotate':
543
-				if ( $operation->angle != 0 ) {
544
-					if ( $image instanceof WP_Image_Editor )
545
-						$image->rotate( $operation->angle );
543
+				if ($operation->angle != 0) {
544
+					if ($image instanceof WP_Image_Editor)
545
+						$image->rotate($operation->angle);
546 546
 					else
547
-						$image = _rotate_image_resource( $image, $operation->angle );
547
+						$image = _rotate_image_resource($image, $operation->angle);
548 548
 				}
549 549
 				break;
550 550
 			case 'flip':
551
-				if ( $operation->axis != 0 )
552
-					if ( $image instanceof WP_Image_Editor )
553
-						$image->flip( ($operation->axis & 1) != 0, ($operation->axis & 2) != 0 );
551
+				if ($operation->axis != 0)
552
+					if ($image instanceof WP_Image_Editor)
553
+						$image->flip(($operation->axis & 1) != 0, ($operation->axis & 2) != 0);
554 554
 					else
555
-						$image = _flip_image_resource( $image, ( $operation->axis & 1 ) != 0, ( $operation->axis & 2 ) != 0 );
555
+						$image = _flip_image_resource($image, ($operation->axis & 1) != 0, ($operation->axis & 2) != 0);
556 556
 				break;
557 557
 			case 'crop':
558 558
 				$sel = $operation->sel;
559 559
 
560
-				if ( $image instanceof WP_Image_Editor ) {
560
+				if ($image instanceof WP_Image_Editor) {
561 561
 					$size = $image->get_size();
562 562
 					$w = $size['width'];
563 563
 					$h = $size['height'];
564 564
 
565
-					$scale = 1 / _image_get_preview_ratio( $w, $h ); // discard preview scaling
566
-					$image->crop( $sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale );
565
+					$scale = 1 / _image_get_preview_ratio($w, $h); // discard preview scaling
566
+					$image->crop($sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale);
567 567
 				} else {
568
-					$scale = 1 / _image_get_preview_ratio( imagesx( $image ), imagesy( $image ) ); // discard preview scaling
569
-					$image = _crop_image_resource( $image, $sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale );
568
+					$scale = 1 / _image_get_preview_ratio(imagesx($image), imagesy($image)); // discard preview scaling
569
+					$image = _crop_image_resource($image, $sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale);
570 570
 				}
571 571
 				break;
572 572
 		}
@@ -583,35 +583,35 @@  discard block
 block discarded – undo
583 583
  * @param int $post_id
584 584
  * @return bool
585 585
  */
586
-function stream_preview_image( $post_id ) {
587
-	$post = get_post( $post_id );
586
+function stream_preview_image($post_id) {
587
+	$post = get_post($post_id);
588 588
 
589 589
 	/** This filter is documented in wp-admin/admin.php */
590
-	@ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) );
590
+	@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
591 591
 
592
-	$img = wp_get_image_editor( _load_image_to_edit_path( $post_id ) );
592
+	$img = wp_get_image_editor(_load_image_to_edit_path($post_id));
593 593
 
594
-	if ( is_wp_error( $img ) ) {
594
+	if (is_wp_error($img)) {
595 595
 		return false;
596 596
 	}
597 597
 
598
-	$changes = !empty($_REQUEST['history']) ? json_decode( wp_unslash($_REQUEST['history']) ) : null;
599
-	if ( $changes )
600
-		$img = image_edit_apply_changes( $img, $changes );
598
+	$changes = ! empty($_REQUEST['history']) ? json_decode(wp_unslash($_REQUEST['history'])) : null;
599
+	if ($changes)
600
+		$img = image_edit_apply_changes($img, $changes);
601 601
 
602 602
 	// Scale the image.
603 603
 	$size = $img->get_size();
604 604
 	$w = $size['width'];
605 605
 	$h = $size['height'];
606 606
 
607
-	$ratio = _image_get_preview_ratio( $w, $h );
608
-	$w2 = max ( 1, $w * $ratio );
609
-	$h2 = max ( 1, $h * $ratio );
607
+	$ratio = _image_get_preview_ratio($w, $h);
608
+	$w2 = max(1, $w * $ratio);
609
+	$h2 = max(1, $h * $ratio);
610 610
 
611
-	if ( is_wp_error( $img->resize( $w2, $h2 ) ) )
611
+	if (is_wp_error($img->resize($w2, $h2)))
612 612
 		return false;
613 613
 
614
-	return wp_stream_image( $img, $post->post_mime_type, $post_id );
614
+	return wp_stream_image($img, $post->post_mime_type, $post_id);
615 615
 }
616 616
 
617 617
 /**
@@ -625,30 +625,30 @@  discard block
 block discarded – undo
625 625
 function wp_restore_image($post_id) {
626 626
 	$meta = wp_get_attachment_metadata($post_id);
627 627
 	$file = get_attached_file($post_id);
628
-	$backup_sizes = $old_backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true );
628
+	$backup_sizes = $old_backup_sizes = get_post_meta($post_id, '_wp_attachment_backup_sizes', true);
629 629
 	$restored = false;
630 630
 	$msg = new stdClass;
631 631
 
632
-	if ( !is_array($backup_sizes) ) {
632
+	if ( ! is_array($backup_sizes)) {
633 633
 		$msg->error = __('Cannot load image metadata.');
634 634
 		return $msg;
635 635
 	}
636 636
 
637 637
 	$parts = pathinfo($file);
638
-	$suffix = time() . rand(100, 999);
638
+	$suffix = time().rand(100, 999);
639 639
 	$default_sizes = get_intermediate_image_sizes();
640 640
 
641
-	if ( isset($backup_sizes['full-orig']) && is_array($backup_sizes['full-orig']) ) {
641
+	if (isset($backup_sizes['full-orig']) && is_array($backup_sizes['full-orig'])) {
642 642
 		$data = $backup_sizes['full-orig'];
643 643
 
644
-		if ( $parts['basename'] != $data['file'] ) {
645
-			if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE ) {
644
+		if ($parts['basename'] != $data['file']) {
645
+			if (defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE) {
646 646
 
647 647
 				// Delete only if it's an edited image.
648
-				if ( preg_match('/-e[0-9]{13}\./', $parts['basename']) ) {
649
-					wp_delete_file( $file );
648
+				if (preg_match('/-e[0-9]{13}\./', $parts['basename'])) {
649
+					wp_delete_file($file);
650 650
 				}
651
-			} elseif ( isset( $meta['width'], $meta['height'] ) ) {
651
+			} elseif (isset($meta['width'], $meta['height'])) {
652 652
 				$backup_sizes["full-$suffix"] = array('width' => $meta['width'], 'height' => $meta['height'], 'file' => $parts['basename']);
653 653
 			}
654 654
 		}
@@ -656,21 +656,21 @@  discard block
 block discarded – undo
656 656
 		$restored_file = path_join($parts['dirname'], $data['file']);
657 657
 		$restored = update_attached_file($post_id, $restored_file);
658 658
 
659
-		$meta['file'] = _wp_relative_upload_path( $restored_file );
659
+		$meta['file'] = _wp_relative_upload_path($restored_file);
660 660
 		$meta['width'] = $data['width'];
661 661
 		$meta['height'] = $data['height'];
662 662
 	}
663 663
 
664
-	foreach ( $default_sizes as $default_size ) {
665
-		if ( isset($backup_sizes["$default_size-orig"]) ) {
664
+	foreach ($default_sizes as $default_size) {
665
+		if (isset($backup_sizes["$default_size-orig"])) {
666 666
 			$data = $backup_sizes["$default_size-orig"];
667
-			if ( isset($meta['sizes'][$default_size]) && $meta['sizes'][$default_size]['file'] != $data['file'] ) {
668
-				if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE ) {
667
+			if (isset($meta['sizes'][$default_size]) && $meta['sizes'][$default_size]['file'] != $data['file']) {
668
+				if (defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE) {
669 669
 
670 670
 					// Delete only if it's an edited image.
671
-					if ( preg_match('/-e[0-9]{13}-/', $meta['sizes'][$default_size]['file']) ) {
672
-						$delete_file = path_join( $parts['dirname'], $meta['sizes'][$default_size]['file'] );
673
-						wp_delete_file( $delete_file );
671
+					if (preg_match('/-e[0-9]{13}-/', $meta['sizes'][$default_size]['file'])) {
672
+						$delete_file = path_join($parts['dirname'], $meta['sizes'][$default_size]['file']);
673
+						wp_delete_file($delete_file);
674 674
 					}
675 675
 				} else {
676 676
 					$backup_sizes["$default_size-{$suffix}"] = $meta['sizes'][$default_size];
@@ -683,14 +683,14 @@  discard block
 block discarded – undo
683 683
 		}
684 684
 	}
685 685
 
686
-	if ( ! wp_update_attachment_metadata( $post_id, $meta ) ||
687
-		( $old_backup_sizes !== $backup_sizes && ! update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes ) ) ) {
686
+	if ( ! wp_update_attachment_metadata($post_id, $meta) ||
687
+		($old_backup_sizes !== $backup_sizes && ! update_post_meta($post_id, '_wp_attachment_backup_sizes', $backup_sizes))) {
688 688
 
689 689
 		$msg->error = __('Cannot save image metadata.');
690 690
 		return $msg;
691 691
 	}
692 692
 
693
-	if ( !$restored )
693
+	if ( ! $restored)
694 694
 		$msg->error = __('Image metadata is inconsistent.');
695 695
 	else
696 696
 		$msg->msg = __('Image restored successfully.');
@@ -707,25 +707,25 @@  discard block
 block discarded – undo
707 707
  * @param int $post_id
708 708
  * @return \stdClass
709 709
  */
710
-function wp_save_image( $post_id ) {
710
+function wp_save_image($post_id) {
711 711
 	global $_wp_additional_image_sizes;
712 712
 
713 713
 	$return = new stdClass;
714 714
 	$success = $delete = $scaled = $nocrop = false;
715
-	$post = get_post( $post_id );
715
+	$post = get_post($post_id);
716 716
 
717
-	$img = wp_get_image_editor( _load_image_to_edit_path( $post_id, 'full' ) );
718
-	if ( is_wp_error( $img ) ) {
719
-		$return->error = esc_js( __('Unable to create new image.') );
717
+	$img = wp_get_image_editor(_load_image_to_edit_path($post_id, 'full'));
718
+	if (is_wp_error($img)) {
719
+		$return->error = esc_js(__('Unable to create new image.'));
720 720
 		return $return;
721 721
 	}
722 722
 
723
-	$fwidth = !empty($_REQUEST['fwidth']) ? intval($_REQUEST['fwidth']) : 0;
724
-	$fheight = !empty($_REQUEST['fheight']) ? intval($_REQUEST['fheight']) : 0;
725
-	$target = !empty($_REQUEST['target']) ? preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['target']) : '';
726
-	$scale = !empty($_REQUEST['do']) && 'scale' == $_REQUEST['do'];
723
+	$fwidth = ! empty($_REQUEST['fwidth']) ? intval($_REQUEST['fwidth']) : 0;
724
+	$fheight = ! empty($_REQUEST['fheight']) ? intval($_REQUEST['fheight']) : 0;
725
+	$target = ! empty($_REQUEST['target']) ? preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['target']) : '';
726
+	$scale = ! empty($_REQUEST['do']) && 'scale' == $_REQUEST['do'];
727 727
 
728
-	if ( $scale && $fwidth > 0 && $fheight > 0 ) {
728
+	if ($scale && $fwidth > 0 && $fheight > 0) {
729 729
 		$size = $img->get_size();
730 730
 		$sX = $size['width'];
731 731
 		$sY = $size['height'];
@@ -734,54 +734,54 @@  discard block
 block discarded – undo
734 734
 		$diff = round($sX / $sY, 2) - round($fwidth / $fheight, 2);
735 735
 		if ( -0.1 < $diff && $diff < 0.1 ) {
736 736
 			// Scale the full size image.
737
-			if ( $img->resize( $fwidth, $fheight ) )
737
+			if ($img->resize($fwidth, $fheight))
738 738
 				$scaled = true;
739 739
 		}
740 740
 
741
-		if ( !$scaled ) {
742
-			$return->error = esc_js( __('Error while saving the scaled image. Please reload the page and try again.') );
741
+		if ( ! $scaled) {
742
+			$return->error = esc_js(__('Error while saving the scaled image. Please reload the page and try again.'));
743 743
 			return $return;
744 744
 		}
745
-	} elseif ( !empty($_REQUEST['history']) ) {
746
-		$changes = json_decode( wp_unslash($_REQUEST['history']) );
747
-		if ( $changes )
745
+	} elseif ( ! empty($_REQUEST['history'])) {
746
+		$changes = json_decode(wp_unslash($_REQUEST['history']));
747
+		if ($changes)
748 748
 			$img = image_edit_apply_changes($img, $changes);
749 749
 	} else {
750
-		$return->error = esc_js( __('Nothing to save, the image has not changed.') );
750
+		$return->error = esc_js(__('Nothing to save, the image has not changed.'));
751 751
 		return $return;
752 752
 	}
753 753
 
754 754
 	$meta = wp_get_attachment_metadata($post_id);
755
-	$backup_sizes = get_post_meta( $post->ID, '_wp_attachment_backup_sizes', true );
755
+	$backup_sizes = get_post_meta($post->ID, '_wp_attachment_backup_sizes', true);
756 756
 
757
-	if ( !is_array($meta) ) {
758
-		$return->error = esc_js( __('Image data does not exist. Please re-upload the image.') );
757
+	if ( ! is_array($meta)) {
758
+		$return->error = esc_js(__('Image data does not exist. Please re-upload the image.'));
759 759
 		return $return;
760 760
 	}
761 761
 
762
-	if ( !is_array($backup_sizes) )
762
+	if ( ! is_array($backup_sizes))
763 763
 		$backup_sizes = array();
764 764
 
765 765
 	// Generate new filename.
766 766
 	$path = get_attached_file($post_id);
767
-	$path_parts = pathinfo( $path );
767
+	$path_parts = pathinfo($path);
768 768
 	$filename = $path_parts['filename'];
769
-	$suffix = time() . rand(100, 999);
769
+	$suffix = time().rand(100, 999);
770 770
 
771
-	if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE &&
772
-		isset($backup_sizes['full-orig']) && $backup_sizes['full-orig']['file'] != $path_parts['basename'] ) {
771
+	if (defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE &&
772
+		isset($backup_sizes['full-orig']) && $backup_sizes['full-orig']['file'] != $path_parts['basename']) {
773 773
 
774
-		if ( 'thumbnail' == $target )
774
+		if ('thumbnail' == $target)
775 775
 			$new_path = "{$path_parts['dirname']}/{$filename}-temp.{$path_parts['extension']}";
776 776
 		else
777 777
 			$new_path = $path;
778 778
 	} else {
779
-		while( true ) {
780
-			$filename = preg_replace( '/-e([0-9]+)$/', '', $filename );
779
+		while (true) {
780
+			$filename = preg_replace('/-e([0-9]+)$/', '', $filename);
781 781
 			$filename .= "-e{$suffix}";
782 782
 			$new_filename = "{$filename}.{$path_parts['extension']}";
783 783
 			$new_path = "{$path_parts['dirname']}/$new_filename";
784
-			if ( file_exists($new_path) )
784
+			if (file_exists($new_path))
785 785
 				$suffix++;
786 786
 			else
787 787
 				break;
@@ -789,92 +789,92 @@  discard block
 block discarded – undo
789 789
 	}
790 790
 
791 791
 	// Save the full-size file, also needed to create sub-sizes.
792
-	if ( !wp_save_image_file($new_path, $img, $post->post_mime_type, $post_id) ) {
793
-		$return->error = esc_js( __('Unable to save the image.') );
792
+	if ( ! wp_save_image_file($new_path, $img, $post->post_mime_type, $post_id)) {
793
+		$return->error = esc_js(__('Unable to save the image.'));
794 794
 		return $return;
795 795
 	}
796 796
 
797
-	if ( 'nothumb' == $target || 'all' == $target || 'full' == $target || $scaled ) {
797
+	if ('nothumb' == $target || 'all' == $target || 'full' == $target || $scaled) {
798 798
 		$tag = false;
799
-		if ( isset($backup_sizes['full-orig']) ) {
800
-			if ( ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE ) && $backup_sizes['full-orig']['file'] != $path_parts['basename'] )
799
+		if (isset($backup_sizes['full-orig'])) {
800
+			if (( ! defined('IMAGE_EDIT_OVERWRITE') || ! IMAGE_EDIT_OVERWRITE) && $backup_sizes['full-orig']['file'] != $path_parts['basename'])
801 801
 				$tag = "full-$suffix";
802 802
 		} else {
803 803
 			$tag = 'full-orig';
804 804
 		}
805 805
 
806
-		if ( $tag )
806
+		if ($tag)
807 807
 			$backup_sizes[$tag] = array('width' => $meta['width'], 'height' => $meta['height'], 'file' => $path_parts['basename']);
808 808
 
809
-		$success = ( $path === $new_path ) || update_attached_file( $post_id, $new_path );
809
+		$success = ($path === $new_path) || update_attached_file($post_id, $new_path);
810 810
 
811
-		$meta['file'] = _wp_relative_upload_path( $new_path );
811
+		$meta['file'] = _wp_relative_upload_path($new_path);
812 812
 
813 813
 		$size = $img->get_size();
814 814
 		$meta['width'] = $size['width'];
815 815
 		$meta['height'] = $size['height'];
816 816
 
817
-		if ( $success && ('nothumb' == $target || 'all' == $target) ) {
817
+		if ($success && ('nothumb' == $target || 'all' == $target)) {
818 818
 			$sizes = get_intermediate_image_sizes();
819
-			if ( 'nothumb' == $target )
820
-				$sizes = array_diff( $sizes, array('thumbnail') );
819
+			if ('nothumb' == $target)
820
+				$sizes = array_diff($sizes, array('thumbnail'));
821 821
 		}
822 822
 
823 823
 		$return->fw = $meta['width'];
824 824
 		$return->fh = $meta['height'];
825
-	} elseif ( 'thumbnail' == $target ) {
826
-		$sizes = array( 'thumbnail' );
825
+	} elseif ('thumbnail' == $target) {
826
+		$sizes = array('thumbnail');
827 827
 		$success = $delete = $nocrop = true;
828 828
 	}
829 829
 
830
-	if ( isset( $sizes ) ) {
830
+	if (isset($sizes)) {
831 831
 		$_sizes = array();
832 832
 
833
-		foreach ( $sizes as $size ) {
833
+		foreach ($sizes as $size) {
834 834
 			$tag = false;
835
-			if ( isset( $meta['sizes'][$size] ) ) {
836
-				if ( isset($backup_sizes["$size-orig"]) ) {
837
-					if ( ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE ) && $backup_sizes["$size-orig"]['file'] != $meta['sizes'][$size]['file'] )
835
+			if (isset($meta['sizes'][$size])) {
836
+				if (isset($backup_sizes["$size-orig"])) {
837
+					if (( ! defined('IMAGE_EDIT_OVERWRITE') || ! IMAGE_EDIT_OVERWRITE) && $backup_sizes["$size-orig"]['file'] != $meta['sizes'][$size]['file'])
838 838
 						$tag = "$size-$suffix";
839 839
 				} else {
840 840
 					$tag = "$size-orig";
841 841
 				}
842 842
 
843
-				if ( $tag )
843
+				if ($tag)
844 844
 					$backup_sizes[$tag] = $meta['sizes'][$size];
845 845
 			}
846 846
 
847
-			if ( isset( $_wp_additional_image_sizes[ $size ] ) ) {
848
-				$width  = intval( $_wp_additional_image_sizes[ $size ]['width'] );
849
-				$height = intval( $_wp_additional_image_sizes[ $size ]['height'] );
850
-				$crop   = ( $nocrop ) ? false : $_wp_additional_image_sizes[ $size ]['crop'];
847
+			if (isset($_wp_additional_image_sizes[$size])) {
848
+				$width  = intval($_wp_additional_image_sizes[$size]['width']);
849
+				$height = intval($_wp_additional_image_sizes[$size]['height']);
850
+				$crop   = ($nocrop) ? false : $_wp_additional_image_sizes[$size]['crop'];
851 851
 			} else {
852
-				$height = get_option( "{$size}_size_h" );
853
-				$width  = get_option( "{$size}_size_w" );
854
-				$crop   = ( $nocrop ) ? false : get_option( "{$size}_crop" );
852
+				$height = get_option("{$size}_size_h");
853
+				$width  = get_option("{$size}_size_w");
854
+				$crop   = ($nocrop) ? false : get_option("{$size}_crop");
855 855
 			}
856 856
 
857
-			$_sizes[ $size ] = array( 'width' => $width, 'height' => $height, 'crop' => $crop );
857
+			$_sizes[$size] = array('width' => $width, 'height' => $height, 'crop' => $crop);
858 858
 		}
859 859
 
860
-		$meta['sizes'] = array_merge( $meta['sizes'], $img->multi_resize( $_sizes ) );
860
+		$meta['sizes'] = array_merge($meta['sizes'], $img->multi_resize($_sizes));
861 861
 	}
862 862
 
863
-	unset( $img );
863
+	unset($img);
864 864
 
865
-	if ( $success ) {
866
-		wp_update_attachment_metadata( $post_id, $meta );
867
-		update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes);
865
+	if ($success) {
866
+		wp_update_attachment_metadata($post_id, $meta);
867
+		update_post_meta($post_id, '_wp_attachment_backup_sizes', $backup_sizes);
868 868
 
869
-		if ( $target == 'thumbnail' || $target == 'all' || $target == 'full' ) {
869
+		if ($target == 'thumbnail' || $target == 'all' || $target == 'full') {
870 870
 			// Check if it's an image edit from attachment edit screen
871
-			if ( ! empty( $_REQUEST['context'] ) && 'edit-attachment' == $_REQUEST['context'] ) {
872
-				$thumb_url = wp_get_attachment_image_src( $post_id, array( 900, 600 ), true );
871
+			if ( ! empty($_REQUEST['context']) && 'edit-attachment' == $_REQUEST['context']) {
872
+				$thumb_url = wp_get_attachment_image_src($post_id, array(900, 600), true);
873 873
 				$return->thumbnail = $thumb_url[0];
874 874
 			} else {
875 875
 				$file_url = wp_get_attachment_url($post_id);
876
-				if ( ! empty( $meta['sizes']['thumbnail'] ) && $thumb = $meta['sizes']['thumbnail'] ) {
877
-					$return->thumbnail = path_join( dirname($file_url), $thumb['file'] );
876
+				if ( ! empty($meta['sizes']['thumbnail']) && $thumb = $meta['sizes']['thumbnail']) {
877
+					$return->thumbnail = path_join(dirname($file_url), $thumb['file']);
878 878
 				} else {
879 879
 					$return->thumbnail = "$file_url?w=128&h=128";
880 880
 				}
@@ -884,10 +884,10 @@  discard block
 block discarded – undo
884 884
 		$delete = true;
885 885
 	}
886 886
 
887
-	if ( $delete ) {
888
-		wp_delete_file( $new_path );
887
+	if ($delete) {
888
+		wp_delete_file($new_path);
889 889
 	}
890 890
 
891
-	$return->msg = esc_js( __('Image saved') );
891
+	$return->msg = esc_js(__('Image saved'));
892 892
 	return $return;
893 893
 }
Please login to merge, or discard this patch.
Braces   +89 added lines, -64 removed lines patch added patch discarded remove patch
@@ -20,23 +20,26 @@  discard block
 block discarded – undo
20 20
 	$sub_sizes = isset($meta['sizes']) && is_array($meta['sizes']);
21 21
 	$note = '';
22 22
 
23
-	if ( isset( $meta['width'], $meta['height'] ) )
24
-		$big = max( $meta['width'], $meta['height'] );
25
-	else
26
-		die( __('Image data does not exist. Please re-upload the image.') );
23
+	if ( isset( $meta['width'], $meta['height'] ) ) {
24
+			$big = max( $meta['width'], $meta['height'] );
25
+	} else {
26
+			die( __('Image data does not exist. Please re-upload the image.') );
27
+	}
27 28
 
28 29
 	$sizer = $big > 400 ? 400 / $big : 1;
29 30
 
30 31
 	$backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true );
31 32
 	$can_restore = false;
32
-	if ( ! empty( $backup_sizes ) && isset( $backup_sizes['full-orig'], $meta['file'] ) )
33
-		$can_restore = $backup_sizes['full-orig']['file'] != basename( $meta['file'] );
33
+	if ( ! empty( $backup_sizes ) && isset( $backup_sizes['full-orig'], $meta['file'] ) ) {
34
+			$can_restore = $backup_sizes['full-orig']['file'] != basename( $meta['file'] );
35
+	}
34 36
 
35 37
 	if ( $msg ) {
36
-		if ( isset($msg->error) )
37
-			$note = "<div class='error'><p>$msg->error</p></div>";
38
-		elseif ( isset($msg->msg) )
39
-			$note = "<div class='updated'><p>$msg->msg</p></div>";
38
+		if ( isset($msg->error) ) {
39
+					$note = "<div class='error'><p>$msg->error</p></div>";
40
+		} elseif ( isset($msg->msg) ) {
41
+					$note = "<div class='updated'><p>$msg->msg</p></div>";
42
+		}
40 43
 	}
41 44
 
42 45
 	?>
@@ -83,8 +86,9 @@  discard block
 block discarded – undo
83 86
 		<div class="imgedit-help">
84 87
 		<p><?php _e('Discard any changes and restore the original image.');
85 88
 
86
-		if ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE )
87
-			echo ' '.__('Previously edited copies of the image will not be deleted.');
89
+		if ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE ) {
90
+					echo ' '.__('Previously edited copies of the image will not be deleted.');
91
+		}
88 92
 
89 93
 		?></p>
90 94
 		<div class="imgedit-submit">
@@ -252,8 +256,9 @@  discard block
 block discarded – undo
252 256
 		 */
253 257
 		$image = apply_filters( 'image_editor_save_pre', $image, $post_id );
254 258
 
255
-		if ( is_wp_error( $image->stream( $mime_type ) ) )
256
-			return false;
259
+		if ( is_wp_error( $image->stream( $mime_type ) ) ) {
260
+					return false;
261
+		}
257 262
 
258 263
 		return true;
259 264
 	} else {
@@ -317,8 +322,9 @@  discard block
 block discarded – undo
317 322
 		 */
318 323
 		$saved = apply_filters( 'wp_save_image_editor_file', null, $filename, $image, $mime_type, $post_id );
319 324
 
320
-		if ( null !== $saved )
321
-			return $saved;
325
+		if ( null !== $saved ) {
326
+					return $saved;
327
+		}
322 328
 
323 329
 		return $image->save( $filename, $mime_type );
324 330
 	} else {
@@ -344,8 +350,9 @@  discard block
 block discarded – undo
344 350
 		 */
345 351
 		$saved = apply_filters( 'wp_save_image_file', null, $filename, $image, $mime_type, $post_id );
346 352
 
347
-		if ( null !== $saved )
348
-			return $saved;
353
+		if ( null !== $saved ) {
354
+					return $saved;
355
+		}
349 356
 
350 357
 		switch ( $mime_type ) {
351 358
 			case 'image/jpeg':
@@ -463,11 +470,13 @@  discard block
 block discarded – undo
463 470
  * @return WP_Image_Editor {@see WP_Image_Editor} instance with changes applied.
464 471
  */
465 472
 function image_edit_apply_changes( $image, $changes ) {
466
-	if ( is_resource( $image ) )
467
-		_deprecated_argument( __FUNCTION__, '3.5', __( '$image needs to be an WP_Image_Editor object' ) );
473
+	if ( is_resource( $image ) ) {
474
+			_deprecated_argument( __FUNCTION__, '3.5', __( '$image needs to be an WP_Image_Editor object' ) );
475
+	}
468 476
 
469
-	if ( !is_array($changes) )
470
-		return $image;
477
+	if ( !is_array($changes) ) {
478
+			return $image;
479
+	}
471 480
 
472 481
 	// Expand change operations.
473 482
 	foreach ( $changes as $key => $obj ) {
@@ -504,8 +513,9 @@  discard block
 block discarded – undo
504 513
 						break;
505 514
 				}
506 515
 			}
507
-			if ( !$combined )
508
-				$filtered[++$i] = $changes[$j];
516
+			if ( !$combined ) {
517
+							$filtered[++$i] = $changes[$j];
518
+			}
509 519
 		}
510 520
 		$changes = $filtered;
511 521
 		unset($filtered);
@@ -541,18 +551,20 @@  discard block
 block discarded – undo
541 551
 		switch ( $operation->type ) {
542 552
 			case 'rotate':
543 553
 				if ( $operation->angle != 0 ) {
544
-					if ( $image instanceof WP_Image_Editor )
545
-						$image->rotate( $operation->angle );
546
-					else
547
-						$image = _rotate_image_resource( $image, $operation->angle );
554
+					if ( $image instanceof WP_Image_Editor ) {
555
+											$image->rotate( $operation->angle );
556
+					} else {
557
+											$image = _rotate_image_resource( $image, $operation->angle );
558
+					}
548 559
 				}
549 560
 				break;
550 561
 			case 'flip':
551
-				if ( $operation->axis != 0 )
552
-					if ( $image instanceof WP_Image_Editor )
562
+				if ( $operation->axis != 0 ) {
563
+									if ( $image instanceof WP_Image_Editor )
553 564
 						$image->flip( ($operation->axis & 1) != 0, ($operation->axis & 2) != 0 );
554
-					else
555
-						$image = _flip_image_resource( $image, ( $operation->axis & 1 ) != 0, ( $operation->axis & 2 ) != 0 );
565
+				} else {
566
+											$image = _flip_image_resource( $image, ( $operation->axis & 1 ) != 0, ( $operation->axis & 2 ) != 0 );
567
+					}
556 568
 				break;
557 569
 			case 'crop':
558 570
 				$sel = $operation->sel;
@@ -596,8 +608,9 @@  discard block
 block discarded – undo
596 608
 	}
597 609
 
598 610
 	$changes = !empty($_REQUEST['history']) ? json_decode( wp_unslash($_REQUEST['history']) ) : null;
599
-	if ( $changes )
600
-		$img = image_edit_apply_changes( $img, $changes );
611
+	if ( $changes ) {
612
+			$img = image_edit_apply_changes( $img, $changes );
613
+	}
601 614
 
602 615
 	// Scale the image.
603 616
 	$size = $img->get_size();
@@ -608,8 +621,9 @@  discard block
 block discarded – undo
608 621
 	$w2 = max ( 1, $w * $ratio );
609 622
 	$h2 = max ( 1, $h * $ratio );
610 623
 
611
-	if ( is_wp_error( $img->resize( $w2, $h2 ) ) )
612
-		return false;
624
+	if ( is_wp_error( $img->resize( $w2, $h2 ) ) ) {
625
+			return false;
626
+	}
613 627
 
614 628
 	return wp_stream_image( $img, $post->post_mime_type, $post_id );
615 629
 }
@@ -690,10 +704,11 @@  discard block
 block discarded – undo
690 704
 		return $msg;
691 705
 	}
692 706
 
693
-	if ( !$restored )
694
-		$msg->error = __('Image metadata is inconsistent.');
695
-	else
696
-		$msg->msg = __('Image restored successfully.');
707
+	if ( !$restored ) {
708
+			$msg->error = __('Image metadata is inconsistent.');
709
+	} else {
710
+			$msg->msg = __('Image restored successfully.');
711
+	}
697 712
 
698 713
 	return $msg;
699 714
 }
@@ -734,8 +749,9 @@  discard block
 block discarded – undo
734 749
 		$diff = round($sX / $sY, 2) - round($fwidth / $fheight, 2);
735 750
 		if ( -0.1 < $diff && $diff < 0.1 ) {
736 751
 			// Scale the full size image.
737
-			if ( $img->resize( $fwidth, $fheight ) )
738
-				$scaled = true;
752
+			if ( $img->resize( $fwidth, $fheight ) ) {
753
+							$scaled = true;
754
+			}
739 755
 		}
740 756
 
741 757
 		if ( !$scaled ) {
@@ -744,8 +760,9 @@  discard block
 block discarded – undo
744 760
 		}
745 761
 	} elseif ( !empty($_REQUEST['history']) ) {
746 762
 		$changes = json_decode( wp_unslash($_REQUEST['history']) );
747
-		if ( $changes )
748
-			$img = image_edit_apply_changes($img, $changes);
763
+		if ( $changes ) {
764
+					$img = image_edit_apply_changes($img, $changes);
765
+		}
749 766
 	} else {
750 767
 		$return->error = esc_js( __('Nothing to save, the image has not changed.') );
751 768
 		return $return;
@@ -759,8 +776,9 @@  discard block
 block discarded – undo
759 776
 		return $return;
760 777
 	}
761 778
 
762
-	if ( !is_array($backup_sizes) )
763
-		$backup_sizes = array();
779
+	if ( !is_array($backup_sizes) ) {
780
+			$backup_sizes = array();
781
+	}
764 782
 
765 783
 	// Generate new filename.
766 784
 	$path = get_attached_file($post_id);
@@ -771,20 +789,22 @@  discard block
 block discarded – undo
771 789
 	if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE &&
772 790
 		isset($backup_sizes['full-orig']) && $backup_sizes['full-orig']['file'] != $path_parts['basename'] ) {
773 791
 
774
-		if ( 'thumbnail' == $target )
775
-			$new_path = "{$path_parts['dirname']}/{$filename}-temp.{$path_parts['extension']}";
776
-		else
777
-			$new_path = $path;
792
+		if ( 'thumbnail' == $target ) {
793
+					$new_path = "{$path_parts['dirname']}/{$filename}-temp.{$path_parts['extension']}";
794
+		} else {
795
+					$new_path = $path;
796
+		}
778 797
 	} else {
779 798
 		while( true ) {
780 799
 			$filename = preg_replace( '/-e([0-9]+)$/', '', $filename );
781 800
 			$filename .= "-e{$suffix}";
782 801
 			$new_filename = "{$filename}.{$path_parts['extension']}";
783 802
 			$new_path = "{$path_parts['dirname']}/$new_filename";
784
-			if ( file_exists($new_path) )
785
-				$suffix++;
786
-			else
787
-				break;
803
+			if ( file_exists($new_path) ) {
804
+							$suffix++;
805
+			} else {
806
+							break;
807
+			}
788 808
 		}
789 809
 	}
790 810
 
@@ -797,14 +817,16 @@  discard block
 block discarded – undo
797 817
 	if ( 'nothumb' == $target || 'all' == $target || 'full' == $target || $scaled ) {
798 818
 		$tag = false;
799 819
 		if ( isset($backup_sizes['full-orig']) ) {
800
-			if ( ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE ) && $backup_sizes['full-orig']['file'] != $path_parts['basename'] )
801
-				$tag = "full-$suffix";
820
+			if ( ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE ) && $backup_sizes['full-orig']['file'] != $path_parts['basename'] ) {
821
+							$tag = "full-$suffix";
822
+			}
802 823
 		} else {
803 824
 			$tag = 'full-orig';
804 825
 		}
805 826
 
806
-		if ( $tag )
807
-			$backup_sizes[$tag] = array('width' => $meta['width'], 'height' => $meta['height'], 'file' => $path_parts['basename']);
827
+		if ( $tag ) {
828
+					$backup_sizes[$tag] = array('width' => $meta['width'], 'height' => $meta['height'], 'file' => $path_parts['basename']);
829
+		}
808 830
 
809 831
 		$success = ( $path === $new_path ) || update_attached_file( $post_id, $new_path );
810 832
 
@@ -816,8 +838,9 @@  discard block
 block discarded – undo
816 838
 
817 839
 		if ( $success && ('nothumb' == $target || 'all' == $target) ) {
818 840
 			$sizes = get_intermediate_image_sizes();
819
-			if ( 'nothumb' == $target )
820
-				$sizes = array_diff( $sizes, array('thumbnail') );
841
+			if ( 'nothumb' == $target ) {
842
+							$sizes = array_diff( $sizes, array('thumbnail') );
843
+			}
821 844
 		}
822 845
 
823 846
 		$return->fw = $meta['width'];
@@ -834,14 +857,16 @@  discard block
 block discarded – undo
834 857
 			$tag = false;
835 858
 			if ( isset( $meta['sizes'][$size] ) ) {
836 859
 				if ( isset($backup_sizes["$size-orig"]) ) {
837
-					if ( ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE ) && $backup_sizes["$size-orig"]['file'] != $meta['sizes'][$size]['file'] )
838
-						$tag = "$size-$suffix";
860
+					if ( ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE ) && $backup_sizes["$size-orig"]['file'] != $meta['sizes'][$size]['file'] ) {
861
+											$tag = "$size-$suffix";
862
+					}
839 863
 				} else {
840 864
 					$tag = "$size-orig";
841 865
 				}
842 866
 
843
-				if ( $tag )
844
-					$backup_sizes[$tag] = $meta['sizes'][$size];
867
+				if ( $tag ) {
868
+									$backup_sizes[$tag] = $meta['sizes'][$size];
869
+				}
845 870
 			}
846 871
 
847 872
 			if ( isset( $_wp_additional_image_sizes[ $size ] ) ) {
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
 		 * @since 3.5.0
521 521
 		 *
522 522
 		 * @param WP_Image_Editor $image   WP_Image_Editor instance.
523
- 		 * @param array           $changes Array of change operations.
523
+		 * @param array           $changes Array of change operations.
524 524
 		 */
525 525
 		$image = apply_filters( 'wp_image_editor_before_change', $image, $changes );
526 526
 	} elseif ( is_resource( $image ) ) {
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
 		 * @deprecated 3.5.0 Use wp_image_editor_before_change instead.
533 533
 		 *
534 534
 		 * @param resource $image   GD image resource.
535
- 		 * @param array    $changes Array of change operations.
535
+		 * @param array    $changes Array of change operations.
536 536
 		 */
537 537
 		$image = apply_filters( 'image_edit_before_change', $image, $changes );
538 538
 	}
Please login to merge, or discard this patch.
src/wp-admin/includes/misc.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
  *
190 190
  * @global WP_Rewrite $wp_rewrite
191 191
  *
192
- * @return bool True if web.config was updated successfully
192
+ * @return null|boolean True if web.config was updated successfully
193 193
  */
194 194
 function iis7_save_url_rewrite_rules(){
195 195
 	if ( is_multisite() )
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
  *
276 276
  * @since 2.0.0
277 277
  *
278
- * @param array $vars An array of globals to reset.
278
+ * @param string[] $vars An array of globals to reset.
279 279
  */
280 280
 function wp_reset_vars( $vars ) {
281 281
 	foreach ( $vars as $var ) {
Please login to merge, or discard this patch.
Braces   +99 added lines, -69 removed lines patch added patch discarded remove patch
@@ -75,12 +75,15 @@  discard block
 block discarded – undo
75 75
 	{
76 76
 		$state = false;
77 77
 		foreach ( $markerdata as $markerline ) {
78
-			if (strpos($markerline, '# END ' . $marker) !== false)
79
-				$state = false;
80
-			if ( $state )
81
-				$result[] = $markerline;
82
-			if (strpos($markerline, '# BEGIN ' . $marker) !== false)
83
-				$state = true;
78
+			if (strpos($markerline, '# END ' . $marker) !== false) {
79
+							$state = false;
80
+			}
81
+			if ( $state ) {
82
+							$result[] = $markerline;
83
+			}
84
+			if (strpos($markerline, '# BEGIN ' . $marker) !== false) {
85
+							$state = true;
86
+			}
84 87
 		}
85 88
 	}
86 89
 
@@ -194,8 +197,9 @@  discard block
 block discarded – undo
194 197
  * @global WP_Rewrite $wp_rewrite
195 198
  */
196 199
 function save_mod_rewrite_rules() {
197
-	if ( is_multisite() )
198
-		return;
200
+	if ( is_multisite() ) {
201
+			return;
202
+	}
199 203
 
200 204
 	global $wp_rewrite;
201 205
 
@@ -227,8 +231,9 @@  discard block
 block discarded – undo
227 231
  * @return bool True if web.config was updated successfully
228 232
  */
229 233
 function iis7_save_url_rewrite_rules(){
230
-	if ( is_multisite() )
231
-		return;
234
+	if ( is_multisite() ) {
235
+			return;
236
+	}
232 237
 
233 238
 	global $wp_rewrite;
234 239
 
@@ -261,8 +266,9 @@  discard block
 block discarded – undo
261 266
 		$oldfiles[] = $file;
262 267
 		$oldfiles = array_reverse( $oldfiles );
263 268
 		$oldfiles = array_unique( $oldfiles );
264
-		if ( 5 < count( $oldfiles ))
265
-			array_pop( $oldfiles );
269
+		if ( 5 < count( $oldfiles )) {
270
+					array_pop( $oldfiles );
271
+		}
266 272
 	} else {
267 273
 		$oldfiles[] = $file;
268 274
 	}
@@ -278,8 +284,9 @@  discard block
 block discarded – undo
278 284
  * @param string $value
279 285
  */
280 286
 function update_home_siteurl( $old_value, $value ) {
281
-	if ( wp_installing() )
282
-		return;
287
+	if ( wp_installing() ) {
288
+			return;
289
+	}
283 290
 
284 291
 	if ( is_multisite() && ms_is_switched() ) {
285 292
 		delete_option( 'rewrite_rules' );
@@ -323,10 +330,11 @@  discard block
 block discarded – undo
323 330
  */
324 331
 function show_message($message) {
325 332
 	if ( is_wp_error($message) ){
326
-		if ( $message->get_error_data() && is_string( $message->get_error_data() ) )
327
-			$message = $message->get_error_message() . ': ' . $message->get_error_data();
328
-		else
329
-			$message = $message->get_error_message();
333
+		if ( $message->get_error_data() && is_string( $message->get_error_data() ) ) {
334
+					$message = $message->get_error_message() . ': ' . $message->get_error_data();
335
+		} else {
336
+					$message = $message->get_error_message();
337
+		}
330 338
 	}
331 339
 	echo "<p>$message</p>\n";
332 340
 	wp_ob_end_flush_all();
@@ -340,11 +348,13 @@  discard block
 block discarded – undo
340 348
  * @return array
341 349
  */
342 350
 function wp_doc_link_parse( $content ) {
343
-	if ( !is_string( $content ) || empty( $content ) )
344
-		return array();
351
+	if ( !is_string( $content ) || empty( $content ) ) {
352
+			return array();
353
+	}
345 354
 
346
-	if ( !function_exists('token_get_all') )
347
-		return array();
355
+	if ( !function_exists('token_get_all') ) {
356
+			return array();
357
+	}
348 358
 
349 359
 	$tokens = token_get_all( $content );
350 360
 	$count = count( $tokens );
@@ -381,8 +391,9 @@  discard block
 block discarded – undo
381 391
 
382 392
 	$out = array();
383 393
 	foreach ( $functions as $function ) {
384
-		if ( in_array( $function, $ignore_functions ) )
385
-			continue;
394
+		if ( in_array( $function, $ignore_functions ) ) {
395
+					continue;
396
+		}
386 397
 		$out[] = $function;
387 398
 	}
388 399
 
@@ -399,23 +410,26 @@  discard block
 block discarded – undo
399 410
 	if ( isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options']) ) {
400 411
 		check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' );
401 412
 
402
-		if ( !$user = wp_get_current_user() )
403
-			return;
413
+		if ( !$user = wp_get_current_user() ) {
414
+					return;
415
+		}
404 416
 		$option = $_POST['wp_screen_options']['option'];
405 417
 		$value = $_POST['wp_screen_options']['value'];
406 418
 
407
-		if ( $option != sanitize_key( $option ) )
408
-			return;
419
+		if ( $option != sanitize_key( $option ) ) {
420
+					return;
421
+		}
409 422
 
410 423
 		$map_option = $option;
411 424
 		$type = str_replace('edit_', '', $map_option);
412 425
 		$type = str_replace('_per_page', '', $type);
413
-		if ( in_array( $type, get_taxonomies() ) )
414
-			$map_option = 'edit_tags_per_page';
415
-		elseif ( in_array( $type, get_post_types() ) )
416
-			$map_option = 'edit_per_page';
417
-		else
418
-			$option = str_replace('-', '_', $option);
426
+		if ( in_array( $type, get_taxonomies() ) ) {
427
+					$map_option = 'edit_tags_per_page';
428
+		} elseif ( in_array( $type, get_post_types() ) ) {
429
+					$map_option = 'edit_per_page';
430
+		} else {
431
+					$option = str_replace('-', '_', $option);
432
+		}
419 433
 
420 434
 		switch ( $map_option ) {
421 435
 			case 'edit_per_page':
@@ -432,8 +446,9 @@  discard block
 block discarded – undo
432 446
 			case 'themes_network_per_page':
433 447
 			case 'site_themes_network_per_page':
434 448
 				$value = (int) $value;
435
-				if ( $value < 1 || $value > 999 )
436
-					return;
449
+				if ( $value < 1 || $value > 999 ) {
450
+									return;
451
+				}
437 452
 				break;
438 453
 			default:
439 454
 
@@ -455,8 +470,9 @@  discard block
 block discarded – undo
455 470
 				 */
456 471
 				$value = apply_filters( 'set-screen-option', false, $option, $value );
457 472
 
458
-				if ( false === $value )
459
-					return;
473
+				if ( false === $value ) {
474
+									return;
475
+				}
460 476
 				break;
461 477
 		}
462 478
 
@@ -481,22 +497,25 @@  discard block
 block discarded – undo
481 497
  * @param string $filename The file path to the configuration file
482 498
  */
483 499
 function iis7_rewrite_rule_exists($filename) {
484
-	if ( ! file_exists($filename) )
485
-		return false;
500
+	if ( ! file_exists($filename) ) {
501
+			return false;
502
+	}
486 503
 	if ( ! class_exists( 'DOMDocument', false ) ) {
487 504
 		return false;
488 505
 	}
489 506
 
490 507
 	$doc = new DOMDocument();
491
-	if ( $doc->load($filename) === false )
492
-		return false;
508
+	if ( $doc->load($filename) === false ) {
509
+			return false;
510
+	}
493 511
 	$xpath = new DOMXPath($doc);
494 512
 	$rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')]');
495
-	if ( $rules->length == 0 )
496
-		return false;
497
-	else
498
-		return true;
499
-}
513
+	if ( $rules->length == 0 ) {
514
+			return false;
515
+	} else {
516
+			return true;
517
+	}
518
+	}
500 519
 
501 520
 /**
502 521
  * Delete WordPress rewrite rule from web.config file if it exists there
@@ -508,8 +527,9 @@  discard block
 block discarded – undo
508 527
  */
509 528
 function iis7_delete_rewrite_rule($filename) {
510 529
 	// If configuration file does not exist then rules also do not exist so there is nothing to delete
511
-	if ( ! file_exists($filename) )
512
-		return true;
530
+	if ( ! file_exists($filename) ) {
531
+			return true;
532
+	}
513 533
 
514 534
 	if ( ! class_exists( 'DOMDocument', false ) ) {
515 535
 		return false;
@@ -518,8 +538,9 @@  discard block
 block discarded – undo
518 538
 	$doc = new DOMDocument();
519 539
 	$doc->preserveWhiteSpace = false;
520 540
 
521
-	if ( $doc -> load($filename) === false )
522
-		return false;
541
+	if ( $doc -> load($filename) === false ) {
542
+			return false;
543
+	}
523 544
 	$xpath = new DOMXPath($doc);
524 545
 	$rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')]');
525 546
 	if ( $rules->length > 0 ) {
@@ -556,15 +577,17 @@  discard block
 block discarded – undo
556 577
 	$doc = new DOMDocument();
557 578
 	$doc->preserveWhiteSpace = false;
558 579
 
559
-	if ( $doc->load($filename) === false )
560
-		return false;
580
+	if ( $doc->load($filename) === false ) {
581
+			return false;
582
+	}
561 583
 
562 584
 	$xpath = new DOMXPath($doc);
563 585
 
564 586
 	// First check if the rule already exists as in that case there is no need to re-add it
565 587
 	$wordpress_rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')]');
566
-	if ( $wordpress_rules->length > 0 )
567
-		return true;
588
+	if ( $wordpress_rules->length > 0 ) {
589
+			return true;
590
+	}
568 591
 
569 592
 	// Check the XPath to the rewrite rule and create XML nodes if they do not exist
570 593
 	$xmlnodes = $xpath->query('/configuration/system.webServer/rewrite/rules');
@@ -742,22 +765,25 @@  discard block
 block discarded – undo
742 765
 
743 766
 	if ( array_key_exists( 'wp-check-locked-posts', $data ) && is_array( $data['wp-check-locked-posts'] ) ) {
744 767
 		foreach ( $data['wp-check-locked-posts'] as $key ) {
745
-			if ( ! $post_id = absint( substr( $key, 5 ) ) )
746
-				continue;
768
+			if ( ! $post_id = absint( substr( $key, 5 ) ) ) {
769
+							continue;
770
+			}
747 771
 
748 772
 			if ( ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) && current_user_can( 'edit_post', $post_id ) ) {
749 773
 				$send = array( 'text' => sprintf( __( '%s is currently editing' ), $user->display_name ) );
750 774
 
751
-				if ( ( $avatar = get_avatar( $user->ID, 18 ) ) && preg_match( "|src='([^']+)'|", $avatar, $matches ) )
752
-					$send['avatar_src'] = $matches[1];
775
+				if ( ( $avatar = get_avatar( $user->ID, 18 ) ) && preg_match( "|src='([^']+)'|", $avatar, $matches ) ) {
776
+									$send['avatar_src'] = $matches[1];
777
+				}
753 778
 
754 779
 				$checked[$key] = $send;
755 780
 			}
756 781
 		}
757 782
 	}
758 783
 
759
-	if ( ! empty( $checked ) )
760
-		$response['wp-check-locked-posts'] = $checked;
784
+	if ( ! empty( $checked ) ) {
785
+			$response['wp-check-locked-posts'] = $checked;
786
+	}
761 787
 
762 788
 	return $response;
763 789
 }
@@ -777,11 +803,13 @@  discard block
 block discarded – undo
777 803
 		$received = $data['wp-refresh-post-lock'];
778 804
 		$send = array();
779 805
 
780
-		if ( ! $post_id = absint( $received['post_id'] ) )
781
-			return $response;
806
+		if ( ! $post_id = absint( $received['post_id'] ) ) {
807
+					return $response;
808
+		}
782 809
 
783
-		if ( ! current_user_can('edit_post', $post_id) )
784
-			return $response;
810
+		if ( ! current_user_can('edit_post', $post_id) ) {
811
+					return $response;
812
+		}
785 813
 
786 814
 		if ( ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) ) {
787 815
 			$error = array(
@@ -789,14 +817,16 @@  discard block
 block discarded – undo
789 817
 			);
790 818
 
791 819
 			if ( $avatar = get_avatar( $user->ID, 64 ) ) {
792
-				if ( preg_match( "|src='([^']+)'|", $avatar, $matches ) )
793
-					$error['avatar_src'] = $matches[1];
820
+				if ( preg_match( "|src='([^']+)'|", $avatar, $matches ) ) {
821
+									$error['avatar_src'] = $matches[1];
822
+				}
794 823
 			}
795 824
 
796 825
 			$send['lock_error'] = $error;
797 826
 		} else {
798
-			if ( $new_lock = wp_set_post_lock( $post_id ) )
799
-				$send['new_lock'] = implode( ':', $new_lock );
827
+			if ( $new_lock = wp_set_post_lock( $post_id ) ) {
828
+							$send['new_lock'] = implode( ':', $new_lock );
829
+			}
800 830
 		}
801 831
 
802 832
 		$response['wp-refresh-post-lock'] = $send;
Please login to merge, or discard this patch.
Spacing   +187 added lines, -187 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 *
29 29
 	 * @param bool $got_rewrite Whether Apache and mod_rewrite are present.
30 30
 	 */
31
-	return apply_filters( 'got_rewrite', $got_rewrite );
31
+	return apply_filters('got_rewrite', $got_rewrite);
32 32
 }
33 33
 
34 34
 /**
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
  * @return bool Whether the server supports URL rewriting.
44 44
  */
45 45
 function got_url_rewrite() {
46
-	$got_url_rewrite = ( got_mod_rewrite() || $GLOBALS['is_nginx'] || iis7_supports_permalinks() );
46
+	$got_url_rewrite = (got_mod_rewrite() || $GLOBALS['is_nginx'] || iis7_supports_permalinks());
47 47
 
48 48
 	/**
49 49
 	 * Filters whether URL rewriting is available.
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @param bool $got_url_rewrite Whether URL rewriting is available.
54 54
 	 */
55
-	return apply_filters( 'got_url_rewrite', $got_url_rewrite );
55
+	return apply_filters('got_url_rewrite', $got_url_rewrite);
56 56
 }
57 57
 
58 58
 /**
@@ -64,22 +64,22 @@  discard block
 block discarded – undo
64 64
  * @param string $marker
65 65
  * @return array An array of strings from a file (.htaccess ) from between BEGIN and END markers.
66 66
  */
67
-function extract_from_markers( $filename, $marker ) {
68
-	$result = array ();
67
+function extract_from_markers($filename, $marker) {
68
+	$result = array();
69 69
 
70
-	if (!file_exists( $filename ) ) {
70
+	if ( ! file_exists($filename)) {
71 71
 		return $result;
72 72
 	}
73 73
 
74
-	if ( $markerdata = explode( "\n", implode( '', file( $filename ) ) ));
74
+	if ($markerdata = explode("\n", implode('', file($filename))));
75 75
 	{
76 76
 		$state = false;
77
-		foreach ( $markerdata as $markerline ) {
78
-			if (strpos($markerline, '# END ' . $marker) !== false)
77
+		foreach ($markerdata as $markerline) {
78
+			if (strpos($markerline, '# END '.$marker) !== false)
79 79
 				$state = false;
80
-			if ( $state )
80
+			if ($state)
81 81
 				$result[] = $markerline;
82
-			if (strpos($markerline, '# BEGIN ' . $marker) !== false)
82
+			if (strpos($markerline, '# BEGIN '.$marker) !== false)
83 83
 				$state = true;
84 84
 		}
85 85
 	}
@@ -101,52 +101,52 @@  discard block
 block discarded – undo
101 101
  * @param array|string $insertion The new content to insert.
102 102
  * @return bool True on write success, false on failure.
103 103
  */
104
-function insert_with_markers( $filename, $marker, $insertion ) {
105
-	if ( ! file_exists( $filename ) ) {
106
-		if ( ! is_writable( dirname( $filename ) ) ) {
104
+function insert_with_markers($filename, $marker, $insertion) {
105
+	if ( ! file_exists($filename)) {
106
+		if ( ! is_writable(dirname($filename))) {
107 107
 			return false;
108 108
 		}
109
-		if ( ! touch( $filename ) ) {
109
+		if ( ! touch($filename)) {
110 110
 			return false;
111 111
 		}
112
-	} elseif ( ! is_writeable( $filename ) ) {
112
+	} elseif ( ! is_writeable($filename)) {
113 113
 		return false;
114 114
 	}
115 115
 
116
-	if ( ! is_array( $insertion ) ) {
117
-		$insertion = explode( "\n", $insertion );
116
+	if ( ! is_array($insertion)) {
117
+		$insertion = explode("\n", $insertion);
118 118
 	}
119 119
 
120 120
 	$start_marker = "# BEGIN {$marker}";
121 121
 	$end_marker   = "# END {$marker}";
122 122
 
123
-	$fp = fopen( $filename, 'r+' );
124
-	if ( ! $fp ) {
123
+	$fp = fopen($filename, 'r+');
124
+	if ( ! $fp) {
125 125
 		return false;
126 126
 	}
127 127
 
128 128
 	// Attempt to get a lock. If the filesystem supports locking, this will block until the lock is acquired.
129
-	flock( $fp, LOCK_EX );
129
+	flock($fp, LOCK_EX);
130 130
 
131 131
 	$lines = array();
132
-	while ( ! feof( $fp ) ) {
133
-		$lines[] = rtrim( fgets( $fp ), "\r\n" );
132
+	while ( ! feof($fp)) {
133
+		$lines[] = rtrim(fgets($fp), "\r\n");
134 134
 	}
135 135
 
136 136
 	// Split out the existing file into the preceeding lines, and those that appear after the marker
137 137
 	$pre_lines = $post_lines = $existing_lines = array();
138 138
 	$found_marker = $found_end_marker = false;
139
-	foreach ( $lines as $line ) {
140
-		if ( ! $found_marker && false !== strpos( $line, $start_marker ) ) {
139
+	foreach ($lines as $line) {
140
+		if ( ! $found_marker && false !== strpos($line, $start_marker)) {
141 141
 			$found_marker = true;
142 142
 			continue;
143
-		} elseif ( ! $found_end_marker && false !== strpos( $line, $end_marker ) ) {
143
+		} elseif ( ! $found_end_marker && false !== strpos($line, $end_marker)) {
144 144
 			$found_end_marker = true;
145 145
 			continue;
146 146
 		}
147
-		if ( ! $found_marker ) {
147
+		if ( ! $found_marker) {
148 148
 			$pre_lines[] = $line;
149
-		} elseif ( $found_marker && $found_end_marker ) {
149
+		} elseif ($found_marker && $found_end_marker) {
150 150
 			$post_lines[] = $line;
151 151
 		} else {
152 152
 			$existing_lines[] = $line;
@@ -154,31 +154,31 @@  discard block
 block discarded – undo
154 154
 	}
155 155
 
156 156
 	// Check to see if there was a change
157
-	if ( $existing_lines === $insertion ) {
158
-		flock( $fp, LOCK_UN );
159
-		fclose( $fp );
157
+	if ($existing_lines === $insertion) {
158
+		flock($fp, LOCK_UN);
159
+		fclose($fp);
160 160
 
161 161
 		return true;
162 162
 	}
163 163
 
164 164
 	// Generate the new file data
165
-	$new_file_data = implode( "\n", array_merge(
165
+	$new_file_data = implode("\n", array_merge(
166 166
 		$pre_lines,
167
-		array( $start_marker ),
167
+		array($start_marker),
168 168
 		$insertion,
169
-		array( $end_marker ),
169
+		array($end_marker),
170 170
 		$post_lines
171
-	) );
171
+	));
172 172
 
173 173
 	// Write to the start of the file, and truncate it to that length
174
-	fseek( $fp, 0 );
175
-	$bytes = fwrite( $fp, $new_file_data );
176
-	if ( $bytes ) {
177
-		ftruncate( $fp, ftell( $fp ) );
174
+	fseek($fp, 0);
175
+	$bytes = fwrite($fp, $new_file_data);
176
+	if ($bytes) {
177
+		ftruncate($fp, ftell($fp));
178 178
 	}
179
-	fflush( $fp );
180
-	flock( $fp, LOCK_UN );
181
-	fclose( $fp );
179
+	fflush($fp);
180
+	flock($fp, LOCK_UN);
181
+	fclose($fp);
182 182
 
183 183
 	return (bool) $bytes;
184 184
 }
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
  * @global WP_Rewrite $wp_rewrite
195 195
  */
196 196
 function save_mod_rewrite_rules() {
197
-	if ( is_multisite() )
197
+	if (is_multisite())
198 198
 		return;
199 199
 
200 200
 	global $wp_rewrite;
@@ -206,10 +206,10 @@  discard block
 block discarded – undo
206 206
 	 * If the file doesn't already exist check for write access to the directory
207 207
 	 * and whether we have some rules. Else check for write access to the file.
208 208
 	 */
209
-	if ((!file_exists($htaccess_file) && is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks()) || is_writable($htaccess_file)) {
210
-		if ( got_mod_rewrite() ) {
211
-			$rules = explode( "\n", $wp_rewrite->mod_rewrite_rules() );
212
-			return insert_with_markers( $htaccess_file, 'WordPress', $rules );
209
+	if (( ! file_exists($htaccess_file) && is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks()) || is_writable($htaccess_file)) {
210
+		if (got_mod_rewrite()) {
211
+			$rules = explode("\n", $wp_rewrite->mod_rewrite_rules());
212
+			return insert_with_markers($htaccess_file, 'WordPress', $rules);
213 213
 		}
214 214
 	}
215 215
 
@@ -226,19 +226,19 @@  discard block
 block discarded – undo
226 226
  *
227 227
  * @return bool True if web.config was updated successfully
228 228
  */
229
-function iis7_save_url_rewrite_rules(){
230
-	if ( is_multisite() )
229
+function iis7_save_url_rewrite_rules() {
230
+	if (is_multisite())
231 231
 		return;
232 232
 
233 233
 	global $wp_rewrite;
234 234
 
235 235
 	$home_path = get_home_path();
236
-	$web_config_file = $home_path . 'web.config';
236
+	$web_config_file = $home_path.'web.config';
237 237
 
238 238
 	// Using win_is_writable() instead of is_writable() because of a bug in Windows PHP
239
-	if ( iis7_supports_permalinks() && ( ( ! file_exists($web_config_file) && win_is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks() ) || win_is_writable($web_config_file) ) ) {
239
+	if (iis7_supports_permalinks() && (( ! file_exists($web_config_file) && win_is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks()) || win_is_writable($web_config_file))) {
240 240
 		$rule = $wp_rewrite->iis7_url_rewrite_rules(false, '', '');
241
-		if ( ! empty($rule) ) {
241
+		if ( ! empty($rule)) {
242 242
 			return iis7_add_rewrite_rule($web_config_file, $rule);
243 243
 		} else {
244 244
 			return iis7_delete_rewrite_rule($web_config_file);
@@ -254,19 +254,19 @@  discard block
 block discarded – undo
254 254
  *
255 255
  * @param string $file
256 256
  */
257
-function update_recently_edited( $file ) {
258
-	$oldfiles = (array ) get_option( 'recently_edited' );
259
-	if ( $oldfiles ) {
260
-		$oldfiles = array_reverse( $oldfiles );
257
+function update_recently_edited($file) {
258
+	$oldfiles = (array) get_option('recently_edited');
259
+	if ($oldfiles) {
260
+		$oldfiles = array_reverse($oldfiles);
261 261
 		$oldfiles[] = $file;
262
-		$oldfiles = array_reverse( $oldfiles );
263
-		$oldfiles = array_unique( $oldfiles );
264
-		if ( 5 < count( $oldfiles ))
265
-			array_pop( $oldfiles );
262
+		$oldfiles = array_reverse($oldfiles);
263
+		$oldfiles = array_unique($oldfiles);
264
+		if (5 < count($oldfiles))
265
+			array_pop($oldfiles);
266 266
 	} else {
267 267
 		$oldfiles[] = $file;
268 268
 	}
269
-	update_option( 'recently_edited', $oldfiles );
269
+	update_option('recently_edited', $oldfiles);
270 270
 }
271 271
 
272 272
 /**
@@ -277,12 +277,12 @@  discard block
 block discarded – undo
277 277
  * @param string $old_value
278 278
  * @param string $value
279 279
  */
280
-function update_home_siteurl( $old_value, $value ) {
281
-	if ( wp_installing() )
280
+function update_home_siteurl($old_value, $value) {
281
+	if (wp_installing())
282 282
 		return;
283 283
 
284
-	if ( is_multisite() && ms_is_switched() ) {
285
-		delete_option( 'rewrite_rules' );
284
+	if (is_multisite() && ms_is_switched()) {
285
+		delete_option('rewrite_rules');
286 286
 	} else {
287 287
 		flush_rewrite_rules();
288 288
 	}
@@ -300,16 +300,16 @@  discard block
 block discarded – undo
300 300
  *
301 301
  * @param array $vars An array of globals to reset.
302 302
  */
303
-function wp_reset_vars( $vars ) {
304
-	foreach ( $vars as $var ) {
305
-		if ( empty( $_POST[ $var ] ) ) {
306
-			if ( empty( $_GET[ $var ] ) ) {
307
-				$GLOBALS[ $var ] = '';
303
+function wp_reset_vars($vars) {
304
+	foreach ($vars as $var) {
305
+		if (empty($_POST[$var])) {
306
+			if (empty($_GET[$var])) {
307
+				$GLOBALS[$var] = '';
308 308
 			} else {
309
-				$GLOBALS[ $var ] = $_GET[ $var ];
309
+				$GLOBALS[$var] = $_GET[$var];
310 310
 			}
311 311
 		} else {
312
-			$GLOBALS[ $var ] = $_POST[ $var ];
312
+			$GLOBALS[$var] = $_POST[$var];
313 313
 		}
314 314
 	}
315 315
 }
@@ -322,9 +322,9 @@  discard block
 block discarded – undo
322 322
  * @param string|WP_Error $message
323 323
  */
324 324
 function show_message($message) {
325
-	if ( is_wp_error($message) ){
326
-		if ( $message->get_error_data() && is_string( $message->get_error_data() ) )
327
-			$message = $message->get_error_message() . ': ' . $message->get_error_data();
325
+	if (is_wp_error($message)) {
326
+		if ($message->get_error_data() && is_string($message->get_error_data()))
327
+			$message = $message->get_error_message().': '.$message->get_error_data();
328 328
 		else
329 329
 			$message = $message->get_error_message();
330 330
 	}
@@ -339,25 +339,25 @@  discard block
 block discarded – undo
339 339
  * @param string $content
340 340
  * @return array
341 341
  */
342
-function wp_doc_link_parse( $content ) {
343
-	if ( !is_string( $content ) || empty( $content ) )
342
+function wp_doc_link_parse($content) {
343
+	if ( ! is_string($content) || empty($content))
344 344
 		return array();
345 345
 
346
-	if ( !function_exists('token_get_all') )
346
+	if ( ! function_exists('token_get_all'))
347 347
 		return array();
348 348
 
349
-	$tokens = token_get_all( $content );
350
-	$count = count( $tokens );
349
+	$tokens = token_get_all($content);
350
+	$count = count($tokens);
351 351
 	$functions = array();
352 352
 	$ignore_functions = array();
353
-	for ( $t = 0; $t < $count - 2; $t++ ) {
354
-		if ( ! is_array( $tokens[ $t ] ) ) {
353
+	for ($t = 0; $t < $count - 2; $t++) {
354
+		if ( ! is_array($tokens[$t])) {
355 355
 			continue;
356 356
 		}
357 357
 
358
-		if ( T_STRING == $tokens[ $t ][0] && ( '(' == $tokens[ $t + 1 ] || '(' == $tokens[ $t + 2 ] ) ) {
358
+		if (T_STRING == $tokens[$t][0] && ('(' == $tokens[$t + 1] || '(' == $tokens[$t + 2])) {
359 359
 			// If it's a function or class defined locally, there's not going to be any docs available
360
-			if ( ( isset( $tokens[ $t - 2 ][1] ) && in_array( $tokens[ $t - 2 ][1], array( 'function', 'class' ) ) ) || ( isset( $tokens[ $t - 2 ][0] ) && T_OBJECT_OPERATOR == $tokens[ $t - 1 ][0] ) ) {
360
+			if ((isset($tokens[$t - 2][1]) && in_array($tokens[$t - 2][1], array('function', 'class'))) || (isset($tokens[$t - 2][0]) && T_OBJECT_OPERATOR == $tokens[$t - 1][0])) {
361 361
 				$ignore_functions[] = $tokens[$t][1];
362 362
 			}
363 363
 			// Add this to our stack of unique references
@@ -365,8 +365,8 @@  discard block
 block discarded – undo
365 365
 		}
366 366
 	}
367 367
 
368
-	$functions = array_unique( $functions );
369
-	sort( $functions );
368
+	$functions = array_unique($functions);
369
+	sort($functions);
370 370
 
371 371
 	/**
372 372
 	 * Filters the list of functions and classes to be ignored from the documentation lookup.
@@ -375,13 +375,13 @@  discard block
 block discarded – undo
375 375
 	 *
376 376
 	 * @param array $ignore_functions Functions and classes to be ignored.
377 377
 	 */
378
-	$ignore_functions = apply_filters( 'documentation_ignore_functions', $ignore_functions );
378
+	$ignore_functions = apply_filters('documentation_ignore_functions', $ignore_functions);
379 379
 
380
-	$ignore_functions = array_unique( $ignore_functions );
380
+	$ignore_functions = array_unique($ignore_functions);
381 381
 
382 382
 	$out = array();
383
-	foreach ( $functions as $function ) {
384
-		if ( in_array( $function, $ignore_functions ) )
383
+	foreach ($functions as $function) {
384
+		if (in_array($function, $ignore_functions))
385 385
 			continue;
386 386
 		$out[] = $function;
387 387
 	}
@@ -396,28 +396,28 @@  discard block
 block discarded – undo
396 396
  */
397 397
 function set_screen_options() {
398 398
 
399
-	if ( isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options']) ) {
400
-		check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' );
399
+	if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
400
+		check_admin_referer('screen-options-nonce', 'screenoptionnonce');
401 401
 
402
-		if ( !$user = wp_get_current_user() )
402
+		if ( ! $user = wp_get_current_user())
403 403
 			return;
404 404
 		$option = $_POST['wp_screen_options']['option'];
405 405
 		$value = $_POST['wp_screen_options']['value'];
406 406
 
407
-		if ( $option != sanitize_key( $option ) )
407
+		if ($option != sanitize_key($option))
408 408
 			return;
409 409
 
410 410
 		$map_option = $option;
411 411
 		$type = str_replace('edit_', '', $map_option);
412 412
 		$type = str_replace('_per_page', '', $type);
413
-		if ( in_array( $type, get_taxonomies() ) )
413
+		if (in_array($type, get_taxonomies()))
414 414
 			$map_option = 'edit_tags_per_page';
415
-		elseif ( in_array( $type, get_post_types() ) )
415
+		elseif (in_array($type, get_post_types()))
416 416
 			$map_option = 'edit_per_page';
417 417
 		else
418 418
 			$option = str_replace('-', '_', $option);
419 419
 
420
-		switch ( $map_option ) {
420
+		switch ($map_option) {
421 421
 			case 'edit_per_page':
422 422
 			case 'users_per_page':
423 423
 			case 'edit_comments_per_page':
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 			case 'themes_network_per_page':
433 433
 			case 'site_themes_network_per_page':
434 434
 				$value = (int) $value;
435
-				if ( $value < 1 || $value > 999 )
435
+				if ($value < 1 || $value > 999)
436 436
 					return;
437 437
 				break;
438 438
 			default:
@@ -453,21 +453,21 @@  discard block
 block discarded – undo
453 453
 				 * @param string   $option The option name.
454 454
 				 * @param int      $value  The number of rows to use.
455 455
 				 */
456
-				$value = apply_filters( 'set-screen-option', false, $option, $value );
456
+				$value = apply_filters('set-screen-option', false, $option, $value);
457 457
 
458
-				if ( false === $value )
458
+				if (false === $value)
459 459
 					return;
460 460
 				break;
461 461
 		}
462 462
 
463 463
 		update_user_meta($user->ID, $option, $value);
464 464
 
465
-		$url = remove_query_arg( array( 'pagenum', 'apage', 'paged' ), wp_get_referer() );
466
-		if ( isset( $_POST['mode'] ) ) {
467
-			$url = add_query_arg( array( 'mode' => $_POST['mode'] ), $url );
465
+		$url = remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer());
466
+		if (isset($_POST['mode'])) {
467
+			$url = add_query_arg(array('mode' => $_POST['mode']), $url);
468 468
 		}
469 469
 
470
-		wp_safe_redirect( $url );
470
+		wp_safe_redirect($url);
471 471
 		exit;
472 472
 	}
473 473
 }
@@ -481,18 +481,18 @@  discard block
 block discarded – undo
481 481
  * @param string $filename The file path to the configuration file
482 482
  */
483 483
 function iis7_rewrite_rule_exists($filename) {
484
-	if ( ! file_exists($filename) )
484
+	if ( ! file_exists($filename))
485 485
 		return false;
486
-	if ( ! class_exists( 'DOMDocument', false ) ) {
486
+	if ( ! class_exists('DOMDocument', false)) {
487 487
 		return false;
488 488
 	}
489 489
 
490 490
 	$doc = new DOMDocument();
491
-	if ( $doc->load($filename) === false )
491
+	if ($doc->load($filename) === false)
492 492
 		return false;
493 493
 	$xpath = new DOMXPath($doc);
494 494
 	$rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]');
495
-	if ( $rules->length == 0 )
495
+	if ($rules->length == 0)
496 496
 		return false;
497 497
 	else
498 498
 		return true;
@@ -508,21 +508,21 @@  discard block
 block discarded – undo
508 508
  */
509 509
 function iis7_delete_rewrite_rule($filename) {
510 510
 	// If configuration file does not exist then rules also do not exist so there is nothing to delete
511
-	if ( ! file_exists($filename) )
511
+	if ( ! file_exists($filename))
512 512
 		return true;
513 513
 
514
-	if ( ! class_exists( 'DOMDocument', false ) ) {
514
+	if ( ! class_exists('DOMDocument', false)) {
515 515
 		return false;
516 516
 	}
517 517
 
518 518
 	$doc = new DOMDocument();
519 519
 	$doc->preserveWhiteSpace = false;
520 520
 
521
-	if ( $doc -> load($filename) === false )
521
+	if ($doc -> load($filename) === false)
522 522
 		return false;
523 523
 	$xpath = new DOMXPath($doc);
524 524
 	$rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]');
525
-	if ( $rules->length > 0 ) {
525
+	if ($rules->length > 0) {
526 526
 		$child = $rules->item(0);
527 527
 		$parent = $child->parentNode;
528 528
 		$parent->removeChild($child);
@@ -542,13 +542,13 @@  discard block
 block discarded – undo
542 542
  * @return bool
543 543
  */
544 544
 function iis7_add_rewrite_rule($filename, $rewrite_rule) {
545
-	if ( ! class_exists( 'DOMDocument', false ) ) {
545
+	if ( ! class_exists('DOMDocument', false)) {
546 546
 		return false;
547 547
 	}
548 548
 
549 549
 	// If configuration file does not exist then we create one.
550
-	if ( ! file_exists($filename) ) {
551
-		$fp = fopen( $filename, 'w');
550
+	if ( ! file_exists($filename)) {
551
+		$fp = fopen($filename, 'w');
552 552
 		fwrite($fp, '<configuration/>');
553 553
 		fclose($fp);
554 554
 	}
@@ -556,25 +556,25 @@  discard block
 block discarded – undo
556 556
 	$doc = new DOMDocument();
557 557
 	$doc->preserveWhiteSpace = false;
558 558
 
559
-	if ( $doc->load($filename) === false )
559
+	if ($doc->load($filename) === false)
560 560
 		return false;
561 561
 
562 562
 	$xpath = new DOMXPath($doc);
563 563
 
564 564
 	// First check if the rule already exists as in that case there is no need to re-add it
565 565
 	$wordpress_rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]');
566
-	if ( $wordpress_rules->length > 0 )
566
+	if ($wordpress_rules->length > 0)
567 567
 		return true;
568 568
 
569 569
 	// Check the XPath to the rewrite rule and create XML nodes if they do not exist
570 570
 	$xmlnodes = $xpath->query('/configuration/system.webServer/rewrite/rules');
571
-	if ( $xmlnodes->length > 0 ) {
571
+	if ($xmlnodes->length > 0) {
572 572
 		$rules_node = $xmlnodes->item(0);
573 573
 	} else {
574 574
 		$rules_node = $doc->createElement('rules');
575 575
 
576 576
 		$xmlnodes = $xpath->query('/configuration/system.webServer/rewrite');
577
-		if ( $xmlnodes->length > 0 ) {
577
+		if ($xmlnodes->length > 0) {
578 578
 			$rewrite_node = $xmlnodes->item(0);
579 579
 			$rewrite_node->appendChild($rules_node);
580 580
 		} else {
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 			$rewrite_node->appendChild($rules_node);
583 583
 
584 584
 			$xmlnodes = $xpath->query('/configuration/system.webServer');
585
-			if ( $xmlnodes->length > 0 ) {
585
+			if ($xmlnodes->length > 0) {
586 586
 				$system_webServer_node = $xmlnodes->item(0);
587 587
 				$system_webServer_node->appendChild($rewrite_node);
588 588
 			} else {
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 				$system_webServer_node->appendChild($rewrite_node);
591 591
 
592 592
 				$xmlnodes = $xpath->query('/configuration');
593
-				if ( $xmlnodes->length > 0 ) {
593
+				if ($xmlnodes->length > 0) {
594 594
 					$config_node = $xmlnodes->item(0);
595 595
 					$config_node->appendChild($system_webServer_node);
596 596
 				} else {
@@ -638,42 +638,42 @@  discard block
 block discarded – undo
638 638
  *
639 639
  * @param int $user_id User ID.
640 640
  */
641
-function admin_color_scheme_picker( $user_id ) {
641
+function admin_color_scheme_picker($user_id) {
642 642
 	global $_wp_admin_css_colors;
643 643
 
644
-	ksort( $_wp_admin_css_colors );
644
+	ksort($_wp_admin_css_colors);
645 645
 
646
-	if ( isset( $_wp_admin_css_colors['fresh'] ) ) {
646
+	if (isset($_wp_admin_css_colors['fresh'])) {
647 647
 		// Set Default ('fresh') and Light should go first.
648
-		$_wp_admin_css_colors = array_filter( array_merge( array( 'fresh' => '', 'light' => '' ), $_wp_admin_css_colors ) );
648
+		$_wp_admin_css_colors = array_filter(array_merge(array('fresh' => '', 'light' => ''), $_wp_admin_css_colors));
649 649
 	}
650 650
 
651
-	$current_color = get_user_option( 'admin_color', $user_id );
651
+	$current_color = get_user_option('admin_color', $user_id);
652 652
 
653
-	if ( empty( $current_color ) || ! isset( $_wp_admin_css_colors[ $current_color ] ) ) {
653
+	if (empty($current_color) || ! isset($_wp_admin_css_colors[$current_color])) {
654 654
 		$current_color = 'fresh';
655 655
 	}
656 656
 
657 657
 	?>
658 658
 	<fieldset id="color-picker" class="scheme-list">
659
-		<legend class="screen-reader-text"><span><?php _e( 'Admin Color Scheme' ); ?></span></legend>
659
+		<legend class="screen-reader-text"><span><?php _e('Admin Color Scheme'); ?></span></legend>
660 660
 		<?php
661
-		wp_nonce_field( 'save-color-scheme', 'color-nonce', false );
662
-		foreach ( $_wp_admin_css_colors as $color => $color_info ) :
661
+		wp_nonce_field('save-color-scheme', 'color-nonce', false);
662
+		foreach ($_wp_admin_css_colors as $color => $color_info) :
663 663
 
664 664
 			?>
665
-			<div class="color-option <?php echo ( $color == $current_color ) ? 'selected' : ''; ?>">
666
-				<input name="admin_color" id="admin_color_<?php echo esc_attr( $color ); ?>" type="radio" value="<?php echo esc_attr( $color ); ?>" class="tog" <?php checked( $color, $current_color ); ?> />
667
-				<input type="hidden" class="css_url" value="<?php echo esc_url( $color_info->url ); ?>" />
668
-				<input type="hidden" class="icon_colors" value="<?php echo esc_attr( wp_json_encode( array( 'icons' => $color_info->icon_colors ) ) ); ?>" />
669
-				<label for="admin_color_<?php echo esc_attr( $color ); ?>"><?php echo esc_html( $color_info->name ); ?></label>
665
+			<div class="color-option <?php echo ($color == $current_color) ? 'selected' : ''; ?>">
666
+				<input name="admin_color" id="admin_color_<?php echo esc_attr($color); ?>" type="radio" value="<?php echo esc_attr($color); ?>" class="tog" <?php checked($color, $current_color); ?> />
667
+				<input type="hidden" class="css_url" value="<?php echo esc_url($color_info->url); ?>" />
668
+				<input type="hidden" class="icon_colors" value="<?php echo esc_attr(wp_json_encode(array('icons' => $color_info->icon_colors))); ?>" />
669
+				<label for="admin_color_<?php echo esc_attr($color); ?>"><?php echo esc_html($color_info->name); ?></label>
670 670
 				<table class="color-palette">
671 671
 					<tr>
672 672
 					<?php
673 673
 
674
-					foreach ( $color_info->colors as $html_color ) {
674
+					foreach ($color_info->colors as $html_color) {
675 675
 						?>
676
-						<td style="background-color: <?php echo esc_attr( $html_color ); ?>">&nbsp;</td>
676
+						<td style="background-color: <?php echo esc_attr($html_color); ?>">&nbsp;</td>
677 677
 						<?php
678 678
 					}
679 679
 
@@ -697,30 +697,30 @@  discard block
 block discarded – undo
697 697
 function wp_color_scheme_settings() {
698 698
 	global $_wp_admin_css_colors;
699 699
 
700
-	$color_scheme = get_user_option( 'admin_color' );
700
+	$color_scheme = get_user_option('admin_color');
701 701
 
702 702
 	// It's possible to have a color scheme set that is no longer registered.
703
-	if ( empty( $_wp_admin_css_colors[ $color_scheme ] ) ) {
703
+	if (empty($_wp_admin_css_colors[$color_scheme])) {
704 704
 		$color_scheme = 'fresh';
705 705
 	}
706 706
 
707
-	if ( ! empty( $_wp_admin_css_colors[ $color_scheme ]->icon_colors ) ) {
708
-		$icon_colors = $_wp_admin_css_colors[ $color_scheme ]->icon_colors;
709
-	} elseif ( ! empty( $_wp_admin_css_colors['fresh']->icon_colors ) ) {
707
+	if ( ! empty($_wp_admin_css_colors[$color_scheme]->icon_colors)) {
708
+		$icon_colors = $_wp_admin_css_colors[$color_scheme]->icon_colors;
709
+	} elseif ( ! empty($_wp_admin_css_colors['fresh']->icon_colors)) {
710 710
 		$icon_colors = $_wp_admin_css_colors['fresh']->icon_colors;
711 711
 	} else {
712 712
 		// Fall back to the default set of icon colors if the default scheme is missing.
713
-		$icon_colors = array( 'base' => '#82878c', 'focus' => '#00a0d2', 'current' => '#fff' );
713
+		$icon_colors = array('base' => '#82878c', 'focus' => '#00a0d2', 'current' => '#fff');
714 714
 	}
715 715
 
716
-	echo '<script type="text/javascript">var _wpColorScheme = ' . wp_json_encode( array( 'icons' => $icon_colors ) ) . ";</script>\n";
716
+	echo '<script type="text/javascript">var _wpColorScheme = '.wp_json_encode(array('icons' => $icon_colors)).";</script>\n";
717 717
 }
718 718
 
719 719
 /**
720 720
  * @since 3.3.0
721 721
  */
722 722
 function _ipad_meta() {
723
-	if ( wp_is_mobile() ) {
723
+	if (wp_is_mobile()) {
724 724
 		?>
725 725
 		<meta name="viewport" id="viewport-meta" content="width=device-width, initial-scale=1">
726 726
 		<?php
@@ -737,18 +737,18 @@  discard block
 block discarded – undo
737 737
  * @param string $screen_id The screen id.
738 738
  * @return array The Heartbeat response.
739 739
  */
740
-function wp_check_locked_posts( $response, $data, $screen_id ) {
740
+function wp_check_locked_posts($response, $data, $screen_id) {
741 741
 	$checked = array();
742 742
 
743
-	if ( array_key_exists( 'wp-check-locked-posts', $data ) && is_array( $data['wp-check-locked-posts'] ) ) {
744
-		foreach ( $data['wp-check-locked-posts'] as $key ) {
745
-			if ( ! $post_id = absint( substr( $key, 5 ) ) )
743
+	if (array_key_exists('wp-check-locked-posts', $data) && is_array($data['wp-check-locked-posts'])) {
744
+		foreach ($data['wp-check-locked-posts'] as $key) {
745
+			if ( ! $post_id = absint(substr($key, 5)))
746 746
 				continue;
747 747
 
748
-			if ( ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) && current_user_can( 'edit_post', $post_id ) ) {
749
-				$send = array( 'text' => sprintf( __( '%s is currently editing' ), $user->display_name ) );
748
+			if (($user_id = wp_check_post_lock($post_id)) && ($user = get_userdata($user_id)) && current_user_can('edit_post', $post_id)) {
749
+				$send = array('text' => sprintf(__('%s is currently editing'), $user->display_name));
750 750
 
751
-				if ( ( $avatar = get_avatar( $user->ID, 18 ) ) && preg_match( "|src='([^']+)'|", $avatar, $matches ) )
751
+				if (($avatar = get_avatar($user->ID, 18)) && preg_match("|src='([^']+)'|", $avatar, $matches))
752 752
 					$send['avatar_src'] = $matches[1];
753 753
 
754 754
 				$checked[$key] = $send;
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 		}
757 757
 	}
758 758
 
759
-	if ( ! empty( $checked ) )
759
+	if ( ! empty($checked))
760 760
 		$response['wp-check-locked-posts'] = $checked;
761 761
 
762 762
 	return $response;
@@ -772,31 +772,31 @@  discard block
 block discarded – undo
772 772
  * @param string $screen_id The screen id.
773 773
  * @return array The Heartbeat response.
774 774
  */
775
-function wp_refresh_post_lock( $response, $data, $screen_id ) {
776
-	if ( array_key_exists( 'wp-refresh-post-lock', $data ) ) {
775
+function wp_refresh_post_lock($response, $data, $screen_id) {
776
+	if (array_key_exists('wp-refresh-post-lock', $data)) {
777 777
 		$received = $data['wp-refresh-post-lock'];
778 778
 		$send = array();
779 779
 
780
-		if ( ! $post_id = absint( $received['post_id'] ) )
780
+		if ( ! $post_id = absint($received['post_id']))
781 781
 			return $response;
782 782
 
783
-		if ( ! current_user_can('edit_post', $post_id) )
783
+		if ( ! current_user_can('edit_post', $post_id))
784 784
 			return $response;
785 785
 
786
-		if ( ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) ) {
786
+		if (($user_id = wp_check_post_lock($post_id)) && ($user = get_userdata($user_id))) {
787 787
 			$error = array(
788
-				'text' => sprintf( __( '%s has taken over and is currently editing.' ), $user->display_name )
788
+				'text' => sprintf(__('%s has taken over and is currently editing.'), $user->display_name)
789 789
 			);
790 790
 
791
-			if ( $avatar = get_avatar( $user->ID, 64 ) ) {
792
-				if ( preg_match( "|src='([^']+)'|", $avatar, $matches ) )
791
+			if ($avatar = get_avatar($user->ID, 64)) {
792
+				if (preg_match("|src='([^']+)'|", $avatar, $matches))
793 793
 					$error['avatar_src'] = $matches[1];
794 794
 			}
795 795
 
796 796
 			$send['lock_error'] = $error;
797 797
 		} else {
798
-			if ( $new_lock = wp_set_post_lock( $post_id ) )
799
-				$send['new_lock'] = implode( ':', $new_lock );
798
+			if ($new_lock = wp_set_post_lock($post_id))
799
+				$send['new_lock'] = implode(':', $new_lock);
800 800
 		}
801 801
 
802 802
 		$response['wp-refresh-post-lock'] = $send;
@@ -815,16 +815,16 @@  discard block
 block discarded – undo
815 815
  * @param string $screen_id The screen id.
816 816
  * @return array The Heartbeat response.
817 817
  */
818
-function wp_refresh_post_nonces( $response, $data, $screen_id ) {
819
-	if ( array_key_exists( 'wp-refresh-post-nonces', $data ) ) {
818
+function wp_refresh_post_nonces($response, $data, $screen_id) {
819
+	if (array_key_exists('wp-refresh-post-nonces', $data)) {
820 820
 		$received = $data['wp-refresh-post-nonces'];
821
-		$response['wp-refresh-post-nonces'] = array( 'check' => 1 );
821
+		$response['wp-refresh-post-nonces'] = array('check' => 1);
822 822
 
823
-		if ( ! $post_id = absint( $received['post_id'] ) ) {
823
+		if ( ! $post_id = absint($received['post_id'])) {
824 824
 			return $response;
825 825
 		}
826 826
 
827
-		if ( ! current_user_can( 'edit_post', $post_id ) ) {
827
+		if ( ! current_user_can('edit_post', $post_id)) {
828 828
 			return $response;
829 829
 		}
830 830
 
@@ -833,10 +833,10 @@  discard block
 block discarded – undo
833 833
 				'getpermalinknonce' => wp_create_nonce('getpermalink'),
834 834
 				'samplepermalinknonce' => wp_create_nonce('samplepermalink'),
835 835
 				'closedpostboxesnonce' => wp_create_nonce('closedpostboxes'),
836
-				'_ajax_linking_nonce' => wp_create_nonce( 'internal-linking' ),
837
-				'_wpnonce' => wp_create_nonce( 'update-post_' . $post_id ),
836
+				'_ajax_linking_nonce' => wp_create_nonce('internal-linking'),
837
+				'_wpnonce' => wp_create_nonce('update-post_'.$post_id),
838 838
 			),
839
-			'heartbeatNonce' => wp_create_nonce( 'heartbeat-nonce' ),
839
+			'heartbeatNonce' => wp_create_nonce('heartbeat-nonce'),
840 840
 		);
841 841
 	}
842 842
 
@@ -853,10 +853,10 @@  discard block
 block discarded – undo
853 853
  * @param array $settings An array of Heartbeat settings.
854 854
  * @return array Filtered Heartbeat settings.
855 855
  */
856
-function wp_heartbeat_set_suspension( $settings ) {
856
+function wp_heartbeat_set_suspension($settings) {
857 857
 	global $pagenow;
858 858
 
859
-	if ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) {
859
+	if ('post.php' === $pagenow || 'post-new.php' === $pagenow) {
860 860
 		$settings['suspension'] = 'disable';
861 861
 	}
862 862
 
@@ -872,19 +872,19 @@  discard block
 block discarded – undo
872 872
  * @param array $data     The $_POST data sent.
873 873
  * @return array The Heartbeat response.
874 874
  */
875
-function heartbeat_autosave( $response, $data ) {
876
-	if ( ! empty( $data['wp_autosave'] ) ) {
877
-		$saved = wp_autosave( $data['wp_autosave'] );
878
-
879
-		if ( is_wp_error( $saved ) ) {
880
-			$response['wp_autosave'] = array( 'success' => false, 'message' => $saved->get_error_message() );
881
-		} elseif ( empty( $saved ) ) {
882
-			$response['wp_autosave'] = array( 'success' => false, 'message' => __( 'Error while saving.' ) );
875
+function heartbeat_autosave($response, $data) {
876
+	if ( ! empty($data['wp_autosave'])) {
877
+		$saved = wp_autosave($data['wp_autosave']);
878
+
879
+		if (is_wp_error($saved)) {
880
+			$response['wp_autosave'] = array('success' => false, 'message' => $saved->get_error_message());
881
+		} elseif (empty($saved)) {
882
+			$response['wp_autosave'] = array('success' => false, 'message' => __('Error while saving.'));
883 883
 		} else {
884 884
 			/* translators: draft saved date format, see https://secure.php.net/date */
885
-			$draft_saved_date_format = __( 'g:i:s a' );
885
+			$draft_saved_date_format = __('g:i:s a');
886 886
 			/* translators: %s: date and time */
887
-			$response['wp_autosave'] = array( 'success' => true, 'message' => sprintf( __( 'Draft saved at %s.' ), date_i18n( $draft_saved_date_format ) ) );
887
+			$response['wp_autosave'] = array('success' => true, 'message' => sprintf(__('Draft saved at %s.'), date_i18n($draft_saved_date_format)));
888 888
 		}
889 889
 	}
890 890
 
@@ -902,15 +902,15 @@  discard block
 block discarded – undo
902 902
 function wp_admin_canonical_url() {
903 903
 	$removable_query_args = wp_removable_query_args();
904 904
 
905
-	if ( empty( $removable_query_args ) ) {
905
+	if (empty($removable_query_args)) {
906 906
 		return;
907 907
 	}
908 908
 
909 909
 	// Ensure we're using an absolute URL.
910
-	$current_url  = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
911
-	$filtered_url = remove_query_arg( $removable_query_args, $current_url );
910
+	$current_url  = set_url_scheme('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
911
+	$filtered_url = remove_query_arg($removable_query_args, $current_url);
912 912
 	?>
913
-	<link id="wp-admin-canonical" rel="canonical" href="<?php echo esc_url( $filtered_url ); ?>" />
913
+	<link id="wp-admin-canonical" rel="canonical" href="<?php echo esc_url($filtered_url); ?>" />
914 914
 	<script>
915 915
 		if ( window.history.replaceState ) {
916 916
 			window.history.replaceState( null, null, document.getElementById( 'wp-admin-canonical' ).href + window.location.hash );
Please login to merge, or discard this patch.
src/wp-admin/includes/ms.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -736,7 +736,7 @@
 block discarded – undo
736 736
  *
737 737
  * @global int $wp_db_version The version number of the database.
738 738
  *
739
- * @return false False if the current user is not a super admin.
739
+ * @return false|null False if the current user is not a super admin.
740 740
  */
741 741
 function site_admin_notice() {
742 742
 	global $wp_db_version;
Please login to merge, or discard this patch.
Braces   +100 added lines, -62 removed lines patch added patch discarded remove patch
@@ -16,14 +16,18 @@  discard block
 block discarded – undo
16 16
  * @return array $_FILES array with 'error' key set if file exceeds quota. 'error' is empty otherwise.
17 17
  */
18 18
 function check_upload_size( $file ) {
19
-	if ( get_site_option( 'upload_space_check_disabled' ) )
20
-		return $file;
19
+	if ( get_site_option( 'upload_space_check_disabled' ) ) {
20
+			return $file;
21
+	}
21 22
 
22
-	if ( $file['error'] != '0' ) // there's already an error
23
+	if ( $file['error'] != '0' ) {
24
+		// there's already an error
23 25
 		return $file;
26
+	}
24 27
 
25
-	if ( defined( 'WP_IMPORTING' ) )
26
-		return $file;
28
+	if ( defined( 'WP_IMPORTING' ) ) {
29
+			return $file;
30
+	}
27 31
 
28 32
 	$space_left = get_upload_space_available();
29 33
 
@@ -148,8 +152,9 @@  discard block
 block discarded – undo
148 152
 			$dh = @opendir( $dir );
149 153
 			if ( $dh ) {
150 154
 				while ( ( $file = @readdir( $dh ) ) !== false ) {
151
-					if ( $file == '.' || $file == '..' )
152
-						continue;
155
+					if ( $file == '.' || $file == '..' ) {
156
+											continue;
157
+					}
153 158
 
154 159
 					if ( @is_dir( $dir . DIRECTORY_SEPARATOR . $file ) ) {
155 160
 						$stack[] = $dir . DIRECTORY_SEPARATOR . $file;
@@ -164,16 +169,18 @@  discard block
 block discarded – undo
164 169
 
165 170
 		$stack = array_reverse( $stack ); // Last added dirs are deepest
166 171
 		foreach ( (array) $stack as $dir ) {
167
-			if ( $dir != $top_dir)
168
-			@rmdir( $dir );
172
+			if ( $dir != $top_dir) {
173
+						@rmdir( $dir );
174
+			}
169 175
 		}
170 176
 
171 177
 		clean_blog_cache( $blog );
172 178
 	}
173 179
 
174
-	if ( $switch )
175
-		restore_current_blog();
176
-}
180
+	if ( $switch ) {
181
+			restore_current_blog();
182
+	}
183
+	}
177 184
 
178 185
 /**
179 186
  * Delete a user from the network and remove from all sites.
@@ -197,8 +204,9 @@  discard block
 block discarded – undo
197 204
 	$id = (int) $id;
198 205
 	$user = new WP_User( $id );
199 206
 
200
-	if ( !$user->exists() )
201
-		return false;
207
+	if ( !$user->exists() ) {
208
+			return false;
209
+	}
202 210
 
203 211
 	// Global super-administrators are protected, and cannot be deleted.
204 212
 	$_super_admins = get_super_admins();
@@ -231,8 +239,9 @@  discard block
 block discarded – undo
231 239
 			$link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id ) );
232 240
 
233 241
 			if ( $link_ids ) {
234
-				foreach ( $link_ids as $link_id )
235
-					wp_delete_link( $link_id );
242
+				foreach ( $link_ids as $link_id ) {
243
+									wp_delete_link( $link_id );
244
+				}
236 245
 			}
237 246
 
238 247
 			restore_current_blog();
@@ -240,8 +249,9 @@  discard block
 block discarded – undo
240 249
 	}
241 250
 
242 251
 	$meta = $wpdb->get_col( $wpdb->prepare( "SELECT umeta_id FROM $wpdb->usermeta WHERE user_id = %d", $id ) );
243
-	foreach ( $meta as $mid )
244
-		delete_metadata_by_mid( 'user', $mid );
252
+	foreach ( $meta as $mid ) {
253
+			delete_metadata_by_mid( 'user', $mid );
254
+	}
245 255
 
246 256
 	$wpdb->delete( $wpdb->users, array( 'ID' => $id ) );
247 257
 
@@ -262,8 +272,9 @@  discard block
 block discarded – undo
262 272
  * @param string $value     The new email address.
263 273
  */
264 274
 function update_option_new_admin_email( $old_value, $value ) {
265
-	if ( $value == get_option( 'admin_email' ) || !is_email( $value ) )
266
-		return;
275
+	if ( $value == get_option( 'admin_email' ) || !is_email( $value ) ) {
276
+			return;
277
+	}
267 278
 
268 279
 	$hash = md5( $value. time() .mt_rand() );
269 280
 	$new_admin_email = array(
@@ -328,11 +339,13 @@  discard block
 block discarded – undo
328 339
 function send_confirmation_on_profile_email() {
329 340
 	global $errors, $wpdb;
330 341
 	$current_user = wp_get_current_user();
331
-	if ( ! is_object($errors) )
332
-		$errors = new WP_Error();
342
+	if ( ! is_object($errors) ) {
343
+			$errors = new WP_Error();
344
+	}
333 345
 
334
-	if ( $current_user->ID != $_POST['user_id'] )
335
-		return false;
346
+	if ( $current_user->ID != $_POST['user_id'] ) {
347
+			return false;
348
+	}
336 349
 
337 350
 	if ( $current_user->user_email != $_POST['email'] ) {
338 351
 		if ( !is_email( $_POST['email'] ) ) {
@@ -423,8 +436,9 @@  discard block
 block discarded – undo
423 436
  * @return bool True if user is over upload space quota, otherwise false.
424 437
  */
425 438
 function upload_is_user_over_quota( $echo = true ) {
426
-	if ( get_site_option( 'upload_space_check_disabled' ) )
427
-		return false;
439
+	if ( get_site_option( 'upload_space_check_disabled' ) ) {
440
+			return false;
441
+	}
428 442
 
429 443
 	$space_allowed = get_space_allowed();
430 444
 	if ( ! is_numeric( $space_allowed ) ) {
@@ -433,8 +447,9 @@  discard block
 block discarded – undo
433 447
 	$space_used = get_space_used();
434 448
 
435 449
 	if ( ( $space_allowed - $space_used ) < 0 ) {
436
-		if ( $echo )
437
-			_e( 'Sorry, you have used your space allocation. Please delete some files to upload more files.' );
450
+		if ( $echo ) {
451
+					_e( 'Sorry, you have used your space allocation. Please delete some files to upload more files.' );
452
+		}
438 453
 		return true;
439 454
 	} else {
440 455
 		return false;
@@ -494,8 +509,9 @@  discard block
 block discarded – undo
494 509
 	$quota = get_option( 'blog_upload_space' );
495 510
 	restore_current_blog();
496 511
 
497
-	if ( !$quota )
498
-		$quota = '';
512
+	if ( !$quota ) {
513
+			$quota = '';
514
+	}
499 515
 
500 516
 	?>
501 517
 	<tr>
@@ -527,8 +543,9 @@  discard block
 block discarded – undo
527 543
 function update_user_status( $id, $pref, $value, $deprecated = null ) {
528 544
 	global $wpdb;
529 545
 
530
-	if ( null !== $deprecated )
531
-		_deprecated_argument( __FUNCTION__, '3.1' );
546
+	if ( null !== $deprecated ) {
547
+			_deprecated_argument( __FUNCTION__, '3.1' );
548
+	}
532 549
 
533 550
 	$wpdb->update( $wpdb->users, array( sanitize_key( $pref ) => $value ), array( 'ID' => $id ) );
534 551
 
@@ -571,8 +588,9 @@  discard block
 block discarded – undo
571 588
 function refresh_user_details( $id ) {
572 589
 	$id = (int) $id;
573 590
 
574
-	if ( !$user = get_userdata( $id ) )
575
-		return false;
591
+	if ( !$user = get_userdata( $id ) ) {
592
+			return false;
593
+	}
576 594
 
577 595
 	clean_user_cache( $user );
578 596
 
@@ -646,18 +664,21 @@  discard block
 block discarded – undo
646 664
  * @access private
647 665
  */
648 666
 function _access_denied_splash() {
649
-	if ( ! is_user_logged_in() || is_network_admin() )
650
-		return;
667
+	if ( ! is_user_logged_in() || is_network_admin() ) {
668
+			return;
669
+	}
651 670
 
652 671
 	$blogs = get_blogs_of_user( get_current_user_id() );
653 672
 
654
-	if ( wp_list_filter( $blogs, array( 'userblog_id' => get_current_blog_id() ) ) )
655
-		return;
673
+	if ( wp_list_filter( $blogs, array( 'userblog_id' => get_current_blog_id() ) ) ) {
674
+			return;
675
+	}
656 676
 
657 677
 	$blog_name = get_bloginfo( 'name' );
658 678
 
659
-	if ( empty( $blogs ) )
660
-		wp_die( sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ), 403 );
679
+	if ( empty( $blogs ) ) {
680
+			wp_die( sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ), 403 );
681
+	}
661 682
 
662 683
 	$output = '<p>' . sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ) . '</p>';
663 684
 	$output .= '<p>' . __( 'If you reached this screen by accident and meant to visit one of your own sites, here are some shortcuts to help you find your way.' ) . '</p>';
@@ -687,8 +708,9 @@  discard block
 block discarded – undo
687 708
  * @return bool True if the user has proper permissions, false if they do not.
688 709
  */
689 710
 function check_import_new_users( $permission ) {
690
-	if ( !is_super_admin() )
691
-		return false;
711
+	if ( !is_super_admin() ) {
712
+			return false;
713
+	}
692 714
 	return true;
693 715
 }
694 716
 // See "import_allow_fetch_attachments" and "import_attachment_size_limit" filters too.
@@ -723,8 +745,10 @@  discard block
 block discarded – undo
723 745
 
724 746
 	}
725 747
 
726
-	if ( $flag === false ) // WordPress english
748
+	if ( $flag === false ) {
749
+		// WordPress english
727 750
 		$output[] = '<option value=""' . selected( $current, '', false ) . '>' . __( 'English' ) . "</option>";
751
+	}
728 752
 
729 753
 	// Order by name
730 754
 	uksort( $output, 'strnatcasecmp' );
@@ -782,14 +806,18 @@  discard block
 block discarded – undo
782 806
  * @return array The new array of post data after checking for collisions.
783 807
  */
784 808
 function avoid_blog_page_permalink_collision( $data, $postarr ) {
785
-	if ( is_subdomain_install() )
786
-		return $data;
787
-	if ( $data['post_type'] != 'page' )
788
-		return $data;
789
-	if ( !isset( $data['post_name'] ) || $data['post_name'] == '' )
790
-		return $data;
791
-	if ( !is_main_site() )
792
-		return $data;
809
+	if ( is_subdomain_install() ) {
810
+			return $data;
811
+	}
812
+	if ( $data['post_type'] != 'page' ) {
813
+			return $data;
814
+	}
815
+	if ( !isset( $data['post_name'] ) || $data['post_name'] == '' ) {
816
+			return $data;
817
+	}
818
+	if ( !is_main_site() ) {
819
+			return $data;
820
+	}
793 821
 
794 822
 	$post_name = $data['post_name'];
795 823
 	$c = 0;
@@ -826,8 +854,9 @@  discard block
 block discarded – undo
826 854
 			?>
827 855
 			<select name="primary_blog" id="primary_blog">
828 856
 				<?php foreach ( (array) $all_blogs as $blog ) {
829
-					if ( $primary_blog == $blog->userblog_id )
830
-						$found = true;
857
+					if ( $primary_blog == $blog->userblog_id ) {
858
+											$found = true;
859
+					}
831 860
 					?><option value="<?php echo $blog->userblog_id ?>"<?php selected( $primary_blog, $blog->userblog_id ); ?>><?php echo esc_url( get_home_url( $blog->userblog_id ) ) ?></option><?php
832 861
 				} ?>
833 862
 			</select>
@@ -839,8 +868,10 @@  discard block
 block discarded – undo
839 868
 		} elseif ( count( $all_blogs ) == 1 ) {
840 869
 			$blog = reset( $all_blogs );
841 870
 			echo esc_url( get_home_url( $blog->userblog_id ) );
842
-			if ( $primary_blog != $blog->userblog_id ) // Set the primary blog again if it's out of sync with blog list.
871
+			if ( $primary_blog != $blog->userblog_id ) {
872
+				// Set the primary blog again if it's out of sync with blog list.
843 873
 				update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id );
874
+			}
844 875
 		} else {
845 876
 			echo "N/A";
846 877
 		}
@@ -963,10 +994,11 @@  discard block
 block discarded – undo
963 994
 function can_edit_network( $site_id ) {
964 995
 	global $wpdb;
965 996
 
966
-	if ( $site_id == $wpdb->siteid )
967
-		$result = true;
968
-	else
969
-		$result = false;
997
+	if ( $site_id == $wpdb->siteid ) {
998
+			$result = true;
999
+	} else {
1000
+			$result = false;
1001
+	}
970 1002
 
971 1003
 	/**
972 1004
 	 * Filter whether this network can be edited from this page.
@@ -1008,8 +1040,11 @@  discard block
 block discarded – undo
1008 1040
 
1009 1041
 	<?php if ( 1 == count( $users ) ) : ?>
1010 1042
 		<p><?php _e( 'You have chosen to delete the user from all networks and sites.' ); ?></p>
1011
-	<?php else : ?>
1012
-		<p><?php _e( 'You have chosen to delete the following users from all networks and sites.' ); ?></p>
1043
+	<?php else {
1044
+	: ?>
1045
+		<p><?php _e( 'You have chosen to delete the following users from all networks and sites.' );
1046
+}
1047
+?></p>
1013 1048
 	<?php endif; ?>
1014 1049
 
1015 1050
 	<form action="users.php?action=dodelete" method="post">
@@ -1092,8 +1127,11 @@  discard block
 block discarded – undo
1092 1127
 
1093 1128
 	if ( 1 == count( $users ) ) : ?>
1094 1129
 		<p><?php _e( 'Once you hit &#8220;Confirm Deletion&#8221;, the user will be permanently removed.' ); ?></p>
1095
-	<?php else : ?>
1096
-		<p><?php _e( 'Once you hit &#8220;Confirm Deletion&#8221;, these users will be permanently removed.' ); ?></p>
1130
+	<?php else {
1131
+	: ?>
1132
+		<p><?php _e( 'Once you hit &#8220;Confirm Deletion&#8221;, these users will be permanently removed.' );
1133
+}
1134
+?></p>
1097 1135
 	<?php endif;
1098 1136
 
1099 1137
 	submit_button( __('Confirm Deletion'), 'primary' );
Please login to merge, or discard this patch.
Spacing   +272 added lines, -272 removed lines patch added patch discarded remove patch
@@ -15,33 +15,33 @@  discard block
 block discarded – undo
15 15
  * @param array $file $_FILES array for a given file.
16 16
  * @return array $_FILES array with 'error' key set if file exceeds quota. 'error' is empty otherwise.
17 17
  */
18
-function check_upload_size( $file ) {
19
-	if ( get_site_option( 'upload_space_check_disabled' ) )
18
+function check_upload_size($file) {
19
+	if (get_site_option('upload_space_check_disabled'))
20 20
 		return $file;
21 21
 
22
-	if ( $file['error'] != '0' ) // there's already an error
22
+	if ($file['error'] != '0') // there's already an error
23 23
 		return $file;
24 24
 
25
-	if ( defined( 'WP_IMPORTING' ) )
25
+	if (defined('WP_IMPORTING'))
26 26
 		return $file;
27 27
 
28 28
 	$space_left = get_upload_space_available();
29 29
 
30
-	$file_size = filesize( $file['tmp_name'] );
31
-	if ( $space_left < $file_size ) {
32
-		$file['error'] = sprintf( __( 'Not enough space to upload. %1$s KB needed.' ), number_format( ( $file_size - $space_left ) / KB_IN_BYTES ) );
30
+	$file_size = filesize($file['tmp_name']);
31
+	if ($space_left < $file_size) {
32
+		$file['error'] = sprintf(__('Not enough space to upload. %1$s KB needed.'), number_format(($file_size - $space_left) / KB_IN_BYTES));
33 33
 	}
34 34
 
35
-	if ( $file_size > ( KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ) ) ) {
36
-		$file['error'] = sprintf( __( 'This file is too big. Files must be less than %1$s KB in size.' ), get_site_option( 'fileupload_maxk', 1500 ) );
35
+	if ($file_size > (KB_IN_BYTES * get_site_option('fileupload_maxk', 1500))) {
36
+		$file['error'] = sprintf(__('This file is too big. Files must be less than %1$s KB in size.'), get_site_option('fileupload_maxk', 1500));
37 37
 	}
38 38
 
39
-	if ( upload_is_user_over_quota( false ) ) {
40
-		$file['error'] = __( 'You have used your space quota. Please delete files before uploading.' );
39
+	if (upload_is_user_over_quota(false)) {
40
+		$file['error'] = __('You have used your space quota. Please delete files before uploading.');
41 41
 	}
42 42
 
43
-	if ( $file['error'] != '0' && ! isset( $_POST['html-upload'] ) && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
44
-		wp_die( $file['error'] . ' <a href="javascript:history.go(-1)">' . __( 'Back' ) . '</a>' );
43
+	if ($file['error'] != '0' && ! isset($_POST['html-upload']) && ( ! defined('DOING_AJAX') || ! DOING_AJAX)) {
44
+		wp_die($file['error'].' <a href="javascript:history.go(-1)">'.__('Back').'</a>');
45 45
 	}
46 46
 
47 47
 	return $file;
@@ -57,16 +57,16 @@  discard block
 block discarded – undo
57 57
  * @param int  $blog_id Site ID.
58 58
  * @param bool $drop    True if site's database tables should be dropped. Default is false.
59 59
  */
60
-function wpmu_delete_blog( $blog_id, $drop = false ) {
60
+function wpmu_delete_blog($blog_id, $drop = false) {
61 61
 	global $wpdb;
62 62
 
63 63
 	$switch = false;
64
-	if ( get_current_blog_id() != $blog_id ) {
64
+	if (get_current_blog_id() != $blog_id) {
65 65
 		$switch = true;
66
-		switch_to_blog( $blog_id );
66
+		switch_to_blog($blog_id);
67 67
 	}
68 68
 
69
-	$blog = get_blog_details( $blog_id );
69
+	$blog = get_blog_details($blog_id);
70 70
 	/**
71 71
 	 * Fires before a site is deleted.
72 72
 	 *
@@ -75,42 +75,42 @@  discard block
 block discarded – undo
75 75
 	 * @param int  $blog_id The site ID.
76 76
 	 * @param bool $drop    True if site's table should be dropped. Default is false.
77 77
 	 */
78
-	do_action( 'delete_blog', $blog_id, $drop );
78
+	do_action('delete_blog', $blog_id, $drop);
79 79
 
80
-	$users = get_users( array( 'blog_id' => $blog_id, 'fields' => 'ids' ) );
80
+	$users = get_users(array('blog_id' => $blog_id, 'fields' => 'ids'));
81 81
 
82 82
 	// Remove users from this blog.
83
-	if ( ! empty( $users ) ) {
84
-		foreach ( $users as $user_id ) {
85
-			remove_user_from_blog( $user_id, $blog_id );
83
+	if ( ! empty($users)) {
84
+		foreach ($users as $user_id) {
85
+			remove_user_from_blog($user_id, $blog_id);
86 86
 		}
87 87
 	}
88 88
 
89
-	update_blog_status( $blog_id, 'deleted', 1 );
89
+	update_blog_status($blog_id, 'deleted', 1);
90 90
 
91 91
 	$current_site = get_current_site();
92 92
 
93 93
 	// If a full blog object is not available, do not destroy anything.
94
-	if ( $drop && ! $blog ) {
94
+	if ($drop && ! $blog) {
95 95
 		$drop = false;
96 96
 	}
97 97
 
98 98
 	// Don't destroy the initial, main, or root blog.
99
-	if ( $drop && ( 1 == $blog_id || is_main_site( $blog_id ) || ( $blog->path == $current_site->path && $blog->domain == $current_site->domain ) ) ) {
99
+	if ($drop && (1 == $blog_id || is_main_site($blog_id) || ($blog->path == $current_site->path && $blog->domain == $current_site->domain))) {
100 100
 		$drop = false;
101 101
 	}
102 102
 
103
-	$upload_path = trim( get_option( 'upload_path' ) );
103
+	$upload_path = trim(get_option('upload_path'));
104 104
 
105 105
 	// If ms_files_rewriting is enabled and upload_path is empty, wp_upload_dir is not reliable.
106
-	if ( $drop && get_site_option( 'ms_files_rewriting' ) && empty( $upload_path ) ) {
106
+	if ($drop && get_site_option('ms_files_rewriting') && empty($upload_path)) {
107 107
 		$drop = false;
108 108
 	}
109 109
 
110
-	if ( $drop ) {
110
+	if ($drop) {
111 111
 		$uploads = wp_get_upload_dir();
112 112
 
113
-		$tables = $wpdb->tables( 'blog' );
113
+		$tables = $wpdb->tables('blog');
114 114
 		/**
115 115
 		 * Filters the tables to drop when the site is deleted.
116 116
 		 *
@@ -119,13 +119,13 @@  discard block
 block discarded – undo
119 119
 		 * @param array $tables  The site tables to be dropped.
120 120
 		 * @param int   $blog_id The ID of the site to drop tables for.
121 121
 		 */
122
-		$drop_tables = apply_filters( 'wpmu_drop_tables', $tables, $blog_id );
122
+		$drop_tables = apply_filters('wpmu_drop_tables', $tables, $blog_id);
123 123
 
124
-		foreach ( (array) $drop_tables as $table ) {
125
-			$wpdb->query( "DROP TABLE IF EXISTS `$table`" );
124
+		foreach ((array) $drop_tables as $table) {
125
+			$wpdb->query("DROP TABLE IF EXISTS `$table`");
126 126
 		}
127 127
 
128
-		$wpdb->delete( $wpdb->blogs, array( 'blog_id' => $blog_id ) );
128
+		$wpdb->delete($wpdb->blogs, array('blog_id' => $blog_id));
129 129
 
130 130
 		/**
131 131
 		 * Filters the upload base directory to delete when the site is deleted.
@@ -135,43 +135,43 @@  discard block
 block discarded – undo
135 135
 		 * @param string $uploads['basedir'] Uploads path without subdirectory. @see wp_upload_dir()
136 136
 		 * @param int    $blog_id            The site ID.
137 137
 		 */
138
-		$dir = apply_filters( 'wpmu_delete_blog_upload_dir', $uploads['basedir'], $blog_id );
139
-		$dir = rtrim( $dir, DIRECTORY_SEPARATOR );
138
+		$dir = apply_filters('wpmu_delete_blog_upload_dir', $uploads['basedir'], $blog_id);
139
+		$dir = rtrim($dir, DIRECTORY_SEPARATOR);
140 140
 		$top_dir = $dir;
141 141
 		$stack = array($dir);
142 142
 		$index = 0;
143 143
 
144
-		while ( $index < count( $stack ) ) {
144
+		while ($index < count($stack)) {
145 145
 			// Get indexed directory from stack
146 146
 			$dir = $stack[$index];
147 147
 
148
-			$dh = @opendir( $dir );
149
-			if ( $dh ) {
150
-				while ( ( $file = @readdir( $dh ) ) !== false ) {
151
-					if ( $file == '.' || $file == '..' )
148
+			$dh = @opendir($dir);
149
+			if ($dh) {
150
+				while (($file = @readdir($dh)) !== false) {
151
+					if ($file == '.' || $file == '..')
152 152
 						continue;
153 153
 
154
-					if ( @is_dir( $dir . DIRECTORY_SEPARATOR . $file ) ) {
155
-						$stack[] = $dir . DIRECTORY_SEPARATOR . $file;
156
-					} elseif ( @is_file( $dir . DIRECTORY_SEPARATOR . $file ) ) {
157
-						@unlink( $dir . DIRECTORY_SEPARATOR . $file );
154
+					if (@is_dir($dir.DIRECTORY_SEPARATOR.$file)) {
155
+						$stack[] = $dir.DIRECTORY_SEPARATOR.$file;
156
+					} elseif (@is_file($dir.DIRECTORY_SEPARATOR.$file)) {
157
+						@unlink($dir.DIRECTORY_SEPARATOR.$file);
158 158
 					}
159 159
 				}
160
-				@closedir( $dh );
160
+				@closedir($dh);
161 161
 			}
162 162
 			$index++;
163 163
 		}
164 164
 
165
-		$stack = array_reverse( $stack ); // Last added dirs are deepest
166
-		foreach ( (array) $stack as $dir ) {
167
-			if ( $dir != $top_dir)
168
-			@rmdir( $dir );
165
+		$stack = array_reverse($stack); // Last added dirs are deepest
166
+		foreach ((array) $stack as $dir) {
167
+			if ($dir != $top_dir)
168
+			@rmdir($dir);
169 169
 		}
170 170
 
171
-		clean_blog_cache( $blog );
171
+		clean_blog_cache($blog);
172 172
 	}
173 173
 
174
-	if ( $switch )
174
+	if ($switch)
175 175
 		restore_current_blog();
176 176
 }
177 177
 
@@ -187,22 +187,22 @@  discard block
 block discarded – undo
187 187
  * @param int $id The user ID.
188 188
  * @return bool True if the user was deleted, otherwise false.
189 189
  */
190
-function wpmu_delete_user( $id ) {
190
+function wpmu_delete_user($id) {
191 191
 	global $wpdb;
192 192
 
193
-	if ( ! is_numeric( $id ) ) {
193
+	if ( ! is_numeric($id)) {
194 194
 		return false;
195 195
 	}
196 196
 
197 197
 	$id = (int) $id;
198
-	$user = new WP_User( $id );
198
+	$user = new WP_User($id);
199 199
 
200
-	if ( !$user->exists() )
200
+	if ( ! $user->exists())
201 201
 		return false;
202 202
 
203 203
 	// Global super-administrators are protected, and cannot be deleted.
204 204
 	$_super_admins = get_super_admins();
205
-	if ( in_array( $user->user_login, $_super_admins, true ) ) {
205
+	if (in_array($user->user_login, $_super_admins, true)) {
206 206
 		return false;
207 207
 	}
208 208
 
@@ -213,42 +213,42 @@  discard block
 block discarded – undo
213 213
 	 *
214 214
 	 * @param int $id ID of the user about to be deleted from the network.
215 215
 	 */
216
-	do_action( 'wpmu_delete_user', $id );
216
+	do_action('wpmu_delete_user', $id);
217 217
 
218
-	$blogs = get_blogs_of_user( $id );
218
+	$blogs = get_blogs_of_user($id);
219 219
 
220
-	if ( ! empty( $blogs ) ) {
221
-		foreach ( $blogs as $blog ) {
222
-			switch_to_blog( $blog->userblog_id );
223
-			remove_user_from_blog( $id, $blog->userblog_id );
220
+	if ( ! empty($blogs)) {
221
+		foreach ($blogs as $blog) {
222
+			switch_to_blog($blog->userblog_id);
223
+			remove_user_from_blog($id, $blog->userblog_id);
224 224
 
225
-			$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id ) );
226
-			foreach ( (array) $post_ids as $post_id ) {
227
-				wp_delete_post( $post_id );
225
+			$post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id));
226
+			foreach ((array) $post_ids as $post_id) {
227
+				wp_delete_post($post_id);
228 228
 			}
229 229
 
230 230
 			// Clean links
231
-			$link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id ) );
231
+			$link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id));
232 232
 
233
-			if ( $link_ids ) {
234
-				foreach ( $link_ids as $link_id )
235
-					wp_delete_link( $link_id );
233
+			if ($link_ids) {
234
+				foreach ($link_ids as $link_id)
235
+					wp_delete_link($link_id);
236 236
 			}
237 237
 
238 238
 			restore_current_blog();
239 239
 		}
240 240
 	}
241 241
 
242
-	$meta = $wpdb->get_col( $wpdb->prepare( "SELECT umeta_id FROM $wpdb->usermeta WHERE user_id = %d", $id ) );
243
-	foreach ( $meta as $mid )
244
-		delete_metadata_by_mid( 'user', $mid );
242
+	$meta = $wpdb->get_col($wpdb->prepare("SELECT umeta_id FROM $wpdb->usermeta WHERE user_id = %d", $id));
243
+	foreach ($meta as $mid)
244
+		delete_metadata_by_mid('user', $mid);
245 245
 
246
-	$wpdb->delete( $wpdb->users, array( 'ID' => $id ) );
246
+	$wpdb->delete($wpdb->users, array('ID' => $id));
247 247
 
248
-	clean_user_cache( $user );
248
+	clean_user_cache($user);
249 249
 
250 250
 	/** This action is documented in wp-admin/includes/user.php */
251
-	do_action( 'deleted_user', $id );
251
+	do_action('deleted_user', $id);
252 252
 
253 253
 	return true;
254 254
 }
@@ -261,19 +261,19 @@  discard block
 block discarded – undo
261 261
  * @param string $old_value The old email address. Not currently used.
262 262
  * @param string $value     The new email address.
263 263
  */
264
-function update_option_new_admin_email( $old_value, $value ) {
265
-	if ( $value == get_option( 'admin_email' ) || !is_email( $value ) )
264
+function update_option_new_admin_email($old_value, $value) {
265
+	if ($value == get_option('admin_email') || ! is_email($value))
266 266
 		return;
267 267
 
268
-	$hash = md5( $value. time() .mt_rand() );
268
+	$hash = md5($value.time().mt_rand());
269 269
 	$new_admin_email = array(
270 270
 		'hash' => $hash,
271 271
 		'newemail' => $value
272 272
 	);
273
-	update_option( 'adminhash', $new_admin_email );
273
+	update_option('adminhash', $new_admin_email);
274 274
 
275 275
 	/* translators: Do not translate USERNAME, ADMIN_URL, EMAIL, SITENAME, SITEURL: those are placeholders. */
276
-	$email_text = __( 'Howdy ###USERNAME###,
276
+	$email_text = __('Howdy ###USERNAME###,
277 277
 
278 278
 You recently requested to have the administration email address on
279 279
 your site changed.
@@ -305,16 +305,16 @@  discard block
 block discarded – undo
305 305
 	 * @param string $email_text      Text in the email.
306 306
 	 * @param string $new_admin_email New admin email that the current administration email was changed to.
307 307
 	 */
308
-	$content = apply_filters( 'new_admin_email_content', $email_text, $new_admin_email );
308
+	$content = apply_filters('new_admin_email_content', $email_text, $new_admin_email);
309 309
 
310 310
 	$current_user = wp_get_current_user();
311
-	$content = str_replace( '###USERNAME###', $current_user->user_login, $content );
312
-	$content = str_replace( '###ADMIN_URL###', esc_url( self_admin_url( 'options.php?adminhash='.$hash ) ), $content );
313
-	$content = str_replace( '###EMAIL###', $value, $content );
314
-	$content = str_replace( '###SITENAME###', get_site_option( 'site_name' ), $content );
315
-	$content = str_replace( '###SITEURL###', network_home_url(), $content );
311
+	$content = str_replace('###USERNAME###', $current_user->user_login, $content);
312
+	$content = str_replace('###ADMIN_URL###', esc_url(self_admin_url('options.php?adminhash='.$hash)), $content);
313
+	$content = str_replace('###EMAIL###', $value, $content);
314
+	$content = str_replace('###SITENAME###', get_site_option('site_name'), $content);
315
+	$content = str_replace('###SITEURL###', network_home_url(), $content);
316 316
 
317
-	wp_mail( $value, sprintf( __( '[%s] New Admin Email Address' ), wp_specialchars_decode( get_option( 'blogname' ) ) ), $content );
317
+	wp_mail($value, sprintf(__('[%s] New Admin Email Address'), wp_specialchars_decode(get_option('blogname'))), $content);
318 318
 }
319 319
 
320 320
 /**
@@ -328,33 +328,33 @@  discard block
 block discarded – undo
328 328
 function send_confirmation_on_profile_email() {
329 329
 	global $errors, $wpdb;
330 330
 	$current_user = wp_get_current_user();
331
-	if ( ! is_object($errors) )
331
+	if ( ! is_object($errors))
332 332
 		$errors = new WP_Error();
333 333
 
334
-	if ( $current_user->ID != $_POST['user_id'] )
334
+	if ($current_user->ID != $_POST['user_id'])
335 335
 		return false;
336 336
 
337
-	if ( $current_user->user_email != $_POST['email'] ) {
338
-		if ( !is_email( $_POST['email'] ) ) {
339
-			$errors->add( 'user_email', __( "<strong>ERROR</strong>: The email address isn&#8217;t correct." ), array( 'form-field' => 'email' ) );
337
+	if ($current_user->user_email != $_POST['email']) {
338
+		if ( ! is_email($_POST['email'])) {
339
+			$errors->add('user_email', __("<strong>ERROR</strong>: The email address isn&#8217;t correct."), array('form-field' => 'email'));
340 340
 			return;
341 341
 		}
342 342
 
343
-		if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM {$wpdb->users} WHERE user_email=%s", $_POST['email'] ) ) ) {
344
-			$errors->add( 'user_email', __( "<strong>ERROR</strong>: The email address is already used." ), array( 'form-field' => 'email' ) );
345
-			delete_user_meta( $current_user->ID, '_new_email' );
343
+		if ($wpdb->get_var($wpdb->prepare("SELECT user_email FROM {$wpdb->users} WHERE user_email=%s", $_POST['email']))) {
344
+			$errors->add('user_email', __("<strong>ERROR</strong>: The email address is already used."), array('form-field' => 'email'));
345
+			delete_user_meta($current_user->ID, '_new_email');
346 346
 			return;
347 347
 		}
348 348
 
349
-		$hash = md5( $_POST['email'] . time() . mt_rand() );
349
+		$hash = md5($_POST['email'].time().mt_rand());
350 350
 		$new_user_email = array(
351 351
 			'hash' => $hash,
352 352
 			'newemail' => $_POST['email']
353 353
 		);
354
-		update_user_meta( $current_user->ID, '_new_email', $new_user_email );
354
+		update_user_meta($current_user->ID, '_new_email', $new_user_email);
355 355
 
356 356
 		/* translators: Do not translate USERNAME, ADMIN_URL, EMAIL, SITENAME, SITEURL: those are placeholders. */
357
-		$email_text = __( 'Howdy ###USERNAME###,
357
+		$email_text = __('Howdy ###USERNAME###,
358 358
 
359 359
 You recently requested to have the email address on your account changed.
360 360
 
@@ -385,15 +385,15 @@  discard block
 block discarded – undo
385 385
 		 * @param string $email_text     Text in the email.
386 386
 		 * @param string $new_user_email New user email that the current user has changed to.
387 387
 		 */
388
-		$content = apply_filters( 'new_user_email_content', $email_text, $new_user_email );
388
+		$content = apply_filters('new_user_email_content', $email_text, $new_user_email);
389 389
 
390
-		$content = str_replace( '###USERNAME###', $current_user->user_login, $content );
391
-		$content = str_replace( '###ADMIN_URL###', esc_url( admin_url( 'profile.php?newuseremail='.$hash ) ), $content );
392
-		$content = str_replace( '###EMAIL###', $_POST['email'], $content);
393
-		$content = str_replace( '###SITENAME###', get_site_option( 'site_name' ), $content );
394
-		$content = str_replace( '###SITEURL###', network_home_url(), $content );
390
+		$content = str_replace('###USERNAME###', $current_user->user_login, $content);
391
+		$content = str_replace('###ADMIN_URL###', esc_url(admin_url('profile.php?newuseremail='.$hash)), $content);
392
+		$content = str_replace('###EMAIL###', $_POST['email'], $content);
393
+		$content = str_replace('###SITENAME###', get_site_option('site_name'), $content);
394
+		$content = str_replace('###SITEURL###', network_home_url(), $content);
395 395
 
396
-		wp_mail( $_POST['email'], sprintf( __( '[%s] New Email Address' ), wp_specialchars_decode( get_option( 'blogname' ) ) ), $content );
396
+		wp_mail($_POST['email'], sprintf(__('[%s] New Email Address'), wp_specialchars_decode(get_option('blogname'))), $content);
397 397
 		$_POST['email'] = $current_user->user_email;
398 398
 	}
399 399
 }
@@ -408,9 +408,9 @@  discard block
 block discarded – undo
408 408
  */
409 409
 function new_user_email_admin_notice() {
410 410
 	global $pagenow;
411
-	if ( 'profile.php' === $pagenow && isset( $_GET['updated'] ) && $email = get_user_meta( get_current_user_id(), '_new_email', true ) ) {
411
+	if ('profile.php' === $pagenow && isset($_GET['updated']) && $email = get_user_meta(get_current_user_id(), '_new_email', true)) {
412 412
 		/* translators: %s: New email address */
413
-		echo '<div class="notice notice-info"><p>' . sprintf( __( 'Your email address has not been updated yet. Please check your inbox at %s for a confirmation email.' ), '<code>' . esc_html( $email['newemail'] ) . '</code>' ) . '</p></div>';
413
+		echo '<div class="notice notice-info"><p>'.sprintf(__('Your email address has not been updated yet. Please check your inbox at %s for a confirmation email.'), '<code>'.esc_html($email['newemail']).'</code>').'</p></div>';
414 414
 	}
415 415
 }
416 416
 
@@ -422,19 +422,19 @@  discard block
 block discarded – undo
422 422
  * @param bool $echo Optional. If $echo is set and the quota is exceeded, a warning message is echoed. Default is true.
423 423
  * @return bool True if user is over upload space quota, otherwise false.
424 424
  */
425
-function upload_is_user_over_quota( $echo = true ) {
426
-	if ( get_site_option( 'upload_space_check_disabled' ) )
425
+function upload_is_user_over_quota($echo = true) {
426
+	if (get_site_option('upload_space_check_disabled'))
427 427
 		return false;
428 428
 
429 429
 	$space_allowed = get_space_allowed();
430
-	if ( ! is_numeric( $space_allowed ) ) {
430
+	if ( ! is_numeric($space_allowed)) {
431 431
 		$space_allowed = 10; // Default space allowed is 10 MB
432 432
 	}
433 433
 	$space_used = get_space_used();
434 434
 
435
-	if ( ( $space_allowed - $space_used ) < 0 ) {
436
-		if ( $echo )
437
-			_e( 'Sorry, you have used your space allocation. Please delete some files to upload more files.' );
435
+	if (($space_allowed - $space_used) < 0) {
436
+		if ($echo)
437
+			_e('Sorry, you have used your space allocation. Please delete some files to upload more files.');
438 438
 		return true;
439 439
 	} else {
440 440
 		return false;
@@ -450,19 +450,19 @@  discard block
 block discarded – undo
450 450
 	$space_allowed = get_space_allowed();
451 451
 	$space_used = get_space_used();
452 452
 
453
-	$percent_used = ( $space_used / $space_allowed ) * 100;
453
+	$percent_used = ($space_used / $space_allowed) * 100;
454 454
 
455
-	if ( $space_allowed > 1000 ) {
456
-		$space = number_format( $space_allowed / KB_IN_BYTES );
455
+	if ($space_allowed > 1000) {
456
+		$space = number_format($space_allowed / KB_IN_BYTES);
457 457
 		/* translators: Gigabytes */
458
-		$space .= __( 'GB' );
458
+		$space .= __('GB');
459 459
 	} else {
460
-		$space = number_format( $space_allowed );
460
+		$space = number_format($space_allowed);
461 461
 		/* translators: Megabytes */
462
-		$space .= __( 'MB' );
462
+		$space .= __('MB');
463 463
 	}
464 464
 	?>
465
-	<strong><?php printf( __( 'Used: %1$s%% of %2$s' ), number_format( $percent_used ), $space ); ?></strong>
465
+	<strong><?php printf(__('Used: %1$s%% of %2$s'), number_format($percent_used), $space); ?></strong>
466 466
 	<?php
467 467
 }
468 468
 
@@ -474,12 +474,12 @@  discard block
 block discarded – undo
474 474
  * @param int $size Current max size in bytes
475 475
  * @return int Max size in bytes
476 476
  */
477
-function fix_import_form_size( $size ) {
478
-	if ( upload_is_user_over_quota( false ) ) {
477
+function fix_import_form_size($size) {
478
+	if (upload_is_user_over_quota(false)) {
479 479
 		return 0;
480 480
 	}
481 481
 	$available = get_upload_space_available();
482
-	return min( $size, $available );
482
+	return min($size, $available);
483 483
 }
484 484
 
485 485
 /**
@@ -489,20 +489,20 @@  discard block
 block discarded – undo
489 489
  *
490 490
  * @param int $id The ID of the site to display the setting for.
491 491
  */
492
-function upload_space_setting( $id ) {
493
-	switch_to_blog( $id );
494
-	$quota = get_option( 'blog_upload_space' );
492
+function upload_space_setting($id) {
493
+	switch_to_blog($id);
494
+	$quota = get_option('blog_upload_space');
495 495
 	restore_current_blog();
496 496
 
497
-	if ( !$quota )
497
+	if ( ! $quota)
498 498
 		$quota = '';
499 499
 
500 500
 	?>
501 501
 	<tr>
502
-		<th><label for="blog-upload-space-number"><?php _e( 'Site Upload Space Quota' ); ?></label></th>
502
+		<th><label for="blog-upload-space-number"><?php _e('Site Upload Space Quota'); ?></label></th>
503 503
 		<td>
504 504
 			<input type="number" step="1" min="0" style="width: 100px" name="option[blog_upload_space]" id="blog-upload-space-number" aria-describedby="blog-upload-space-desc" value="<?php echo $quota; ?>" />
505
-			<span id="blog-upload-space-desc"><span class="screen-reader-text"><?php _e( 'Size in megabytes' ); ?></span> <?php _e( 'MB (Leave blank for network default)' ); ?></span>
505
+			<span id="blog-upload-space-desc"><span class="screen-reader-text"><?php _e('Size in megabytes'); ?></span> <?php _e('MB (Leave blank for network default)'); ?></span>
506 506
 		</td>
507 507
 	</tr>
508 508
 	<?php
@@ -524,19 +524,19 @@  discard block
 block discarded – undo
524 524
  * @param null   $deprecated Deprecated as of 3.0.2 and should not be used.
525 525
  * @return int   The initially passed $value.
526 526
  */
527
-function update_user_status( $id, $pref, $value, $deprecated = null ) {
527
+function update_user_status($id, $pref, $value, $deprecated = null) {
528 528
 	global $wpdb;
529 529
 
530
-	if ( null !== $deprecated )
531
-		_deprecated_argument( __FUNCTION__, '3.1' );
530
+	if (null !== $deprecated)
531
+		_deprecated_argument(__FUNCTION__, '3.1');
532 532
 
533
-	$wpdb->update( $wpdb->users, array( sanitize_key( $pref ) => $value ), array( 'ID' => $id ) );
533
+	$wpdb->update($wpdb->users, array(sanitize_key($pref) => $value), array('ID' => $id));
534 534
 
535
-	$user = new WP_User( $id );
536
-	clean_user_cache( $user );
535
+	$user = new WP_User($id);
536
+	clean_user_cache($user);
537 537
 
538
-	if ( $pref == 'spam' ) {
539
-		if ( $value == 1 ) {
538
+	if ($pref == 'spam') {
539
+		if ($value == 1) {
540 540
 			/**
541 541
 			 * Fires after the user is marked as a SPAM user.
542 542
 			 *
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
 			 *
545 545
 			 * @param int $id ID of the user marked as SPAM.
546 546
 			 */
547
-			do_action( 'make_spam_user', $id );
547
+			do_action('make_spam_user', $id);
548 548
 		} else {
549 549
 			/**
550 550
 			 * Fires after the user is marked as a HAM user. Opposite of SPAM.
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
 			 *
554 554
 			 * @param int $id ID of the user marked as HAM.
555 555
 			 */
556
-			do_action( 'make_ham_user', $id );
556
+			do_action('make_ham_user', $id);
557 557
 		}
558 558
 	}
559 559
 
@@ -568,13 +568,13 @@  discard block
 block discarded – undo
568 568
  * @param int $id The user ID.
569 569
  * @return bool|int The ID of the refreshed user or false if the user does not exist.
570 570
  */
571
-function refresh_user_details( $id ) {
571
+function refresh_user_details($id) {
572 572
 	$id = (int) $id;
573 573
 
574
-	if ( !$user = get_userdata( $id ) )
574
+	if ( ! $user = get_userdata($id))
575 575
 		return false;
576 576
 
577
-	clean_user_cache( $user );
577
+	clean_user_cache($user);
578 578
 
579 579
 	return $id;
580 580
 }
@@ -588,8 +588,8 @@  discard block
 block discarded – undo
588 588
  * @return string The language corresponding to $code if it exists. If it does not exist,
589 589
  *                then the first two letters of $code is returned.
590 590
  */
591
-function format_code_lang( $code = '' ) {
592
-	$code = strtolower( substr( $code, 0, 2 ) );
591
+function format_code_lang($code = '') {
592
+	$code = strtolower(substr($code, 0, 2));
593 593
 	$lang_codes = array(
594 594
 		'aa' => 'Afar', 'ab' => 'Abkhazian', 'af' => 'Afrikaans', 'ak' => 'Akan', 'sq' => 'Albanian', 'am' => 'Amharic', 'ar' => 'Arabic', 'an' => 'Aragonese', 'hy' => 'Armenian', 'as' => 'Assamese', 'av' => 'Avaric', 'ae' => 'Avestan', 'ay' => 'Aymara', 'az' => 'Azerbaijani', 'ba' => 'Bashkir', 'bm' => 'Bambara', 'eu' => 'Basque', 'be' => 'Belarusian', 'bn' => 'Bengali',
595 595
 		'bh' => 'Bihari', 'bi' => 'Bislama', 'bs' => 'Bosnian', 'br' => 'Breton', 'bg' => 'Bulgarian', 'my' => 'Burmese', 'ca' => 'Catalan; Valencian', 'ch' => 'Chamorro', 'ce' => 'Chechen', 'zh' => 'Chinese', 'cu' => 'Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic', 'cv' => 'Chuvash', 'kw' => 'Cornish', 'co' => 'Corsican', 'cr' => 'Cree',
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 		'no' => 'Norwegian', 'ny' => 'Chichewa; Chewa; Nyanja', 'oc' => 'Occitan, Provençal', 'oj' => 'Ojibwa', 'or' => 'Oriya', 'om' => 'Oromo', 'os' => 'Ossetian; Ossetic', 'pa' => 'Panjabi; Punjabi', 'fa' => 'Persian', 'pi' => 'Pali', 'pl' => 'Polish', 'pt' => 'Portuguese', 'ps' => 'Pushto', 'qu' => 'Quechua', 'rm' => 'Romansh', 'ro' => 'Romanian', 'rn' => 'Rundi', 'ru' => 'Russian',
602 602
 		'sg' => 'Sango', 'sa' => 'Sanskrit', 'sr' => 'Serbian', 'hr' => 'Croatian', 'si' => 'Sinhala; Sinhalese', 'sk' => 'Slovak', 'sl' => 'Slovenian', 'se' => 'Northern Sami', 'sm' => 'Samoan', 'sn' => 'Shona', 'sd' => 'Sindhi', 'so' => 'Somali', 'st' => 'Sotho, Southern', 'es' => 'Spanish; Castilian', 'sc' => 'Sardinian', 'ss' => 'Swati', 'su' => 'Sundanese', 'sw' => 'Swahili',
603 603
 		'sv' => 'Swedish', 'ty' => 'Tahitian', 'ta' => 'Tamil', 'tt' => 'Tatar', 'te' => 'Telugu', 'tg' => 'Tajik', 'tl' => 'Tagalog', 'th' => 'Thai', 'bo' => 'Tibetan', 'ti' => 'Tigrinya', 'to' => 'Tonga (Tonga Islands)', 'tn' => 'Tswana', 'ts' => 'Tsonga', 'tk' => 'Turkmen', 'tr' => 'Turkish', 'tw' => 'Twi', 'ug' => 'Uighur; Uyghur', 'uk' => 'Ukrainian', 'ur' => 'Urdu', 'uz' => 'Uzbek',
604
-		've' => 'Venda', 'vi' => 'Vietnamese', 'vo' => 'Volapük', 'cy' => 'Welsh','wa' => 'Walloon','wo' => 'Wolof', 'xh' => 'Xhosa', 'yi' => 'Yiddish', 'yo' => 'Yoruba', 'za' => 'Zhuang; Chuang', 'zu' => 'Zulu' );
604
+		've' => 'Venda', 'vi' => 'Vietnamese', 'vo' => 'Volapük', 'cy' => 'Welsh', 'wa' => 'Walloon', 'wo' => 'Wolof', 'xh' => 'Xhosa', 'yi' => 'Yiddish', 'yo' => 'Yoruba', 'za' => 'Zhuang; Chuang', 'zu' => 'Zulu' );
605 605
 
606 606
 	/**
607 607
 	 * Filters the language codes.
@@ -611,8 +611,8 @@  discard block
 block discarded – undo
611 611
 	 * @param array  $lang_codes Key/value pair of language codes where key is the short version.
612 612
 	 * @param string $code       A two-letter designation of the language.
613 613
 	 */
614
-	$lang_codes = apply_filters( 'lang_codes', $lang_codes, $code );
615
-	return strtr( $code, $lang_codes );
614
+	$lang_codes = apply_filters('lang_codes', $lang_codes, $code);
615
+	return strtr($code, $lang_codes);
616 616
 }
617 617
 
618 618
 /**
@@ -627,12 +627,12 @@  discard block
 block discarded – undo
627 627
  * @return object|array Returns `$term`, after filtering the 'slug' field with sanitize_title()
628 628
  *                      if $taxonomy is 'category' or 'post_tag'.
629 629
  */
630
-function sync_category_tag_slugs( $term, $taxonomy ) {
631
-	if ( global_terms_enabled() && ( $taxonomy == 'category' || $taxonomy == 'post_tag' ) ) {
632
-		if ( is_object( $term ) ) {
633
-			$term->slug = sanitize_title( $term->name );
630
+function sync_category_tag_slugs($term, $taxonomy) {
631
+	if (global_terms_enabled() && ($taxonomy == 'category' || $taxonomy == 'post_tag')) {
632
+		if (is_object($term)) {
633
+			$term->slug = sanitize_title($term->name);
634 634
 		} else {
635
-			$term['slug'] = sanitize_title( $term['name'] );
635
+			$term['slug'] = sanitize_title($term['name']);
636 636
 		}
637 637
 	}
638 638
 	return $term;
@@ -646,36 +646,36 @@  discard block
 block discarded – undo
646 646
  * @access private
647 647
  */
648 648
 function _access_denied_splash() {
649
-	if ( ! is_user_logged_in() || is_network_admin() )
649
+	if ( ! is_user_logged_in() || is_network_admin())
650 650
 		return;
651 651
 
652
-	$blogs = get_blogs_of_user( get_current_user_id() );
652
+	$blogs = get_blogs_of_user(get_current_user_id());
653 653
 
654
-	if ( wp_list_filter( $blogs, array( 'userblog_id' => get_current_blog_id() ) ) )
654
+	if (wp_list_filter($blogs, array('userblog_id' => get_current_blog_id())))
655 655
 		return;
656 656
 
657
-	$blog_name = get_bloginfo( 'name' );
657
+	$blog_name = get_bloginfo('name');
658 658
 
659
-	if ( empty( $blogs ) )
660
-		wp_die( sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ), 403 );
659
+	if (empty($blogs))
660
+		wp_die(sprintf(__('You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.'), $blog_name), 403);
661 661
 
662
-	$output = '<p>' . sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ) . '</p>';
663
-	$output .= '<p>' . __( 'If you reached this screen by accident and meant to visit one of your own sites, here are some shortcuts to help you find your way.' ) . '</p>';
662
+	$output = '<p>'.sprintf(__('You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.'), $blog_name).'</p>';
663
+	$output .= '<p>'.__('If you reached this screen by accident and meant to visit one of your own sites, here are some shortcuts to help you find your way.').'</p>';
664 664
 
665
-	$output .= '<h3>' . __('Your Sites') . '</h3>';
665
+	$output .= '<h3>'.__('Your Sites').'</h3>';
666 666
 	$output .= '<table>';
667 667
 
668
-	foreach ( $blogs as $blog ) {
668
+	foreach ($blogs as $blog) {
669 669
 		$output .= '<tr>';
670 670
 		$output .= "<td>{$blog->blogname}</td>";
671
-		$output .= '<td><a href="' . esc_url( get_admin_url( $blog->userblog_id ) ) . '">' . __( 'Visit Dashboard' ) . '</a> | ' .
672
-			'<a href="' . esc_url( get_home_url( $blog->userblog_id ) ). '">' . __( 'View Site' ) . '</a></td>';
671
+		$output .= '<td><a href="'.esc_url(get_admin_url($blog->userblog_id)).'">'.__('Visit Dashboard').'</a> | '.
672
+			'<a href="'.esc_url(get_home_url($blog->userblog_id)).'">'.__('View Site').'</a></td>';
673 673
 		$output .= '</tr>';
674 674
 	}
675 675
 
676 676
 	$output .= '</table>';
677 677
 
678
-	wp_die( $output, 403 );
678
+	wp_die($output, 403);
679 679
 }
680 680
 
681 681
 /**
@@ -686,8 +686,8 @@  discard block
 block discarded – undo
686 686
  * @param string $permission A permission to be checked. Currently not used.
687 687
  * @return bool True if the user has proper permissions, false if they do not.
688 688
  */
689
-function check_import_new_users( $permission ) {
690
-	if ( !is_super_admin() )
689
+function check_import_new_users($permission) {
690
+	if ( ! is_super_admin())
691 691
 		return false;
692 692
 	return true;
693 693
 }
@@ -701,33 +701,33 @@  discard block
 block discarded – undo
701 701
  * @param array  $lang_files Optional. An array of the language files. Default empty array.
702 702
  * @param string $current    Optional. The current language code. Default empty.
703 703
  */
704
-function mu_dropdown_languages( $lang_files = array(), $current = '' ) {
704
+function mu_dropdown_languages($lang_files = array(), $current = '') {
705 705
 	$flag = false;
706 706
 	$output = array();
707 707
 
708
-	foreach ( (array) $lang_files as $val ) {
709
-		$code_lang = basename( $val, '.mo' );
708
+	foreach ((array) $lang_files as $val) {
709
+		$code_lang = basename($val, '.mo');
710 710
 
711
-		if ( $code_lang == 'en_US' ) { // American English
711
+		if ($code_lang == 'en_US') { // American English
712 712
 			$flag = true;
713
-			$ae = __( 'American English' );
714
-			$output[$ae] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . $ae . '</option>';
715
-		} elseif ( $code_lang == 'en_GB' ) { // British English
713
+			$ae = __('American English');
714
+			$output[$ae] = '<option value="'.esc_attr($code_lang).'"'.selected($current, $code_lang, false).'> '.$ae.'</option>';
715
+		} elseif ($code_lang == 'en_GB') { // British English
716 716
 			$flag = true;
717
-			$be = __( 'British English' );
718
-			$output[$be] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . $be . '</option>';
717
+			$be = __('British English');
718
+			$output[$be] = '<option value="'.esc_attr($code_lang).'"'.selected($current, $code_lang, false).'> '.$be.'</option>';
719 719
 		} else {
720
-			$translated = format_code_lang( $code_lang );
721
-			$output[$translated] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . esc_html ( $translated ) . '</option>';
720
+			$translated = format_code_lang($code_lang);
721
+			$output[$translated] = '<option value="'.esc_attr($code_lang).'"'.selected($current, $code_lang, false).'> '.esc_html($translated).'</option>';
722 722
 		}
723 723
 
724 724
 	}
725 725
 
726
-	if ( $flag === false ) // WordPress english
727
-		$output[] = '<option value=""' . selected( $current, '', false ) . '>' . __( 'English' ) . "</option>";
726
+	if ($flag === false) // WordPress english
727
+		$output[] = '<option value=""'.selected($current, '', false).'>'.__('English')."</option>";
728 728
 
729 729
 	// Order by name
730
-	uksort( $output, 'strnatcasecmp' );
730
+	uksort($output, 'strnatcasecmp');
731 731
 
732 732
 	/**
733 733
 	 * Filters the languages available in the dropdown.
@@ -738,9 +738,9 @@  discard block
 block discarded – undo
738 738
 	 * @param array $lang_files Available language files.
739 739
 	 * @param string $current   The current language code.
740 740
 	 */
741
-	$output = apply_filters( 'mu_dropdown_languages', $output, $lang_files, $current );
741
+	$output = apply_filters('mu_dropdown_languages', $output, $lang_files, $current);
742 742
 
743
-	echo implode( "\n\t", $output );
743
+	echo implode("\n\t", $output);
744 744
 }
745 745
 
746 746
 /**
@@ -756,16 +756,16 @@  discard block
 block discarded – undo
756 756
 function site_admin_notice() {
757 757
 	global $wp_db_version, $pagenow;
758 758
 
759
-	if ( ! is_super_admin() ) {
759
+	if ( ! is_super_admin()) {
760 760
 		return false;
761 761
 	}
762 762
 
763
-	if ( 'upgrade.php' == $pagenow ) {
763
+	if ('upgrade.php' == $pagenow) {
764 764
 		return;
765 765
 	}
766 766
 
767
-	if ( get_site_option( 'wpmu_upgrade_site' ) != $wp_db_version ) {
768
-		echo "<div class='update-nag'>" . sprintf( __( 'Thank you for Updating! Please visit the <a href="%s">Upgrade Network</a> page to update all your sites.' ), esc_url( network_admin_url( 'upgrade.php' ) ) ) . "</div>";
767
+	if (get_site_option('wpmu_upgrade_site') != $wp_db_version) {
768
+		echo "<div class='update-nag'>".sprintf(__('Thank you for Updating! Please visit the <a href="%s">Upgrade Network</a> page to update all your sites.'), esc_url(network_admin_url('upgrade.php')))."</div>";
769 769
 	}
770 770
 }
771 771
 
@@ -781,23 +781,23 @@  discard block
 block discarded – undo
781 781
  * @param array $postarr An array of posts. Not currently used.
782 782
  * @return array The new array of post data after checking for collisions.
783 783
  */
784
-function avoid_blog_page_permalink_collision( $data, $postarr ) {
785
-	if ( is_subdomain_install() )
784
+function avoid_blog_page_permalink_collision($data, $postarr) {
785
+	if (is_subdomain_install())
786 786
 		return $data;
787
-	if ( $data['post_type'] != 'page' )
787
+	if ($data['post_type'] != 'page')
788 788
 		return $data;
789
-	if ( !isset( $data['post_name'] ) || $data['post_name'] == '' )
789
+	if ( ! isset($data['post_name']) || $data['post_name'] == '')
790 790
 		return $data;
791
-	if ( !is_main_site() )
791
+	if ( ! is_main_site())
792 792
 		return $data;
793 793
 
794 794
 	$post_name = $data['post_name'];
795 795
 	$c = 0;
796
-	while( $c < 10 && get_id_from_blogname( $post_name ) ) {
797
-		$post_name .= mt_rand( 1, 10 );
798
-		$c ++;
796
+	while ($c < 10 && get_id_from_blogname($post_name)) {
797
+		$post_name .= mt_rand(1, 10);
798
+		$c++;
799 799
 	}
800
-	if ( $post_name != $data['post_name'] ) {
800
+	if ($post_name != $data['post_name']) {
801 801
 		$data['post_name'] = $post_name;
802 802
 	}
803 803
 	return $data;
@@ -816,31 +816,31 @@  discard block
 block discarded – undo
816 816
 	<table class="form-table">
817 817
 	<tr>
818 818
 	<?php /* translators: My sites label */ ?>
819
-		<th scope="row"><label for="primary_blog"><?php _e( 'Primary Site' ); ?></label></th>
819
+		<th scope="row"><label for="primary_blog"><?php _e('Primary Site'); ?></label></th>
820 820
 		<td>
821 821
 		<?php
822
-		$all_blogs = get_blogs_of_user( get_current_user_id() );
823
-		$primary_blog = get_user_meta( get_current_user_id(), 'primary_blog', true );
824
-		if ( count( $all_blogs ) > 1 ) {
822
+		$all_blogs = get_blogs_of_user(get_current_user_id());
823
+		$primary_blog = get_user_meta(get_current_user_id(), 'primary_blog', true);
824
+		if (count($all_blogs) > 1) {
825 825
 			$found = false;
826 826
 			?>
827 827
 			<select name="primary_blog" id="primary_blog">
828
-				<?php foreach ( (array) $all_blogs as $blog ) {
829
-					if ( $primary_blog == $blog->userblog_id )
828
+				<?php foreach ((array) $all_blogs as $blog) {
829
+					if ($primary_blog == $blog->userblog_id)
830 830
 						$found = true;
831
-					?><option value="<?php echo $blog->userblog_id ?>"<?php selected( $primary_blog, $blog->userblog_id ); ?>><?php echo esc_url( get_home_url( $blog->userblog_id ) ) ?></option><?php
831
+					?><option value="<?php echo $blog->userblog_id ?>"<?php selected($primary_blog, $blog->userblog_id); ?>><?php echo esc_url(get_home_url($blog->userblog_id)) ?></option><?php
832 832
 				} ?>
833 833
 			</select>
834 834
 			<?php
835
-			if ( !$found ) {
836
-				$blog = reset( $all_blogs );
837
-				update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id );
835
+			if ( ! $found) {
836
+				$blog = reset($all_blogs);
837
+				update_user_meta(get_current_user_id(), 'primary_blog', $blog->userblog_id);
838 838
 			}
839
-		} elseif ( count( $all_blogs ) == 1 ) {
840
-			$blog = reset( $all_blogs );
841
-			echo esc_url( get_home_url( $blog->userblog_id ) );
842
-			if ( $primary_blog != $blog->userblog_id ) // Set the primary blog again if it's out of sync with blog list.
843
-				update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id );
839
+		} elseif (count($all_blogs) == 1) {
840
+			$blog = reset($all_blogs);
841
+			echo esc_url(get_home_url($blog->userblog_id));
842
+			if ($primary_blog != $blog->userblog_id) // Set the primary blog again if it's out of sync with blog list.
843
+				update_user_meta(get_current_user_id(), 'primary_blog', $blog->userblog_id);
844 844
 		} else {
845 845
 			echo "N/A";
846 846
 		}
@@ -864,10 +864,10 @@  discard block
 block discarded – undo
864 864
  * @param int $site_id The network/site ID to check.
865 865
  * @return bool True if network can be edited, otherwise false.
866 866
  */
867
-function can_edit_network( $site_id ) {
867
+function can_edit_network($site_id) {
868 868
 	global $wpdb;
869 869
 
870
-	if ( $site_id == $wpdb->siteid )
870
+	if ($site_id == $wpdb->siteid)
871 871
 		$result = true;
872 872
 	else
873 873
 		$result = false;
@@ -880,7 +880,7 @@  discard block
 block discarded – undo
880 880
 	 * @param bool $result  Whether the network can be edited from this page.
881 881
 	 * @param int  $site_id The network/site ID to check.
882 882
 	 */
883
-	return apply_filters( 'can_edit_network', $result, $site_id );
883
+	return apply_filters('can_edit_network', $result, $site_id);
884 884
 }
885 885
 
886 886
 /**
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
 function _thickbox_path_admin_subfolder() {
894 894
 ?>
895 895
 <script type="text/javascript">
896
-var tb_pathToImage = "<?php echo includes_url( 'js/thickbox/loadingAnimation.gif', 'relative' ); ?>";
896
+var tb_pathToImage = "<?php echo includes_url('js/thickbox/loadingAnimation.gif', 'relative'); ?>";
897 897
 </script>
898 898
 <?php
899 899
 }
@@ -902,77 +902,77 @@  discard block
 block discarded – undo
902 902
  *
903 903
  * @param array $users
904 904
  */
905
-function confirm_delete_users( $users ) {
905
+function confirm_delete_users($users) {
906 906
 	$current_user = wp_get_current_user();
907
-	if ( ! is_array( $users ) || empty( $users ) ) {
907
+	if ( ! is_array($users) || empty($users)) {
908 908
 		return false;
909 909
 	}
910 910
 	?>
911
-	<h1><?php esc_html_e( 'Users' ); ?></h1>
911
+	<h1><?php esc_html_e('Users'); ?></h1>
912 912
 
913
-	<?php if ( 1 == count( $users ) ) : ?>
914
-		<p><?php _e( 'You have chosen to delete the user from all networks and sites.' ); ?></p>
913
+	<?php if (1 == count($users)) : ?>
914
+		<p><?php _e('You have chosen to delete the user from all networks and sites.'); ?></p>
915 915
 	<?php else : ?>
916
-		<p><?php _e( 'You have chosen to delete the following users from all networks and sites.' ); ?></p>
916
+		<p><?php _e('You have chosen to delete the following users from all networks and sites.'); ?></p>
917 917
 	<?php endif; ?>
918 918
 
919 919
 	<form action="users.php?action=dodelete" method="post">
920 920
 	<input type="hidden" name="dodelete" />
921 921
 	<?php
922
-	wp_nonce_field( 'ms-users-delete' );
922
+	wp_nonce_field('ms-users-delete');
923 923
 	$site_admins = get_super_admins();
924
-	$admin_out = '<option value="' . esc_attr( $current_user->ID ) . '">' . $current_user->user_login . '</option>'; ?>
924
+	$admin_out = '<option value="'.esc_attr($current_user->ID).'">'.$current_user->user_login.'</option>'; ?>
925 925
 	<table class="form-table">
926
-	<?php foreach ( ( $allusers = (array) $_POST['allusers'] ) as $user_id ) {
927
-		if ( $user_id != '' && $user_id != '0' ) {
928
-			$delete_user = get_userdata( $user_id );
926
+	<?php foreach (($allusers = (array) $_POST['allusers']) as $user_id) {
927
+		if ($user_id != '' && $user_id != '0') {
928
+			$delete_user = get_userdata($user_id);
929 929
 
930
-			if ( ! current_user_can( 'delete_user', $delete_user->ID ) ) {
931
-				wp_die( sprintf( __( 'Warning! User %s cannot be deleted.' ), $delete_user->user_login ) );
930
+			if ( ! current_user_can('delete_user', $delete_user->ID)) {
931
+				wp_die(sprintf(__('Warning! User %s cannot be deleted.'), $delete_user->user_login));
932 932
 			}
933 933
 
934
-			if ( in_array( $delete_user->user_login, $site_admins ) ) {
935
-				wp_die( sprintf( __( 'Warning! User cannot be deleted. The user %s is a network administrator.' ), '<em>' . $delete_user->user_login . '</em>' ) );
934
+			if (in_array($delete_user->user_login, $site_admins)) {
935
+				wp_die(sprintf(__('Warning! User cannot be deleted. The user %s is a network administrator.'), '<em>'.$delete_user->user_login.'</em>'));
936 936
 			}
937 937
 			?>
938 938
 			<tr>
939 939
 				<th scope="row"><?php echo $delete_user->user_login; ?>
940
-					<?php echo '<input type="hidden" name="user[]" value="' . esc_attr( $user_id ) . '" />' . "\n"; ?>
940
+					<?php echo '<input type="hidden" name="user[]" value="'.esc_attr($user_id).'" />'."\n"; ?>
941 941
 				</th>
942
-			<?php $blogs = get_blogs_of_user( $user_id, true );
942
+			<?php $blogs = get_blogs_of_user($user_id, true);
943 943
 
944
-			if ( ! empty( $blogs ) ) {
944
+			if ( ! empty($blogs)) {
945 945
 				?>
946 946
 				<td><fieldset><p><legend><?php printf(
947 947
 					/* translators: user login */
948
-					__( 'What should be done with content owned by %s?' ),
949
-					'<em>' . $delete_user->user_login . '</em>'
948
+					__('What should be done with content owned by %s?'),
949
+					'<em>'.$delete_user->user_login.'</em>'
950 950
 				); ?></legend></p>
951 951
 				<?php
952
-				foreach ( (array) $blogs as $key => $details ) {
953
-					$blog_users = get_users( array( 'blog_id' => $details->userblog_id, 'fields' => array( 'ID', 'user_login' ) ) );
954
-					if ( is_array( $blog_users ) && !empty( $blog_users ) ) {
955
-						$user_site = "<a href='" . esc_url( get_home_url( $details->userblog_id ) ) . "'>{$details->blogname}</a>";
956
-						$user_dropdown = '<label for="reassign_user" class="screen-reader-text">' . __( 'Select a user' ) . '</label>';
952
+				foreach ((array) $blogs as $key => $details) {
953
+					$blog_users = get_users(array('blog_id' => $details->userblog_id, 'fields' => array('ID', 'user_login')));
954
+					if (is_array($blog_users) && ! empty($blog_users)) {
955
+						$user_site = "<a href='".esc_url(get_home_url($details->userblog_id))."'>{$details->blogname}</a>";
956
+						$user_dropdown = '<label for="reassign_user" class="screen-reader-text">'.__('Select a user').'</label>';
957 957
 						$user_dropdown .= "<select name='blog[$user_id][$key]' id='reassign_user'>";
958 958
 						$user_list = '';
959
-						foreach ( $blog_users as $user ) {
960
-							if ( ! in_array( $user->ID, $allusers ) ) {
959
+						foreach ($blog_users as $user) {
960
+							if ( ! in_array($user->ID, $allusers)) {
961 961
 								$user_list .= "<option value='{$user->ID}'>{$user->user_login}</option>";
962 962
 							}
963 963
 						}
964
-						if ( '' == $user_list ) {
964
+						if ('' == $user_list) {
965 965
 							$user_list = $admin_out;
966 966
 						}
967 967
 						$user_dropdown .= $user_list;
968 968
 						$user_dropdown .= "</select>\n";
969 969
 						?>
970 970
 						<ul style="list-style:none;">
971
-							<li><?php printf( __( 'Site: %s' ), $user_site ); ?></li>
972
-							<li><label><input type="radio" id="delete_option0" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="delete" checked="checked" />
973
-							<?php _e( 'Delete all content.' ); ?></label></li>
974
-							<li><label><input type="radio" id="delete_option1" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="reassign" />
975
-							<?php _e( 'Attribute all content to:' ); ?></label>
971
+							<li><?php printf(__('Site: %s'), $user_site); ?></li>
972
+							<li><label><input type="radio" id="delete_option0" name="delete[<?php echo $details->userblog_id.']['.$delete_user->ID ?>]" value="delete" checked="checked" />
973
+							<?php _e('Delete all content.'); ?></label></li>
974
+							<li><label><input type="radio" id="delete_option1" name="delete[<?php echo $details->userblog_id.']['.$delete_user->ID ?>]" value="reassign" />
975
+							<?php _e('Attribute all content to:'); ?></label>
976 976
 							<?php echo $user_dropdown; ?></li>
977 977
 						</ul>
978 978
 						<?php
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
 				echo "</fieldset></td></tr>";
982 982
 			} else {
983 983
 				?>
984
-				<td><fieldset><p><legend><?php _e( 'User has no sites or content and will be deleted.' ); ?></legend></p>
984
+				<td><fieldset><p><legend><?php _e('User has no sites or content and will be deleted.'); ?></legend></p>
985 985
 			<?php } ?>
986 986
 			</tr>
987 987
 		<?php
@@ -992,15 +992,15 @@  discard block
 block discarded – undo
992 992
 	</table>
993 993
 	<?php
994 994
 	/** This action is documented in wp-admin/users.php */
995
-	do_action( 'delete_user_form', $current_user, $allusers );
995
+	do_action('delete_user_form', $current_user, $allusers);
996 996
 
997
-	if ( 1 == count( $users ) ) : ?>
998
-		<p><?php _e( 'Once you hit &#8220;Confirm Deletion&#8221;, the user will be permanently removed.' ); ?></p>
997
+	if (1 == count($users)) : ?>
998
+		<p><?php _e('Once you hit &#8220;Confirm Deletion&#8221;, the user will be permanently removed.'); ?></p>
999 999
 	<?php else : ?>
1000
-		<p><?php _e( 'Once you hit &#8220;Confirm Deletion&#8221;, these users will be permanently removed.' ); ?></p>
1000
+		<p><?php _e('Once you hit &#8220;Confirm Deletion&#8221;, these users will be permanently removed.'); ?></p>
1001 1001
 	<?php endif;
1002 1002
 
1003
-	submit_button( __('Confirm Deletion'), 'primary' );
1003
+	submit_button(__('Confirm Deletion'), 'primary');
1004 1004
 	?>
1005 1005
 	</form>
1006 1006
 	<?php
@@ -1042,7 +1042,7 @@  discard block
 block discarded – undo
1042 1042
  *     @type string  $selected  The ID of the selected link.
1043 1043
  * }
1044 1044
  */
1045
-function network_edit_site_nav( $args = array() ) {
1045
+function network_edit_site_nav($args = array()) {
1046 1046
 
1047 1047
 	/**
1048 1048
 	 * Filters the links that appear on site-editing network pages.
@@ -1063,51 +1063,51 @@  discard block
 block discarded – undo
1063 1063
 	 *     }
1064 1064
 	 * }
1065 1065
 	 */
1066
-	$links = apply_filters( 'network_edit_site_nav_links', array(
1067
-		'site-info'     => array( 'label' => __( 'Info' ),     'url' => 'site-info.php',     'cap' => 'manage_sites' ),
1068
-		'site-users'    => array( 'label' => __( 'Users' ),    'url' => 'site-users.php',    'cap' => 'manage_sites' ),
1069
-		'site-themes'   => array( 'label' => __( 'Themes' ),   'url' => 'site-themes.php',   'cap' => 'manage_sites' ),
1070
-		'site-settings' => array( 'label' => __( 'Settings' ), 'url' => 'site-settings.php', 'cap' => 'manage_sites' )
1071
-	) );
1066
+	$links = apply_filters('network_edit_site_nav_links', array(
1067
+		'site-info'     => array('label' => __('Info'), 'url' => 'site-info.php', 'cap' => 'manage_sites'),
1068
+		'site-users'    => array('label' => __('Users'), 'url' => 'site-users.php', 'cap' => 'manage_sites'),
1069
+		'site-themes'   => array('label' => __('Themes'), 'url' => 'site-themes.php', 'cap' => 'manage_sites'),
1070
+		'site-settings' => array('label' => __('Settings'), 'url' => 'site-settings.php', 'cap' => 'manage_sites')
1071
+	));
1072 1072
 
1073 1073
 	// Parse arguments
1074
-	$r = wp_parse_args( $args, array(
1075
-		'blog_id'  => isset( $_GET['blog_id'] ) ? (int) $_GET['blog_id'] : 0,
1074
+	$r = wp_parse_args($args, array(
1075
+		'blog_id'  => isset($_GET['blog_id']) ? (int) $_GET['blog_id'] : 0,
1076 1076
 		'links'    => $links,
1077 1077
 		'selected' => 'site-info',
1078
-	) );
1078
+	));
1079 1079
 
1080 1080
 	// Setup the links array
1081 1081
 	$screen_links = array();
1082 1082
 
1083 1083
 	// Loop through tabs
1084
-	foreach ( $r['links'] as $link_id => $link ) {
1084
+	foreach ($r['links'] as $link_id => $link) {
1085 1085
 
1086 1086
 		// Skip link if user can't access
1087
-		if ( ! current_user_can( $link['cap'], $r['blog_id'] ) ) {
1087
+		if ( ! current_user_can($link['cap'], $r['blog_id'])) {
1088 1088
 			continue;
1089 1089
 		}
1090 1090
 
1091 1091
 		// Link classes
1092
-		$classes = array( 'nav-tab' );
1092
+		$classes = array('nav-tab');
1093 1093
 
1094 1094
 		// Selected is set by the parent OR assumed by the $pagenow global
1095
-		if ( $r['selected'] === $link_id || $link['url'] === $GLOBALS['pagenow'] ) {
1095
+		if ($r['selected'] === $link_id || $link['url'] === $GLOBALS['pagenow']) {
1096 1096
 			$classes[] = 'nav-tab-active';
1097 1097
 		}
1098 1098
 
1099 1099
 		// Escape each class
1100
-		$esc_classes = implode( ' ', $classes );
1100
+		$esc_classes = implode(' ', $classes);
1101 1101
 
1102 1102
 		// Get the URL for this link
1103
-		$url = add_query_arg( array( 'id' => $r['blog_id'] ), network_admin_url( $link['url'] ) );
1103
+		$url = add_query_arg(array('id' => $r['blog_id']), network_admin_url($link['url']));
1104 1104
 
1105 1105
 		// Add link to nav links
1106
-		$screen_links[ $link_id ] = '<a href="' . esc_url( $url ) . '" id="' . esc_attr( $link_id ) . '" class="' . $esc_classes . '">' . esc_html( $link['label'] ) . '</a>';
1106
+		$screen_links[$link_id] = '<a href="'.esc_url($url).'" id="'.esc_attr($link_id).'" class="'.$esc_classes.'">'.esc_html($link['label']).'</a>';
1107 1107
 	}
1108 1108
 
1109 1109
 	// All done!
1110 1110
 	echo '<h2 class="nav-tab-wrapper wp-clearfix">';
1111
-	echo implode( '', $screen_links );
1111
+	echo implode('', $screen_links);
1112 1112
 	echo '</h2>';
1113 1113
 }
Please login to merge, or discard this patch.
src/wp-admin/includes/nav-menu.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1282,7 +1282,7 @@
 block discarded – undo
1282 1282
  *
1283 1283
  * @param int|string $nav_menu_selected_id (id, slug, or name ) of the currently-selected menu
1284 1284
  * @param string $nav_menu_selected_title Title of the currently-selected menu
1285
- * @return array $messages The menu updated message
1285
+ * @return string[] $messages The menu updated message
1286 1286
  */
1287 1287
 function wp_nav_menu_update_menu_items ( $nav_menu_selected_id, $nav_menu_selected_title ) {
1288 1288
 	$unsorted_menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array( 'orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID', 'post_status' => 'draft,publish' ) );
Please login to merge, or discard this patch.
Spacing   +285 added lines, -285 removed lines patch added patch discarded remove patch
@@ -8,10 +8,10 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 /** Walker_Nav_Menu_Edit class */
11
-require_once( ABSPATH . 'wp-admin/includes/class-walker-nav-menu-edit.php' );
11
+require_once(ABSPATH.'wp-admin/includes/class-walker-nav-menu-edit.php');
12 12
 
13 13
 /** Walker_Nav_Menu_Checklist class */
14
-require_once( ABSPATH . 'wp-admin/includes/class-walker-nav-menu-checklist.php' );
14
+require_once(ABSPATH.'wp-admin/includes/class-walker-nav-menu-checklist.php');
15 15
 
16 16
 /**
17 17
  * Prints the appropriate response to a menu quick search.
@@ -20,41 +20,41 @@  discard block
 block discarded – undo
20 20
  *
21 21
  * @param array $request The unsanitized request values.
22 22
  */
23
-function _wp_ajax_menu_quick_search( $request = array() ) {
23
+function _wp_ajax_menu_quick_search($request = array()) {
24 24
 	$args = array();
25
-	$type = isset( $request['type'] ) ? $request['type'] : '';
26
-	$object_type = isset( $request['object_type'] ) ? $request['object_type'] : '';
27
-	$query = isset( $request['q'] ) ? $request['q'] : '';
28
-	$response_format = isset( $request['response-format'] ) && in_array( $request['response-format'], array( 'json', 'markup' ) ) ? $request['response-format'] : 'json';
25
+	$type = isset($request['type']) ? $request['type'] : '';
26
+	$object_type = isset($request['object_type']) ? $request['object_type'] : '';
27
+	$query = isset($request['q']) ? $request['q'] : '';
28
+	$response_format = isset($request['response-format']) && in_array($request['response-format'], array('json', 'markup')) ? $request['response-format'] : 'json';
29 29
 
30
-	if ( 'markup' == $response_format ) {
30
+	if ('markup' == $response_format) {
31 31
 		$args['walker'] = new Walker_Nav_Menu_Checklist;
32 32
 	}
33 33
 
34
-	if ( 'get-post-item' == $type ) {
35
-		if ( post_type_exists( $object_type ) ) {
36
-			if ( isset( $request['ID'] ) ) {
34
+	if ('get-post-item' == $type) {
35
+		if (post_type_exists($object_type)) {
36
+			if (isset($request['ID'])) {
37 37
 				$object_id = (int) $request['ID'];
38
-				if ( 'markup' == $response_format ) {
39
-					echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_post( $object_id ) ) ), 0, (object) $args );
40
-				} elseif ( 'json' == $response_format ) {
38
+				if ('markup' == $response_format) {
39
+					echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', array(get_post($object_id))), 0, (object) $args);
40
+				} elseif ('json' == $response_format) {
41 41
 					echo wp_json_encode(
42 42
 						array(
43 43
 							'ID' => $object_id,
44
-							'post_title' => get_the_title( $object_id ),
45
-							'post_type' => get_post_type( $object_id ),
44
+							'post_title' => get_the_title($object_id),
45
+							'post_type' => get_post_type($object_id),
46 46
 						)
47 47
 					);
48 48
 					echo "\n";
49 49
 				}
50 50
 			}
51
-		} elseif ( taxonomy_exists( $object_type ) ) {
52
-			if ( isset( $request['ID'] ) ) {
51
+		} elseif (taxonomy_exists($object_type)) {
52
+			if (isset($request['ID'])) {
53 53
 				$object_id = (int) $request['ID'];
54
-				if ( 'markup' == $response_format ) {
55
-					echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_term( $object_id, $object_type ) ) ), 0, (object) $args );
56
-				} elseif ( 'json' == $response_format ) {
57
-					$post_obj = get_term( $object_id, $object_type );
54
+				if ('markup' == $response_format) {
55
+					echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', array(get_term($object_id, $object_type))), 0, (object) $args);
56
+				} elseif ('json' == $response_format) {
57
+					$post_obj = get_term($object_id, $object_type);
58 58
 					echo wp_json_encode(
59 59
 						array(
60 60
 							'ID' => $object_id,
@@ -68,46 +68,46 @@  discard block
 block discarded – undo
68 68
 
69 69
 		}
70 70
 
71
-	} elseif ( preg_match('/quick-search-(posttype|taxonomy)-([a-zA-Z_-]*\b)/', $type, $matches) ) {
72
-		if ( 'posttype' == $matches[1] && get_post_type_object( $matches[2] ) ) {
73
-			$search_results_query = new WP_Query( array(
71
+	} elseif (preg_match('/quick-search-(posttype|taxonomy)-([a-zA-Z_-]*\b)/', $type, $matches)) {
72
+		if ('posttype' == $matches[1] && get_post_type_object($matches[2])) {
73
+			$search_results_query = new WP_Query(array(
74 74
 				'no_found_rows'          => true,
75 75
 				'update_post_meta_cache' => false,
76 76
 				'update_post_term_cache' => false,
77 77
 				'posts_per_page'         => 10,
78 78
 				'post_type'              => $matches[2],
79 79
 				's'                      => $query,
80
-			) );
81
-			if ( ! $search_results_query->have_posts() ) {
80
+			));
81
+			if ( ! $search_results_query->have_posts()) {
82 82
 				return;
83 83
 			}
84
-			while ( $search_results_query->have_posts() ) {
84
+			while ($search_results_query->have_posts()) {
85 85
 				$post = $search_results_query->next_post();
86
-				if ( 'markup' == $response_format ) {
86
+				if ('markup' == $response_format) {
87 87
 					$var_by_ref = $post->ID;
88
-					echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_post( $var_by_ref ) ) ), 0, (object) $args );
89
-				} elseif ( 'json' == $response_format ) {
88
+					echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', array(get_post($var_by_ref))), 0, (object) $args);
89
+				} elseif ('json' == $response_format) {
90 90
 					echo wp_json_encode(
91 91
 						array(
92 92
 							'ID' => $post->ID,
93
-							'post_title' => get_the_title( $post->ID ),
93
+							'post_title' => get_the_title($post->ID),
94 94
 							'post_type' => $matches[2],
95 95
 						)
96 96
 					);
97 97
 					echo "\n";
98 98
 				}
99 99
 			}
100
-		} elseif ( 'taxonomy' == $matches[1] ) {
101
-			$terms = get_terms( $matches[2], array(
100
+		} elseif ('taxonomy' == $matches[1]) {
101
+			$terms = get_terms($matches[2], array(
102 102
 				'name__like' => $query,
103 103
 				'number' => 10,
104 104
 			));
105
-			if ( empty( $terms ) || is_wp_error( $terms ) )
105
+			if (empty($terms) || is_wp_error($terms))
106 106
 				return;
107
-			foreach ( (array) $terms as $term ) {
108
-				if ( 'markup' == $response_format ) {
109
-					echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( $term ) ), 0, (object) $args );
110
-				} elseif ( 'json' == $response_format ) {
107
+			foreach ((array) $terms as $term) {
108
+				if ('markup' == $response_format) {
109
+					echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', array($term)), 0, (object) $args);
110
+				} elseif ('json' == $response_format) {
111 111
 					echo wp_json_encode(
112 112
 						array(
113 113
 							'ID' => $term->term_id,
@@ -130,17 +130,17 @@  discard block
 block discarded – undo
130 130
 function wp_nav_menu_setup() {
131 131
 	// Register meta boxes
132 132
 	wp_nav_menu_post_type_meta_boxes();
133
-	add_meta_box( 'add-custom-links', __( 'Custom Links' ), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' );
133
+	add_meta_box('add-custom-links', __('Custom Links'), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default');
134 134
 	wp_nav_menu_taxonomy_meta_boxes();
135 135
 
136 136
 	// Register advanced menu items (columns)
137
-	add_filter( 'manage_nav-menus_columns', 'wp_nav_menu_manage_columns' );
137
+	add_filter('manage_nav-menus_columns', 'wp_nav_menu_manage_columns');
138 138
 
139 139
 	// If first time editing, disable advanced items by default.
140
-	if ( false === get_user_option( 'managenav-menuscolumnshidden' ) ) {
140
+	if (false === get_user_option('managenav-menuscolumnshidden')) {
141 141
 		$user = wp_get_current_user();
142 142
 		update_user_option($user->ID, 'managenav-menuscolumnshidden',
143
-			array( 0 => 'link-target', 1 => 'css-classes', 2 => 'xfn', 3 => 'description', 4 => 'title-attribute', ),
143
+			array(0 => 'link-target', 1 => 'css-classes', 2 => 'xfn', 3 => 'description', 4 => 'title-attribute',),
144 144
 			true);
145 145
 	}
146 146
 }
@@ -155,17 +155,17 @@  discard block
 block discarded – undo
155 155
 function wp_initial_nav_menu_meta_boxes() {
156 156
 	global $wp_meta_boxes;
157 157
 
158
-	if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array($wp_meta_boxes) )
158
+	if (get_user_option('metaboxhidden_nav-menus') !== false || ! is_array($wp_meta_boxes))
159 159
 		return;
160 160
 
161
-	$initial_meta_boxes = array( 'add-post-type-page', 'add-post-type-post', 'add-custom-links', 'add-category' );
161
+	$initial_meta_boxes = array('add-post-type-page', 'add-post-type-post', 'add-custom-links', 'add-category');
162 162
 	$hidden_meta_boxes = array();
163 163
 
164
-	foreach ( array_keys($wp_meta_boxes['nav-menus']) as $context ) {
165
-		foreach ( array_keys($wp_meta_boxes['nav-menus'][$context]) as $priority ) {
166
-			foreach ( $wp_meta_boxes['nav-menus'][$context][$priority] as $box ) {
167
-				if ( in_array( $box['id'], $initial_meta_boxes ) ) {
168
-					unset( $box['id'] );
164
+	foreach (array_keys($wp_meta_boxes['nav-menus']) as $context) {
165
+		foreach (array_keys($wp_meta_boxes['nav-menus'][$context]) as $priority) {
166
+			foreach ($wp_meta_boxes['nav-menus'][$context][$priority] as $box) {
167
+				if (in_array($box['id'], $initial_meta_boxes)) {
168
+					unset($box['id']);
169 169
 				} else {
170 170
 					$hidden_meta_boxes[] = $box['id'];
171 171
 				}
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	}
175 175
 
176 176
 	$user = wp_get_current_user();
177
-	update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true );
177
+	update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
178 178
 }
179 179
 
180 180
 /**
@@ -183,12 +183,12 @@  discard block
 block discarded – undo
183 183
  * @since 3.0.0
184 184
  */
185 185
 function wp_nav_menu_post_type_meta_boxes() {
186
-	$post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'object' );
186
+	$post_types = get_post_types(array('show_in_nav_menus' => true), 'object');
187 187
 
188
-	if ( ! $post_types )
188
+	if ( ! $post_types)
189 189
 		return;
190 190
 
191
-	foreach ( $post_types as $post_type ) {
191
+	foreach ($post_types as $post_type) {
192 192
 		/**
193 193
 		 * Filters whether a menu items meta box will be added for the current
194 194
 		 * object type.
@@ -201,12 +201,12 @@  discard block
 block discarded – undo
201 201
 		 * @param object $meta_box_object The current object to add a menu items
202 202
 		 *                                meta box for.
203 203
 		 */
204
-		$post_type = apply_filters( 'nav_menu_meta_box_object', $post_type );
205
-		if ( $post_type ) {
204
+		$post_type = apply_filters('nav_menu_meta_box_object', $post_type);
205
+		if ($post_type) {
206 206
 			$id = $post_type->name;
207 207
 			// Give pages a higher priority.
208
-			$priority = ( 'page' == $post_type->name ? 'core' : 'default' );
209
-			add_meta_box( "add-post-type-{$id}", $post_type->labels->name, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', $priority, $post_type );
208
+			$priority = ('page' == $post_type->name ? 'core' : 'default');
209
+			add_meta_box("add-post-type-{$id}", $post_type->labels->name, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', $priority, $post_type);
210 210
 		}
211 211
 	}
212 212
 }
@@ -217,17 +217,17 @@  discard block
 block discarded – undo
217 217
  * @since 3.0.0
218 218
  */
219 219
 function wp_nav_menu_taxonomy_meta_boxes() {
220
-	$taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'object' );
220
+	$taxonomies = get_taxonomies(array('show_in_nav_menus' => true), 'object');
221 221
 
222
-	if ( !$taxonomies )
222
+	if ( ! $taxonomies)
223 223
 		return;
224 224
 
225
-	foreach ( $taxonomies as $tax ) {
225
+	foreach ($taxonomies as $tax) {
226 226
 		/** This filter is documented in wp-admin/includes/nav-menu.php */
227
-		$tax = apply_filters( 'nav_menu_meta_box_object', $tax );
228
-		if ( $tax ) {
227
+		$tax = apply_filters('nav_menu_meta_box_object', $tax);
228
+		if ($tax) {
229 229
 			$id = $tax->name;
230
-			add_meta_box( "add-{$id}", $tax->labels->name, 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax );
230
+			add_meta_box("add-{$id}", $tax->labels->name, 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax);
231 231
 		}
232 232
 	}
233 233
 }
@@ -242,13 +242,13 @@  discard block
 block discarded – undo
242 242
  * @param int|string $nav_menu_selected_id (id, name or slug) of the currently-selected menu
243 243
  * @return string Disabled attribute if at least one menu exists, false if not
244 244
  */
245
-function wp_nav_menu_disabled_check( $nav_menu_selected_id ) {
245
+function wp_nav_menu_disabled_check($nav_menu_selected_id) {
246 246
 	global $one_theme_location_no_menus;
247 247
 
248
-	if ( $one_theme_location_no_menus )
248
+	if ($one_theme_location_no_menus)
249 249
 		return false;
250 250
 
251
-	return disabled( $nav_menu_selected_id, 0 );
251
+	return disabled($nav_menu_selected_id, 0);
252 252
 }
253 253
 
254 254
 /**
@@ -268,18 +268,18 @@  discard block
 block discarded – undo
268 268
 	<div class="customlinkdiv" id="customlinkdiv">
269 269
 		<input type="hidden" value="custom" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-type]" />
270 270
 		<p id="menu-item-url-wrap" class="wp-clearfix">
271
-			<label class="howto" for="custom-menu-item-url"><?php _e( 'URL' ); ?></label>
271
+			<label class="howto" for="custom-menu-item-url"><?php _e('URL'); ?></label>
272 272
 			<input id="custom-menu-item-url" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-url]" type="text" class="code menu-item-textbox" value="http://" />
273 273
 		</p>
274 274
 
275 275
 		<p id="menu-item-name-wrap" class="wp-clearfix">
276
-			<label class="howto" for="custom-menu-item-name"><?php _e( 'Link Text' ); ?></label>
276
+			<label class="howto" for="custom-menu-item-name"><?php _e('Link Text'); ?></label>
277 277
 			<input id="custom-menu-item-name" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-title]" type="text" class="regular-text menu-item-textbox" />
278 278
 		</p>
279 279
 
280 280
 		<p class="button-controls wp-clearfix">
281 281
 			<span class="add-to-menu">
282
-				<input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-custom-menu-item" id="submit-customlinkdiv" />
282
+				<input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-custom-menu-item" id="submit-customlinkdiv" />
283 283
 				<span class="spinner"></span>
284 284
 			</span>
285 285
 		</p>
@@ -299,15 +299,15 @@  discard block
 block discarded – undo
299 299
  * @param string $object Not used.
300 300
  * @param string $post_type The post type object.
301 301
  */
302
-function wp_nav_menu_item_post_type_meta_box( $object, $post_type ) {
302
+function wp_nav_menu_item_post_type_meta_box($object, $post_type) {
303 303
 	global $_nav_menu_placeholder, $nav_menu_selected_id;
304 304
 
305 305
 	$post_type_name = $post_type['args']->name;
306 306
 
307 307
 	// Paginate browsing for large numbers of post objects.
308 308
 	$per_page = 50;
309
-	$pagenum = isset( $_REQUEST[$post_type_name . '-tab'] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1;
310
-	$offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0;
309
+	$pagenum = isset($_REQUEST[$post_type_name.'-tab']) && isset($_REQUEST['paged']) ? absint($_REQUEST['paged']) : 1;
310
+	$offset = 0 < $pagenum ? $per_page * ($pagenum - 1) : 0;
311 311
 
312 312
 	$args = array(
313 313
 		'offset' => $offset,
@@ -320,23 +320,23 @@  discard block
 block discarded – undo
320 320
 		'update_post_meta_cache' => false
321 321
 	);
322 322
 
323
-	if ( isset( $post_type['args']->_default_query ) )
324
-		$args = array_merge($args, (array) $post_type['args']->_default_query );
323
+	if (isset($post_type['args']->_default_query))
324
+		$args = array_merge($args, (array) $post_type['args']->_default_query);
325 325
 
326 326
 	// @todo transient caching of these results with proper invalidation on updating of a post of this type
327 327
 	$get_posts = new WP_Query;
328
-	$posts = $get_posts->query( $args );
329
-	if ( ! $get_posts->post_count ) {
330
-		echo '<p>' . __( 'No items.' ) . '</p>';
328
+	$posts = $get_posts->query($args);
329
+	if ( ! $get_posts->post_count) {
330
+		echo '<p>'.__('No items.').'</p>';
331 331
 		return;
332 332
 	}
333 333
 
334 334
 	$num_pages = $get_posts->max_num_pages;
335 335
 
336
-	$page_links = paginate_links( array(
336
+	$page_links = paginate_links(array(
337 337
 		'base' => add_query_arg(
338 338
 			array(
339
-				$post_type_name . '-tab' => 'all',
339
+				$post_type_name.'-tab' => 'all',
340 340
 				'paged' => '%#%',
341 341
 				'item-type' => 'post_type',
342 342
 				'item-object' => $post_type_name,
@@ -350,18 +350,18 @@  discard block
 block discarded – undo
350 350
 	));
351 351
 
352 352
 	$db_fields = false;
353
-	if ( is_post_type_hierarchical( $post_type_name ) ) {
354
-		$db_fields = array( 'parent' => 'post_parent', 'id' => 'ID' );
353
+	if (is_post_type_hierarchical($post_type_name)) {
354
+		$db_fields = array('parent' => 'post_parent', 'id' => 'ID');
355 355
 	}
356 356
 
357
-	$walker = new Walker_Nav_Menu_Checklist( $db_fields );
357
+	$walker = new Walker_Nav_Menu_Checklist($db_fields);
358 358
 
359 359
 	$current_tab = 'most-recent';
360
-	if ( isset( $_REQUEST[$post_type_name . '-tab'] ) && in_array( $_REQUEST[$post_type_name . '-tab'], array('all', 'search') ) ) {
361
-		$current_tab = $_REQUEST[$post_type_name . '-tab'];
360
+	if (isset($_REQUEST[$post_type_name.'-tab']) && in_array($_REQUEST[$post_type_name.'-tab'], array('all', 'search'))) {
361
+		$current_tab = $_REQUEST[$post_type_name.'-tab'];
362 362
 	}
363 363
 
364
-	if ( ! empty( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) {
364
+	if ( ! empty($_REQUEST['quick-search-posttype-'.$post_type_name])) {
365 365
 		$current_tab = 'search';
366 366
 	}
367 367
 
@@ -377,30 +377,30 @@  discard block
 block discarded – undo
377 377
 	?>
378 378
 	<div id="posttype-<?php echo $post_type_name; ?>" class="posttypediv">
379 379
 		<ul id="posttype-<?php echo $post_type_name; ?>-tabs" class="posttype-tabs add-menu-item-tabs">
380
-			<li <?php echo ( 'most-recent' == $current_tab ? ' class="tabs"' : '' ); ?>>
381
-				<a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-most-recent" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'most-recent', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent">
382
-					<?php _e( 'Most Recent' ); ?>
380
+			<li <?php echo ('most-recent' == $current_tab ? ' class="tabs"' : ''); ?>>
381
+				<a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr($post_type_name); ?>-most-recent" href="<?php if ($nav_menu_selected_id) echo esc_url(add_query_arg($post_type_name.'-tab', 'most-recent', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent">
382
+					<?php _e('Most Recent'); ?>
383 383
 				</a>
384 384
 			</li>
385
-			<li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>>
386
-				<a class="nav-tab-link" data-type="<?php echo esc_attr( $post_type_name ); ?>-all" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'all', remove_query_arg($removed_args))); ?>#<?php echo $post_type_name; ?>-all">
387
-					<?php _e( 'View All' ); ?>
385
+			<li <?php echo ('all' == $current_tab ? ' class="tabs"' : ''); ?>>
386
+				<a class="nav-tab-link" data-type="<?php echo esc_attr($post_type_name); ?>-all" href="<?php if ($nav_menu_selected_id) echo esc_url(add_query_arg($post_type_name.'-tab', 'all', remove_query_arg($removed_args))); ?>#<?php echo $post_type_name; ?>-all">
387
+					<?php _e('View All'); ?>
388 388
 				</a>
389 389
 			</li>
390
-			<li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>>
391
-				<a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-search" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search">
392
-					<?php _e( 'Search'); ?>
390
+			<li <?php echo ('search' == $current_tab ? ' class="tabs"' : ''); ?>>
391
+				<a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr($post_type_name); ?>-search" href="<?php if ($nav_menu_selected_id) echo esc_url(add_query_arg($post_type_name.'-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search">
392
+					<?php _e('Search'); ?>
393 393
 				</a>
394 394
 			</li>
395 395
 		</ul><!-- .posttype-tabs -->
396 396
 
397 397
 		<div id="tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent" class="tabs-panel <?php
398
-			echo ( 'most-recent' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
398
+			echo ('most-recent' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
399 399
 		?>">
400 400
 			<ul id="<?php echo $post_type_name; ?>checklist-most-recent" class="categorychecklist form-no-clear">
401 401
 				<?php
402
-				$recent_args = array_merge( $args, array( 'orderby' => 'post_date', 'order' => 'DESC', 'posts_per_page' => 15 ) );
403
-				$most_recent = $get_posts->query( $recent_args );
402
+				$recent_args = array_merge($args, array('orderby' => 'post_date', 'order' => 'DESC', 'posts_per_page' => 15));
403
+				$most_recent = $get_posts->query($recent_args);
404 404
 				$args['walker'] = $walker;
405 405
 
406 406
 				/**
@@ -415,50 +415,50 @@  discard block
 block discarded – undo
415 415
 				 * @param array  $args        An array of WP_Query arguments.
416 416
 				 * @param object $post_type   The current post type object for this menu item meta box.
417 417
 				 */
418
-				$most_recent = apply_filters( "nav_menu_items_{$post_type_name}_recent", $most_recent, $args, $post_type );
418
+				$most_recent = apply_filters("nav_menu_items_{$post_type_name}_recent", $most_recent, $args, $post_type);
419 419
 
420
-				echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $most_recent), 0, (object) $args );
420
+				echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $most_recent), 0, (object) $args);
421 421
 				?>
422 422
 			</ul>
423 423
 		</div><!-- /.tabs-panel -->
424 424
 
425 425
 		<div class="tabs-panel <?php
426
-			echo ( 'search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
426
+			echo ('search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
427 427
 		?>" id="tabs-panel-posttype-<?php echo $post_type_name; ?>-search">
428 428
 			<?php
429
-			if ( isset( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) {
430
-				$searched = esc_attr( $_REQUEST['quick-search-posttype-' . $post_type_name] );
431
-				$search_results = get_posts( array( 's' => $searched, 'post_type' => $post_type_name, 'fields' => 'all', 'order' => 'DESC', ) );
429
+			if (isset($_REQUEST['quick-search-posttype-'.$post_type_name])) {
430
+				$searched = esc_attr($_REQUEST['quick-search-posttype-'.$post_type_name]);
431
+				$search_results = get_posts(array('s' => $searched, 'post_type' => $post_type_name, 'fields' => 'all', 'order' => 'DESC',));
432 432
 			} else {
433 433
 				$searched = '';
434 434
 				$search_results = array();
435 435
 			}
436 436
 			?>
437 437
 			<p class="quick-search-wrap">
438
-				<label for="quick-search-posttype-<?php echo $post_type_name; ?>" class="screen-reader-text"><?php _e( 'Search' ); ?></label>
438
+				<label for="quick-search-posttype-<?php echo $post_type_name; ?>" class="screen-reader-text"><?php _e('Search'); ?></label>
439 439
 				<input type="search" class="quick-search" value="<?php echo $searched; ?>" name="quick-search-posttype-<?php echo $post_type_name; ?>" id="quick-search-posttype-<?php echo $post_type_name; ?>" />
440 440
 				<span class="spinner"></span>
441
-				<?php submit_button( __( 'Search' ), 'button-small quick-search-submit button-secondary hide-if-js', 'submit', false, array( 'id' => 'submit-quick-search-posttype-' . $post_type_name ) ); ?>
441
+				<?php submit_button(__('Search'), 'button-small quick-search-submit button-secondary hide-if-js', 'submit', false, array('id' => 'submit-quick-search-posttype-'.$post_type_name)); ?>
442 442
 			</p>
443 443
 
444 444
 			<ul id="<?php echo $post_type_name; ?>-search-checklist" data-wp-lists="list:<?php echo $post_type_name?>" class="categorychecklist form-no-clear">
445
-			<?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?>
445
+			<?php if ( ! empty($search_results) && ! is_wp_error($search_results)) : ?>
446 446
 				<?php
447 447
 				$args['walker'] = $walker;
448
-				echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args );
448
+				echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args);
449 449
 				?>
450
-			<?php elseif ( is_wp_error( $search_results ) ) : ?>
450
+			<?php elseif (is_wp_error($search_results)) : ?>
451 451
 				<li><?php echo $search_results->get_error_message(); ?></li>
452
-			<?php elseif ( ! empty( $searched ) ) : ?>
452
+			<?php elseif ( ! empty($searched)) : ?>
453 453
 				<li><?php _e('No results found.'); ?></li>
454 454
 			<?php endif; ?>
455 455
 			</ul>
456 456
 		</div><!-- /.tabs-panel -->
457 457
 
458 458
 		<div id="<?php echo $post_type_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php
459
-			echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
459
+			echo ('all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
460 460
 		?>">
461
-			<?php if ( ! empty( $page_links ) ) : ?>
461
+			<?php if ( ! empty($page_links)) : ?>
462 462
 				<div class="add-menu-item-pagelinks">
463 463
 					<?php echo $page_links; ?>
464 464
 				</div>
@@ -471,15 +471,15 @@  discard block
 block discarded – undo
471 471
 				 * If we're dealing with pages, let's put a checkbox for the front
472 472
 				 * page at the top of the list.
473 473
 				 */
474
-				if ( 'page' == $post_type_name ) {
475
-					$front_page = 'page' == get_option('show_on_front') ? (int) get_option( 'page_on_front' ) : 0;
476
-					if ( ! empty( $front_page ) ) {
477
-						$front_page_obj = get_post( $front_page );
474
+				if ('page' == $post_type_name) {
475
+					$front_page = 'page' == get_option('show_on_front') ? (int) get_option('page_on_front') : 0;
476
+					if ( ! empty($front_page)) {
477
+						$front_page_obj = get_post($front_page);
478 478
 						$front_page_obj->front_or_home = true;
479
-						array_unshift( $posts, $front_page_obj );
479
+						array_unshift($posts, $front_page_obj);
480 480
 					} else {
481
-						$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1;
482
-						array_unshift( $posts, (object) array(
481
+						$_nav_menu_placeholder = (0 > $_nav_menu_placeholder) ? intval($_nav_menu_placeholder) - 1 : -1;
482
+						array_unshift($posts, (object) array(
483 483
 							'front_or_home' => true,
484 484
 							'ID' => 0,
485 485
 							'object_id' => $_nav_menu_placeholder,
@@ -490,15 +490,15 @@  discard block
 block discarded – undo
490 490
 							'post_type' => 'nav_menu_item',
491 491
 							'type' => 'custom',
492 492
 							'url' => home_url('/'),
493
-						) );
493
+						));
494 494
 					}
495 495
 				}
496 496
 
497
-				$post_type = get_post_type_object( $post_type_name );
498
-				$archive_link = get_post_type_archive_link( $post_type_name );
499
-				if ( $post_type->has_archive ) {
500
-					$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1;
501
-					array_unshift( $posts, (object) array(
497
+				$post_type = get_post_type_object($post_type_name);
498
+				$archive_link = get_post_type_archive_link($post_type_name);
499
+				if ($post_type->has_archive) {
500
+					$_nav_menu_placeholder = (0 > $_nav_menu_placeholder) ? intval($_nav_menu_placeholder) - 1 : -1;
501
+					array_unshift($posts, (object) array(
502 502
 						'ID' => 0,
503 503
 						'object_id' => $_nav_menu_placeholder,
504 504
 						'object'     => $post_type_name,
@@ -507,8 +507,8 @@  discard block
 block discarded – undo
507 507
 						'post_title' => $post_type->labels->archives,
508 508
 						'post_type' => 'nav_menu_item',
509 509
 						'type' => 'post_type_archive',
510
-						'url' => get_post_type_archive_link( $post_type_name ),
511
-					) );
510
+						'url' => get_post_type_archive_link($post_type_name),
511
+					));
512 512
 				}
513 513
 
514 514
 				/**
@@ -526,10 +526,10 @@  discard block
 block discarded – undo
526 526
 				 * @param array        $args      An array of WP_Query arguments.
527 527
 				 * @param WP_Post_Type $post_type The current post type object for this menu item meta box.
528 528
 				 */
529
-				$posts = apply_filters( "nav_menu_items_{$post_type_name}", $posts, $args, $post_type );
530
-				$checkbox_items = walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $posts), 0, (object) $args );
529
+				$posts = apply_filters("nav_menu_items_{$post_type_name}", $posts, $args, $post_type);
530
+				$checkbox_items = walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $posts), 0, (object) $args);
531 531
 
532
-				if ( 'all' == $current_tab && ! empty( $_REQUEST['selectall'] ) ) {
532
+				if ('all' == $current_tab && ! empty($_REQUEST['selectall'])) {
533 533
 					$checkbox_items = preg_replace('/(type=(.)checkbox(\2))/', '$1 checked=$2checked$2', $checkbox_items);
534 534
 
535 535
 				}
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 				echo $checkbox_items;
538 538
 				?>
539 539
 			</ul>
540
-			<?php if ( ! empty( $page_links ) ) : ?>
540
+			<?php if ( ! empty($page_links)) : ?>
541 541
 				<div class="add-menu-item-pagelinks">
542 542
 					<?php echo $page_links; ?>
543 543
 				</div>
@@ -547,18 +547,18 @@  discard block
 block discarded – undo
547 547
 		<p class="button-controls wp-clearfix">
548 548
 			<span class="list-controls">
549 549
 				<a href="<?php
550
-					echo esc_url( add_query_arg(
550
+					echo esc_url(add_query_arg(
551 551
 						array(
552
-							$post_type_name . '-tab' => 'all',
552
+							$post_type_name.'-tab' => 'all',
553 553
 							'selectall' => 1,
554 554
 						),
555
-						remove_query_arg( $removed_args )
555
+						remove_query_arg($removed_args)
556 556
 					));
557 557
 				?>#posttype-<?php echo $post_type_name; ?>" class="select-all"><?php _e('Select All'); ?></a>
558 558
 			</span>
559 559
 
560 560
 			<span class="add-to-menu">
561
-				<input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" name="add-post-type-menu-item" id="<?php echo esc_attr( 'submit-posttype-' . $post_type_name ); ?>" />
561
+				<input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-post-type-menu-item" id="<?php echo esc_attr('submit-posttype-'.$post_type_name); ?>" />
562 562
 				<span class="spinner"></span>
563 563
 			</span>
564 564
 		</p>
@@ -577,14 +577,14 @@  discard block
 block discarded – undo
577 577
  * @param string $object Not used.
578 578
  * @param string $taxonomy The taxonomy object.
579 579
  */
580
-function wp_nav_menu_item_taxonomy_meta_box( $object, $taxonomy ) {
580
+function wp_nav_menu_item_taxonomy_meta_box($object, $taxonomy) {
581 581
 	global $nav_menu_selected_id;
582 582
 	$taxonomy_name = $taxonomy['args']->name;
583 583
 
584 584
 	// Paginate browsing for large numbers of objects.
585 585
 	$per_page = 50;
586
-	$pagenum = isset( $_REQUEST[$taxonomy_name . '-tab'] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1;
587
-	$offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0;
586
+	$pagenum = isset($_REQUEST[$taxonomy_name.'-tab']) && isset($_REQUEST['paged']) ? absint($_REQUEST['paged']) : 1;
587
+	$offset = 0 < $pagenum ? $per_page * ($pagenum - 1) : 0;
588 588
 
589 589
 	$args = array(
590 590
 		'child_of' => 0,
@@ -599,19 +599,19 @@  discard block
 block discarded – undo
599 599
 		'pad_counts' => false,
600 600
 	);
601 601
 
602
-	$terms = get_terms( $taxonomy_name, $args );
602
+	$terms = get_terms($taxonomy_name, $args);
603 603
 
604
-	if ( ! $terms || is_wp_error($terms) ) {
605
-		echo '<p>' . __( 'No items.' ) . '</p>';
604
+	if ( ! $terms || is_wp_error($terms)) {
605
+		echo '<p>'.__('No items.').'</p>';
606 606
 		return;
607 607
 	}
608 608
 
609
-	$num_pages = ceil( wp_count_terms( $taxonomy_name , array_merge( $args, array('number' => '', 'offset' => '') ) ) / $per_page );
609
+	$num_pages = ceil(wp_count_terms($taxonomy_name, array_merge($args, array('number' => '', 'offset' => ''))) / $per_page);
610 610
 
611
-	$page_links = paginate_links( array(
611
+	$page_links = paginate_links(array(
612 612
 		'base' => add_query_arg(
613 613
 			array(
614
-				$taxonomy_name . '-tab' => 'all',
614
+				$taxonomy_name.'-tab' => 'all',
615 615
 				'paged' => '%#%',
616 616
 				'item-type' => 'taxonomy',
617 617
 				'item-object' => $taxonomy_name,
@@ -625,18 +625,18 @@  discard block
 block discarded – undo
625 625
 	));
626 626
 
627 627
 	$db_fields = false;
628
-	if ( is_taxonomy_hierarchical( $taxonomy_name ) ) {
629
-		$db_fields = array( 'parent' => 'parent', 'id' => 'term_id' );
628
+	if (is_taxonomy_hierarchical($taxonomy_name)) {
629
+		$db_fields = array('parent' => 'parent', 'id' => 'term_id');
630 630
 	}
631 631
 
632
-	$walker = new Walker_Nav_Menu_Checklist( $db_fields );
632
+	$walker = new Walker_Nav_Menu_Checklist($db_fields);
633 633
 
634 634
 	$current_tab = 'most-used';
635
-	if ( isset( $_REQUEST[$taxonomy_name . '-tab'] ) && in_array( $_REQUEST[$taxonomy_name . '-tab'], array('all', 'most-used', 'search') ) ) {
636
-		$current_tab = $_REQUEST[$taxonomy_name . '-tab'];
635
+	if (isset($_REQUEST[$taxonomy_name.'-tab']) && in_array($_REQUEST[$taxonomy_name.'-tab'], array('all', 'most-used', 'search'))) {
636
+		$current_tab = $_REQUEST[$taxonomy_name.'-tab'];
637 637
 	}
638 638
 
639
-	if ( ! empty( $_REQUEST['quick-search-taxonomy-' . $taxonomy_name] ) ) {
639
+	if ( ! empty($_REQUEST['quick-search-taxonomy-'.$taxonomy_name])) {
640 640
 		$current_tab = 'search';
641 641
 	}
642 642
 
@@ -652,39 +652,39 @@  discard block
 block discarded – undo
652 652
 	?>
653 653
 	<div id="taxonomy-<?php echo $taxonomy_name; ?>" class="taxonomydiv">
654 654
 		<ul id="taxonomy-<?php echo $taxonomy_name; ?>-tabs" class="taxonomy-tabs add-menu-item-tabs">
655
-			<li <?php echo ( 'most-used' == $current_tab ? ' class="tabs"' : '' ); ?>>
656
-				<a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-pop" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'most-used', remove_query_arg($removed_args))); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-pop">
657
-					<?php _e( 'Most Used' ); ?>
655
+			<li <?php echo ('most-used' == $current_tab ? ' class="tabs"' : ''); ?>>
656
+				<a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr($taxonomy_name); ?>-pop" href="<?php if ($nav_menu_selected_id) echo esc_url(add_query_arg($taxonomy_name.'-tab', 'most-used', remove_query_arg($removed_args))); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-pop">
657
+					<?php _e('Most Used'); ?>
658 658
 				</a>
659 659
 			</li>
660
-			<li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>>
661
-				<a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-all" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'all', remove_query_arg($removed_args))); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-all">
662
-					<?php _e( 'View All' ); ?>
660
+			<li <?php echo ('all' == $current_tab ? ' class="tabs"' : ''); ?>>
661
+				<a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr($taxonomy_name); ?>-all" href="<?php if ($nav_menu_selected_id) echo esc_url(add_query_arg($taxonomy_name.'-tab', 'all', remove_query_arg($removed_args))); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-all">
662
+					<?php _e('View All'); ?>
663 663
 				</a>
664 664
 			</li>
665
-			<li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>>
666
-				<a class="nav-tab-link" data-type="tabs-panel-search-taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>">
667
-					<?php _e( 'Search' ); ?>
665
+			<li <?php echo ('search' == $current_tab ? ' class="tabs"' : ''); ?>>
666
+				<a class="nav-tab-link" data-type="tabs-panel-search-taxonomy-<?php echo esc_attr($taxonomy_name); ?>" href="<?php if ($nav_menu_selected_id) echo esc_url(add_query_arg($taxonomy_name.'-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>">
667
+					<?php _e('Search'); ?>
668 668
 				</a>
669 669
 			</li>
670 670
 		</ul><!-- .taxonomy-tabs -->
671 671
 
672 672
 		<div id="tabs-panel-<?php echo $taxonomy_name; ?>-pop" class="tabs-panel <?php
673
-			echo ( 'most-used' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
673
+			echo ('most-used' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
674 674
 		?>">
675 675
 			<ul id="<?php echo $taxonomy_name; ?>checklist-pop" class="categorychecklist form-no-clear" >
676 676
 				<?php
677
-				$popular_terms = get_terms( $taxonomy_name, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) );
677
+				$popular_terms = get_terms($taxonomy_name, array('orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false));
678 678
 				$args['walker'] = $walker;
679
-				echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $popular_terms), 0, (object) $args );
679
+				echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $popular_terms), 0, (object) $args);
680 680
 				?>
681 681
 			</ul>
682 682
 		</div><!-- /.tabs-panel -->
683 683
 
684 684
 		<div id="tabs-panel-<?php echo $taxonomy_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php
685
-			echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
685
+			echo ('all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
686 686
 		?>">
687
-			<?php if ( ! empty( $page_links ) ) : ?>
687
+			<?php if ( ! empty($page_links)) : ?>
688 688
 				<div class="add-menu-item-pagelinks">
689 689
 					<?php echo $page_links; ?>
690 690
 				</div>
@@ -692,10 +692,10 @@  discard block
 block discarded – undo
692 692
 			<ul id="<?php echo $taxonomy_name; ?>checklist" data-wp-lists="list:<?php echo $taxonomy_name?>" class="categorychecklist form-no-clear">
693 693
 				<?php
694 694
 				$args['walker'] = $walker;
695
-				echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $terms), 0, (object) $args );
695
+				echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $terms), 0, (object) $args);
696 696
 				?>
697 697
 			</ul>
698
-			<?php if ( ! empty( $page_links ) ) : ?>
698
+			<?php if ( ! empty($page_links)) : ?>
699 699
 				<div class="add-menu-item-pagelinks">
700 700
 					<?php echo $page_links; ?>
701 701
 				</div>
@@ -703,33 +703,33 @@  discard block
 block discarded – undo
703 703
 		</div><!-- /.tabs-panel -->
704 704
 
705 705
 		<div class="tabs-panel <?php
706
-			echo ( 'search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
706
+			echo ('search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
707 707
 		?>" id="tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>">
708 708
 			<?php
709
-			if ( isset( $_REQUEST['quick-search-taxonomy-' . $taxonomy_name] ) ) {
710
-				$searched = esc_attr( $_REQUEST['quick-search-taxonomy-' . $taxonomy_name] );
711
-				$search_results = get_terms( $taxonomy_name, array( 'name__like' => $searched, 'fields' => 'all', 'orderby' => 'count', 'order' => 'DESC', 'hierarchical' => false ) );
709
+			if (isset($_REQUEST['quick-search-taxonomy-'.$taxonomy_name])) {
710
+				$searched = esc_attr($_REQUEST['quick-search-taxonomy-'.$taxonomy_name]);
711
+				$search_results = get_terms($taxonomy_name, array('name__like' => $searched, 'fields' => 'all', 'orderby' => 'count', 'order' => 'DESC', 'hierarchical' => false));
712 712
 			} else {
713 713
 				$searched = '';
714 714
 				$search_results = array();
715 715
 			}
716 716
 			?>
717 717
 			<p class="quick-search-wrap">
718
-				<label for="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" class="screen-reader-text"><?php _e( 'Search' ); ?></label>
718
+				<label for="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" class="screen-reader-text"><?php _e('Search'); ?></label>
719 719
 				<input type="search" class="quick-search" value="<?php echo $searched; ?>" name="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" id="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" />
720 720
 				<span class="spinner"></span>
721
-				<?php submit_button( __( 'Search' ), 'button-small quick-search-submit button-secondary hide-if-js', 'submit', false, array( 'id' => 'submit-quick-search-taxonomy-' . $taxonomy_name ) ); ?>
721
+				<?php submit_button(__('Search'), 'button-small quick-search-submit button-secondary hide-if-js', 'submit', false, array('id' => 'submit-quick-search-taxonomy-'.$taxonomy_name)); ?>
722 722
 			</p>
723 723
 
724 724
 			<ul id="<?php echo $taxonomy_name; ?>-search-checklist" data-wp-lists="list:<?php echo $taxonomy_name?>" class="categorychecklist form-no-clear">
725
-			<?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?>
725
+			<?php if ( ! empty($search_results) && ! is_wp_error($search_results)) : ?>
726 726
 				<?php
727 727
 				$args['walker'] = $walker;
728
-				echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args );
728
+				echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args);
729 729
 				?>
730
-			<?php elseif ( is_wp_error( $search_results ) ) : ?>
730
+			<?php elseif (is_wp_error($search_results)) : ?>
731 731
 				<li><?php echo $search_results->get_error_message(); ?></li>
732
-			<?php elseif ( ! empty( $searched ) ) : ?>
732
+			<?php elseif ( ! empty($searched)) : ?>
733 733
 				<li><?php _e('No results found.'); ?></li>
734 734
 			<?php endif; ?>
735 735
 			</ul>
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
 				<a href="<?php
741 741
 					echo esc_url(add_query_arg(
742 742
 						array(
743
-							$taxonomy_name . '-tab' => 'all',
743
+							$taxonomy_name.'-tab' => 'all',
744 744
 							'selectall' => 1,
745 745
 						),
746 746
 						remove_query_arg($removed_args)
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
 			</span>
750 750
 
751 751
 			<span class="add-to-menu">
752
-				<input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" name="add-taxonomy-menu-item" id="<?php echo esc_attr( 'submit-taxonomy-' . $taxonomy_name ); ?>" />
752
+				<input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-taxonomy-menu-item" id="<?php echo esc_attr('submit-taxonomy-'.$taxonomy_name); ?>" />
753 753
 				<span class="spinner"></span>
754 754
 			</span>
755 755
 		</p>
@@ -767,25 +767,25 @@  discard block
 block discarded – undo
767 767
  * @param array $menu_data The unsanitized posted menu item data.
768 768
  * @return array The database IDs of the items saved
769 769
  */
770
-function wp_save_nav_menu_items( $menu_id = 0, $menu_data = array() ) {
770
+function wp_save_nav_menu_items($menu_id = 0, $menu_data = array()) {
771 771
 	$menu_id = (int) $menu_id;
772 772
 	$items_saved = array();
773 773
 
774
-	if ( 0 == $menu_id || is_nav_menu( $menu_id ) ) {
774
+	if (0 == $menu_id || is_nav_menu($menu_id)) {
775 775
 
776 776
 		// Loop through all the menu items' POST values.
777
-		foreach ( (array) $menu_data as $_possible_db_id => $_item_object_data ) {
777
+		foreach ((array) $menu_data as $_possible_db_id => $_item_object_data) {
778 778
 			if (
779 779
 				// Checkbox is not checked.
780
-				empty( $_item_object_data['menu-item-object-id'] ) &&
780
+				empty($_item_object_data['menu-item-object-id']) &&
781 781
 				(
782 782
 					// And item type either isn't set.
783
-					! isset( $_item_object_data['menu-item-type'] ) ||
783
+					! isset($_item_object_data['menu-item-type']) ||
784 784
 					// Or URL is the default.
785
-					in_array( $_item_object_data['menu-item-url'], array( 'http://', '' ) ) ||
786
-					! ( 'custom' == $_item_object_data['menu-item-type'] && ! isset( $_item_object_data['menu-item-db-id'] ) ) || // or it's not a custom menu item (but not the custom home page)
785
+					in_array($_item_object_data['menu-item-url'], array('http://', '')) ||
786
+					! ('custom' == $_item_object_data['menu-item-type'] && ! isset($_item_object_data['menu-item-db-id'])) || // or it's not a custom menu item (but not the custom home page)
787 787
 					// Or it *is* a custom menu item that already exists.
788
-					! empty( $_item_object_data['menu-item-db-id'] )
788
+					! empty($_item_object_data['menu-item-db-id'])
789 789
 				)
790 790
 			) {
791 791
 				// Then this potential menu item is not getting added to this menu.
@@ -794,8 +794,8 @@  discard block
 block discarded – undo
794 794
 
795 795
 			// If this possible menu item doesn't actually have a menu database ID yet.
796 796
 			if (
797
-				empty( $_item_object_data['menu-item-db-id'] ) ||
798
-				( 0 > $_possible_db_id ) ||
797
+				empty($_item_object_data['menu-item-db-id']) ||
798
+				(0 > $_possible_db_id) ||
799 799
 				$_possible_db_id != $_item_object_data['menu-item-db-id']
800 800
 			) {
801 801
 				$_actual_db_id = 0;
@@ -804,22 +804,22 @@  discard block
 block discarded – undo
804 804
 			}
805 805
 
806 806
 			$args = array(
807
-				'menu-item-db-id' => ( isset( $_item_object_data['menu-item-db-id'] ) ? $_item_object_data['menu-item-db-id'] : '' ),
808
-				'menu-item-object-id' => ( isset( $_item_object_data['menu-item-object-id'] ) ? $_item_object_data['menu-item-object-id'] : '' ),
809
-				'menu-item-object' => ( isset( $_item_object_data['menu-item-object'] ) ? $_item_object_data['menu-item-object'] : '' ),
810
-				'menu-item-parent-id' => ( isset( $_item_object_data['menu-item-parent-id'] ) ? $_item_object_data['menu-item-parent-id'] : '' ),
811
-				'menu-item-position' => ( isset( $_item_object_data['menu-item-position'] ) ? $_item_object_data['menu-item-position'] : '' ),
812
-				'menu-item-type' => ( isset( $_item_object_data['menu-item-type'] ) ? $_item_object_data['menu-item-type'] : '' ),
813
-				'menu-item-title' => ( isset( $_item_object_data['menu-item-title'] ) ? $_item_object_data['menu-item-title'] : '' ),
814
-				'menu-item-url' => ( isset( $_item_object_data['menu-item-url'] ) ? $_item_object_data['menu-item-url'] : '' ),
815
-				'menu-item-description' => ( isset( $_item_object_data['menu-item-description'] ) ? $_item_object_data['menu-item-description'] : '' ),
816
-				'menu-item-attr-title' => ( isset( $_item_object_data['menu-item-attr-title'] ) ? $_item_object_data['menu-item-attr-title'] : '' ),
817
-				'menu-item-target' => ( isset( $_item_object_data['menu-item-target'] ) ? $_item_object_data['menu-item-target'] : '' ),
818
-				'menu-item-classes' => ( isset( $_item_object_data['menu-item-classes'] ) ? $_item_object_data['menu-item-classes'] : '' ),
819
-				'menu-item-xfn' => ( isset( $_item_object_data['menu-item-xfn'] ) ? $_item_object_data['menu-item-xfn'] : '' ),
807
+				'menu-item-db-id' => (isset($_item_object_data['menu-item-db-id']) ? $_item_object_data['menu-item-db-id'] : ''),
808
+				'menu-item-object-id' => (isset($_item_object_data['menu-item-object-id']) ? $_item_object_data['menu-item-object-id'] : ''),
809
+				'menu-item-object' => (isset($_item_object_data['menu-item-object']) ? $_item_object_data['menu-item-object'] : ''),
810
+				'menu-item-parent-id' => (isset($_item_object_data['menu-item-parent-id']) ? $_item_object_data['menu-item-parent-id'] : ''),
811
+				'menu-item-position' => (isset($_item_object_data['menu-item-position']) ? $_item_object_data['menu-item-position'] : ''),
812
+				'menu-item-type' => (isset($_item_object_data['menu-item-type']) ? $_item_object_data['menu-item-type'] : ''),
813
+				'menu-item-title' => (isset($_item_object_data['menu-item-title']) ? $_item_object_data['menu-item-title'] : ''),
814
+				'menu-item-url' => (isset($_item_object_data['menu-item-url']) ? $_item_object_data['menu-item-url'] : ''),
815
+				'menu-item-description' => (isset($_item_object_data['menu-item-description']) ? $_item_object_data['menu-item-description'] : ''),
816
+				'menu-item-attr-title' => (isset($_item_object_data['menu-item-attr-title']) ? $_item_object_data['menu-item-attr-title'] : ''),
817
+				'menu-item-target' => (isset($_item_object_data['menu-item-target']) ? $_item_object_data['menu-item-target'] : ''),
818
+				'menu-item-classes' => (isset($_item_object_data['menu-item-classes']) ? $_item_object_data['menu-item-classes'] : ''),
819
+				'menu-item-xfn' => (isset($_item_object_data['menu-item-xfn']) ? $_item_object_data['menu-item-xfn'] : ''),
820 820
 			);
821 821
 
822
-			$items_saved[] = wp_update_nav_menu_item( $menu_id, $_actual_db_id, $args );
822
+			$items_saved[] = wp_update_nav_menu_item($menu_id, $_actual_db_id, $args);
823 823
 
824 824
 		}
825 825
 	}
@@ -836,23 +836,23 @@  discard block
 block discarded – undo
836 836
  * @param object $object The post type or taxonomy meta-object.
837 837
  * @return object The post type of taxonomy object.
838 838
  */
839
-function _wp_nav_menu_meta_box_object( $object = null ) {
840
-	if ( isset( $object->name ) ) {
839
+function _wp_nav_menu_meta_box_object($object = null) {
840
+	if (isset($object->name)) {
841 841
 
842
-		if ( 'page' == $object->name ) {
842
+		if ('page' == $object->name) {
843 843
 			$object->_default_query = array(
844 844
 				'orderby' => 'menu_order title',
845 845
 				'post_status' => 'publish',
846 846
 			);
847 847
 
848 848
 		// Posts should show only published items.
849
-		} elseif ( 'post' == $object->name ) {
849
+		} elseif ('post' == $object->name) {
850 850
 			$object->_default_query = array(
851 851
 				'post_status' => 'publish',
852 852
 			);
853 853
 
854 854
 		// Categories should be in reverse chronological order.
855
-		} elseif ( 'category' == $object->name ) {
855
+		} elseif ('category' == $object->name) {
856 856
 			$object->_default_query = array(
857 857
 				'orderby' => 'id',
858 858
 				'order' => 'DESC',
@@ -877,19 +877,19 @@  discard block
 block discarded – undo
877 877
  * @param int $menu_id Optional. The ID of the menu to format. Default 0.
878 878
  * @return string|WP_Error $output The menu formatted to edit or error object on failure.
879 879
  */
880
-function wp_get_nav_menu_to_edit( $menu_id = 0 ) {
881
-	$menu = wp_get_nav_menu_object( $menu_id );
880
+function wp_get_nav_menu_to_edit($menu_id = 0) {
881
+	$menu = wp_get_nav_menu_object($menu_id);
882 882
 
883 883
 	// If the menu exists, get its items.
884
-	if ( is_nav_menu( $menu ) ) {
885
-		$menu_items = wp_get_nav_menu_items( $menu->term_id, array('post_status' => 'any') );
884
+	if (is_nav_menu($menu)) {
885
+		$menu_items = wp_get_nav_menu_items($menu->term_id, array('post_status' => 'any'));
886 886
 		$result = '<div id="menu-instructions" class="post-body-plain';
887
-		$result .= ( ! empty($menu_items) ) ? ' menu-instructions-inactive">' : '">';
888
-		$result .= '<p>' . __( 'Add menu items from the column on the left.' ) . '</p>';
887
+		$result .= ( ! empty($menu_items)) ? ' menu-instructions-inactive">' : '">';
888
+		$result .= '<p>'.__('Add menu items from the column on the left.').'</p>';
889 889
 		$result .= '</div>';
890 890
 
891
-		if ( empty($menu_items) )
892
-			return $result . ' <ul class="menu" id="menu-to-edit"> </ul>';
891
+		if (empty($menu_items))
892
+			return $result.' <ul class="menu" id="menu-to-edit"> </ul>';
893 893
 
894 894
 		/**
895 895
 		 * Filters the Walker class used when adding nav menu items.
@@ -899,40 +899,40 @@  discard block
 block discarded – undo
899 899
 		 * @param string $class   The walker class to use. Default 'Walker_Nav_Menu_Edit'.
900 900
 		 * @param int    $menu_id ID of the menu being rendered.
901 901
 		 */
902
-		$walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id );
902
+		$walker_class_name = apply_filters('wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id);
903 903
 
904
-		if ( class_exists( $walker_class_name ) ) {
904
+		if (class_exists($walker_class_name)) {
905 905
 			$walker = new $walker_class_name;
906 906
 		} else {
907
-			return new WP_Error( 'menu_walker_not_exist',
907
+			return new WP_Error('menu_walker_not_exist',
908 908
 				/* translators: %s: walker class name */
909
-				sprintf( __( 'The Walker class named %s does not exist.' ),
910
-					'<strong>' . $walker_class_name . '</strong>'
909
+				sprintf(__('The Walker class named %s does not exist.'),
910
+					'<strong>'.$walker_class_name.'</strong>'
911 911
 				)
912 912
 			);
913 913
 		}
914 914
 
915 915
 		$some_pending_menu_items = $some_invalid_menu_items = false;
916
-		foreach ( (array) $menu_items as $menu_item ) {
917
-			if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status )
916
+		foreach ((array) $menu_items as $menu_item) {
917
+			if (isset($menu_item->post_status) && 'draft' == $menu_item->post_status)
918 918
 				$some_pending_menu_items = true;
919
-			if ( ! empty( $menu_item->_invalid ) )
919
+			if ( ! empty($menu_item->_invalid))
920 920
 				$some_invalid_menu_items = true;
921 921
 		}
922 922
 
923
-		if ( $some_pending_menu_items ) {
924
-			$result .= '<div class="notice notice-info notice-alt inline"><p>' . __( 'Click Save Menu to make pending menu items public.' ) . '</p></div>';
923
+		if ($some_pending_menu_items) {
924
+			$result .= '<div class="notice notice-info notice-alt inline"><p>'.__('Click Save Menu to make pending menu items public.').'</p></div>';
925 925
 		}
926 926
 
927
-		if ( $some_invalid_menu_items ) {
928
-			$result .= '<div class="notice notice-error notice-alt inline"><p>' . __( 'There are some invalid menu items. Please check or delete them.' ) . '</p></div>';
927
+		if ($some_invalid_menu_items) {
928
+			$result .= '<div class="notice notice-error notice-alt inline"><p>'.__('There are some invalid menu items. Please check or delete them.').'</p></div>';
929 929
 		}
930 930
 
931 931
 		$result .= '<ul class="menu" id="menu-to-edit"> ';
932
-		$result .= walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $menu_items), 0, (object) array('walker' => $walker ) );
932
+		$result .= walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $menu_items), 0, (object) array('walker' => $walker));
933 933
 		$result .= ' </ul> ';
934 934
 		return $result;
935
-	} elseif ( is_wp_error( $menu ) ) {
935
+	} elseif (is_wp_error($menu)) {
936 936
 		return $menu;
937 937
 	}
938 938
 
@@ -947,13 +947,13 @@  discard block
 block discarded – undo
947 947
  */
948 948
 function wp_nav_menu_manage_columns() {
949 949
 	return array(
950
-		'_title'          => __( 'Show advanced menu properties' ),
950
+		'_title'          => __('Show advanced menu properties'),
951 951
 		'cb'              => '<input type="checkbox" />',
952
-		'link-target'     => __( 'Link Target' ),
953
-		'title-attribute' => __( 'Title Attribute' ),
954
-		'css-classes'     => __( 'CSS Classes' ),
955
-		'xfn'             => __( 'Link Relationship (XFN)' ),
956
-		'description'     => __( 'Description' ),
952
+		'link-target'     => __('Link Target'),
953
+		'title-attribute' => __('Title Attribute'),
954
+		'css-classes'     => __('CSS Classes'),
955
+		'xfn'             => __('Link Relationship (XFN)'),
956
+		'description'     => __('Description'),
957 957
 	);
958 958
 }
959 959
 
@@ -967,13 +967,13 @@  discard block
 block discarded – undo
967 967
  */
968 968
 function _wp_delete_orphaned_draft_menu_items() {
969 969
 	global $wpdb;
970
-	$delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
970
+	$delete_timestamp = time() - (DAY_IN_SECONDS * EMPTY_TRASH_DAYS);
971 971
 
972 972
 	// Delete orphaned draft menu items.
973
-	$menu_items_to_delete = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type = 'nav_menu_item' AND post_status = 'draft' AND meta_key = '_menu_item_orphaned' AND meta_value < '%d'", $delete_timestamp ) );
973
+	$menu_items_to_delete = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type = 'nav_menu_item' AND post_status = 'draft' AND meta_key = '_menu_item_orphaned' AND meta_value < '%d'", $delete_timestamp));
974 974
 
975
-	foreach ( (array) $menu_items_to_delete as $menu_item_id )
976
-		wp_delete_post( $menu_item_id, true );
975
+	foreach ((array) $menu_items_to_delete as $menu_item_id)
976
+		wp_delete_post($menu_item_id, true);
977 977
 }
978 978
 
979 979
 /**
@@ -985,12 +985,12 @@  discard block
 block discarded – undo
985 985
  * @param string $nav_menu_selected_title Title of the currently-selected menu
986 986
  * @return array $messages The menu updated message
987 987
  */
988
-function wp_nav_menu_update_menu_items ( $nav_menu_selected_id, $nav_menu_selected_title ) {
989
-	$unsorted_menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array( 'orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID', 'post_status' => 'draft,publish' ) );
988
+function wp_nav_menu_update_menu_items($nav_menu_selected_id, $nav_menu_selected_title) {
989
+	$unsorted_menu_items = wp_get_nav_menu_items($nav_menu_selected_id, array('orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID', 'post_status' => 'draft,publish'));
990 990
 	$messages = array();
991 991
 	$menu_items = array();
992 992
 	// Index menu items by db ID
993
-	foreach ( $unsorted_menu_items as $_item )
993
+	foreach ($unsorted_menu_items as $_item)
994 994
 		$menu_items[$_item->db_id] = $_item;
995 995
 
996 996
 	$post_fields = array(
@@ -1000,66 +1000,66 @@  discard block
 block discarded – undo
1000 1000
 		'menu-item-attr-title', 'menu-item-target', 'menu-item-classes', 'menu-item-xfn'
1001 1001
 	);
1002 1002
 
1003
-	wp_defer_term_counting( true );
1003
+	wp_defer_term_counting(true);
1004 1004
 	// Loop through all the menu items' POST variables
1005
-	if ( ! empty( $_POST['menu-item-db-id'] ) ) {
1006
-		foreach ( (array) $_POST['menu-item-db-id'] as $_key => $k ) {
1005
+	if ( ! empty($_POST['menu-item-db-id'])) {
1006
+		foreach ((array) $_POST['menu-item-db-id'] as $_key => $k) {
1007 1007
 
1008 1008
 			// Menu item title can't be blank
1009
-			if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] )
1009
+			if ( ! isset($_POST['menu-item-title'][$_key]) || '' == $_POST['menu-item-title'][$_key])
1010 1010
 				continue;
1011 1011
 
1012 1012
 			$args = array();
1013
-			foreach ( $post_fields as $field )
1014
-				$args[$field] = isset( $_POST[$field][$_key] ) ? $_POST[$field][$_key] : '';
1013
+			foreach ($post_fields as $field)
1014
+				$args[$field] = isset($_POST[$field][$_key]) ? $_POST[$field][$_key] : '';
1015 1015
 
1016
-			$menu_item_db_id = wp_update_nav_menu_item( $nav_menu_selected_id, ( $_POST['menu-item-db-id'][$_key] != $_key ? 0 : $_key ), $args );
1016
+			$menu_item_db_id = wp_update_nav_menu_item($nav_menu_selected_id, ($_POST['menu-item-db-id'][$_key] != $_key ? 0 : $_key), $args);
1017 1017
 
1018
-			if ( is_wp_error( $menu_item_db_id ) ) {
1019
-				$messages[] = '<div id="message" class="error"><p>' . $menu_item_db_id->get_error_message() . '</p></div>';
1018
+			if (is_wp_error($menu_item_db_id)) {
1019
+				$messages[] = '<div id="message" class="error"><p>'.$menu_item_db_id->get_error_message().'</p></div>';
1020 1020
 			} else {
1021
-				unset( $menu_items[ $menu_item_db_id ] );
1021
+				unset($menu_items[$menu_item_db_id]);
1022 1022
 			}
1023 1023
 		}
1024 1024
 	}
1025 1025
 
1026 1026
 	// Remove menu items from the menu that weren't in $_POST
1027
-	if ( ! empty( $menu_items ) ) {
1028
-		foreach ( array_keys( $menu_items ) as $menu_item_id ) {
1029
-			if ( is_nav_menu_item( $menu_item_id ) ) {
1030
-				wp_delete_post( $menu_item_id );
1027
+	if ( ! empty($menu_items)) {
1028
+		foreach (array_keys($menu_items) as $menu_item_id) {
1029
+			if (is_nav_menu_item($menu_item_id)) {
1030
+				wp_delete_post($menu_item_id);
1031 1031
 			}
1032 1032
 		}
1033 1033
 	}
1034 1034
 
1035 1035
 	// Store 'auto-add' pages.
1036
-	$auto_add = ! empty( $_POST['auto-add-pages'] );
1037
-	$nav_menu_option = (array) get_option( 'nav_menu_options' );
1038
-	if ( ! isset( $nav_menu_option['auto_add'] ) )
1036
+	$auto_add = ! empty($_POST['auto-add-pages']);
1037
+	$nav_menu_option = (array) get_option('nav_menu_options');
1038
+	if ( ! isset($nav_menu_option['auto_add']))
1039 1039
 		$nav_menu_option['auto_add'] = array();
1040
-	if ( $auto_add ) {
1041
-		if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) )
1040
+	if ($auto_add) {
1041
+		if ( ! in_array($nav_menu_selected_id, $nav_menu_option['auto_add']))
1042 1042
 			$nav_menu_option['auto_add'][] = $nav_menu_selected_id;
1043 1043
 	} else {
1044
-		if ( false !== ( $key = array_search( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) )
1045
-			unset( $nav_menu_option['auto_add'][$key] );
1044
+		if (false !== ($key = array_search($nav_menu_selected_id, $nav_menu_option['auto_add'])))
1045
+			unset($nav_menu_option['auto_add'][$key]);
1046 1046
 	}
1047 1047
 	// Remove nonexistent/deleted menus
1048
-	$nav_menu_option['auto_add'] = array_intersect( $nav_menu_option['auto_add'], wp_get_nav_menus( array( 'fields' => 'ids' ) ) );
1049
-	update_option( 'nav_menu_options', $nav_menu_option );
1048
+	$nav_menu_option['auto_add'] = array_intersect($nav_menu_option['auto_add'], wp_get_nav_menus(array('fields' => 'ids')));
1049
+	update_option('nav_menu_options', $nav_menu_option);
1050 1050
 
1051
-	wp_defer_term_counting( false );
1051
+	wp_defer_term_counting(false);
1052 1052
 
1053 1053
 	/** This action is documented in wp-includes/nav-menu.php */
1054
-	do_action( 'wp_update_nav_menu', $nav_menu_selected_id );
1054
+	do_action('wp_update_nav_menu', $nav_menu_selected_id);
1055 1055
 
1056
-	$messages[] = '<div id="message" class="updated notice is-dismissible"><p>' .
1056
+	$messages[] = '<div id="message" class="updated notice is-dismissible"><p>'.
1057 1057
 		/* translators: %s: nav menu title */
1058
-		sprintf( __( '%s has been updated.' ),
1059
-			'<strong>' . $nav_menu_selected_title . '</strong>'
1060
-		) . '</p></div>';
1058
+		sprintf(__('%s has been updated.'),
1059
+			'<strong>'.$nav_menu_selected_title.'</strong>'
1060
+		).'</p></div>';
1061 1061
 
1062
-	unset( $menu_items, $unsorted_menu_items );
1062
+	unset($menu_items, $unsorted_menu_items);
1063 1063
 
1064 1064
 	return $messages;
1065 1065
 }
@@ -1073,36 +1073,36 @@  discard block
 block discarded – undo
1073 1073
  * @access private
1074 1074
  */
1075 1075
 function _wp_expand_nav_menu_post_data() {
1076
-	if ( ! isset( $_POST['nav-menu-data'] ) ) {
1076
+	if ( ! isset($_POST['nav-menu-data'])) {
1077 1077
 		return;
1078 1078
 	}
1079 1079
 
1080
-	$data = json_decode( stripslashes( $_POST['nav-menu-data'] ) );
1080
+	$data = json_decode(stripslashes($_POST['nav-menu-data']));
1081 1081
 
1082
-	if ( ! is_null( $data ) && $data ) {
1083
-		foreach ( $data as $post_input_data ) {
1082
+	if ( ! is_null($data) && $data) {
1083
+		foreach ($data as $post_input_data) {
1084 1084
 			// For input names that are arrays (e.g. `menu-item-db-id[3][4][5]`),
1085 1085
 			// derive the array path keys via regex and set the value in $_POST.
1086
-			preg_match( '#([^\[]*)(\[(.+)\])?#', $post_input_data->name, $matches );
1086
+			preg_match('#([^\[]*)(\[(.+)\])?#', $post_input_data->name, $matches);
1087 1087
 
1088
-			$array_bits = array( $matches[1] );
1088
+			$array_bits = array($matches[1]);
1089 1089
 
1090
-			if ( isset( $matches[3] ) ) {
1091
-				$array_bits = array_merge( $array_bits, explode( '][', $matches[3] ) );
1090
+			if (isset($matches[3])) {
1091
+				$array_bits = array_merge($array_bits, explode('][', $matches[3]));
1092 1092
 			}
1093 1093
 
1094 1094
 			$new_post_data = array();
1095 1095
 
1096 1096
 			// Build the new array value from leaf to trunk.
1097
-			for ( $i = count( $array_bits ) - 1; $i >= 0; $i -- ) {
1098
-				if ( $i == count( $array_bits ) - 1 ) {
1099
-					$new_post_data[ $array_bits[ $i ] ] = wp_slash( $post_input_data->value );
1097
+			for ($i = count($array_bits) - 1; $i >= 0; $i--) {
1098
+				if ($i == count($array_bits) - 1) {
1099
+					$new_post_data[$array_bits[$i]] = wp_slash($post_input_data->value);
1100 1100
 				} else {
1101
-					$new_post_data = array( $array_bits[ $i ] => $new_post_data );
1101
+					$new_post_data = array($array_bits[$i] => $new_post_data);
1102 1102
 				}
1103 1103
 			}
1104 1104
 
1105
-			$_POST = array_replace_recursive( $_POST, $new_post_data );
1105
+			$_POST = array_replace_recursive($_POST, $new_post_data);
1106 1106
 		}
1107 1107
 	}
1108 1108
 }
Please login to merge, or discard this patch.
Braces   +73 added lines, -39 removed lines patch added patch discarded remove patch
@@ -102,8 +102,9 @@  discard block
 block discarded – undo
102 102
 				'name__like' => $query,
103 103
 				'number' => 10,
104 104
 			));
105
-			if ( empty( $terms ) || is_wp_error( $terms ) )
106
-				return;
105
+			if ( empty( $terms ) || is_wp_error( $terms ) ) {
106
+							return;
107
+			}
107 108
 			foreach ( (array) $terms as $term ) {
108 109
 				if ( 'markup' == $response_format ) {
109 110
 					echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( $term ) ), 0, (object) $args );
@@ -155,8 +156,9 @@  discard block
 block discarded – undo
155 156
 function wp_initial_nav_menu_meta_boxes() {
156 157
 	global $wp_meta_boxes;
157 158
 
158
-	if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array($wp_meta_boxes) )
159
-		return;
159
+	if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array($wp_meta_boxes) ) {
160
+			return;
161
+	}
160 162
 
161 163
 	$initial_meta_boxes = array( 'add-post-type-page', 'add-post-type-post', 'add-custom-links', 'add-category' );
162 164
 	$hidden_meta_boxes = array();
@@ -185,8 +187,9 @@  discard block
 block discarded – undo
185 187
 function wp_nav_menu_post_type_meta_boxes() {
186 188
 	$post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'object' );
187 189
 
188
-	if ( ! $post_types )
189
-		return;
190
+	if ( ! $post_types ) {
191
+			return;
192
+	}
190 193
 
191 194
 	foreach ( $post_types as $post_type ) {
192 195
 		/**
@@ -219,8 +222,9 @@  discard block
 block discarded – undo
219 222
 function wp_nav_menu_taxonomy_meta_boxes() {
220 223
 	$taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'object' );
221 224
 
222
-	if ( !$taxonomies )
223
-		return;
225
+	if ( !$taxonomies ) {
226
+			return;
227
+	}
224 228
 
225 229
 	foreach ( $taxonomies as $tax ) {
226 230
 		/** This filter is documented in wp-admin/includes/nav-menu.php */
@@ -245,8 +249,9 @@  discard block
 block discarded – undo
245 249
 function wp_nav_menu_disabled_check( $nav_menu_selected_id ) {
246 250
 	global $one_theme_location_no_menus;
247 251
 
248
-	if ( $one_theme_location_no_menus )
249
-		return false;
252
+	if ( $one_theme_location_no_menus ) {
253
+			return false;
254
+	}
250 255
 
251 256
 	return disabled( $nav_menu_selected_id, 0 );
252 257
 }
@@ -320,8 +325,9 @@  discard block
 block discarded – undo
320 325
 		'update_post_meta_cache' => false
321 326
 	);
322 327
 
323
-	if ( isset( $post_type['args']->_default_query ) )
324
-		$args = array_merge($args, (array) $post_type['args']->_default_query );
328
+	if ( isset( $post_type['args']->_default_query ) ) {
329
+			$args = array_merge($args, (array) $post_type['args']->_default_query );
330
+	}
325 331
 
326 332
 	// @todo transient caching of these results with proper invalidation on updating of a post of this type
327 333
 	$get_posts = new WP_Query;
@@ -378,17 +384,26 @@  discard block
 block discarded – undo
378 384
 	<div id="posttype-<?php echo $post_type_name; ?>" class="posttypediv">
379 385
 		<ul id="posttype-<?php echo $post_type_name; ?>-tabs" class="posttype-tabs add-menu-item-tabs">
380 386
 			<li <?php echo ( 'most-recent' == $current_tab ? ' class="tabs"' : '' ); ?>>
381
-				<a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-most-recent" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'most-recent', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent">
387
+				<a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-most-recent" href="<?php if ( $nav_menu_selected_id ) {
388
+	echo esc_url(add_query_arg($post_type_name . '-tab', 'most-recent', remove_query_arg($removed_args)));
389
+}
390
+?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent">
382 391
 					<?php _e( 'Most Recent' ); ?>
383 392
 				</a>
384 393
 			</li>
385 394
 			<li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>>
386
-				<a class="nav-tab-link" data-type="<?php echo esc_attr( $post_type_name ); ?>-all" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'all', remove_query_arg($removed_args))); ?>#<?php echo $post_type_name; ?>-all">
395
+				<a class="nav-tab-link" data-type="<?php echo esc_attr( $post_type_name ); ?>-all" href="<?php if ( $nav_menu_selected_id ) {
396
+	echo esc_url(add_query_arg($post_type_name . '-tab', 'all', remove_query_arg($removed_args)));
397
+}
398
+?>#<?php echo $post_type_name; ?>-all">
387 399
 					<?php _e( 'View All' ); ?>
388 400
 				</a>
389 401
 			</li>
390 402
 			<li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>>
391
-				<a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-search" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search">
403
+				<a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-search" href="<?php if ( $nav_menu_selected_id ) {
404
+	echo esc_url(add_query_arg($post_type_name . '-tab', 'search', remove_query_arg($removed_args)));
405
+}
406
+?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search">
392 407
 					<?php _e( 'Search'); ?>
393 408
 				</a>
394 409
 			</li>
@@ -653,17 +668,26 @@  discard block
 block discarded – undo
653 668
 	<div id="taxonomy-<?php echo $taxonomy_name; ?>" class="taxonomydiv">
654 669
 		<ul id="taxonomy-<?php echo $taxonomy_name; ?>-tabs" class="taxonomy-tabs add-menu-item-tabs">
655 670
 			<li <?php echo ( 'most-used' == $current_tab ? ' class="tabs"' : '' ); ?>>
656
-				<a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-pop" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'most-used', remove_query_arg($removed_args))); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-pop">
671
+				<a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-pop" href="<?php if ( $nav_menu_selected_id ) {
672
+	echo esc_url(add_query_arg($taxonomy_name . '-tab', 'most-used', remove_query_arg($removed_args)));
673
+}
674
+?>#tabs-panel-<?php echo $taxonomy_name; ?>-pop">
657 675
 					<?php _e( 'Most Used' ); ?>
658 676
 				</a>
659 677
 			</li>
660 678
 			<li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>>
661
-				<a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-all" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'all', remove_query_arg($removed_args))); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-all">
679
+				<a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-all" href="<?php if ( $nav_menu_selected_id ) {
680
+	echo esc_url(add_query_arg($taxonomy_name . '-tab', 'all', remove_query_arg($removed_args)));
681
+}
682
+?>#tabs-panel-<?php echo $taxonomy_name; ?>-all">
662 683
 					<?php _e( 'View All' ); ?>
663 684
 				</a>
664 685
 			</li>
665 686
 			<li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>>
666
-				<a class="nav-tab-link" data-type="tabs-panel-search-taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>">
687
+				<a class="nav-tab-link" data-type="tabs-panel-search-taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>" href="<?php if ( $nav_menu_selected_id ) {
688
+	echo esc_url(add_query_arg($taxonomy_name . '-tab', 'search', remove_query_arg($removed_args)));
689
+}
690
+?>#tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>">
667 691
 					<?php _e( 'Search' ); ?>
668 692
 				</a>
669 693
 			</li>
@@ -888,8 +912,9 @@  discard block
 block discarded – undo
888 912
 		$result .= '<p>' . __( 'Add menu items from the column on the left.' ) . '</p>';
889 913
 		$result .= '</div>';
890 914
 
891
-		if ( empty($menu_items) )
892
-			return $result . ' <ul class="menu" id="menu-to-edit"> </ul>';
915
+		if ( empty($menu_items) ) {
916
+					return $result . ' <ul class="menu" id="menu-to-edit"> </ul>';
917
+		}
893 918
 
894 919
 		/**
895 920
 		 * Filters the Walker class used when adding nav menu items.
@@ -914,10 +939,12 @@  discard block
 block discarded – undo
914 939
 
915 940
 		$some_pending_menu_items = $some_invalid_menu_items = false;
916 941
 		foreach ( (array) $menu_items as $menu_item ) {
917
-			if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status )
918
-				$some_pending_menu_items = true;
919
-			if ( ! empty( $menu_item->_invalid ) )
920
-				$some_invalid_menu_items = true;
942
+			if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status ) {
943
+							$some_pending_menu_items = true;
944
+			}
945
+			if ( ! empty( $menu_item->_invalid ) ) {
946
+							$some_invalid_menu_items = true;
947
+			}
921 948
 		}
922 949
 
923 950
 		if ( $some_pending_menu_items ) {
@@ -972,9 +999,10 @@  discard block
 block discarded – undo
972 999
 	// Delete orphaned draft menu items.
973 1000
 	$menu_items_to_delete = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type = 'nav_menu_item' AND post_status = 'draft' AND meta_key = '_menu_item_orphaned' AND meta_value < '%d'", $delete_timestamp ) );
974 1001
 
975
-	foreach ( (array) $menu_items_to_delete as $menu_item_id )
976
-		wp_delete_post( $menu_item_id, true );
977
-}
1002
+	foreach ( (array) $menu_items_to_delete as $menu_item_id ) {
1003
+			wp_delete_post( $menu_item_id, true );
1004
+	}
1005
+	}
978 1006
 
979 1007
 /**
980 1008
  * Saves nav menu items
@@ -990,8 +1018,9 @@  discard block
 block discarded – undo
990 1018
 	$messages = array();
991 1019
 	$menu_items = array();
992 1020
 	// Index menu items by db ID
993
-	foreach ( $unsorted_menu_items as $_item )
994
-		$menu_items[$_item->db_id] = $_item;
1021
+	foreach ( $unsorted_menu_items as $_item ) {
1022
+			$menu_items[$_item->db_id] = $_item;
1023
+	}
995 1024
 
996 1025
 	$post_fields = array(
997 1026
 		'menu-item-db-id', 'menu-item-object-id', 'menu-item-object',
@@ -1006,12 +1035,14 @@  discard block
 block discarded – undo
1006 1035
 		foreach ( (array) $_POST['menu-item-db-id'] as $_key => $k ) {
1007 1036
 
1008 1037
 			// Menu item title can't be blank
1009
-			if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] )
1010
-				continue;
1038
+			if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] ) {
1039
+							continue;
1040
+			}
1011 1041
 
1012 1042
 			$args = array();
1013
-			foreach ( $post_fields as $field )
1014
-				$args[$field] = isset( $_POST[$field][$_key] ) ? $_POST[$field][$_key] : '';
1043
+			foreach ( $post_fields as $field ) {
1044
+							$args[$field] = isset( $_POST[$field][$_key] ) ? $_POST[$field][$_key] : '';
1045
+			}
1015 1046
 
1016 1047
 			$menu_item_db_id = wp_update_nav_menu_item( $nav_menu_selected_id, ( $_POST['menu-item-db-id'][$_key] != $_key ? 0 : $_key ), $args );
1017 1048
 
@@ -1035,14 +1066,17 @@  discard block
 block discarded – undo
1035 1066
 	// Store 'auto-add' pages.
1036 1067
 	$auto_add = ! empty( $_POST['auto-add-pages'] );
1037 1068
 	$nav_menu_option = (array) get_option( 'nav_menu_options' );
1038
-	if ( ! isset( $nav_menu_option['auto_add'] ) )
1039
-		$nav_menu_option['auto_add'] = array();
1069
+	if ( ! isset( $nav_menu_option['auto_add'] ) ) {
1070
+			$nav_menu_option['auto_add'] = array();
1071
+	}
1040 1072
 	if ( $auto_add ) {
1041
-		if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) )
1042
-			$nav_menu_option['auto_add'][] = $nav_menu_selected_id;
1073
+		if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) {
1074
+					$nav_menu_option['auto_add'][] = $nav_menu_selected_id;
1075
+		}
1043 1076
 	} else {
1044
-		if ( false !== ( $key = array_search( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) )
1045
-			unset( $nav_menu_option['auto_add'][$key] );
1077
+		if ( false !== ( $key = array_search( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) ) {
1078
+					unset( $nav_menu_option['auto_add'][$key] );
1079
+		}
1046 1080
 	}
1047 1081
 	// Remove nonexistent/deleted menus
1048 1082
 	$nav_menu_option['auto_add'] = array_intersect( $nav_menu_option['auto_add'], wp_get_nav_menus( array( 'fields' => 'ids' ) ) );
Please login to merge, or discard this patch.
src/wp-admin/includes/upgrade.php 5 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1795,7 +1795,7 @@  discard block
 block discarded – undo
1795 1795
  *
1796 1796
  * @param string $table Database table name.
1797 1797
  * @param string $index Index name to drop.
1798
- * @return true True, when finished.
1798
+ * @return boolean True, when finished.
1799 1799
  */
1800 1800
 function drop_index($table, $index) {
1801 1801
 	global $wpdb;
@@ -1818,7 +1818,7 @@  discard block
 block discarded – undo
1818 1818
  *
1819 1819
  * @param string $table Database table name.
1820 1820
  * @param string $index Database table index column.
1821
- * @return true True, when done with execution.
1821
+ * @return boolean True, when done with execution.
1822 1822
  */
1823 1823
 function add_clean_index($table, $index) {
1824 1824
 	global $wpdb;
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2114,7 +2114,7 @@
 block discarded – undo
2114 2114
 	global $wpdb;
2115 2115
 
2116 2116
 	if ( in_array( $queries, array( '', 'all', 'blog', 'global', 'ms_global' ), true ) )
2117
-	    $queries = wp_get_db_schema( $queries );
2117
+		$queries = wp_get_db_schema( $queries );
2118 2118
 
2119 2119
 	// Separate individual queries into an array
2120 2120
 	if ( !is_array($queries) ) {
Please login to merge, or discard this patch.
Switch Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -2710,22 +2710,22 @@
 block discarded – undo
2710 2710
  */
2711 2711
 function translate_level_to_role($level) {
2712 2712
 	switch ($level) {
2713
-	case 10:
2714
-	case 9:
2715
-	case 8:
2716
-		return 'administrator';
2717
-	case 7:
2718
-	case 6:
2719
-	case 5:
2720
-		return 'editor';
2721
-	case 4:
2722
-	case 3:
2723
-	case 2:
2724
-		return 'author';
2725
-	case 1:
2726
-		return 'contributor';
2727
-	case 0:
2728
-		return 'subscriber';
2713
+		case 10:
2714
+		case 9:
2715
+		case 8:
2716
+			return 'administrator';
2717
+		case 7:
2718
+		case 6:
2719
+		case 5:
2720
+			return 'editor';
2721
+		case 4:
2722
+		case 3:
2723
+		case 2:
2724
+			return 'author';
2725
+		case 1:
2726
+			return 'contributor';
2727
+		case 0:
2728
+			return 'subscriber';
2729 2729
 	}
2730 2730
 }
2731 2731
 
Please login to merge, or discard this patch.
Spacing   +600 added lines, -600 removed lines patch added patch discarded remove patch
@@ -9,16 +9,16 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 /** Include user install customize script. */
12
-if ( file_exists(WP_CONTENT_DIR . '/install.php') )
13
-	require (WP_CONTENT_DIR . '/install.php');
12
+if (file_exists(WP_CONTENT_DIR.'/install.php'))
13
+	require (WP_CONTENT_DIR.'/install.php');
14 14
 
15 15
 /** WordPress Administration API */
16
-require_once(ABSPATH . 'wp-admin/includes/admin.php');
16
+require_once(ABSPATH.'wp-admin/includes/admin.php');
17 17
 
18 18
 /** WordPress Schema API */
19
-require_once(ABSPATH . 'wp-admin/includes/schema.php');
19
+require_once(ABSPATH.'wp-admin/includes/schema.php');
20 20
 
21
-if ( !function_exists('wp_install') ) :
21
+if ( ! function_exists('wp_install')) :
22 22
 /**
23 23
  * Installs the site.
24 24
  *
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
  * @param string $language      Optional. Language chosen. Default empty.
37 37
  * @return array Array keys 'url', 'user_id', 'password', and 'password_message'.
38 38
  */
39
-function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '', $language = '' ) {
40
-	if ( !empty( $deprecated ) )
41
-		_deprecated_argument( __FUNCTION__, '2.6' );
39
+function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '', $language = '') {
40
+	if ( ! empty($deprecated))
41
+		_deprecated_argument(__FUNCTION__, '2.6');
42 42
 
43 43
 	wp_check_mysql_version();
44 44
 	wp_cache_flush();
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 	update_option('admin_email', $user_email);
51 51
 	update_option('blog_public', $public);
52 52
 
53
-	if ( $language ) {
54
-		update_option( 'WPLANG', $language );
53
+	if ($language) {
54
+		update_option('WPLANG', $language);
55 55
 	}
56 56
 
57 57
 	$guessurl = wp_guess_url();
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	update_option('siteurl', $guessurl);
60 60
 
61 61
 	// If not a public blog, don't ping.
62
-	if ( ! $public )
62
+	if ( ! $public)
63 63
 		update_option('default_pingback_flag', 0);
64 64
 
65 65
 	/*
@@ -69,13 +69,13 @@  discard block
 block discarded – undo
69 69
 	$user_id = username_exists($user_name);
70 70
 	$user_password = trim($user_password);
71 71
 	$email_password = false;
72
-	if ( !$user_id && empty($user_password) ) {
73
-		$user_password = wp_generate_password( 12, false );
72
+	if ( ! $user_id && empty($user_password)) {
73
+		$user_password = wp_generate_password(12, false);
74 74
 		$message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.');
75 75
 		$user_id = wp_create_user($user_name, $user_password, $user_email);
76 76
 		update_user_option($user_id, 'default_password_nag', true, true);
77 77
 		$email_password = true;
78
-	} elseif ( ! $user_id ) {
78
+	} elseif ( ! $user_id) {
79 79
 		// Password has been provided
80 80
 		$message = '<em>'.__('Your chosen password.').'</em>';
81 81
 		$user_id = wp_create_user($user_name, $user_password, $user_email);
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 
93 93
 	flush_rewrite_rules();
94 94
 
95
-	wp_new_blog_notification($blog_title, $guessurl, $user_id, ($email_password ? $user_password : __('The password you chose during the install.') ) );
95
+	wp_new_blog_notification($blog_title, $guessurl, $user_id, ($email_password ? $user_password : __('The password you chose during the install.')));
96 96
 
97 97
 	wp_cache_flush();
98 98
 
@@ -103,13 +103,13 @@  discard block
 block discarded – undo
103 103
 	 *
104 104
 	 * @param WP_User $user The site owner.
105 105
 	 */
106
-	do_action( 'wp_install', $user );
106
+	do_action('wp_install', $user);
107 107
 
108 108
 	return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message);
109 109
 }
110 110
 endif;
111 111
 
112
-if ( !function_exists('wp_install_defaults') ) :
112
+if ( ! function_exists('wp_install_defaults')) :
113 113
 /**
114 114
  * Creates the initial content for a newly-installed site.
115 115
  *
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
  *
125 125
  * @param int $user_id User ID.
126 126
  */
127
-function wp_install_defaults( $user_id ) {
127
+function wp_install_defaults($user_id) {
128 128
 	global $wpdb, $wp_rewrite, $table_prefix;
129 129
 
130 130
 	// Default category
@@ -132,10 +132,10 @@  discard block
 block discarded – undo
132 132
 	/* translators: Default category slug */
133 133
 	$cat_slug = sanitize_title(_x('Uncategorized', 'Default category slug'));
134 134
 
135
-	if ( global_terms_enabled() ) {
136
-		$cat_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) );
137
-		if ( $cat_id == null ) {
138
-			$wpdb->insert( $wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)) );
135
+	if (global_terms_enabled()) {
136
+		$cat_id = $wpdb->get_var($wpdb->prepare("SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug));
137
+		if ($cat_id == null) {
138
+			$wpdb->insert($wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)));
139 139
 			$cat_id = $wpdb->insert_id;
140 140
 		}
141 141
 		update_option('default_category', $cat_id);
@@ -143,35 +143,35 @@  discard block
 block discarded – undo
143 143
 		$cat_id = 1;
144 144
 	}
145 145
 
146
-	$wpdb->insert( $wpdb->terms, array('term_id' => $cat_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0) );
147
-	$wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1));
146
+	$wpdb->insert($wpdb->terms, array('term_id' => $cat_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0));
147
+	$wpdb->insert($wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1));
148 148
 	$cat_tt_id = $wpdb->insert_id;
149 149
 
150 150
 	// First post
151
-	$now = current_time( 'mysql' );
152
-	$now_gmt = current_time( 'mysql', 1 );
153
-	$first_post_guid = get_option( 'home' ) . '/?p=1';
151
+	$now = current_time('mysql');
152
+	$now_gmt = current_time('mysql', 1);
153
+	$first_post_guid = get_option('home').'/?p=1';
154 154
 
155
-	if ( is_multisite() ) {
156
-		$first_post = get_site_option( 'first_post' );
155
+	if (is_multisite()) {
156
+		$first_post = get_site_option('first_post');
157 157
 
158
-		if ( ! $first_post ) {
158
+		if ( ! $first_post) {
159 159
 			/* translators: %s: site link */
160
-			$first_post = __( 'Welcome to %s. This is your first post. Edit or delete it, then start blogging!' );
160
+			$first_post = __('Welcome to %s. This is your first post. Edit or delete it, then start blogging!');
161 161
 		}
162 162
 
163
-		$first_post = sprintf( $first_post,
164
-			sprintf( '<a href="%s">%s</a>', esc_url( network_home_url() ), get_current_site()->site_name )
163
+		$first_post = sprintf($first_post,
164
+			sprintf('<a href="%s">%s</a>', esc_url(network_home_url()), get_current_site()->site_name)
165 165
 		);
166 166
 
167 167
 		// Back-compat for pre-4.4
168
-		$first_post = str_replace( 'SITE_URL', esc_url( network_home_url() ), $first_post );
169
-		$first_post = str_replace( 'SITE_NAME', get_current_site()->site_name, $first_post );
168
+		$first_post = str_replace('SITE_URL', esc_url(network_home_url()), $first_post);
169
+		$first_post = str_replace('SITE_NAME', get_current_site()->site_name, $first_post);
170 170
 	} else {
171
-		$first_post = __( 'Welcome to WordPress. This is your first post. Edit or delete it, then start writing!' );
171
+		$first_post = __('Welcome to WordPress. This is your first post. Edit or delete it, then start writing!');
172 172
 	}
173 173
 
174
-	$wpdb->insert( $wpdb->posts, array(
174
+	$wpdb->insert($wpdb->posts, array(
175 175
 		'post_author' => $user_id,
176 176
 		'post_date' => $now,
177 177
 		'post_date_gmt' => $now_gmt,
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 		'post_excerpt' => '',
180 180
 		'post_title' => __('Hello world!'),
181 181
 		/* translators: Default post slug */
182
-		'post_name' => sanitize_title( _x('hello-world', 'Default post slug') ),
182
+		'post_name' => sanitize_title(_x('hello-world', 'Default post slug')),
183 183
 		'post_modified' => $now,
184 184
 		'post_modified_gmt' => $now_gmt,
185 185
 		'guid' => $first_post_guid,
@@ -188,22 +188,22 @@  discard block
 block discarded – undo
188 188
 		'pinged' => '',
189 189
 		'post_content_filtered' => ''
190 190
 	));
191
-	$wpdb->insert( $wpdb->term_relationships, array('term_taxonomy_id' => $cat_tt_id, 'object_id' => 1) );
191
+	$wpdb->insert($wpdb->term_relationships, array('term_taxonomy_id' => $cat_tt_id, 'object_id' => 1));
192 192
 
193 193
 	// Default comment
194
-	$first_comment_author = __( 'A WordPress Commenter' );
194
+	$first_comment_author = __('A WordPress Commenter');
195 195
 	$first_comment_email = '[email protected]';
196 196
 	$first_comment_url = 'https://wordpress.org/';
197
-	$first_comment = __( 'Hi, this is a comment.
197
+	$first_comment = __('Hi, this is a comment.
198 198
 To moderate comments, just log in. There you will have the option to edit or delete them.
199 199
 Commenter avatars come from <a href="https://gravatar.com">Gravatar</a>.' );
200
-	if ( is_multisite() ) {
201
-		$first_comment_author = get_site_option( 'first_comment_author', $first_comment_author );
202
-		$first_comment_email = get_site_option( 'first_comment_email', $first_comment_email );
203
-		$first_comment_url = get_site_option( 'first_comment_url', network_home_url() );
204
-		$first_comment = get_site_option( 'first_comment', $first_comment );
200
+	if (is_multisite()) {
201
+		$first_comment_author = get_site_option('first_comment_author', $first_comment_author);
202
+		$first_comment_email = get_site_option('first_comment_email', $first_comment_email);
203
+		$first_comment_url = get_site_option('first_comment_url', network_home_url());
204
+		$first_comment = get_site_option('first_comment', $first_comment);
205 205
 	}
206
-	$wpdb->insert( $wpdb->comments, array(
206
+	$wpdb->insert($wpdb->comments, array(
207 207
 		'comment_post_ID' => 1,
208 208
 		'comment_author' => $first_comment_author,
209 209
 		'comment_author_email' => $first_comment_email,
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	));
215 215
 
216 216
 	// First Page
217
-	$first_page = sprintf( __( "This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:
217
+	$first_page = sprintf(__("This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:
218 218
 
219 219
 <blockquote>Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my website. I live in Los Angeles, have a great dog named Jack, and I like pi&#241;a coladas. (And gettin' caught in the rain.)</blockquote>
220 220
 
@@ -222,20 +222,20 @@  discard block
 block discarded – undo
222 222
 
223 223
 <blockquote>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</blockquote>
224 224
 
225
-As a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to delete this page and create new pages for your content. Have fun!" ), admin_url() );
226
-	if ( is_multisite() )
227
-		$first_page = get_site_option( 'first_page', $first_page );
228
-	$first_post_guid = get_option('home') . '/?page_id=2';
229
-	$wpdb->insert( $wpdb->posts, array(
225
+As a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to delete this page and create new pages for your content. Have fun!" ), admin_url());
226
+	if (is_multisite())
227
+		$first_page = get_site_option('first_page', $first_page);
228
+	$first_post_guid = get_option('home').'/?page_id=2';
229
+	$wpdb->insert($wpdb->posts, array(
230 230
 		'post_author' => $user_id,
231 231
 		'post_date' => $now,
232 232
 		'post_date_gmt' => $now_gmt,
233 233
 		'post_content' => $first_page,
234 234
 		'post_excerpt' => '',
235 235
 		'comment_status' => 'closed',
236
-		'post_title' => __( 'Sample Page' ),
236
+		'post_title' => __('Sample Page'),
237 237
 		/* translators: Default page slug */
238
-		'post_name' => __( 'sample-page' ),
238
+		'post_name' => __('sample-page'),
239 239
 		'post_modified' => $now,
240 240
 		'post_modified_gmt' => $now_gmt,
241 241
 		'guid' => $first_post_guid,
@@ -244,37 +244,37 @@  discard block
 block discarded – undo
244 244
 		'pinged' => '',
245 245
 		'post_content_filtered' => ''
246 246
 	));
247
-	$wpdb->insert( $wpdb->postmeta, array( 'post_id' => 2, 'meta_key' => '_wp_page_template', 'meta_value' => 'default' ) );
247
+	$wpdb->insert($wpdb->postmeta, array('post_id' => 2, 'meta_key' => '_wp_page_template', 'meta_value' => 'default'));
248 248
 
249 249
 	// Set up default widgets for default theme.
250
-	update_option( 'widget_search', array ( 2 => array ( 'title' => '' ), '_multiwidget' => 1 ) );
251
-	update_option( 'widget_recent-posts', array ( 2 => array ( 'title' => '', 'number' => 5 ), '_multiwidget' => 1 ) );
252
-	update_option( 'widget_recent-comments', array ( 2 => array ( 'title' => '', 'number' => 5 ), '_multiwidget' => 1 ) );
253
-	update_option( 'widget_archives', array ( 2 => array ( 'title' => '', 'count' => 0, 'dropdown' => 0 ), '_multiwidget' => 1 ) );
254
-	update_option( 'widget_categories', array ( 2 => array ( 'title' => '', 'count' => 0, 'hierarchical' => 0, 'dropdown' => 0 ), '_multiwidget' => 1 ) );
255
-	update_option( 'widget_meta', array ( 2 => array ( 'title' => '' ), '_multiwidget' => 1 ) );
256
-	update_option( 'sidebars_widgets', array ( 'wp_inactive_widgets' => array (), 'sidebar-1' => array ( 0 => 'search-2', 1 => 'recent-posts-2', 2 => 'recent-comments-2', 3 => 'archives-2', 4 => 'categories-2', 5 => 'meta-2', ), 'array_version' => 3 ) );
257
-
258
-	if ( ! is_multisite() )
259
-		update_user_meta( $user_id, 'show_welcome_panel', 1 );
260
-	elseif ( ! is_super_admin( $user_id ) && ! metadata_exists( 'user', $user_id, 'show_welcome_panel' ) )
261
-		update_user_meta( $user_id, 'show_welcome_panel', 2 );
262
-
263
-	if ( is_multisite() ) {
250
+	update_option('widget_search', array(2 => array('title' => ''), '_multiwidget' => 1));
251
+	update_option('widget_recent-posts', array(2 => array('title' => '', 'number' => 5), '_multiwidget' => 1));
252
+	update_option('widget_recent-comments', array(2 => array('title' => '', 'number' => 5), '_multiwidget' => 1));
253
+	update_option('widget_archives', array(2 => array('title' => '', 'count' => 0, 'dropdown' => 0), '_multiwidget' => 1));
254
+	update_option('widget_categories', array(2 => array('title' => '', 'count' => 0, 'hierarchical' => 0, 'dropdown' => 0), '_multiwidget' => 1));
255
+	update_option('widget_meta', array(2 => array('title' => ''), '_multiwidget' => 1));
256
+	update_option('sidebars_widgets', array('wp_inactive_widgets' => array(), 'sidebar-1' => array(0 => 'search-2', 1 => 'recent-posts-2', 2 => 'recent-comments-2', 3 => 'archives-2', 4 => 'categories-2', 5 => 'meta-2',), 'array_version' => 3));
257
+
258
+	if ( ! is_multisite())
259
+		update_user_meta($user_id, 'show_welcome_panel', 1);
260
+	elseif ( ! is_super_admin($user_id) && ! metadata_exists('user', $user_id, 'show_welcome_panel'))
261
+		update_user_meta($user_id, 'show_welcome_panel', 2);
262
+
263
+	if (is_multisite()) {
264 264
 		// Flush rules to pick up the new page.
265 265
 		$wp_rewrite->init();
266 266
 		$wp_rewrite->flush_rules();
267 267
 
268 268
 		$user = new WP_User($user_id);
269
-		$wpdb->update( $wpdb->options, array('option_value' => $user->user_email), array('option_name' => 'admin_email') );
269
+		$wpdb->update($wpdb->options, array('option_value' => $user->user_email), array('option_name' => 'admin_email'));
270 270
 
271 271
 		// Remove all perms except for the login user.
272
-		$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'user_level') );
273
-		$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'capabilities') );
272
+		$wpdb->query($wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'user_level'));
273
+		$wpdb->query($wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'capabilities'));
274 274
 
275 275
 		// Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) TODO: Get previous_blog_id.
276
-		if ( !is_super_admin( $user_id ) && $user_id != 1 )
277
-			$wpdb->delete( $wpdb->usermeta, array( 'user_id' => $user_id , 'meta_key' => $wpdb->base_prefix.'1_capabilities' ) );
276
+		if ( ! is_super_admin($user_id) && $user_id != 1)
277
+			$wpdb->delete($wpdb->usermeta, array('user_id' => $user_id, 'meta_key' => $wpdb->base_prefix.'1_capabilities'));
278 278
 	}
279 279
 }
280 280
 endif;
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 	global $wp_rewrite;
295 295
 
296 296
 	// Bail if a permalink structure is already enabled.
297
-	if ( get_option( 'permalink_structure' ) ) {
297
+	if (get_option('permalink_structure')) {
298 298
 		return true;
299 299
 	}
300 300
 
@@ -311,20 +311,20 @@  discard block
 block discarded – undo
311 311
 		'/index.php/%year%/%monthnum%/%day%/%postname%/'
312 312
 	);
313 313
 
314
-	foreach ( (array) $permalink_structures as $permalink_structure ) {
315
-		$wp_rewrite->set_permalink_structure( $permalink_structure );
314
+	foreach ((array) $permalink_structures as $permalink_structure) {
315
+		$wp_rewrite->set_permalink_structure($permalink_structure);
316 316
 
317 317
 		/*
318 318
 	 	 * Flush rules with the hard option to force refresh of the web-server's
319 319
 	 	 * rewrite config file (e.g. .htaccess or web.config).
320 320
 	 	 */
321
-		$wp_rewrite->flush_rules( true );
321
+		$wp_rewrite->flush_rules(true);
322 322
 
323 323
 		// Test against a real WordPress Post, or if none were created, a random 404 page.
324
-		$test_url = get_permalink( 1 );
324
+		$test_url = get_permalink(1);
325 325
 
326
-		if ( ! $test_url ) {
327
-			$test_url = home_url( '/wordpress-check-for-rewrites/' );
326
+		if ( ! $test_url) {
327
+			$test_url = home_url('/wordpress-check-for-rewrites/');
328 328
 		}
329 329
 
330 330
 		/*
@@ -334,11 +334,11 @@  discard block
 block discarded – undo
334 334
 	 	 * Uses wp_remote_get() instead of wp_remote_head() because web servers
335 335
 	 	 * can block head requests.
336 336
 	 	 */
337
-		$response          = wp_remote_get( $test_url, array( 'timeout' => 5 ) );
338
-		$x_pingback_header = wp_remote_retrieve_header( $response, 'x-pingback' );
339
-		$pretty_permalinks = $x_pingback_header && $x_pingback_header === get_bloginfo( 'pingback_url' );
337
+		$response          = wp_remote_get($test_url, array('timeout' => 5));
338
+		$x_pingback_header = wp_remote_retrieve_header($response, 'x-pingback');
339
+		$pretty_permalinks = $x_pingback_header && $x_pingback_header === get_bloginfo('pingback_url');
340 340
 
341
-		if ( $pretty_permalinks ) {
341
+		if ($pretty_permalinks) {
342 342
 			return true;
343 343
 		}
344 344
 	}
@@ -347,13 +347,13 @@  discard block
 block discarded – undo
347 347
 	 * If it makes it this far, pretty permalinks failed.
348 348
 	 * Fallback to query-string permalinks.
349 349
 	 */
350
-	$wp_rewrite->set_permalink_structure( '' );
351
-	$wp_rewrite->flush_rules( true );
350
+	$wp_rewrite->set_permalink_structure('');
351
+	$wp_rewrite->flush_rules(true);
352 352
 
353 353
 	return false;
354 354
 }
355 355
 
356
-if ( !function_exists('wp_new_blog_notification') ) :
356
+if ( ! function_exists('wp_new_blog_notification')) :
357 357
 /**
358 358
  * Notifies the site admin that the setup is complete.
359 359
  *
@@ -368,11 +368,11 @@  discard block
 block discarded – undo
368 368
  * @param string $password   User's Password.
369 369
  */
370 370
 function wp_new_blog_notification($blog_title, $blog_url, $user_id, $password) {
371
-	$user = new WP_User( $user_id );
371
+	$user = new WP_User($user_id);
372 372
 	$email = $user->user_email;
373 373
 	$name = $user->user_login;
374 374
 	$login_url = wp_login_url();
375
-	$message = sprintf( __( "Your new WordPress site has been successfully set up at:
375
+	$message = sprintf(__("Your new WordPress site has been successfully set up at:
376 376
 
377 377
 %1\$s
378 378
 
@@ -386,13 +386,13 @@  discard block
 block discarded – undo
386 386
 
387 387
 --The WordPress Team
388 388
 https://wordpress.org/
389
-"), $blog_url, $name, $password, $login_url );
389
+"), $blog_url, $name, $password, $login_url);
390 390
 
391 391
 	@wp_mail($email, __('New WordPress Site'), $message);
392 392
 }
393 393
 endif;
394 394
 
395
-if ( !function_exists('wp_upgrade') ) :
395
+if ( ! function_exists('wp_upgrade')) :
396 396
 /**
397 397
  * Runs WordPress Upgrade functions.
398 398
  *
@@ -410,10 +410,10 @@  discard block
 block discarded – undo
410 410
 	$wp_current_db_version = __get_option('db_version');
411 411
 
412 412
 	// We are up-to-date. Nothing to do.
413
-	if ( $wp_db_version == $wp_current_db_version )
413
+	if ($wp_db_version == $wp_current_db_version)
414 414
 		return;
415 415
 
416
-	if ( ! is_blog_installed() )
416
+	if ( ! is_blog_installed())
417 417
 		return;
418 418
 
419 419
 	wp_check_mysql_version();
@@ -421,15 +421,15 @@  discard block
 block discarded – undo
421 421
 	pre_schema_upgrade();
422 422
 	make_db_current_silent();
423 423
 	upgrade_all();
424
-	if ( is_multisite() && is_main_site() )
424
+	if (is_multisite() && is_main_site())
425 425
 		upgrade_network();
426 426
 	wp_cache_flush();
427 427
 
428
-	if ( is_multisite() ) {
429
-		if ( $wpdb->get_row( "SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'" ) )
430
-			$wpdb->query( "UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'" );
428
+	if (is_multisite()) {
429
+		if ($wpdb->get_row("SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'"))
430
+			$wpdb->query("UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'");
431 431
 		else
432
-			$wpdb->query( "INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());" );
432
+			$wpdb->query("INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());");
433 433
 	}
434 434
 
435 435
 	/**
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
 	 * @param int $wp_db_version         The new $wp_db_version.
441 441
 	 * @param int $wp_current_db_version The old (current) $wp_db_version.
442 442
 	 */
443
-	do_action( 'wp_upgrade', $wp_db_version, $wp_current_db_version );
443
+	do_action('wp_upgrade', $wp_db_version, $wp_current_db_version);
444 444
 }
445 445
 endif;
446 446
 
@@ -461,109 +461,109 @@  discard block
 block discarded – undo
461 461
 	$wp_current_db_version = __get_option('db_version');
462 462
 
463 463
 	// We are up-to-date. Nothing to do.
464
-	if ( $wp_db_version == $wp_current_db_version )
464
+	if ($wp_db_version == $wp_current_db_version)
465 465
 		return;
466 466
 
467 467
 	// If the version is not set in the DB, try to guess the version.
468
-	if ( empty($wp_current_db_version) ) {
468
+	if (empty($wp_current_db_version)) {
469 469
 		$wp_current_db_version = 0;
470 470
 
471 471
 		// If the template option exists, we have 1.5.
472 472
 		$template = __get_option('template');
473
-		if ( !empty($template) )
473
+		if ( ! empty($template))
474 474
 			$wp_current_db_version = 2541;
475 475
 	}
476 476
 
477
-	if ( $wp_current_db_version < 6039 )
477
+	if ($wp_current_db_version < 6039)
478 478
 		upgrade_230_options_table();
479 479
 
480 480
 	populate_options();
481 481
 
482
-	if ( $wp_current_db_version < 2541 ) {
482
+	if ($wp_current_db_version < 2541) {
483 483
 		upgrade_100();
484 484
 		upgrade_101();
485 485
 		upgrade_110();
486 486
 		upgrade_130();
487 487
 	}
488 488
 
489
-	if ( $wp_current_db_version < 3308 )
489
+	if ($wp_current_db_version < 3308)
490 490
 		upgrade_160();
491 491
 
492
-	if ( $wp_current_db_version < 4772 )
492
+	if ($wp_current_db_version < 4772)
493 493
 		upgrade_210();
494 494
 
495
-	if ( $wp_current_db_version < 4351 )
495
+	if ($wp_current_db_version < 4351)
496 496
 		upgrade_old_slugs();
497 497
 
498
-	if ( $wp_current_db_version < 5539 )
498
+	if ($wp_current_db_version < 5539)
499 499
 		upgrade_230();
500 500
 
501
-	if ( $wp_current_db_version < 6124 )
501
+	if ($wp_current_db_version < 6124)
502 502
 		upgrade_230_old_tables();
503 503
 
504
-	if ( $wp_current_db_version < 7499 )
504
+	if ($wp_current_db_version < 7499)
505 505
 		upgrade_250();
506 506
 
507
-	if ( $wp_current_db_version < 7935 )
507
+	if ($wp_current_db_version < 7935)
508 508
 		upgrade_252();
509 509
 
510
-	if ( $wp_current_db_version < 8201 )
510
+	if ($wp_current_db_version < 8201)
511 511
 		upgrade_260();
512 512
 
513
-	if ( $wp_current_db_version < 8989 )
513
+	if ($wp_current_db_version < 8989)
514 514
 		upgrade_270();
515 515
 
516
-	if ( $wp_current_db_version < 10360 )
516
+	if ($wp_current_db_version < 10360)
517 517
 		upgrade_280();
518 518
 
519
-	if ( $wp_current_db_version < 11958 )
519
+	if ($wp_current_db_version < 11958)
520 520
 		upgrade_290();
521 521
 
522
-	if ( $wp_current_db_version < 15260 )
522
+	if ($wp_current_db_version < 15260)
523 523
 		upgrade_300();
524 524
 
525
-	if ( $wp_current_db_version < 19389 )
525
+	if ($wp_current_db_version < 19389)
526 526
 		upgrade_330();
527 527
 
528
-	if ( $wp_current_db_version < 20080 )
528
+	if ($wp_current_db_version < 20080)
529 529
 		upgrade_340();
530 530
 
531
-	if ( $wp_current_db_version < 22422 )
531
+	if ($wp_current_db_version < 22422)
532 532
 		upgrade_350();
533 533
 
534
-	if ( $wp_current_db_version < 25824 )
534
+	if ($wp_current_db_version < 25824)
535 535
 		upgrade_370();
536 536
 
537
-	if ( $wp_current_db_version < 26148 )
537
+	if ($wp_current_db_version < 26148)
538 538
 		upgrade_372();
539 539
 
540
-	if ( $wp_current_db_version < 26691 )
540
+	if ($wp_current_db_version < 26691)
541 541
 		upgrade_380();
542 542
 
543
-	if ( $wp_current_db_version < 29630 )
543
+	if ($wp_current_db_version < 29630)
544 544
 		upgrade_400();
545 545
 
546
-	if ( $wp_current_db_version < 33055 )
546
+	if ($wp_current_db_version < 33055)
547 547
 		upgrade_430();
548 548
 
549
-	if ( $wp_current_db_version < 33056 )
549
+	if ($wp_current_db_version < 33056)
550 550
 		upgrade_431();
551 551
 
552
-	if ( $wp_current_db_version < 35700 )
552
+	if ($wp_current_db_version < 35700)
553 553
 		upgrade_440();
554 554
 
555
-	if ( $wp_current_db_version < 36686 )
555
+	if ($wp_current_db_version < 36686)
556 556
 		upgrade_450();
557 557
 
558
-	if ( $wp_current_db_version < 37854 )
558
+	if ($wp_current_db_version < 37854)
559 559
 		upgrade_460();
560 560
 
561 561
 	maybe_disable_link_manager();
562 562
 
563 563
 	maybe_disable_automattic_widgets();
564 564
 
565
-	update_option( 'db_version', $wp_db_version );
566
-	update_option( 'db_upgraded', true );
565
+	update_option('db_version', $wp_db_version);
566
+	update_option('db_upgraded', true);
567 567
 }
568 568
 
569 569
 /**
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
 		foreach ($posts as $post) {
584 584
 			if ('' == $post->post_name) {
585 585
 				$newtitle = sanitize_title($post->post_title);
586
-				$wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_name = %s WHERE ID = %d", $newtitle, $post->ID) );
586
+				$wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET post_name = %s WHERE ID = %d", $newtitle, $post->ID));
587 587
 			}
588 588
 		}
589 589
 	}
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 	foreach ($categories as $category) {
593 593
 		if ('' == $category->category_nicename) {
594 594
 			$newtitle = sanitize_title($category->cat_name);
595
-			$wpdb->update( $wpdb->categories, array('category_nicename' => $newtitle), array('cat_ID' => $category->cat_ID) );
595
+			$wpdb->update($wpdb->categories, array('category_nicename' => $newtitle), array('cat_ID' => $category->cat_ID));
596 596
 		}
597 597
 	}
598 598
 
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
 		SET option_value = REPLACE(option_value, 'wp-links/links-images/', 'wp-images/links/')
601 601
 		WHERE option_name LIKE %s
602 602
 		AND option_value LIKE %s";
603
-	$wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( 'links_rating_image' ) . '%', $wpdb->esc_like( 'wp-links/links-images/' ) . '%' ) );
603
+	$wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('links_rating_image').'%', $wpdb->esc_like('wp-links/links-images/').'%'));
604 604
 
605 605
 	$done_ids = $wpdb->get_results("SELECT DISTINCT post_id FROM $wpdb->post2cat");
606 606
 	if ($done_ids) :
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 		foreach ($done_ids as $done_id) :
609 609
 			$done_posts[] = $done_id->post_id;
610 610
 		endforeach;
611
-		$catwhere = ' AND ID NOT IN (' . implode(',', $done_posts) . ')';
611
+		$catwhere = ' AND ID NOT IN ('.implode(',', $done_posts).')';
612 612
 	else:
613 613
 		$catwhere = '';
614 614
 	endif;
@@ -617,9 +617,9 @@  discard block
 block discarded – undo
617 617
 	if ($allposts) :
618 618
 		foreach ($allposts as $post) {
619 619
 			// Check to see if it's already been imported
620
-			$cat = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->post2cat WHERE post_id = %d AND category_id = %d", $post->ID, $post->post_category) );
621
-			if (!$cat && 0 != $post->post_category) { // If there's no result
622
-				$wpdb->insert( $wpdb->post2cat, array('post_id' => $post->ID, 'category_id' => $post->post_category) );
620
+			$cat = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->post2cat WHERE post_id = %d AND category_id = %d", $post->ID, $post->post_category));
621
+			if ( ! $cat && 0 != $post->post_category) { // If there's no result
622
+				$wpdb->insert($wpdb->post2cat, array('post_id' => $post->ID, 'category_id' => $post->post_category));
623 623
 			}
624 624
 		}
625 625
 	endif;
@@ -642,8 +642,8 @@  discard block
 block discarded – undo
642 642
 	add_clean_index($wpdb->categories, 'category_nicename');
643 643
 	add_clean_index($wpdb->comments, 'comment_approved');
644 644
 	add_clean_index($wpdb->comments, 'comment_post_ID');
645
-	add_clean_index($wpdb->links , 'link_category');
646
-	add_clean_index($wpdb->links , 'link_visible');
645
+	add_clean_index($wpdb->links, 'link_category');
646
+	add_clean_index($wpdb->links, 'link_visible');
647 647
 }
648 648
 
649 649
 /**
@@ -662,14 +662,14 @@  discard block
 block discarded – undo
662 662
 	foreach ($users as $user) {
663 663
 		if ('' == $user->user_nicename) {
664 664
 			$newname = sanitize_title($user->user_nickname);
665
-			$wpdb->update( $wpdb->users, array('user_nicename' => $newname), array('ID' => $user->ID) );
665
+			$wpdb->update($wpdb->users, array('user_nicename' => $newname), array('ID' => $user->ID));
666 666
 		}
667 667
 	}
668 668
 
669 669
 	$users = $wpdb->get_results("SELECT ID, user_pass from $wpdb->users");
670 670
 	foreach ($users as $row) {
671
-		if (!preg_match('/^[A-Fa-f0-9]{32}$/', $row->user_pass)) {
672
-			$wpdb->update( $wpdb->users, array('user_pass' => md5($row->user_pass)), array('ID' => $row->ID) );
671
+		if ( ! preg_match('/^[A-Fa-f0-9]{32}$/', $row->user_pass)) {
672
+			$wpdb->update($wpdb->users, array('user_pass' => md5($row->user_pass)), array('ID' => $row->ID));
673 673
 		}
674 674
 	}
675 675
 
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
 
679 679
 	$time_difference = $all_options->time_difference;
680 680
 
681
-		$server_time = time()+date('Z');
681
+		$server_time = time() + date('Z');
682 682
 	$weblogger_time = $server_time + $time_difference * HOUR_IN_SECONDS;
683 683
 	$gmt_time = time();
684 684
 
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
 	// <michel_v> I just slapped myself silly for not thinking about it earlier
696 696
 	$got_gmt_fields = ! ($wpdb->get_var("SELECT MAX(post_date_gmt) FROM $wpdb->posts") == '0000-00-00 00:00:00');
697 697
 
698
-	if (!$got_gmt_fields) {
698
+	if ( ! $got_gmt_fields) {
699 699
 
700 700
 		// Add or subtract time to all dates, to get GMT dates
701 701
 		$add_hours = intval($diff_gmt_weblogger);
@@ -727,12 +727,12 @@  discard block
 block discarded – undo
727 727
 			$post_content = addslashes(deslash($post->post_content));
728 728
 			$post_title = addslashes(deslash($post->post_title));
729 729
 			$post_excerpt = addslashes(deslash($post->post_excerpt));
730
-			if ( empty($post->guid) )
730
+			if (empty($post->guid))
731 731
 				$guid = get_permalink($post->ID);
732 732
 			else
733 733
 				$guid = $post->guid;
734 734
 
735
-			$wpdb->update( $wpdb->posts, compact('post_title', 'post_content', 'post_excerpt', 'guid'), array('ID' => $post->ID) );
735
+			$wpdb->update($wpdb->posts, compact('post_title', 'post_content', 'post_excerpt', 'guid'), array('ID' => $post->ID));
736 736
 
737 737
 		}
738 738
 	}
@@ -744,7 +744,7 @@  discard block
 block discarded – undo
744 744
 			$comment_content = deslash($comment->comment_content);
745 745
 			$comment_author = deslash($comment->comment_author);
746 746
 
747
-			$wpdb->update($wpdb->comments, compact('comment_content', 'comment_author'), array('comment_ID' => $comment->comment_ID) );
747
+			$wpdb->update($wpdb->comments, compact('comment_content', 'comment_author'), array('comment_ID' => $comment->comment_ID));
748 748
 		}
749 749
 	}
750 750
 
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
 			$link_name = deslash($link->link_name);
756 756
 			$link_description = deslash($link->link_description);
757 757
 
758
-			$wpdb->update( $wpdb->links, compact('link_name', 'link_description'), array('link_id' => $link->link_id) );
758
+			$wpdb->update($wpdb->links, compact('link_name', 'link_description'), array('link_id' => $link->link_id));
759 759
 		}
760 760
 	}
761 761
 
@@ -765,16 +765,16 @@  discard block
 block discarded – undo
765 765
 	 * If plugins are not stored in an array, they're stored in the old
766 766
 	 * newline separated format. Convert to new format.
767 767
 	 */
768
-	if ( !is_array( $active_plugins ) ) {
768
+	if ( ! is_array($active_plugins)) {
769 769
 		$active_plugins = explode("\n", trim($active_plugins));
770 770
 		update_option('active_plugins', $active_plugins);
771 771
 	}
772 772
 
773 773
 	// Obsolete tables
774
-	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optionvalues');
775
-	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiontypes');
776
-	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroups');
777
-	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroup_options');
774
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'optionvalues');
775
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'optiontypes');
776
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'optiongroups');
777
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'optiongroup_options');
778 778
 
779 779
 	// Update comments table to use comment_type
780 780
 	$wpdb->query("UPDATE $wpdb->comments SET comment_type='trackback', comment_content = REPLACE(comment_content, '<trackback />', '') WHERE comment_content LIKE '<trackback />%'");
@@ -782,11 +782,11 @@  discard block
 block discarded – undo
782 782
 
783 783
 	// Some versions have multiple duplicate option_name rows with the same values
784 784
 	$options = $wpdb->get_results("SELECT option_name, COUNT(option_name) AS dupes FROM `$wpdb->options` GROUP BY option_name");
785
-	foreach ( $options as $option ) {
786
-		if ( 1 != $option->dupes ) { // Could this be done in the query?
785
+	foreach ($options as $option) {
786
+		if (1 != $option->dupes) { // Could this be done in the query?
787 787
 			$limit = $option->dupes - 1;
788
-			$dupe_ids = $wpdb->get_col( $wpdb->prepare("SELECT option_id FROM $wpdb->options WHERE option_name = %s LIMIT %d", $option->option_name, $limit) );
789
-			if ( $dupe_ids ) {
788
+			$dupe_ids = $wpdb->get_col($wpdb->prepare("SELECT option_id FROM $wpdb->options WHERE option_name = %s LIMIT %d", $option->option_name, $limit));
789
+			if ($dupe_ids) {
790 790
 				$dupe_ids = join($dupe_ids, ',');
791 791
 				$wpdb->query("DELETE FROM $wpdb->options WHERE option_id IN ($dupe_ids)");
792 792
 			}
@@ -811,27 +811,27 @@  discard block
 block discarded – undo
811 811
 	populate_roles_160();
812 812
 
813 813
 	$users = $wpdb->get_results("SELECT * FROM $wpdb->users");
814
-	foreach ( $users as $user ) :
815
-		if ( !empty( $user->user_firstname ) )
816
-			update_user_meta( $user->ID, 'first_name', wp_slash($user->user_firstname) );
817
-		if ( !empty( $user->user_lastname ) )
818
-			update_user_meta( $user->ID, 'last_name', wp_slash($user->user_lastname) );
819
-		if ( !empty( $user->user_nickname ) )
820
-			update_user_meta( $user->ID, 'nickname', wp_slash($user->user_nickname) );
821
-		if ( !empty( $user->user_level ) )
822
-			update_user_meta( $user->ID, $wpdb->prefix . 'user_level', $user->user_level );
823
-		if ( !empty( $user->user_icq ) )
824
-			update_user_meta( $user->ID, 'icq', wp_slash($user->user_icq) );
825
-		if ( !empty( $user->user_aim ) )
826
-			update_user_meta( $user->ID, 'aim', wp_slash($user->user_aim) );
827
-		if ( !empty( $user->user_msn ) )
828
-			update_user_meta( $user->ID, 'msn', wp_slash($user->user_msn) );
829
-		if ( !empty( $user->user_yim ) )
830
-			update_user_meta( $user->ID, 'yim', wp_slash($user->user_icq) );
831
-		if ( !empty( $user->user_description ) )
832
-			update_user_meta( $user->ID, 'description', wp_slash($user->user_description) );
833
-
834
-		if ( isset( $user->user_idmode ) ):
814
+	foreach ($users as $user) :
815
+		if ( ! empty($user->user_firstname))
816
+			update_user_meta($user->ID, 'first_name', wp_slash($user->user_firstname));
817
+		if ( ! empty($user->user_lastname))
818
+			update_user_meta($user->ID, 'last_name', wp_slash($user->user_lastname));
819
+		if ( ! empty($user->user_nickname))
820
+			update_user_meta($user->ID, 'nickname', wp_slash($user->user_nickname));
821
+		if ( ! empty($user->user_level))
822
+			update_user_meta($user->ID, $wpdb->prefix.'user_level', $user->user_level);
823
+		if ( ! empty($user->user_icq))
824
+			update_user_meta($user->ID, 'icq', wp_slash($user->user_icq));
825
+		if ( ! empty($user->user_aim))
826
+			update_user_meta($user->ID, 'aim', wp_slash($user->user_aim));
827
+		if ( ! empty($user->user_msn))
828
+			update_user_meta($user->ID, 'msn', wp_slash($user->user_msn));
829
+		if ( ! empty($user->user_yim))
830
+			update_user_meta($user->ID, 'yim', wp_slash($user->user_icq));
831
+		if ( ! empty($user->user_description))
832
+			update_user_meta($user->ID, 'description', wp_slash($user->user_description));
833
+
834
+		if (isset($user->user_idmode)):
835 835
 			$idmode = $user->user_idmode;
836 836
 			if ($idmode == 'nickname') $id = $user->user_nickname;
837 837
 			if ($idmode == 'login') $id = $user->user_login;
@@ -839,46 +839,46 @@  discard block
 block discarded – undo
839 839
 			if ($idmode == 'lastname') $id = $user->user_lastname;
840 840
 			if ($idmode == 'namefl') $id = $user->user_firstname.' '.$user->user_lastname;
841 841
 			if ($idmode == 'namelf') $id = $user->user_lastname.' '.$user->user_firstname;
842
-			if (!$idmode) $id = $user->user_nickname;
843
-			$wpdb->update( $wpdb->users, array('display_name' => $id), array('ID' => $user->ID) );
842
+			if ( ! $idmode) $id = $user->user_nickname;
843
+			$wpdb->update($wpdb->users, array('display_name' => $id), array('ID' => $user->ID));
844 844
 		endif;
845 845
 
846 846
 		// FIXME: RESET_CAPS is temporary code to reset roles and caps if flag is set.
847
-		$caps = get_user_meta( $user->ID, $wpdb->prefix . 'capabilities');
848
-		if ( empty($caps) || defined('RESET_CAPS') ) {
849
-			$level = get_user_meta($user->ID, $wpdb->prefix . 'user_level', true);
847
+		$caps = get_user_meta($user->ID, $wpdb->prefix.'capabilities');
848
+		if (empty($caps) || defined('RESET_CAPS')) {
849
+			$level = get_user_meta($user->ID, $wpdb->prefix.'user_level', true);
850 850
 			$role = translate_level_to_role($level);
851
-			update_user_meta( $user->ID, $wpdb->prefix . 'capabilities', array($role => true) );
851
+			update_user_meta($user->ID, $wpdb->prefix.'capabilities', array($role => true));
852 852
 		}
853 853
 
854 854
 	endforeach;
855
-	$old_user_fields = array( 'user_firstname', 'user_lastname', 'user_icq', 'user_aim', 'user_msn', 'user_yim', 'user_idmode', 'user_ip', 'user_domain', 'user_browser', 'user_description', 'user_nickname', 'user_level' );
855
+	$old_user_fields = array('user_firstname', 'user_lastname', 'user_icq', 'user_aim', 'user_msn', 'user_yim', 'user_idmode', 'user_ip', 'user_domain', 'user_browser', 'user_description', 'user_nickname', 'user_level');
856 856
 	$wpdb->hide_errors();
857
-	foreach ( $old_user_fields as $old )
857
+	foreach ($old_user_fields as $old)
858 858
 		$wpdb->query("ALTER TABLE $wpdb->users DROP $old");
859 859
 	$wpdb->show_errors();
860 860
 
861 861
 	// Populate comment_count field of posts table.
862
-	$comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID" );
863
-	if ( is_array( $comments ) )
862
+	$comments = $wpdb->get_results("SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID");
863
+	if (is_array($comments))
864 864
 		foreach ($comments as $comment)
865
-			$wpdb->update( $wpdb->posts, array('comment_count' => $comment->c), array('ID' => $comment->comment_post_ID) );
865
+			$wpdb->update($wpdb->posts, array('comment_count' => $comment->c), array('ID' => $comment->comment_post_ID));
866 866
 
867 867
 	/*
868 868
 	 * Some alpha versions used a post status of object instead of attachment
869 869
 	 * and put the mime type in post_type instead of post_mime_type.
870 870
 	 */
871
-	if ( $wp_current_db_version > 2541 && $wp_current_db_version <= 3091 ) {
871
+	if ($wp_current_db_version > 2541 && $wp_current_db_version <= 3091) {
872 872
 		$objects = $wpdb->get_results("SELECT ID, post_type FROM $wpdb->posts WHERE post_status = 'object'");
873 873
 		foreach ($objects as $object) {
874
-			$wpdb->update( $wpdb->posts, array(	'post_status' => 'attachment',
874
+			$wpdb->update($wpdb->posts, array('post_status' => 'attachment',
875 875
 												'post_mime_type' => $object->post_type,
876 876
 												'post_type' => ''),
877
-										 array( 'ID' => $object->ID ) );
877
+										 array('ID' => $object->ID));
878 878
 
879 879
 			$meta = get_post_meta($object->ID, 'imagedata', true);
880
-			if ( ! empty($meta['file']) )
881
-				update_attached_file( $object->ID, $meta['file'] );
880
+			if ( ! empty($meta['file']))
881
+				update_attached_file($object->ID, $meta['file']);
882 882
 		}
883 883
 	}
884 884
 }
@@ -895,38 +895,38 @@  discard block
 block discarded – undo
895 895
 function upgrade_210() {
896 896
 	global $wpdb, $wp_current_db_version;
897 897
 
898
-	if ( $wp_current_db_version < 3506 ) {
898
+	if ($wp_current_db_version < 3506) {
899 899
 		// Update status and type.
900 900
 		$posts = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts");
901 901
 
902
-		if ( ! empty($posts) ) foreach ($posts as $post) {
902
+		if ( ! empty($posts)) foreach ($posts as $post) {
903 903
 			$status = $post->post_status;
904 904
 			$type = 'post';
905 905
 
906
-			if ( 'static' == $status ) {
906
+			if ('static' == $status) {
907 907
 				$status = 'publish';
908 908
 				$type = 'page';
909
-			} elseif ( 'attachment' == $status ) {
909
+			} elseif ('attachment' == $status) {
910 910
 				$status = 'inherit';
911 911
 				$type = 'attachment';
912 912
 			}
913 913
 
914
-			$wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_status = %s, post_type = %s WHERE ID = %d", $status, $type, $post->ID) );
914
+			$wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET post_status = %s, post_type = %s WHERE ID = %d", $status, $type, $post->ID));
915 915
 		}
916 916
 	}
917 917
 
918
-	if ( $wp_current_db_version < 3845 ) {
918
+	if ($wp_current_db_version < 3845) {
919 919
 		populate_roles_210();
920 920
 	}
921 921
 
922
-	if ( $wp_current_db_version < 3531 ) {
922
+	if ($wp_current_db_version < 3531) {
923 923
 		// Give future posts a post_status of future.
924 924
 		$now = gmdate('Y-m-d H:i:59');
925
-		$wpdb->query ("UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '$now'");
925
+		$wpdb->query("UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '$now'");
926 926
 
927 927
 		$posts = $wpdb->get_results("SELECT ID, post_date FROM $wpdb->posts WHERE post_status ='future'");
928
-		if ( !empty($posts) )
929
-			foreach ( $posts as $post )
928
+		if ( ! empty($posts))
929
+			foreach ($posts as $post)
930 930
 				wp_schedule_single_event(mysql2date('U', $post->post_date, false), 'publish_future_post', array($post->ID));
931 931
 	}
932 932
 }
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
 function upgrade_230() {
944 944
 	global $wp_current_db_version, $wpdb;
945 945
 
946
-	if ( $wp_current_db_version < 5200 ) {
946
+	if ($wp_current_db_version < 5200) {
947 947
 		populate_roles_230();
948 948
 	}
949 949
 
@@ -960,78 +960,78 @@  discard block
 block discarded – undo
960 960
 		$term_group = 0;
961 961
 
962 962
 		// Associate terms with the same slug in a term group and make slugs unique.
963
-		if ( $exists = $wpdb->get_results( $wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug) ) ) {
963
+		if ($exists = $wpdb->get_results($wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug))) {
964 964
 			$term_group = $exists[0]->term_group;
965 965
 			$id = $exists[0]->term_id;
966 966
 			$num = 2;
967 967
 			do {
968
-				$alt_slug = $slug . "-$num";
968
+				$alt_slug = $slug."-$num";
969 969
 				$num++;
970
-				$slug_check = $wpdb->get_var( $wpdb->prepare("SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug) );
971
-			} while ( $slug_check );
970
+				$slug_check = $wpdb->get_var($wpdb->prepare("SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug));
971
+			} while ($slug_check);
972 972
 
973 973
 			$slug = $alt_slug;
974 974
 
975
-			if ( empty( $term_group ) ) {
975
+			if (empty($term_group)) {
976 976
 				$term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms GROUP BY term_group") + 1;
977
-				$wpdb->query( $wpdb->prepare("UPDATE $wpdb->terms SET term_group = %d WHERE term_id = %d", $term_group, $id) );
977
+				$wpdb->query($wpdb->prepare("UPDATE $wpdb->terms SET term_group = %d WHERE term_id = %d", $term_group, $id));
978 978
 			}
979 979
 		}
980 980
 
981
-		$wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->terms (term_id, name, slug, term_group) VALUES
982
-		(%d, %s, %s, %d)", $term_id, $name, $slug, $term_group) );
981
+		$wpdb->query($wpdb->prepare("INSERT INTO $wpdb->terms (term_id, name, slug, term_group) VALUES
982
+		(%d, %s, %s, %d)", $term_id, $name, $slug, $term_group));
983 983
 
984 984
 		$count = 0;
985
-		if ( !empty($category->category_count) ) {
985
+		if ( ! empty($category->category_count)) {
986 986
 			$count = (int) $category->category_count;
987 987
 			$taxonomy = 'category';
988
-			$wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count) );
988
+			$wpdb->query($wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count));
989 989
 			$tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
990 990
 		}
991 991
 
992
-		if ( !empty($category->link_count) ) {
992
+		if ( ! empty($category->link_count)) {
993 993
 			$count = (int) $category->link_count;
994 994
 			$taxonomy = 'link_category';
995
-			$wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count) );
995
+			$wpdb->query($wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count));
996 996
 			$tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
997 997
 		}
998 998
 
999
-		if ( !empty($category->tag_count) ) {
999
+		if ( ! empty($category->tag_count)) {
1000 1000
 			$have_tags = true;
1001 1001
 			$count = (int) $category->tag_count;
1002 1002
 			$taxonomy = 'post_tag';
1003
-			$wpdb->insert( $wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count') );
1003
+			$wpdb->insert($wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count'));
1004 1004
 			$tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
1005 1005
 		}
1006 1006
 
1007
-		if ( empty($count) ) {
1007
+		if (empty($count)) {
1008 1008
 			$count = 0;
1009 1009
 			$taxonomy = 'category';
1010
-			$wpdb->insert( $wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count') );
1010
+			$wpdb->insert($wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count'));
1011 1011
 			$tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
1012 1012
 		}
1013 1013
 	}
1014 1014
 
1015 1015
 	$select = 'post_id, category_id';
1016
-	if ( $have_tags )
1016
+	if ($have_tags)
1017 1017
 		$select .= ', rel_type';
1018 1018
 
1019 1019
 	$posts = $wpdb->get_results("SELECT $select FROM $wpdb->post2cat GROUP BY post_id, category_id");
1020
-	foreach ( $posts as $post ) {
1020
+	foreach ($posts as $post) {
1021 1021
 		$post_id = (int) $post->post_id;
1022 1022
 		$term_id = (int) $post->category_id;
1023 1023
 		$taxonomy = 'category';
1024
-		if ( !empty($post->rel_type) && 'tag' == $post->rel_type)
1024
+		if ( ! empty($post->rel_type) && 'tag' == $post->rel_type)
1025 1025
 			$taxonomy = 'tag';
1026 1026
 		$tt_id = $tt_ids[$term_id][$taxonomy];
1027
-		if ( empty($tt_id) )
1027
+		if (empty($tt_id))
1028 1028
 			continue;
1029 1029
 
1030
-		$wpdb->insert( $wpdb->term_relationships, array('object_id' => $post_id, 'term_taxonomy_id' => $tt_id) );
1030
+		$wpdb->insert($wpdb->term_relationships, array('object_id' => $post_id, 'term_taxonomy_id' => $tt_id));
1031 1031
 	}
1032 1032
 
1033 1033
 	// < 3570 we used linkcategories. >= 3570 we used categories and link2cat.
1034
-	if ( $wp_current_db_version < 3570 ) {
1034
+	if ($wp_current_db_version < 3570) {
1035 1035
 		/*
1036 1036
 		 * Create link_category terms for link categories. Create a map of link
1037 1037
 		 * cat IDs to link_category terms.
@@ -1039,8 +1039,8 @@  discard block
 block discarded – undo
1039 1039
 		$link_cat_id_map = array();
1040 1040
 		$default_link_cat = 0;
1041 1041
 		$tt_ids = array();
1042
-		$link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM " . $wpdb->prefix . 'linkcategories');
1043
-		foreach ( $link_cats as $category) {
1042
+		$link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM ".$wpdb->prefix.'linkcategories');
1043
+		foreach ($link_cats as $category) {
1044 1044
 			$cat_id = (int) $category->cat_id;
1045 1045
 			$term_id = 0;
1046 1046
 			$name = wp_slash($category->cat_name);
@@ -1048,66 +1048,66 @@  discard block
 block discarded – undo
1048 1048
 			$term_group = 0;
1049 1049
 
1050 1050
 			// Associate terms with the same slug in a term group and make slugs unique.
1051
-			if ( $exists = $wpdb->get_results( $wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug) ) ) {
1051
+			if ($exists = $wpdb->get_results($wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug))) {
1052 1052
 				$term_group = $exists[0]->term_group;
1053 1053
 				$term_id = $exists[0]->term_id;
1054 1054
 			}
1055 1055
 
1056
-			if ( empty($term_id) ) {
1057
-				$wpdb->insert( $wpdb->terms, compact('name', 'slug', 'term_group') );
1056
+			if (empty($term_id)) {
1057
+				$wpdb->insert($wpdb->terms, compact('name', 'slug', 'term_group'));
1058 1058
 				$term_id = (int) $wpdb->insert_id;
1059 1059
 			}
1060 1060
 
1061 1061
 			$link_cat_id_map[$cat_id] = $term_id;
1062 1062
 			$default_link_cat = $term_id;
1063 1063
 
1064
-			$wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $term_id, 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 0) );
1064
+			$wpdb->insert($wpdb->term_taxonomy, array('term_id' => $term_id, 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 0));
1065 1065
 			$tt_ids[$term_id] = (int) $wpdb->insert_id;
1066 1066
 		}
1067 1067
 
1068 1068
 		// Associate links to cats.
1069 1069
 		$links = $wpdb->get_results("SELECT link_id, link_category FROM $wpdb->links");
1070
-		if ( !empty($links) ) foreach ( $links as $link ) {
1071
-			if ( 0 == $link->link_category )
1070
+		if ( ! empty($links)) foreach ($links as $link) {
1071
+			if (0 == $link->link_category)
1072 1072
 				continue;
1073
-			if ( ! isset($link_cat_id_map[$link->link_category]) )
1073
+			if ( ! isset($link_cat_id_map[$link->link_category]))
1074 1074
 				continue;
1075 1075
 			$term_id = $link_cat_id_map[$link->link_category];
1076 1076
 			$tt_id = $tt_ids[$term_id];
1077
-			if ( empty($tt_id) )
1077
+			if (empty($tt_id))
1078 1078
 				continue;
1079 1079
 
1080
-			$wpdb->insert( $wpdb->term_relationships, array('object_id' => $link->link_id, 'term_taxonomy_id' => $tt_id) );
1080
+			$wpdb->insert($wpdb->term_relationships, array('object_id' => $link->link_id, 'term_taxonomy_id' => $tt_id));
1081 1081
 		}
1082 1082
 
1083 1083
 		// Set default to the last category we grabbed during the upgrade loop.
1084 1084
 		update_option('default_link_category', $default_link_cat);
1085 1085
 	} else {
1086 1086
 		$links = $wpdb->get_results("SELECT link_id, category_id FROM $wpdb->link2cat GROUP BY link_id, category_id");
1087
-		foreach ( $links as $link ) {
1087
+		foreach ($links as $link) {
1088 1088
 			$link_id = (int) $link->link_id;
1089 1089
 			$term_id = (int) $link->category_id;
1090 1090
 			$taxonomy = 'link_category';
1091 1091
 			$tt_id = $tt_ids[$term_id][$taxonomy];
1092
-			if ( empty($tt_id) )
1092
+			if (empty($tt_id))
1093 1093
 				continue;
1094
-			$wpdb->insert( $wpdb->term_relationships, array('object_id' => $link_id, 'term_taxonomy_id' => $tt_id) );
1094
+			$wpdb->insert($wpdb->term_relationships, array('object_id' => $link_id, 'term_taxonomy_id' => $tt_id));
1095 1095
 		}
1096 1096
 	}
1097 1097
 
1098
-	if ( $wp_current_db_version < 4772 ) {
1098
+	if ($wp_current_db_version < 4772) {
1099 1099
 		// Obsolete linkcategories table
1100
-		$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'linkcategories');
1100
+		$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'linkcategories');
1101 1101
 	}
1102 1102
 
1103 1103
 	// Recalculate all counts
1104 1104
 	$terms = $wpdb->get_results("SELECT term_taxonomy_id, taxonomy FROM $wpdb->term_taxonomy");
1105
-	foreach ( (array) $terms as $term ) {
1106
-		if ( ('post_tag' == $term->taxonomy) || ('category' == $term->taxonomy) )
1107
-			$count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term->term_taxonomy_id) );
1105
+	foreach ((array) $terms as $term) {
1106
+		if (('post_tag' == $term->taxonomy) || ('category' == $term->taxonomy))
1107
+			$count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term->term_taxonomy_id));
1108 1108
 		else
1109
-			$count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id) );
1110
-		$wpdb->update( $wpdb->term_taxonomy, array('count' => $count), array('term_taxonomy_id' => $term->term_taxonomy_id) );
1109
+			$count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id));
1110
+		$wpdb->update($wpdb->term_taxonomy, array('count' => $count), array('term_taxonomy_id' => $term->term_taxonomy_id));
1111 1111
 	}
1112 1112
 }
1113 1113
 
@@ -1121,9 +1121,9 @@  discard block
 block discarded – undo
1121 1121
  */
1122 1122
 function upgrade_230_options_table() {
1123 1123
 	global $wpdb;
1124
-	$old_options_fields = array( 'option_can_override', 'option_type', 'option_width', 'option_height', 'option_description', 'option_admin_level' );
1124
+	$old_options_fields = array('option_can_override', 'option_type', 'option_width', 'option_height', 'option_description', 'option_admin_level');
1125 1125
 	$wpdb->hide_errors();
1126
-	foreach ( $old_options_fields as $old )
1126
+	foreach ($old_options_fields as $old)
1127 1127
 		$wpdb->query("ALTER TABLE $wpdb->options DROP $old");
1128 1128
 	$wpdb->show_errors();
1129 1129
 }
@@ -1138,9 +1138,9 @@  discard block
 block discarded – undo
1138 1138
  */
1139 1139
 function upgrade_230_old_tables() {
1140 1140
 	global $wpdb;
1141
-	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'categories');
1142
-	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'link2cat');
1143
-	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'post2cat');
1141
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'categories');
1142
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'link2cat');
1143
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'post2cat');
1144 1144
 }
1145 1145
 
1146 1146
 /**
@@ -1168,7 +1168,7 @@  discard block
 block discarded – undo
1168 1168
 function upgrade_250() {
1169 1169
 	global $wp_current_db_version;
1170 1170
 
1171
-	if ( $wp_current_db_version < 6689 ) {
1171
+	if ($wp_current_db_version < 6689) {
1172 1172
 		populate_roles_250();
1173 1173
 	}
1174 1174
 
@@ -1199,7 +1199,7 @@  discard block
 block discarded – undo
1199 1199
 function upgrade_260() {
1200 1200
 	global $wp_current_db_version;
1201 1201
 
1202
-	if ( $wp_current_db_version < 8000 )
1202
+	if ($wp_current_db_version < 8000)
1203 1203
 		populate_roles_260();
1204 1204
 }
1205 1205
 
@@ -1215,12 +1215,12 @@  discard block
 block discarded – undo
1215 1215
 function upgrade_270() {
1216 1216
 	global $wpdb, $wp_current_db_version;
1217 1217
 
1218
-	if ( $wp_current_db_version < 8980 )
1218
+	if ($wp_current_db_version < 8980)
1219 1219
 		populate_roles_270();
1220 1220
 
1221 1221
 	// Update post_date for unpublished posts with empty timestamp
1222
-	if ( $wp_current_db_version < 8921 )
1223
-		$wpdb->query( "UPDATE $wpdb->posts SET post_date = post_modified WHERE post_date = '0000-00-00 00:00:00'" );
1222
+	if ($wp_current_db_version < 8921)
1223
+		$wpdb->query("UPDATE $wpdb->posts SET post_date = post_modified WHERE post_date = '0000-00-00 00:00:00'");
1224 1224
 }
1225 1225
 
1226 1226
 /**
@@ -1235,22 +1235,22 @@  discard block
 block discarded – undo
1235 1235
 function upgrade_280() {
1236 1236
 	global $wp_current_db_version, $wpdb;
1237 1237
 
1238
-	if ( $wp_current_db_version < 10360 )
1238
+	if ($wp_current_db_version < 10360)
1239 1239
 		populate_roles_280();
1240
-	if ( is_multisite() ) {
1240
+	if (is_multisite()) {
1241 1241
 		$start = 0;
1242
-		while( $rows = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options ORDER BY option_id LIMIT $start, 20" ) ) {
1243
-			foreach ( $rows as $row ) {
1242
+		while ($rows = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options ORDER BY option_id LIMIT $start, 20")) {
1243
+			foreach ($rows as $row) {
1244 1244
 				$value = $row->option_value;
1245
-				if ( !@unserialize( $value ) )
1246
-					$value = stripslashes( $value );
1247
-				if ( $value !== $row->option_value ) {
1248
-					update_option( $row->option_name, $value );
1245
+				if ( ! @unserialize($value))
1246
+					$value = stripslashes($value);
1247
+				if ($value !== $row->option_value) {
1248
+					update_option($row->option_name, $value);
1249 1249
 				}
1250 1250
 			}
1251 1251
 			$start += 20;
1252 1252
 		}
1253
-		refresh_blog_details( $wpdb->blogid );
1253
+		refresh_blog_details($wpdb->blogid);
1254 1254
 	}
1255 1255
 }
1256 1256
 
@@ -1265,11 +1265,11 @@  discard block
 block discarded – undo
1265 1265
 function upgrade_290() {
1266 1266
 	global $wp_current_db_version;
1267 1267
 
1268
-	if ( $wp_current_db_version < 11958 ) {
1268
+	if ($wp_current_db_version < 11958) {
1269 1269
 		// Previously, setting depth to 1 would redundantly disable threading, but now 2 is the minimum depth to avoid confusion
1270
-		if ( get_option( 'thread_comments_depth' ) == '1' ) {
1271
-			update_option( 'thread_comments_depth', 2 );
1272
-			update_option( 'thread_comments', 0 );
1270
+		if (get_option('thread_comments_depth') == '1') {
1271
+			update_option('thread_comments_depth', 2);
1272
+			update_option('thread_comments', 0);
1273 1273
 		}
1274 1274
 	}
1275 1275
 }
@@ -1286,14 +1286,14 @@  discard block
 block discarded – undo
1286 1286
 function upgrade_300() {
1287 1287
 	global $wp_current_db_version, $wpdb;
1288 1288
 
1289
-	if ( $wp_current_db_version < 15093 )
1289
+	if ($wp_current_db_version < 15093)
1290 1290
 		populate_roles_300();
1291 1291
 
1292
-	if ( $wp_current_db_version < 14139 && is_multisite() && is_main_site() && ! defined( 'MULTISITE' ) && get_site_option( 'siteurl' ) === false )
1293
-		add_site_option( 'siteurl', '' );
1292
+	if ($wp_current_db_version < 14139 && is_multisite() && is_main_site() && ! defined('MULTISITE') && get_site_option('siteurl') === false)
1293
+		add_site_option('siteurl', '');
1294 1294
 
1295 1295
 	// 3.0 screen options key name changes.
1296
-	if ( wp_should_upgrade_global_tables() ) {
1296
+	if (wp_should_upgrade_global_tables()) {
1297 1297
 		$sql = "DELETE FROM $wpdb->usermeta
1298 1298
 			WHERE meta_key LIKE %s
1299 1299
 			OR meta_key LIKE %s
@@ -1307,15 +1307,15 @@  discard block
 block discarded – undo
1307 1307
 			OR meta_key = 'manageeditcolumnshidden'
1308 1308
 			OR meta_key = 'categories_per_page'
1309 1309
 			OR meta_key = 'edit_tags_per_page'";
1310
-		$prefix = $wpdb->esc_like( $wpdb->base_prefix );
1311
-		$wpdb->query( $wpdb->prepare( $sql,
1312
-			$prefix . '%' . $wpdb->esc_like( 'meta-box-hidden' ) . '%',
1313
-			$prefix . '%' . $wpdb->esc_like( 'closedpostboxes' ) . '%',
1314
-			$prefix . '%' . $wpdb->esc_like( 'manage-'	   ) . '%' . $wpdb->esc_like( '-columns-hidden' ) . '%',
1315
-			$prefix . '%' . $wpdb->esc_like( 'meta-box-order'  ) . '%',
1316
-			$prefix . '%' . $wpdb->esc_like( 'metaboxorder'    ) . '%',
1317
-			$prefix . '%' . $wpdb->esc_like( 'screen_layout'   ) . '%'
1318
-		) );
1310
+		$prefix = $wpdb->esc_like($wpdb->base_prefix);
1311
+		$wpdb->query($wpdb->prepare($sql,
1312
+			$prefix.'%'.$wpdb->esc_like('meta-box-hidden').'%',
1313
+			$prefix.'%'.$wpdb->esc_like('closedpostboxes').'%',
1314
+			$prefix.'%'.$wpdb->esc_like('manage-').'%'.$wpdb->esc_like('-columns-hidden').'%',
1315
+			$prefix.'%'.$wpdb->esc_like('meta-box-order').'%',
1316
+			$prefix.'%'.$wpdb->esc_like('metaboxorder').'%',
1317
+			$prefix.'%'.$wpdb->esc_like('screen_layout').'%'
1318
+		));
1319 1319
 	}
1320 1320
 
1321 1321
 }
@@ -1334,52 +1334,52 @@  discard block
 block discarded – undo
1334 1334
 function upgrade_330() {
1335 1335
 	global $wp_current_db_version, $wpdb, $wp_registered_widgets, $sidebars_widgets;
1336 1336
 
1337
-	if ( $wp_current_db_version < 19061 && wp_should_upgrade_global_tables() ) {
1338
-		$wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key IN ('show_admin_bar_admin', 'plugins_last_view')" );
1337
+	if ($wp_current_db_version < 19061 && wp_should_upgrade_global_tables()) {
1338
+		$wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key IN ('show_admin_bar_admin', 'plugins_last_view')");
1339 1339
 	}
1340 1340
 
1341
-	if ( $wp_current_db_version >= 11548 )
1341
+	if ($wp_current_db_version >= 11548)
1342 1342
 		return;
1343 1343
 
1344
-	$sidebars_widgets = get_option( 'sidebars_widgets', array() );
1344
+	$sidebars_widgets = get_option('sidebars_widgets', array());
1345 1345
 	$_sidebars_widgets = array();
1346 1346
 
1347
-	if ( isset($sidebars_widgets['wp_inactive_widgets']) || empty($sidebars_widgets) )
1347
+	if (isset($sidebars_widgets['wp_inactive_widgets']) || empty($sidebars_widgets))
1348 1348
 		$sidebars_widgets['array_version'] = 3;
1349
-	elseif ( !isset($sidebars_widgets['array_version']) )
1349
+	elseif ( ! isset($sidebars_widgets['array_version']))
1350 1350
 		$sidebars_widgets['array_version'] = 1;
1351 1351
 
1352
-	switch ( $sidebars_widgets['array_version'] ) {
1352
+	switch ($sidebars_widgets['array_version']) {
1353 1353
 		case 1 :
1354
-			foreach ( (array) $sidebars_widgets as $index => $sidebar )
1355
-			if ( is_array($sidebar) )
1356
-			foreach ( (array) $sidebar as $i => $name ) {
1354
+			foreach ((array) $sidebars_widgets as $index => $sidebar)
1355
+			if (is_array($sidebar))
1356
+			foreach ((array) $sidebar as $i => $name) {
1357 1357
 				$id = strtolower($name);
1358
-				if ( isset($wp_registered_widgets[$id]) ) {
1358
+				if (isset($wp_registered_widgets[$id])) {
1359 1359
 					$_sidebars_widgets[$index][$i] = $id;
1360 1360
 					continue;
1361 1361
 				}
1362 1362
 				$id = sanitize_title($name);
1363
-				if ( isset($wp_registered_widgets[$id]) ) {
1363
+				if (isset($wp_registered_widgets[$id])) {
1364 1364
 					$_sidebars_widgets[$index][$i] = $id;
1365 1365
 					continue;
1366 1366
 				}
1367 1367
 
1368 1368
 				$found = false;
1369 1369
 
1370
-				foreach ( $wp_registered_widgets as $widget_id => $widget ) {
1371
-					if ( strtolower($widget['name']) == strtolower($name) ) {
1370
+				foreach ($wp_registered_widgets as $widget_id => $widget) {
1371
+					if (strtolower($widget['name']) == strtolower($name)) {
1372 1372
 						$_sidebars_widgets[$index][$i] = $widget['id'];
1373 1373
 						$found = true;
1374 1374
 						break;
1375
-					} elseif ( sanitize_title($widget['name']) == sanitize_title($name) ) {
1375
+					} elseif (sanitize_title($widget['name']) == sanitize_title($name)) {
1376 1376
 						$_sidebars_widgets[$index][$i] = $widget['id'];
1377 1377
 						$found = true;
1378 1378
 						break;
1379 1379
 					}
1380 1380
 				}
1381 1381
 
1382
-				if ( $found )
1382
+				if ($found)
1383 1383
 					continue;
1384 1384
 
1385 1385
 				unset($_sidebars_widgets[$index][$i]);
@@ -1391,7 +1391,7 @@  discard block
 block discarded – undo
1391 1391
 		case 2 :
1392 1392
 			$sidebars_widgets = retrieve_widgets();
1393 1393
 			$sidebars_widgets['array_version'] = 3;
1394
-			update_option( 'sidebars_widgets', $sidebars_widgets );
1394
+			update_option('sidebars_widgets', $sidebars_widgets);
1395 1395
 	}
1396 1396
 }
1397 1397
 
@@ -1407,27 +1407,27 @@  discard block
 block discarded – undo
1407 1407
 function upgrade_340() {
1408 1408
 	global $wp_current_db_version, $wpdb;
1409 1409
 
1410
-	if ( $wp_current_db_version < 19798 ) {
1410
+	if ($wp_current_db_version < 19798) {
1411 1411
 		$wpdb->hide_errors();
1412
-		$wpdb->query( "ALTER TABLE $wpdb->options DROP COLUMN blog_id" );
1412
+		$wpdb->query("ALTER TABLE $wpdb->options DROP COLUMN blog_id");
1413 1413
 		$wpdb->show_errors();
1414 1414
 	}
1415 1415
 
1416
-	if ( $wp_current_db_version < 19799 ) {
1416
+	if ($wp_current_db_version < 19799) {
1417 1417
 		$wpdb->hide_errors();
1418 1418
 		$wpdb->query("ALTER TABLE $wpdb->comments DROP INDEX comment_approved");
1419 1419
 		$wpdb->show_errors();
1420 1420
 	}
1421 1421
 
1422
-	if ( $wp_current_db_version < 20022 && wp_should_upgrade_global_tables() ) {
1423
-		$wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key = 'themes_last_view'" );
1422
+	if ($wp_current_db_version < 20022 && wp_should_upgrade_global_tables()) {
1423
+		$wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key = 'themes_last_view'");
1424 1424
 	}
1425 1425
 
1426
-	if ( $wp_current_db_version < 20080 ) {
1427
-		if ( 'yes' == $wpdb->get_var( "SELECT autoload FROM $wpdb->options WHERE option_name = 'uninstall_plugins'" ) ) {
1428
-			$uninstall_plugins = get_option( 'uninstall_plugins' );
1429
-			delete_option( 'uninstall_plugins' );
1430
-			add_option( 'uninstall_plugins', $uninstall_plugins, null, 'no' );
1426
+	if ($wp_current_db_version < 20080) {
1427
+		if ('yes' == $wpdb->get_var("SELECT autoload FROM $wpdb->options WHERE option_name = 'uninstall_plugins'")) {
1428
+			$uninstall_plugins = get_option('uninstall_plugins');
1429
+			delete_option('uninstall_plugins');
1430
+			add_option('uninstall_plugins', $uninstall_plugins, null, 'no');
1431 1431
 		}
1432 1432
 	}
1433 1433
 }
@@ -1444,23 +1444,23 @@  discard block
 block discarded – undo
1444 1444
 function upgrade_350() {
1445 1445
 	global $wp_current_db_version, $wpdb;
1446 1446
 
1447
-	if ( $wp_current_db_version < 22006 && $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) )
1448
-		update_option( 'link_manager_enabled', 1 ); // Previously set to 0 by populate_options()
1447
+	if ($wp_current_db_version < 22006 && $wpdb->get_var("SELECT link_id FROM $wpdb->links LIMIT 1"))
1448
+		update_option('link_manager_enabled', 1); // Previously set to 0 by populate_options()
1449 1449
 
1450
-	if ( $wp_current_db_version < 21811 && wp_should_upgrade_global_tables() ) {
1450
+	if ($wp_current_db_version < 21811 && wp_should_upgrade_global_tables()) {
1451 1451
 		$meta_keys = array();
1452
-		foreach ( array_merge( get_post_types(), get_taxonomies() ) as $name ) {
1453
-			if ( false !== strpos( $name, '-' ) )
1454
-			$meta_keys[] = 'edit_' . str_replace( '-', '_', $name ) . '_per_page';
1452
+		foreach (array_merge(get_post_types(), get_taxonomies()) as $name) {
1453
+			if (false !== strpos($name, '-'))
1454
+			$meta_keys[] = 'edit_'.str_replace('-', '_', $name).'_per_page';
1455 1455
 		}
1456
-		if ( $meta_keys ) {
1457
-			$meta_keys = implode( "', '", $meta_keys );
1458
-			$wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key IN ('$meta_keys')" );
1456
+		if ($meta_keys) {
1457
+			$meta_keys = implode("', '", $meta_keys);
1458
+			$wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key IN ('$meta_keys')");
1459 1459
 		}
1460 1460
 	}
1461 1461
 
1462
-	if ( $wp_current_db_version < 22422 && $term = get_term_by( 'slug', 'post-format-standard', 'post_format' ) )
1463
-		wp_delete_term( $term->term_id, 'post_format' );
1462
+	if ($wp_current_db_version < 22422 && $term = get_term_by('slug', 'post-format-standard', 'post_format'))
1463
+		wp_delete_term($term->term_id, 'post_format');
1464 1464
 }
1465 1465
 
1466 1466
 /**
@@ -1473,8 +1473,8 @@  discard block
 block discarded – undo
1473 1473
  */
1474 1474
 function upgrade_370() {
1475 1475
 	global $wp_current_db_version;
1476
-	if ( $wp_current_db_version < 25824 )
1477
-		wp_clear_scheduled_hook( 'wp_auto_updates_maybe_update' );
1476
+	if ($wp_current_db_version < 25824)
1477
+		wp_clear_scheduled_hook('wp_auto_updates_maybe_update');
1478 1478
 }
1479 1479
 
1480 1480
 /**
@@ -1488,8 +1488,8 @@  discard block
 block discarded – undo
1488 1488
  */
1489 1489
 function upgrade_372() {
1490 1490
 	global $wp_current_db_version;
1491
-	if ( $wp_current_db_version < 26148 )
1492
-		wp_clear_scheduled_hook( 'wp_maybe_auto_update' );
1491
+	if ($wp_current_db_version < 26148)
1492
+		wp_clear_scheduled_hook('wp_maybe_auto_update');
1493 1493
 }
1494 1494
 
1495 1495
 /**
@@ -1502,8 +1502,8 @@  discard block
 block discarded – undo
1502 1502
  */
1503 1503
 function upgrade_380() {
1504 1504
 	global $wp_current_db_version;
1505
-	if ( $wp_current_db_version < 26691 ) {
1506
-		deactivate_plugins( array( 'mp6/mp6.php' ), true );
1505
+	if ($wp_current_db_version < 26691) {
1506
+		deactivate_plugins(array('mp6/mp6.php'), true);
1507 1507
 	}
1508 1508
 }
1509 1509
 
@@ -1517,12 +1517,12 @@  discard block
 block discarded – undo
1517 1517
  */
1518 1518
 function upgrade_400() {
1519 1519
 	global $wp_current_db_version;
1520
-	if ( $wp_current_db_version < 29630 ) {
1521
-		if ( ! is_multisite() && false === get_option( 'WPLANG' ) ) {
1522
-			if ( defined( 'WPLANG' ) && ( '' !== WPLANG ) && in_array( WPLANG, get_available_languages() ) ) {
1523
-				update_option( 'WPLANG', WPLANG );
1520
+	if ($wp_current_db_version < 29630) {
1521
+		if ( ! is_multisite() && false === get_option('WPLANG')) {
1522
+			if (defined('WPLANG') && ('' !== WPLANG) && in_array(WPLANG, get_available_languages())) {
1523
+				update_option('WPLANG', WPLANG);
1524 1524
 			} else {
1525
-				update_option( 'WPLANG', '' );
1525
+				update_option('WPLANG', '');
1526 1526
 			}
1527 1527
 		}
1528 1528
 	}
@@ -1551,29 +1551,29 @@  discard block
 block discarded – undo
1551 1551
 function upgrade_430() {
1552 1552
 	global $wp_current_db_version, $wpdb;
1553 1553
 
1554
-	if ( $wp_current_db_version < 32364 ) {
1554
+	if ($wp_current_db_version < 32364) {
1555 1555
 		upgrade_430_fix_comments();
1556 1556
 	}
1557 1557
 
1558 1558
 	// Shared terms are split in a separate process.
1559
-	if ( $wp_current_db_version < 32814 ) {
1560
-		update_option( 'finished_splitting_shared_terms', 0 );
1561
-		wp_schedule_single_event( time() + ( 1 * MINUTE_IN_SECONDS ), 'wp_split_shared_term_batch' );
1559
+	if ($wp_current_db_version < 32814) {
1560
+		update_option('finished_splitting_shared_terms', 0);
1561
+		wp_schedule_single_event(time() + (1 * MINUTE_IN_SECONDS), 'wp_split_shared_term_batch');
1562 1562
 	}
1563 1563
 
1564
-	if ( $wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset ) {
1565
-		if ( is_multisite() ) {
1566
-			$tables = $wpdb->tables( 'blog' );
1564
+	if ($wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset) {
1565
+		if (is_multisite()) {
1566
+			$tables = $wpdb->tables('blog');
1567 1567
 		} else {
1568
-			$tables = $wpdb->tables( 'all' );
1569
-			if ( ! wp_should_upgrade_global_tables() ) {
1570
-				$global_tables = $wpdb->tables( 'global' );
1571
-				$tables = array_diff_assoc( $tables, $global_tables );
1568
+			$tables = $wpdb->tables('all');
1569
+			if ( ! wp_should_upgrade_global_tables()) {
1570
+				$global_tables = $wpdb->tables('global');
1571
+				$tables = array_diff_assoc($tables, $global_tables);
1572 1572
 			}
1573 1573
 		}
1574 1574
 
1575
-		foreach ( $tables as $table ) {
1576
-			maybe_convert_table_to_utf8mb4( $table );
1575
+		foreach ($tables as $table) {
1576
+			maybe_convert_table_to_utf8mb4($table);
1577 1577
 		}
1578 1578
 	}
1579 1579
 }
@@ -1590,18 +1590,18 @@  discard block
 block discarded – undo
1590 1590
 function upgrade_430_fix_comments() {
1591 1591
 	global $wp_current_db_version, $wpdb;
1592 1592
 
1593
-	$content_length = $wpdb->get_col_length( $wpdb->comments, 'comment_content' );
1593
+	$content_length = $wpdb->get_col_length($wpdb->comments, 'comment_content');
1594 1594
 
1595
-	if ( is_wp_error( $content_length ) ) {
1595
+	if (is_wp_error($content_length)) {
1596 1596
 		return;
1597 1597
 	}
1598 1598
 
1599
-	if ( false === $content_length ) {
1599
+	if (false === $content_length) {
1600 1600
 		$content_length = array(
1601 1601
 			'type'   => 'byte',
1602 1602
 			'length' => 65535,
1603 1603
 		);
1604
-	} elseif ( ! is_array( $content_length ) ) {
1604
+	} elseif ( ! is_array($content_length)) {
1605 1605
 		$length = (int) $content_length > 0 ? (int) $content_length : 65535;
1606 1606
 		$content_length = array(
1607 1607
 			'type'	 => 'byte',
@@ -1609,12 +1609,12 @@  discard block
 block discarded – undo
1609 1609
 		);
1610 1610
 	}
1611 1611
 
1612
-	if ( 'byte' !== $content_length['type'] || 0 === $content_length['length'] ) {
1612
+	if ('byte' !== $content_length['type'] || 0 === $content_length['length']) {
1613 1613
 		// Sites with malformed DB schemas are on their own.
1614 1614
 		return;
1615 1615
 	}
1616 1616
 
1617
-	$allowed_length = intval( $content_length['length'] ) - 10;
1617
+	$allowed_length = intval($content_length['length']) - 10;
1618 1618
 
1619 1619
 	$comments = $wpdb->get_results(
1620 1620
 		"SELECT `comment_ID` FROM `{$wpdb->comments}`
@@ -1623,8 +1623,8 @@  discard block
 block discarded – undo
1623 1623
 			AND ( `comment_content` LIKE '%<%' OR `comment_content` LIKE '%>%' )"
1624 1624
 	);
1625 1625
 
1626
-	foreach ( $comments as $comment ) {
1627
-		wp_delete_comment( $comment->comment_ID, true );
1626
+	foreach ($comments as $comment) {
1627
+		wp_delete_comment($comment->comment_ID, true);
1628 1628
 	}
1629 1629
 }
1630 1630
 
@@ -1637,9 +1637,9 @@  discard block
 block discarded – undo
1637 1637
 function upgrade_431() {
1638 1638
 	// Fix incorrect cron entries for term splitting
1639 1639
 	$cron_array = _get_cron_array();
1640
-	if ( isset( $cron_array['wp_batch_split_terms'] ) ) {
1641
-		unset( $cron_array['wp_batch_split_terms'] );
1642
-		_set_cron_array( $cron_array );
1640
+	if (isset($cron_array['wp_batch_split_terms'])) {
1641
+		unset($cron_array['wp_batch_split_terms']);
1642
+		_set_cron_array($cron_array);
1643 1643
 	}
1644 1644
 }
1645 1645
 
@@ -1655,15 +1655,15 @@  discard block
 block discarded – undo
1655 1655
 function upgrade_440() {
1656 1656
 	global $wp_current_db_version, $wpdb;
1657 1657
 
1658
-	if ( $wp_current_db_version < 34030 ) {
1659
-		$wpdb->query( "ALTER TABLE {$wpdb->options} MODIFY option_name VARCHAR(191)" );
1658
+	if ($wp_current_db_version < 34030) {
1659
+		$wpdb->query("ALTER TABLE {$wpdb->options} MODIFY option_name VARCHAR(191)");
1660 1660
 	}
1661 1661
 
1662 1662
 	// Remove the unused 'add_users' role.
1663 1663
 	$roles = wp_roles();
1664
-	foreach ( $roles->role_objects as $role ) {
1665
-		if ( $role->has_cap( 'add_users' ) ) {
1666
-			$role->remove_cap( 'add_users' );
1664
+	foreach ($roles->role_objects as $role) {
1665
+		if ($role->has_cap('add_users')) {
1666
+			$role->remove_cap('add_users');
1667 1667
 		}
1668 1668
 	}
1669 1669
 }
@@ -1680,17 +1680,17 @@  discard block
 block discarded – undo
1680 1680
 function upgrade_450() {
1681 1681
 	global $wp_current_db_version, $wpdb;
1682 1682
 
1683
-	if ( $wp_current_db_version < 36180 ) {
1684
-		wp_clear_scheduled_hook( 'wp_maybe_auto_update' );
1683
+	if ($wp_current_db_version < 36180) {
1684
+		wp_clear_scheduled_hook('wp_maybe_auto_update');
1685 1685
 	}
1686 1686
 
1687 1687
 	// Remove unused email confirmation options, moved to usermeta.
1688
-	if ( $wp_current_db_version < 36679 && is_multisite() ) {
1689
-		$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name REGEXP '^[0-9]+_new_email$'" );
1688
+	if ($wp_current_db_version < 36679 && is_multisite()) {
1689
+		$wpdb->query("DELETE FROM $wpdb->options WHERE option_name REGEXP '^[0-9]+_new_email$'");
1690 1690
 	}
1691 1691
 
1692 1692
 	// Remove unused user setting for wpLink.
1693
-	delete_user_setting( 'wplink' );
1693
+	delete_user_setting('wplink');
1694 1694
 }
1695 1695
 
1696 1696
 /**
@@ -1703,7 +1703,7 @@  discard block
 block discarded – undo
1703 1703
  * @global wpdb $wpdb                  WordPress database abstraction object.
1704 1704
  */
1705 1705
 function upgrade_460() {
1706
-	delete_post_meta_by_key( '_post_restored_from' );
1706
+	delete_post_meta_by_key('_post_restored_from');
1707 1707
 }
1708 1708
 
1709 1709
 /**
@@ -1718,7 +1718,7 @@  discard block
 block discarded – undo
1718 1718
 	global $wp_current_db_version, $wpdb;
1719 1719
 
1720 1720
 	// Always.
1721
-	if ( is_main_network() ) {
1721
+	if (is_main_network()) {
1722 1722
 		/*
1723 1723
 		 * Deletes all expired transients. The multi-table delete syntax is used
1724 1724
 		 * to delete the transient record from table a, and the corresponding
@@ -1730,32 +1730,32 @@  discard block
 block discarded – undo
1730 1730
 			AND a.meta_key NOT LIKE %s
1731 1731
 			AND b.meta_key = CONCAT( '_site_transient_timeout_', SUBSTRING( a.meta_key, 17 ) )
1732 1732
 			AND b.meta_value < %d";
1733
-		$wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( '_site_transient_' ) . '%', $wpdb->esc_like ( '_site_transient_timeout_' ) . '%', $time ) );
1733
+		$wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('_site_transient_').'%', $wpdb->esc_like('_site_transient_timeout_').'%', $time));
1734 1734
 	}
1735 1735
 
1736 1736
 	// 2.8.
1737
-	if ( $wp_current_db_version < 11549 ) {
1738
-		$wpmu_sitewide_plugins = get_site_option( 'wpmu_sitewide_plugins' );
1739
-		$active_sitewide_plugins = get_site_option( 'active_sitewide_plugins' );
1740
-		if ( $wpmu_sitewide_plugins ) {
1741
-			if ( !$active_sitewide_plugins )
1737
+	if ($wp_current_db_version < 11549) {
1738
+		$wpmu_sitewide_plugins = get_site_option('wpmu_sitewide_plugins');
1739
+		$active_sitewide_plugins = get_site_option('active_sitewide_plugins');
1740
+		if ($wpmu_sitewide_plugins) {
1741
+			if ( ! $active_sitewide_plugins)
1742 1742
 				$sitewide_plugins = (array) $wpmu_sitewide_plugins;
1743 1743
 			else
1744
-				$sitewide_plugins = array_merge( (array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins );
1744
+				$sitewide_plugins = array_merge((array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins);
1745 1745
 
1746
-			update_site_option( 'active_sitewide_plugins', $sitewide_plugins );
1746
+			update_site_option('active_sitewide_plugins', $sitewide_plugins);
1747 1747
 		}
1748
-		delete_site_option( 'wpmu_sitewide_plugins' );
1749
-		delete_site_option( 'deactivated_sitewide_plugins' );
1748
+		delete_site_option('wpmu_sitewide_plugins');
1749
+		delete_site_option('deactivated_sitewide_plugins');
1750 1750
 
1751 1751
 		$start = 0;
1752
-		while( $rows = $wpdb->get_results( "SELECT meta_key, meta_value FROM {$wpdb->sitemeta} ORDER BY meta_id LIMIT $start, 20" ) ) {
1753
-			foreach ( $rows as $row ) {
1752
+		while ($rows = $wpdb->get_results("SELECT meta_key, meta_value FROM {$wpdb->sitemeta} ORDER BY meta_id LIMIT $start, 20")) {
1753
+			foreach ($rows as $row) {
1754 1754
 				$value = $row->meta_value;
1755
-				if ( !@unserialize( $value ) )
1756
-					$value = stripslashes( $value );
1757
-				if ( $value !== $row->meta_value ) {
1758
-					update_site_option( $row->meta_key, $value );
1755
+				if ( ! @unserialize($value))
1756
+					$value = stripslashes($value);
1757
+				if ($value !== $row->meta_value) {
1758
+					update_site_option($row->meta_key, $value);
1759 1759
 				}
1760 1760
 			}
1761 1761
 			$start += 20;
@@ -1763,95 +1763,95 @@  discard block
 block discarded – undo
1763 1763
 	}
1764 1764
 
1765 1765
 	// 3.0
1766
-	if ( $wp_current_db_version < 13576 )
1767
-		update_site_option( 'global_terms_enabled', '1' );
1766
+	if ($wp_current_db_version < 13576)
1767
+		update_site_option('global_terms_enabled', '1');
1768 1768
 
1769 1769
 	// 3.3
1770
-	if ( $wp_current_db_version < 19390 )
1771
-		update_site_option( 'initial_db_version', $wp_current_db_version );
1770
+	if ($wp_current_db_version < 19390)
1771
+		update_site_option('initial_db_version', $wp_current_db_version);
1772 1772
 
1773
-	if ( $wp_current_db_version < 19470 ) {
1774
-		if ( false === get_site_option( 'active_sitewide_plugins' ) )
1775
-			update_site_option( 'active_sitewide_plugins', array() );
1773
+	if ($wp_current_db_version < 19470) {
1774
+		if (false === get_site_option('active_sitewide_plugins'))
1775
+			update_site_option('active_sitewide_plugins', array());
1776 1776
 	}
1777 1777
 
1778 1778
 	// 3.4
1779
-	if ( $wp_current_db_version < 20148 ) {
1779
+	if ($wp_current_db_version < 20148) {
1780 1780
 		// 'allowedthemes' keys things by stylesheet. 'allowed_themes' keyed things by name.
1781
-		$allowedthemes  = get_site_option( 'allowedthemes'  );
1782
-		$allowed_themes = get_site_option( 'allowed_themes' );
1783
-		if ( false === $allowedthemes && is_array( $allowed_themes ) && $allowed_themes ) {
1781
+		$allowedthemes  = get_site_option('allowedthemes');
1782
+		$allowed_themes = get_site_option('allowed_themes');
1783
+		if (false === $allowedthemes && is_array($allowed_themes) && $allowed_themes) {
1784 1784
 			$converted = array();
1785 1785
 			$themes = wp_get_themes();
1786
-			foreach ( $themes as $stylesheet => $theme_data ) {
1787
-				if ( isset( $allowed_themes[ $theme_data->get('Name') ] ) )
1788
-					$converted[ $stylesheet ] = true;
1786
+			foreach ($themes as $stylesheet => $theme_data) {
1787
+				if (isset($allowed_themes[$theme_data->get('Name')]))
1788
+					$converted[$stylesheet] = true;
1789 1789
 			}
1790
-			update_site_option( 'allowedthemes', $converted );
1791
-			delete_site_option( 'allowed_themes' );
1790
+			update_site_option('allowedthemes', $converted);
1791
+			delete_site_option('allowed_themes');
1792 1792
 		}
1793 1793
 	}
1794 1794
 
1795 1795
 	// 3.5
1796
-	if ( $wp_current_db_version < 21823 )
1797
-		update_site_option( 'ms_files_rewriting', '1' );
1796
+	if ($wp_current_db_version < 21823)
1797
+		update_site_option('ms_files_rewriting', '1');
1798 1798
 
1799 1799
 	// 3.5.2
1800
-	if ( $wp_current_db_version < 24448 ) {
1801
-		$illegal_names = get_site_option( 'illegal_names' );
1802
-		if ( is_array( $illegal_names ) && count( $illegal_names ) === 1 ) {
1803
-			$illegal_name = reset( $illegal_names );
1804
-			$illegal_names = explode( ' ', $illegal_name );
1805
-			update_site_option( 'illegal_names', $illegal_names );
1800
+	if ($wp_current_db_version < 24448) {
1801
+		$illegal_names = get_site_option('illegal_names');
1802
+		if (is_array($illegal_names) && count($illegal_names) === 1) {
1803
+			$illegal_name = reset($illegal_names);
1804
+			$illegal_names = explode(' ', $illegal_name);
1805
+			update_site_option('illegal_names', $illegal_names);
1806 1806
 		}
1807 1807
 	}
1808 1808
 
1809 1809
 	// 4.2
1810
-	if ( $wp_current_db_version < 31351 && $wpdb->charset === 'utf8mb4' ) {
1811
-		if ( wp_should_upgrade_global_tables() ) {
1812
-			$wpdb->query( "ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
1813
-			$wpdb->query( "ALTER TABLE $wpdb->site DROP INDEX domain, ADD INDEX domain(domain(140),path(51))" );
1814
-			$wpdb->query( "ALTER TABLE $wpdb->sitemeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
1815
-			$wpdb->query( "ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))" );
1810
+	if ($wp_current_db_version < 31351 && $wpdb->charset === 'utf8mb4') {
1811
+		if (wp_should_upgrade_global_tables()) {
1812
+			$wpdb->query("ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
1813
+			$wpdb->query("ALTER TABLE $wpdb->site DROP INDEX domain, ADD INDEX domain(domain(140),path(51))");
1814
+			$wpdb->query("ALTER TABLE $wpdb->sitemeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
1815
+			$wpdb->query("ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))");
1816 1816
 
1817
-			$tables = $wpdb->tables( 'global' );
1817
+			$tables = $wpdb->tables('global');
1818 1818
 
1819 1819
 			// sitecategories may not exist.
1820
-			if ( ! $wpdb->get_var( "SHOW TABLES LIKE '{$tables['sitecategories']}'" ) ) {
1821
-				unset( $tables['sitecategories'] );
1820
+			if ( ! $wpdb->get_var("SHOW TABLES LIKE '{$tables['sitecategories']}'")) {
1821
+				unset($tables['sitecategories']);
1822 1822
 			}
1823 1823
 
1824
-			foreach ( $tables as $table ) {
1825
-				maybe_convert_table_to_utf8mb4( $table );
1824
+			foreach ($tables as $table) {
1825
+				maybe_convert_table_to_utf8mb4($table);
1826 1826
 			}
1827 1827
 		}
1828 1828
 	}
1829 1829
 
1830 1830
 	// 4.3
1831
-	if ( $wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset ) {
1832
-		if ( wp_should_upgrade_global_tables() ) {
1831
+	if ($wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset) {
1832
+		if (wp_should_upgrade_global_tables()) {
1833 1833
 			$upgrade = false;
1834
-			$indexes = $wpdb->get_results( "SHOW INDEXES FROM $wpdb->signups" );
1835
-			foreach ( $indexes as $index ) {
1836
-				if ( 'domain_path' == $index->Key_name && 'domain' == $index->Column_name && 140 != $index->Sub_part ) {
1834
+			$indexes = $wpdb->get_results("SHOW INDEXES FROM $wpdb->signups");
1835
+			foreach ($indexes as $index) {
1836
+				if ('domain_path' == $index->Key_name && 'domain' == $index->Column_name && 140 != $index->Sub_part) {
1837 1837
 					$upgrade = true;
1838 1838
 					break;
1839 1839
 				}
1840 1840
 			}
1841 1841
 
1842
-			if ( $upgrade ) {
1843
-				$wpdb->query( "ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))" );
1842
+			if ($upgrade) {
1843
+				$wpdb->query("ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))");
1844 1844
 			}
1845 1845
 
1846
-			$tables = $wpdb->tables( 'global' );
1846
+			$tables = $wpdb->tables('global');
1847 1847
 
1848 1848
 			// sitecategories may not exist.
1849
-			if ( ! $wpdb->get_var( "SHOW TABLES LIKE '{$tables['sitecategories']}'" ) ) {
1850
-				unset( $tables['sitecategories'] );
1849
+			if ( ! $wpdb->get_var("SHOW TABLES LIKE '{$tables['sitecategories']}'")) {
1850
+				unset($tables['sitecategories']);
1851 1851
 			}
1852 1852
 
1853
-			foreach ( $tables as $table ) {
1854
-				maybe_convert_table_to_utf8mb4( $table );
1853
+			foreach ($tables as $table) {
1854
+				maybe_convert_table_to_utf8mb4($table);
1855 1855
 			}
1856 1856
 		}
1857 1857
 	}
@@ -1879,9 +1879,9 @@  discard block
 block discarded – undo
1879 1879
 function maybe_create_table($table_name, $create_ddl) {
1880 1880
 	global $wpdb;
1881 1881
 
1882
-	$query = $wpdb->prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $table_name ) );
1882
+	$query = $wpdb->prepare("SHOW TABLES LIKE %s", $wpdb->esc_like($table_name));
1883 1883
 
1884
-	if ( $wpdb->get_var( $query ) == $table_name ) {
1884
+	if ($wpdb->get_var($query) == $table_name) {
1885 1885
 		return true;
1886 1886
 	}
1887 1887
 
@@ -1889,7 +1889,7 @@  discard block
 block discarded – undo
1889 1889
 	$wpdb->query($create_ddl);
1890 1890
 
1891 1891
 	// We cannot directly tell that whether this succeeded!
1892
-	if ( $wpdb->get_var( $query ) == $table_name ) {
1892
+	if ($wpdb->get_var($query) == $table_name) {
1893 1893
 		return true;
1894 1894
 	}
1895 1895
 	return false;
@@ -1950,7 +1950,7 @@  discard block
 block discarded – undo
1950 1950
  */
1951 1951
 function maybe_add_column($table_name, $column_name, $create_ddl) {
1952 1952
 	global $wpdb;
1953
-	foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
1953
+	foreach ($wpdb->get_col("DESC $table_name", 0) as $column) {
1954 1954
 		if ($column == $column_name) {
1955 1955
 			return true;
1956 1956
 		}
@@ -1960,7 +1960,7 @@  discard block
 block discarded – undo
1960 1960
 	$wpdb->query($create_ddl);
1961 1961
 
1962 1962
 	// We cannot directly tell that whether this succeeded!
1963
-	foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
1963
+	foreach ($wpdb->get_col("DESC $table_name", 0) as $column) {
1964 1964
 		if ($column == $column_name) {
1965 1965
 			return true;
1966 1966
 		}
@@ -1978,37 +1978,37 @@  discard block
 block discarded – undo
1978 1978
  * @param string $table The table to convert.
1979 1979
  * @return bool true if the table was converted, false if it wasn't.
1980 1980
  */
1981
-function maybe_convert_table_to_utf8mb4( $table ) {
1981
+function maybe_convert_table_to_utf8mb4($table) {
1982 1982
 	global $wpdb;
1983 1983
 
1984
-	$results = $wpdb->get_results( "SHOW FULL COLUMNS FROM `$table`" );
1985
-	if ( ! $results ) {
1984
+	$results = $wpdb->get_results("SHOW FULL COLUMNS FROM `$table`");
1985
+	if ( ! $results) {
1986 1986
 		return false;
1987 1987
 	}
1988 1988
 
1989
-	foreach ( $results as $column ) {
1990
-		if ( $column->Collation ) {
1991
-			list( $charset ) = explode( '_', $column->Collation );
1992
-			$charset = strtolower( $charset );
1993
-			if ( 'utf8' !== $charset && 'utf8mb4' !== $charset ) {
1989
+	foreach ($results as $column) {
1990
+		if ($column->Collation) {
1991
+			list($charset) = explode('_', $column->Collation);
1992
+			$charset = strtolower($charset);
1993
+			if ('utf8' !== $charset && 'utf8mb4' !== $charset) {
1994 1994
 				// Don't upgrade tables that have non-utf8 columns.
1995 1995
 				return false;
1996 1996
 			}
1997 1997
 		}
1998 1998
 	}
1999 1999
 
2000
-	$table_details = $wpdb->get_row( "SHOW TABLE STATUS LIKE '$table'" );
2001
-	if ( ! $table_details ) {
2000
+	$table_details = $wpdb->get_row("SHOW TABLE STATUS LIKE '$table'");
2001
+	if ( ! $table_details) {
2002 2002
 		return false;
2003 2003
 	}
2004 2004
 
2005
-	list( $table_charset ) = explode( '_', $table_details->Collation );
2006
-	$table_charset = strtolower( $table_charset );
2007
-	if ( 'utf8mb4' === $table_charset ) {
2005
+	list($table_charset) = explode('_', $table_details->Collation);
2006
+	$table_charset = strtolower($table_charset);
2007
+	if ('utf8mb4' === $table_charset) {
2008 2008
 		return true;
2009 2009
 	}
2010 2010
 
2011
-	return $wpdb->query( "ALTER TABLE $table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci" );
2011
+	return $wpdb->query("ALTER TABLE $table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci");
2012 2012
 }
2013 2013
 
2014 2014
 /**
@@ -2023,11 +2023,11 @@  discard block
 block discarded – undo
2023 2023
 function get_alloptions_110() {
2024 2024
 	global $wpdb;
2025 2025
 	$all_options = new stdClass;
2026
-	if ( $options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ) ) {
2027
-		foreach ( $options as $option ) {
2028
-			if ( 'siteurl' == $option->option_name || 'home' == $option->option_name || 'category_base' == $option->option_name )
2029
-				$option->option_value = untrailingslashit( $option->option_value );
2030
-			$all_options->{$option->option_name} = stripslashes( $option->option_value );
2026
+	if ($options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options")) {
2027
+		foreach ($options as $option) {
2028
+			if ('siteurl' == $option->option_name || 'home' == $option->option_name || 'category_base' == $option->option_name)
2029
+				$option->option_value = untrailingslashit($option->option_value);
2030
+			$all_options->{$option->option_name} = stripslashes($option->option_value);
2031 2031
 		}
2032 2032
 	}
2033 2033
 	return $all_options;
@@ -2048,21 +2048,21 @@  discard block
 block discarded – undo
2048 2048
 function __get_option($setting) {
2049 2049
 	global $wpdb;
2050 2050
 
2051
-	if ( $setting == 'home' && defined( 'WP_HOME' ) )
2052
-		return untrailingslashit( WP_HOME );
2051
+	if ($setting == 'home' && defined('WP_HOME'))
2052
+		return untrailingslashit(WP_HOME);
2053 2053
 
2054
-	if ( $setting == 'siteurl' && defined( 'WP_SITEURL' ) )
2055
-		return untrailingslashit( WP_SITEURL );
2054
+	if ($setting == 'siteurl' && defined('WP_SITEURL'))
2055
+		return untrailingslashit(WP_SITEURL);
2056 2056
 
2057
-	$option = $wpdb->get_var( $wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s", $setting ) );
2057
+	$option = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s", $setting));
2058 2058
 
2059
-	if ( 'home' == $setting && '' == $option )
2060
-		return __get_option( 'siteurl' );
2059
+	if ('home' == $setting && '' == $option)
2060
+		return __get_option('siteurl');
2061 2061
 
2062
-	if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting || 'tag_base' == $setting )
2063
-		$option = untrailingslashit( $option );
2062
+	if ('siteurl' == $setting || 'home' == $setting || 'category_base' == $setting || 'tag_base' == $setting)
2063
+		$option = untrailingslashit($option);
2064 2064
 
2065
-	return maybe_unserialize( $option );
2065
+	return maybe_unserialize($option);
2066 2066
 }
2067 2067
 
2068 2068
 /**
@@ -2110,16 +2110,16 @@  discard block
 block discarded – undo
2110 2110
  *                              Default true.
2111 2111
  * @return array Strings containing the results of the various update queries.
2112 2112
  */
2113
-function dbDelta( $queries = '', $execute = true ) {
2113
+function dbDelta($queries = '', $execute = true) {
2114 2114
 	global $wpdb;
2115 2115
 
2116
-	if ( in_array( $queries, array( '', 'all', 'blog', 'global', 'ms_global' ), true ) )
2117
-	    $queries = wp_get_db_schema( $queries );
2116
+	if (in_array($queries, array('', 'all', 'blog', 'global', 'ms_global'), true))
2117
+	    $queries = wp_get_db_schema($queries);
2118 2118
 
2119 2119
 	// Separate individual queries into an array
2120
-	if ( !is_array($queries) ) {
2121
-		$queries = explode( ';', $queries );
2122
-		$queries = array_filter( $queries );
2120
+	if ( ! is_array($queries)) {
2121
+		$queries = explode(';', $queries);
2122
+		$queries = array_filter($queries);
2123 2123
 	}
2124 2124
 
2125 2125
 	/**
@@ -2129,7 +2129,7 @@  discard block
 block discarded – undo
2129 2129
 	 *
2130 2130
 	 * @param array $queries An array of dbDelta SQL queries.
2131 2131
 	 */
2132
-	$queries = apply_filters( 'dbdelta_queries', $queries );
2132
+	$queries = apply_filters('dbdelta_queries', $queries);
2133 2133
 
2134 2134
 	$cqueries = array(); // Creation Queries
2135 2135
 	$iqueries = array(); // Insertion Queries
@@ -2137,14 +2137,14 @@  discard block
 block discarded – undo
2137 2137
 
2138 2138
 	// Create a tablename index for an array ($cqueries) of queries
2139 2139
 	foreach ($queries as $qry) {
2140
-		if ( preg_match( "|CREATE TABLE ([^ ]*)|", $qry, $matches ) ) {
2141
-			$cqueries[ trim( $matches[1], '`' ) ] = $qry;
2140
+		if (preg_match("|CREATE TABLE ([^ ]*)|", $qry, $matches)) {
2141
+			$cqueries[trim($matches[1], '`')] = $qry;
2142 2142
 			$for_update[$matches[1]] = 'Created table '.$matches[1];
2143
-		} elseif ( preg_match( "|CREATE DATABASE ([^ ]*)|", $qry, $matches ) ) {
2144
-			array_unshift( $cqueries, $qry );
2145
-		} elseif ( preg_match( "|INSERT INTO ([^ ]*)|", $qry, $matches ) ) {
2143
+		} elseif (preg_match("|CREATE DATABASE ([^ ]*)|", $qry, $matches)) {
2144
+			array_unshift($cqueries, $qry);
2145
+		} elseif (preg_match("|INSERT INTO ([^ ]*)|", $qry, $matches)) {
2146 2146
 			$iqueries[] = $qry;
2147
-		} elseif ( preg_match( "|UPDATE ([^ ]*)|", $qry, $matches ) ) {
2147
+		} elseif (preg_match("|UPDATE ([^ ]*)|", $qry, $matches)) {
2148 2148
 			$iqueries[] = $qry;
2149 2149
 		} else {
2150 2150
 			// Unrecognized query type
@@ -2160,7 +2160,7 @@  discard block
 block discarded – undo
2160 2160
 	 *
2161 2161
 	 * @param array $cqueries An array of dbDelta create SQL queries.
2162 2162
 	 */
2163
-	$cqueries = apply_filters( 'dbdelta_create_queries', $cqueries );
2163
+	$cqueries = apply_filters('dbdelta_create_queries', $cqueries);
2164 2164
 
2165 2165
 	/**
2166 2166
 	 * Filters the dbDelta SQL queries for inserting or updating.
@@ -2171,25 +2171,25 @@  discard block
 block discarded – undo
2171 2171
 	 *
2172 2172
 	 * @param array $iqueries An array of dbDelta insert or update SQL queries.
2173 2173
 	 */
2174
-	$iqueries = apply_filters( 'dbdelta_insert_queries', $iqueries );
2174
+	$iqueries = apply_filters('dbdelta_insert_queries', $iqueries);
2175 2175
 
2176
-	$text_fields = array( 'tinytext', 'text', 'mediumtext', 'longtext' );
2177
-	$blob_fields = array( 'tinyblob', 'blob', 'mediumblob', 'longblob' );
2176
+	$text_fields = array('tinytext', 'text', 'mediumtext', 'longtext');
2177
+	$blob_fields = array('tinyblob', 'blob', 'mediumblob', 'longblob');
2178 2178
 
2179
-	$global_tables = $wpdb->tables( 'global' );
2180
-	foreach ( $cqueries as $table => $qry ) {
2179
+	$global_tables = $wpdb->tables('global');
2180
+	foreach ($cqueries as $table => $qry) {
2181 2181
 		// Upgrade global tables only for the main site. Don't upgrade at all if conditions are not optimal.
2182
-		if ( in_array( $table, $global_tables ) && ! wp_should_upgrade_global_tables() ) {
2183
-			unset( $cqueries[ $table ], $for_update[ $table ] );
2182
+		if (in_array($table, $global_tables) && ! wp_should_upgrade_global_tables()) {
2183
+			unset($cqueries[$table], $for_update[$table]);
2184 2184
 			continue;
2185 2185
 		}
2186 2186
 
2187 2187
 		// Fetch the table column structure from the database
2188 2188
 		$suppress = $wpdb->suppress_errors();
2189 2189
 		$tablefields = $wpdb->get_results("DESCRIBE {$table};");
2190
-		$wpdb->suppress_errors( $suppress );
2190
+		$wpdb->suppress_errors($suppress);
2191 2191
 
2192
-		if ( ! $tablefields )
2192
+		if ( ! $tablefields)
2193 2193
 			continue;
2194 2194
 
2195 2195
 		// Clear the field and index arrays.
@@ -2203,17 +2203,17 @@  discard block
 block discarded – undo
2203 2203
 		$flds = explode("\n", $qryline);
2204 2204
 
2205 2205
 		// For every field line specified in the query.
2206
-		foreach ( $flds as $fld ) {
2207
-			$fld = trim( $fld, " \t\n\r\0\x0B," ); // Default trim characters, plus ','.
2206
+		foreach ($flds as $fld) {
2207
+			$fld = trim($fld, " \t\n\r\0\x0B,"); // Default trim characters, plus ','.
2208 2208
 
2209 2209
 			// Extract the field name.
2210
-			preg_match( '|^([^ ]*)|', $fld, $fvals );
2211
-			$fieldname = trim( $fvals[1], '`' );
2212
-			$fieldname_lowercased = strtolower( $fieldname );
2210
+			preg_match('|^([^ ]*)|', $fld, $fvals);
2211
+			$fieldname = trim($fvals[1], '`');
2212
+			$fieldname_lowercased = strtolower($fieldname);
2213 2213
 
2214 2214
 			// Verify the found field name.
2215 2215
 			$validfield = true;
2216
-			switch ( $fieldname_lowercased ) {
2216
+			switch ($fieldname_lowercased) {
2217 2217
 				case '':
2218 2218
 				case 'primary':
2219 2219
 				case 'index':
@@ -2257,19 +2257,19 @@  discard block
 block discarded – undo
2257 2257
 					);
2258 2258
 
2259 2259
 					// Uppercase the index type and normalize space characters.
2260
-					$index_type = strtoupper( preg_replace( '/\s+/', ' ', trim( $index_matches['index_type'] ) ) );
2260
+					$index_type = strtoupper(preg_replace('/\s+/', ' ', trim($index_matches['index_type'])));
2261 2261
 
2262 2262
 					// 'INDEX' is a synonym for 'KEY', standardize on 'KEY'.
2263
-					$index_type = str_replace( 'INDEX', 'KEY', $index_type );
2263
+					$index_type = str_replace('INDEX', 'KEY', $index_type);
2264 2264
 
2265 2265
 					// Escape the index name with backticks. An index for a primary key has no name.
2266
-					$index_name = ( 'PRIMARY KEY' === $index_type ) ? '' : '`' . $index_matches['index_name'] . '`';
2266
+					$index_name = ('PRIMARY KEY' === $index_type) ? '' : '`'.$index_matches['index_name'].'`';
2267 2267
 
2268 2268
 					// Parse the columns. Multiple columns are separated by a comma.
2269
-					$index_columns = array_map( 'trim', explode( ',', $index_matches['index_columns'] ) );
2269
+					$index_columns = array_map('trim', explode(',', $index_matches['index_columns']));
2270 2270
 
2271 2271
 					// Normalize columns.
2272
-					foreach ( $index_columns as &$index_column ) {
2272
+					foreach ($index_columns as &$index_column) {
2273 2273
 						// Extract column name and number of indexed characters (sub_part).
2274 2274
 						preg_match(
2275 2275
 							  '/'
@@ -2294,66 +2294,66 @@  discard block
 block discarded – undo
2294 2294
 						);
2295 2295
 
2296 2296
 						// Escape the column name with backticks.
2297
-						$index_column = '`' . $index_column_matches['column_name'] . '`';
2297
+						$index_column = '`'.$index_column_matches['column_name'].'`';
2298 2298
 
2299 2299
 						// Append the optional sup part with the number of indexed characters.
2300
-						if ( isset( $index_column_matches['sub_part'] ) ) {
2301
-							$index_column .= '(' . $index_column_matches['sub_part'] . ')';
2300
+						if (isset($index_column_matches['sub_part'])) {
2301
+							$index_column .= '('.$index_column_matches['sub_part'].')';
2302 2302
 						}
2303 2303
 					}
2304 2304
 
2305 2305
 					// Build the normalized index definition and add it to the list of indices.
2306
-					$indices[] = "{$index_type} {$index_name} (" . implode( ',', $index_columns ) . ")";
2306
+					$indices[] = "{$index_type} {$index_name} (".implode(',', $index_columns).")";
2307 2307
 
2308 2308
 					// Destroy no longer needed variables.
2309
-					unset( $index_column, $index_column_matches, $index_matches, $index_type, $index_name, $index_columns );
2309
+					unset($index_column, $index_column_matches, $index_matches, $index_type, $index_name, $index_columns);
2310 2310
 
2311 2311
 					break;
2312 2312
 			}
2313 2313
 
2314 2314
 			// If it's a valid field, add it to the field array.
2315
-			if ( $validfield ) {
2316
-				$cfields[ $fieldname_lowercased ] = $fld;
2315
+			if ($validfield) {
2316
+				$cfields[$fieldname_lowercased] = $fld;
2317 2317
 			}
2318 2318
 		}
2319 2319
 
2320 2320
 		// For every field in the table.
2321
-		foreach ( $tablefields as $tablefield ) {
2322
-			$tablefield_field_lowercased = strtolower( $tablefield->Field );
2323
-			$tablefield_type_lowercased = strtolower( $tablefield->Type );
2321
+		foreach ($tablefields as $tablefield) {
2322
+			$tablefield_field_lowercased = strtolower($tablefield->Field);
2323
+			$tablefield_type_lowercased = strtolower($tablefield->Type);
2324 2324
 
2325 2325
 			// If the table field exists in the field array ...
2326
-			if ( array_key_exists( $tablefield_field_lowercased, $cfields ) ) {
2326
+			if (array_key_exists($tablefield_field_lowercased, $cfields)) {
2327 2327
 
2328 2328
 				// Get the field type from the query.
2329
-				preg_match( '|`?' . $tablefield->Field . '`? ([^ ]*( unsigned)?)|i', $cfields[ $tablefield_field_lowercased ], $matches );
2329
+				preg_match('|`?'.$tablefield->Field.'`? ([^ ]*( unsigned)?)|i', $cfields[$tablefield_field_lowercased], $matches);
2330 2330
 				$fieldtype = $matches[1];
2331
-				$fieldtype_lowercased = strtolower( $fieldtype );
2331
+				$fieldtype_lowercased = strtolower($fieldtype);
2332 2332
 
2333 2333
 				// Is actual field type different from the field type in query?
2334 2334
 				if ($tablefield->Type != $fieldtype) {
2335 2335
 					$do_change = true;
2336
-					if ( in_array( $fieldtype_lowercased, $text_fields ) && in_array( $tablefield_type_lowercased, $text_fields ) ) {
2337
-						if ( array_search( $fieldtype_lowercased, $text_fields ) < array_search( $tablefield_type_lowercased, $text_fields ) ) {
2336
+					if (in_array($fieldtype_lowercased, $text_fields) && in_array($tablefield_type_lowercased, $text_fields)) {
2337
+						if (array_search($fieldtype_lowercased, $text_fields) < array_search($tablefield_type_lowercased, $text_fields)) {
2338 2338
 							$do_change = false;
2339 2339
 						}
2340 2340
 					}
2341 2341
 
2342
-					if ( in_array( $fieldtype_lowercased, $blob_fields ) && in_array( $tablefield_type_lowercased, $blob_fields ) ) {
2343
-						if ( array_search( $fieldtype_lowercased, $blob_fields ) < array_search( $tablefield_type_lowercased, $blob_fields ) ) {
2342
+					if (in_array($fieldtype_lowercased, $blob_fields) && in_array($tablefield_type_lowercased, $blob_fields)) {
2343
+						if (array_search($fieldtype_lowercased, $blob_fields) < array_search($tablefield_type_lowercased, $blob_fields)) {
2344 2344
 							$do_change = false;
2345 2345
 						}
2346 2346
 					}
2347 2347
 
2348
-					if ( $do_change ) {
2348
+					if ($do_change) {
2349 2349
 						// Add a query to change the column type.
2350
-						$cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN `{$tablefield->Field}` " . $cfields[ $tablefield_field_lowercased ];
2350
+						$cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN `{$tablefield->Field}` ".$cfields[$tablefield_field_lowercased];
2351 2351
 						$for_update[$table.'.'.$tablefield->Field] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}";
2352 2352
 					}
2353 2353
 				}
2354 2354
 
2355 2355
 				// Get the default value from the array.
2356
-				if ( preg_match( "| DEFAULT '(.*?)'|i", $cfields[ $tablefield_field_lowercased ], $matches ) ) {
2356
+				if (preg_match("| DEFAULT '(.*?)'|i", $cfields[$tablefield_field_lowercased], $matches)) {
2357 2357
 					$default_value = $matches[1];
2358 2358
 					if ($tablefield->Default != $default_value) {
2359 2359
 						// Add a query to change the column's default value
@@ -2363,7 +2363,7 @@  discard block
 block discarded – undo
2363 2363
 				}
2364 2364
 
2365 2365
 				// Remove the field from the array (so it's not added).
2366
-				unset( $cfields[ $tablefield_field_lowercased ] );
2366
+				unset($cfields[$tablefield_field_lowercased]);
2367 2367
 			} else {
2368 2368
 				// This field exists in the table, but not in the creation queries?
2369 2369
 			}
@@ -2389,7 +2389,7 @@  discard block
 block discarded – undo
2389 2389
 				// Add the index to the index data array.
2390 2390
 				$keyname = $tableindex->Key_name;
2391 2391
 				$index_ary[$keyname]['columns'][] = array('fieldname' => $tableindex->Column_name, 'subpart' => $tableindex->Sub_part);
2392
-				$index_ary[$keyname]['unique'] = ($tableindex->Non_unique == 0)?true:false;
2392
+				$index_ary[$keyname]['unique'] = ($tableindex->Non_unique == 0) ? true : false;
2393 2393
 				$index_ary[$keyname]['index_type'] = $tableindex->Index_type;
2394 2394
 			}
2395 2395
 
@@ -2400,36 +2400,36 @@  discard block
 block discarded – undo
2400 2400
 				$index_string = '';
2401 2401
 				if ($index_name == 'PRIMARY') {
2402 2402
 					$index_string .= 'PRIMARY ';
2403
-				} elseif ( $index_data['unique'] ) {
2403
+				} elseif ($index_data['unique']) {
2404 2404
 					$index_string .= 'UNIQUE ';
2405 2405
 				}
2406
-				if ( 'FULLTEXT' === strtoupper( $index_data['index_type'] ) ) {
2406
+				if ('FULLTEXT' === strtoupper($index_data['index_type'])) {
2407 2407
 					$index_string .= 'FULLTEXT ';
2408 2408
 				}
2409
-				if ( 'SPATIAL' === strtoupper( $index_data['index_type'] ) ) {
2409
+				if ('SPATIAL' === strtoupper($index_data['index_type'])) {
2410 2410
 					$index_string .= 'SPATIAL ';
2411 2411
 				}
2412 2412
 				$index_string .= 'KEY ';
2413
-				if ( 'PRIMARY' !== $index_name  ) {
2414
-					$index_string .= '`' . $index_name . '`';
2413
+				if ('PRIMARY' !== $index_name) {
2414
+					$index_string .= '`'.$index_name.'`';
2415 2415
 				}
2416 2416
 				$index_columns = '';
2417 2417
 
2418 2418
 				// For each column in the index.
2419 2419
 				foreach ($index_data['columns'] as $column_data) {
2420
-					if ( $index_columns != '' ) {
2420
+					if ($index_columns != '') {
2421 2421
 						$index_columns .= ',';
2422 2422
 					}
2423 2423
 
2424 2424
 					// Add the field to the column list string.
2425
-					$index_columns .= '`' . $column_data['fieldname'] . '`';
2425
+					$index_columns .= '`'.$column_data['fieldname'].'`';
2426 2426
 					if ($column_data['subpart'] != '') {
2427 2427
 						$index_columns .= '('.$column_data['subpart'].')';
2428 2428
 					}
2429 2429
 				}
2430 2430
 
2431 2431
 				// The alternative index string doesn't care about subparts
2432
-				$alt_index_columns = preg_replace( '/\([^)]*\)/', '', $index_columns );
2432
+				$alt_index_columns = preg_replace('/\([^)]*\)/', '', $index_columns);
2433 2433
 
2434 2434
 				// Add the column list to the index create string.
2435 2435
 				$index_strings = array(
@@ -2437,9 +2437,9 @@  discard block
 block discarded – undo
2437 2437
 					"$index_string ($alt_index_columns)",
2438 2438
 				);
2439 2439
 
2440
-				foreach ( $index_strings as $index_string ) {
2441
-					if ( ! ( ( $aindex = array_search( $index_string, $indices ) ) === false ) ) {
2442
-						unset( $indices[ $aindex ] );
2440
+				foreach ($index_strings as $index_string) {
2441
+					if ( ! (($aindex = array_search($index_string, $indices)) === false)) {
2442
+						unset($indices[$aindex]);
2443 2443
 						break;
2444 2444
 					}
2445 2445
 				}
@@ -2447,14 +2447,14 @@  discard block
 block discarded – undo
2447 2447
 		}
2448 2448
 
2449 2449
 		// For every remaining index specified for the table.
2450
-		foreach ( (array) $indices as $index ) {
2450
+		foreach ((array) $indices as $index) {
2451 2451
 			// Push a query line into $cqueries that adds the index to that table.
2452 2452
 			$cqueries[] = "ALTER TABLE {$table} ADD $index";
2453
-			$for_update[] = 'Added index ' . $table . ' ' . $index;
2453
+			$for_update[] = 'Added index '.$table.' '.$index;
2454 2454
 		}
2455 2455
 
2456 2456
 		// Remove the original table creation query from processing.
2457
-		unset( $cqueries[ $table ], $for_update[ $table ] );
2457
+		unset($cqueries[$table], $for_update[$table]);
2458 2458
 	}
2459 2459
 
2460 2460
 	$allqueries = array_merge($cqueries, $iqueries);
@@ -2479,8 +2479,8 @@  discard block
 block discarded – undo
2479 2479
  *
2480 2480
  * @param string $tables Optional. Which set of tables to update. Default is 'all'.
2481 2481
  */
2482
-function make_db_current( $tables = 'all' ) {
2483
-	$alterations = dbDelta( $tables );
2482
+function make_db_current($tables = 'all') {
2483
+	$alterations = dbDelta($tables);
2484 2484
 	echo "<ol>\n";
2485 2485
 	foreach ($alterations as $alteration) echo "<li>$alteration</li>\n";
2486 2486
 	echo "</ol>\n";
@@ -2498,8 +2498,8 @@  discard block
 block discarded – undo
2498 2498
  *
2499 2499
  * @param string $tables Optional. Which set of tables to update. Default is 'all'.
2500 2500
  */
2501
-function make_db_current_silent( $tables = 'all' ) {
2502
-	dbDelta( $tables );
2501
+function make_db_current_silent($tables = 'all') {
2502
+	dbDelta($tables);
2503 2503
 }
2504 2504
 
2505 2505
 /**
@@ -2515,9 +2515,9 @@  discard block
 block discarded – undo
2515 2515
  */
2516 2516
 function make_site_theme_from_oldschool($theme_name, $template) {
2517 2517
 	$home_path = get_home_path();
2518
-	$site_dir = WP_CONTENT_DIR . "/themes/$template";
2518
+	$site_dir = WP_CONTENT_DIR."/themes/$template";
2519 2519
 
2520
-	if (! file_exists("$home_path/index.php"))
2520
+	if ( ! file_exists("$home_path/index.php"))
2521 2521
 		return false;
2522 2522
 
2523 2523
 	/*
@@ -2536,7 +2536,7 @@  discard block
 block discarded – undo
2536 2536
 		if ($oldfile == 'index.php') {
2537 2537
 			$index = implode('', file("$oldpath/$oldfile"));
2538 2538
 			if (strpos($index, 'WP_USE_THEMES') !== false) {
2539
-				if (! @copy(WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME . '/index.php', "$site_dir/$newfile"))
2539
+				if ( ! @copy(WP_CONTENT_DIR.'/themes/'.WP_DEFAULT_THEME.'/index.php', "$site_dir/$newfile"))
2540 2540
 					return false;
2541 2541
 
2542 2542
 				// Don't copy anything.
@@ -2544,7 +2544,7 @@  discard block
 block discarded – undo
2544 2544
 			}
2545 2545
 		}
2546 2546
 
2547
-		if (! @copy("$oldpath/$oldfile", "$site_dir/$newfile"))
2547
+		if ( ! @copy("$oldpath/$oldfile", "$site_dir/$newfile"))
2548 2548
 			return false;
2549 2549
 
2550 2550
 		chmod("$site_dir/$newfile", 0777);
@@ -2556,7 +2556,7 @@  discard block
 block discarded – undo
2556 2556
 
2557 2557
 			foreach ($lines as $line) {
2558 2558
 				if (preg_match('/require.*wp-blog-header/', $line))
2559
-					$line = '//' . $line;
2559
+					$line = '//'.$line;
2560 2560
 
2561 2561
 				// Update stylesheet references.
2562 2562
 				$line = str_replace("<?php echo __get_option('siteurl'); ?>/wp-layout.css", "<?php bloginfo('stylesheet_url'); ?>", $line);
@@ -2571,7 +2571,7 @@  discard block
 block discarded – undo
2571 2571
 	}
2572 2572
 
2573 2573
 	// Add a theme header.
2574
-	$header = "/*\nTheme Name: $theme_name\nTheme URI: " . __get_option('siteurl') . "\nDescription: A theme automatically created by the update.\nVersion: 1.0\nAuthor: Moi\n*/\n";
2574
+	$header = "/*\nTheme Name: $theme_name\nTheme URI: ".__get_option('siteurl')."\nDescription: A theme automatically created by the update.\nVersion: 1.0\nAuthor: Moi\n*/\n";
2575 2575
 
2576 2576
 	$stylelines = file_get_contents("$site_dir/style.css");
2577 2577
 	if ($stylelines) {
@@ -2597,18 +2597,18 @@  discard block
 block discarded – undo
2597 2597
  * @return false|void
2598 2598
  */
2599 2599
 function make_site_theme_from_default($theme_name, $template) {
2600
-	$site_dir = WP_CONTENT_DIR . "/themes/$template";
2601
-	$default_dir = WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME;
2600
+	$site_dir = WP_CONTENT_DIR."/themes/$template";
2601
+	$default_dir = WP_CONTENT_DIR.'/themes/'.WP_DEFAULT_THEME;
2602 2602
 
2603 2603
 	// Copy files from the default theme to the site theme.
2604 2604
 	//$files = array('index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css');
2605 2605
 
2606 2606
 	$theme_dir = @ opendir($default_dir);
2607 2607
 	if ($theme_dir) {
2608
-		while(($theme_file = readdir( $theme_dir )) !== false) {
2608
+		while (($theme_file = readdir($theme_dir)) !== false) {
2609 2609
 			if (is_dir("$default_dir/$theme_file"))
2610 2610
 				continue;
2611
-			if (! @copy("$default_dir/$theme_file", "$site_dir/$theme_file"))
2611
+			if ( ! @copy("$default_dir/$theme_file", "$site_dir/$theme_file"))
2612 2612
 				return;
2613 2613
 			chmod("$site_dir/$theme_file", 0777);
2614 2614
 		}
@@ -2621,28 +2621,28 @@  discard block
 block discarded – undo
2621 2621
 		$f = fopen("$site_dir/style.css", 'w');
2622 2622
 
2623 2623
 		foreach ($stylelines as $line) {
2624
-			if (strpos($line, 'Theme Name:') !== false) $line = 'Theme Name: ' . $theme_name;
2625
-			elseif (strpos($line, 'Theme URI:') !== false) $line = 'Theme URI: ' . __get_option('url');
2624
+			if (strpos($line, 'Theme Name:') !== false) $line = 'Theme Name: '.$theme_name;
2625
+			elseif (strpos($line, 'Theme URI:') !== false) $line = 'Theme URI: '.__get_option('url');
2626 2626
 			elseif (strpos($line, 'Description:') !== false) $line = 'Description: Your theme.';
2627 2627
 			elseif (strpos($line, 'Version:') !== false) $line = 'Version: 1';
2628 2628
 			elseif (strpos($line, 'Author:') !== false) $line = 'Author: You';
2629
-			fwrite($f, $line . "\n");
2629
+			fwrite($f, $line."\n");
2630 2630
 		}
2631 2631
 		fclose($f);
2632 2632
 	}
2633 2633
 
2634 2634
 	// Copy the images.
2635 2635
 	umask(0);
2636
-	if (! mkdir("$site_dir/images", 0777)) {
2636
+	if ( ! mkdir("$site_dir/images", 0777)) {
2637 2637
 		return false;
2638 2638
 	}
2639 2639
 
2640 2640
 	$images_dir = @ opendir("$default_dir/images");
2641 2641
 	if ($images_dir) {
2642
-		while(($image = readdir($images_dir)) !== false) {
2642
+		while (($image = readdir($images_dir)) !== false) {
2643 2643
 			if (is_dir("$default_dir/images/$image"))
2644 2644
 				continue;
2645
-			if (! @copy("$default_dir/images/$image", "$site_dir/images/$image"))
2645
+			if ( ! @copy("$default_dir/images/$image", "$site_dir/images/$image"))
2646 2646
 				return;
2647 2647
 			chmod("$site_dir/images/$image", 0777);
2648 2648
 		}
@@ -2663,30 +2663,30 @@  discard block
 block discarded – undo
2663 2663
 	// Name the theme after the blog.
2664 2664
 	$theme_name = __get_option('blogname');
2665 2665
 	$template = sanitize_title($theme_name);
2666
-	$site_dir = WP_CONTENT_DIR . "/themes/$template";
2666
+	$site_dir = WP_CONTENT_DIR."/themes/$template";
2667 2667
 
2668 2668
 	// If the theme already exists, nothing to do.
2669
-	if ( is_dir($site_dir)) {
2669
+	if (is_dir($site_dir)) {
2670 2670
 		return false;
2671 2671
 	}
2672 2672
 
2673 2673
 	// We must be able to write to the themes dir.
2674
-	if (! is_writable(WP_CONTENT_DIR . "/themes")) {
2674
+	if ( ! is_writable(WP_CONTENT_DIR."/themes")) {
2675 2675
 		return false;
2676 2676
 	}
2677 2677
 
2678 2678
 	umask(0);
2679
-	if (! mkdir($site_dir, 0777)) {
2679
+	if ( ! mkdir($site_dir, 0777)) {
2680 2680
 		return false;
2681 2681
 	}
2682 2682
 
2683
-	if (file_exists(ABSPATH . 'wp-layout.css')) {
2684
-		if (! make_site_theme_from_oldschool($theme_name, $template)) {
2683
+	if (file_exists(ABSPATH.'wp-layout.css')) {
2684
+		if ( ! make_site_theme_from_oldschool($theme_name, $template)) {
2685 2685
 			// TODO: rm -rf the site theme directory.
2686 2686
 			return false;
2687 2687
 		}
2688 2688
 	} else {
2689
-		if (! make_site_theme_from_default($theme_name, $template))
2689
+		if ( ! make_site_theme_from_default($theme_name, $template))
2690 2690
 			// TODO: rm -rf the site theme directory.
2691 2691
 			return false;
2692 2692
 	}
@@ -2739,8 +2739,8 @@  discard block
 block discarded – undo
2739 2739
 function wp_check_mysql_version() {
2740 2740
 	global $wpdb;
2741 2741
 	$result = $wpdb->check_database_version();
2742
-	if ( is_wp_error( $result ) )
2743
-		die( $result->get_error_message() );
2742
+	if (is_wp_error($result))
2743
+		die($result->get_error_message());
2744 2744
 }
2745 2745
 
2746 2746
 /**
@@ -2749,12 +2749,12 @@  discard block
 block discarded – undo
2749 2749
  * @since 2.2.0
2750 2750
  */
2751 2751
 function maybe_disable_automattic_widgets() {
2752
-	$plugins = __get_option( 'active_plugins' );
2752
+	$plugins = __get_option('active_plugins');
2753 2753
 
2754
-	foreach ( (array) $plugins as $plugin ) {
2755
-		if ( basename( $plugin ) == 'widgets.php' ) {
2756
-			array_splice( $plugins, array_search( $plugin, $plugins ), 1 );
2757
-			update_option( 'active_plugins', $plugins );
2754
+	foreach ((array) $plugins as $plugin) {
2755
+		if (basename($plugin) == 'widgets.php') {
2756
+			array_splice($plugins, array_search($plugin, $plugins), 1);
2757
+			update_option('active_plugins', $plugins);
2758 2758
 			break;
2759 2759
 		}
2760 2760
 	}
@@ -2771,8 +2771,8 @@  discard block
 block discarded – undo
2771 2771
 function maybe_disable_link_manager() {
2772 2772
 	global $wp_current_db_version, $wpdb;
2773 2773
 
2774
-	if ( $wp_current_db_version >= 22006 && get_option( 'link_manager_enabled' ) && ! $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) )
2775
-		update_option( 'link_manager_enabled', 0 );
2774
+	if ($wp_current_db_version >= 22006 && get_option('link_manager_enabled') && ! $wpdb->get_var("SELECT link_id FROM $wpdb->links LIMIT 1"))
2775
+		update_option('link_manager_enabled', 0);
2776 2776
 }
2777 2777
 
2778 2778
 /**
@@ -2787,7 +2787,7 @@  discard block
 block discarded – undo
2787 2787
 	global $wp_current_db_version, $wpdb;
2788 2788
 
2789 2789
 	// Upgrade versions prior to 2.9
2790
-	if ( $wp_current_db_version < 11557 ) {
2790
+	if ($wp_current_db_version < 11557) {
2791 2791
 		// Delete duplicate options. Keep the option with the highest option_id.
2792 2792
 		$wpdb->query("DELETE o1 FROM $wpdb->options AS o1 JOIN $wpdb->options AS o2 USING (`option_name`) WHERE o2.option_id > o1.option_id");
2793 2793
 
@@ -2799,40 +2799,40 @@  discard block
 block discarded – undo
2799 2799
 	}
2800 2800
 
2801 2801
 	// Multisite schema upgrades.
2802
-	if ( $wp_current_db_version < 25448 && is_multisite() && wp_should_upgrade_global_tables() ) {
2802
+	if ($wp_current_db_version < 25448 && is_multisite() && wp_should_upgrade_global_tables()) {
2803 2803
 
2804 2804
 		// Upgrade verions prior to 3.7
2805
-		if ( $wp_current_db_version < 25179 ) {
2805
+		if ($wp_current_db_version < 25179) {
2806 2806
 			// New primary key for signups.
2807
-			$wpdb->query( "ALTER TABLE $wpdb->signups ADD signup_id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST" );
2808
-			$wpdb->query( "ALTER TABLE $wpdb->signups DROP INDEX domain" );
2807
+			$wpdb->query("ALTER TABLE $wpdb->signups ADD signup_id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST");
2808
+			$wpdb->query("ALTER TABLE $wpdb->signups DROP INDEX domain");
2809 2809
 		}
2810 2810
 
2811
-		if ( $wp_current_db_version < 25448 ) {
2811
+		if ($wp_current_db_version < 25448) {
2812 2812
 			// Convert archived from enum to tinyint.
2813
-			$wpdb->query( "ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived varchar(1) NOT NULL default '0'" );
2814
-			$wpdb->query( "ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived tinyint(2) NOT NULL default 0" );
2813
+			$wpdb->query("ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived varchar(1) NOT NULL default '0'");
2814
+			$wpdb->query("ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived tinyint(2) NOT NULL default 0");
2815 2815
 		}
2816 2816
 	}
2817 2817
 
2818 2818
 	// Upgrade versions prior to 4.2.
2819
-	if ( $wp_current_db_version < 31351 ) {
2820
-		if ( ! is_multisite() && wp_should_upgrade_global_tables() ) {
2821
-			$wpdb->query( "ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
2819
+	if ($wp_current_db_version < 31351) {
2820
+		if ( ! is_multisite() && wp_should_upgrade_global_tables()) {
2821
+			$wpdb->query("ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
2822 2822
 		}
2823
-		$wpdb->query( "ALTER TABLE $wpdb->terms DROP INDEX slug, ADD INDEX slug(slug(191))" );
2824
-		$wpdb->query( "ALTER TABLE $wpdb->terms DROP INDEX name, ADD INDEX name(name(191))" );
2825
-		$wpdb->query( "ALTER TABLE $wpdb->commentmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
2826
-		$wpdb->query( "ALTER TABLE $wpdb->postmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
2827
-		$wpdb->query( "ALTER TABLE $wpdb->posts DROP INDEX post_name, ADD INDEX post_name(post_name(191))" );
2823
+		$wpdb->query("ALTER TABLE $wpdb->terms DROP INDEX slug, ADD INDEX slug(slug(191))");
2824
+		$wpdb->query("ALTER TABLE $wpdb->terms DROP INDEX name, ADD INDEX name(name(191))");
2825
+		$wpdb->query("ALTER TABLE $wpdb->commentmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
2826
+		$wpdb->query("ALTER TABLE $wpdb->postmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
2827
+		$wpdb->query("ALTER TABLE $wpdb->posts DROP INDEX post_name, ADD INDEX post_name(post_name(191))");
2828 2828
 	}
2829 2829
 
2830 2830
 	// Upgrade versions prior to 4.4.
2831
-	if ( $wp_current_db_version < 34978 ) {
2831
+	if ($wp_current_db_version < 34978) {
2832 2832
 		// If compatible termmeta table is found, use it, but enforce a proper index and update collation.
2833
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->termmeta}'" ) && $wpdb->get_results( "SHOW INDEX FROM {$wpdb->termmeta} WHERE Column_name = 'meta_key'" ) ) {
2834
-			$wpdb->query( "ALTER TABLE $wpdb->termmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
2835
-			maybe_convert_table_to_utf8mb4( $wpdb->termmeta );
2833
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->termmeta}'") && $wpdb->get_results("SHOW INDEX FROM {$wpdb->termmeta} WHERE Column_name = 'meta_key'")) {
2834
+			$wpdb->query("ALTER TABLE $wpdb->termmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
2835
+			maybe_convert_table_to_utf8mb4($wpdb->termmeta);
2836 2836
 		}
2837 2837
 	}
2838 2838
 }
@@ -2845,7 +2845,7 @@  discard block
 block discarded – undo
2845 2845
  * @global wpdb   $wpdb
2846 2846
  * @global string $charset_collate
2847 2847
  */
2848
-if ( !function_exists( 'install_global_terms' ) ) :
2848
+if ( ! function_exists('install_global_terms')) :
2849 2849
 function install_global_terms() {
2850 2850
 	global $wpdb, $charset_collate;
2851 2851
 	$ms_queries = "
@@ -2860,7 +2860,7 @@  discard block
 block discarded – undo
2860 2860
 ) $charset_collate;
2861 2861
 ";
2862 2862
 // now create tables
2863
-	dbDelta( $ms_queries );
2863
+	dbDelta($ms_queries);
2864 2864
 }
2865 2865
 endif;
2866 2866
 
@@ -2885,7 +2885,7 @@  discard block
 block discarded – undo
2885 2885
 function wp_should_upgrade_global_tables() {
2886 2886
 
2887 2887
 	// Return false early if explicitly not upgrading
2888
-	if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
2888
+	if (defined('DO_NOT_UPGRADE_GLOBAL_TABLES')) {
2889 2889
 		return false;
2890 2890
 	}
2891 2891
 
@@ -2893,12 +2893,12 @@  discard block
 block discarded – undo
2893 2893
 	$should_upgrade = true;
2894 2894
 
2895 2895
 	// Set to false if not on main network (does not matter if not multi-network)
2896
-	if ( ! is_main_network() ) {
2896
+	if ( ! is_main_network()) {
2897 2897
 		$should_upgrade = false;
2898 2898
 	}
2899 2899
 
2900 2900
 	// Set to false if not on main site of current network (does not matter if not multi-site)
2901
-	if ( ! is_main_site() ) {
2901
+	if ( ! is_main_site()) {
2902 2902
 		$should_upgrade = false;
2903 2903
 	}
2904 2904
 
@@ -2907,5 +2907,5 @@  discard block
 block discarded – undo
2907 2907
 	 *
2908 2908
 	 * @param bool $should_upgrade Whether to run the upgrade routines on global tables.
2909 2909
 	 */
2910
-	return apply_filters( 'wp_should_upgrade_global_tables', $should_upgrade );
2910
+	return apply_filters('wp_should_upgrade_global_tables', $should_upgrade);
2911 2911
 }
Please login to merge, or discard this patch.
Braces   +368 added lines, -238 removed lines patch added patch discarded remove patch
@@ -9,8 +9,9 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 /** Include user install customize script. */
12
-if ( file_exists(WP_CONTENT_DIR . '/install.php') )
12
+if ( file_exists(WP_CONTENT_DIR . '/install.php') ) {
13 13
 	require (WP_CONTENT_DIR . '/install.php');
14
+}
14 15
 
15 16
 /** WordPress Administration API */
16 17
 require_once(ABSPATH . 'wp-admin/includes/admin.php');
@@ -37,8 +38,9 @@  discard block
 block discarded – undo
37 38
  * @return array Array keys 'url', 'user_id', 'password', and 'password_message'.
38 39
  */
39 40
 function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '', $language = '' ) {
40
-	if ( !empty( $deprecated ) )
41
-		_deprecated_argument( __FUNCTION__, '2.6' );
41
+	if ( !empty( $deprecated ) ) {
42
+			_deprecated_argument( __FUNCTION__, '2.6' );
43
+	}
42 44
 
43 45
 	wp_check_mysql_version();
44 46
 	wp_cache_flush();
@@ -59,8 +61,9 @@  discard block
 block discarded – undo
59 61
 	update_option('siteurl', $guessurl);
60 62
 
61 63
 	// If not a public blog, don't ping.
62
-	if ( ! $public )
63
-		update_option('default_pingback_flag', 0);
64
+	if ( ! $public ) {
65
+			update_option('default_pingback_flag', 0);
66
+	}
64 67
 
65 68
 	/*
66 69
 	 * Create default user. If the user already exists, the user tables are
@@ -223,8 +226,9 @@  discard block
 block discarded – undo
223 226
 <blockquote>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</blockquote>
224 227
 
225 228
 As a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to delete this page and create new pages for your content. Have fun!" ), admin_url() );
226
-	if ( is_multisite() )
227
-		$first_page = get_site_option( 'first_page', $first_page );
229
+	if ( is_multisite() ) {
230
+			$first_page = get_site_option( 'first_page', $first_page );
231
+	}
228 232
 	$first_post_guid = get_option('home') . '/?page_id=2';
229 233
 	$wpdb->insert( $wpdb->posts, array(
230 234
 		'post_author' => $user_id,
@@ -255,10 +259,11 @@  discard block
 block discarded – undo
255 259
 	update_option( 'widget_meta', array ( 2 => array ( 'title' => '' ), '_multiwidget' => 1 ) );
256 260
 	update_option( 'sidebars_widgets', array ( 'wp_inactive_widgets' => array (), 'sidebar-1' => array ( 0 => 'search-2', 1 => 'recent-posts-2', 2 => 'recent-comments-2', 3 => 'archives-2', 4 => 'categories-2', 5 => 'meta-2', ), 'array_version' => 3 ) );
257 261
 
258
-	if ( ! is_multisite() )
259
-		update_user_meta( $user_id, 'show_welcome_panel', 1 );
260
-	elseif ( ! is_super_admin( $user_id ) && ! metadata_exists( 'user', $user_id, 'show_welcome_panel' ) )
261
-		update_user_meta( $user_id, 'show_welcome_panel', 2 );
262
+	if ( ! is_multisite() ) {
263
+			update_user_meta( $user_id, 'show_welcome_panel', 1 );
264
+	} elseif ( ! is_super_admin( $user_id ) && ! metadata_exists( 'user', $user_id, 'show_welcome_panel' ) ) {
265
+			update_user_meta( $user_id, 'show_welcome_panel', 2 );
266
+	}
262 267
 
263 268
 	if ( is_multisite() ) {
264 269
 		// Flush rules to pick up the new page.
@@ -273,8 +278,9 @@  discard block
 block discarded – undo
273 278
 		$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'capabilities') );
274 279
 
275 280
 		// Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) TODO: Get previous_blog_id.
276
-		if ( !is_super_admin( $user_id ) && $user_id != 1 )
277
-			$wpdb->delete( $wpdb->usermeta, array( 'user_id' => $user_id , 'meta_key' => $wpdb->base_prefix.'1_capabilities' ) );
281
+		if ( !is_super_admin( $user_id ) && $user_id != 1 ) {
282
+					$wpdb->delete( $wpdb->usermeta, array( 'user_id' => $user_id , 'meta_key' => $wpdb->base_prefix.'1_capabilities' ) );
283
+		}
278 284
 	}
279 285
 }
280 286
 endif;
@@ -410,26 +416,30 @@  discard block
 block discarded – undo
410 416
 	$wp_current_db_version = __get_option('db_version');
411 417
 
412 418
 	// We are up-to-date. Nothing to do.
413
-	if ( $wp_db_version == $wp_current_db_version )
414
-		return;
419
+	if ( $wp_db_version == $wp_current_db_version ) {
420
+			return;
421
+	}
415 422
 
416
-	if ( ! is_blog_installed() )
417
-		return;
423
+	if ( ! is_blog_installed() ) {
424
+			return;
425
+	}
418 426
 
419 427
 	wp_check_mysql_version();
420 428
 	wp_cache_flush();
421 429
 	pre_schema_upgrade();
422 430
 	make_db_current_silent();
423 431
 	upgrade_all();
424
-	if ( is_multisite() && is_main_site() )
425
-		upgrade_network();
432
+	if ( is_multisite() && is_main_site() ) {
433
+			upgrade_network();
434
+	}
426 435
 	wp_cache_flush();
427 436
 
428 437
 	if ( is_multisite() ) {
429
-		if ( $wpdb->get_row( "SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'" ) )
430
-			$wpdb->query( "UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'" );
431
-		else
432
-			$wpdb->query( "INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());" );
438
+		if ( $wpdb->get_row( "SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'" ) ) {
439
+					$wpdb->query( "UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'" );
440
+		} else {
441
+					$wpdb->query( "INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());" );
442
+		}
433 443
 	}
434 444
 
435 445
 	/**
@@ -461,8 +471,9 @@  discard block
 block discarded – undo
461 471
 	$wp_current_db_version = __get_option('db_version');
462 472
 
463 473
 	// We are up-to-date. Nothing to do.
464
-	if ( $wp_db_version == $wp_current_db_version )
465
-		return;
474
+	if ( $wp_db_version == $wp_current_db_version ) {
475
+			return;
476
+	}
466 477
 
467 478
 	// If the version is not set in the DB, try to guess the version.
468 479
 	if ( empty($wp_current_db_version) ) {
@@ -470,12 +481,14 @@  discard block
 block discarded – undo
470 481
 
471 482
 		// If the template option exists, we have 1.5.
472 483
 		$template = __get_option('template');
473
-		if ( !empty($template) )
474
-			$wp_current_db_version = 2541;
484
+		if ( !empty($template) ) {
485
+					$wp_current_db_version = 2541;
486
+		}
475 487
 	}
476 488
 
477
-	if ( $wp_current_db_version < 6039 )
478
-		upgrade_230_options_table();
489
+	if ( $wp_current_db_version < 6039 ) {
490
+			upgrade_230_options_table();
491
+	}
479 492
 
480 493
 	populate_options();
481 494
 
@@ -486,77 +499,101 @@  discard block
 block discarded – undo
486 499
 		upgrade_130();
487 500
 	}
488 501
 
489
-	if ( $wp_current_db_version < 3308 )
490
-		upgrade_160();
502
+	if ( $wp_current_db_version < 3308 ) {
503
+			upgrade_160();
504
+	}
491 505
 
492
-	if ( $wp_current_db_version < 4772 )
493
-		upgrade_210();
506
+	if ( $wp_current_db_version < 4772 ) {
507
+			upgrade_210();
508
+	}
494 509
 
495
-	if ( $wp_current_db_version < 4351 )
496
-		upgrade_old_slugs();
510
+	if ( $wp_current_db_version < 4351 ) {
511
+			upgrade_old_slugs();
512
+	}
497 513
 
498
-	if ( $wp_current_db_version < 5539 )
499
-		upgrade_230();
514
+	if ( $wp_current_db_version < 5539 ) {
515
+			upgrade_230();
516
+	}
500 517
 
501
-	if ( $wp_current_db_version < 6124 )
502
-		upgrade_230_old_tables();
518
+	if ( $wp_current_db_version < 6124 ) {
519
+			upgrade_230_old_tables();
520
+	}
503 521
 
504
-	if ( $wp_current_db_version < 7499 )
505
-		upgrade_250();
522
+	if ( $wp_current_db_version < 7499 ) {
523
+			upgrade_250();
524
+	}
506 525
 
507
-	if ( $wp_current_db_version < 7935 )
508
-		upgrade_252();
526
+	if ( $wp_current_db_version < 7935 ) {
527
+			upgrade_252();
528
+	}
509 529
 
510
-	if ( $wp_current_db_version < 8201 )
511
-		upgrade_260();
530
+	if ( $wp_current_db_version < 8201 ) {
531
+			upgrade_260();
532
+	}
512 533
 
513
-	if ( $wp_current_db_version < 8989 )
514
-		upgrade_270();
534
+	if ( $wp_current_db_version < 8989 ) {
535
+			upgrade_270();
536
+	}
515 537
 
516
-	if ( $wp_current_db_version < 10360 )
517
-		upgrade_280();
538
+	if ( $wp_current_db_version < 10360 ) {
539
+			upgrade_280();
540
+	}
518 541
 
519
-	if ( $wp_current_db_version < 11958 )
520
-		upgrade_290();
542
+	if ( $wp_current_db_version < 11958 ) {
543
+			upgrade_290();
544
+	}
521 545
 
522
-	if ( $wp_current_db_version < 15260 )
523
-		upgrade_300();
546
+	if ( $wp_current_db_version < 15260 ) {
547
+			upgrade_300();
548
+	}
524 549
 
525
-	if ( $wp_current_db_version < 19389 )
526
-		upgrade_330();
550
+	if ( $wp_current_db_version < 19389 ) {
551
+			upgrade_330();
552
+	}
527 553
 
528
-	if ( $wp_current_db_version < 20080 )
529
-		upgrade_340();
554
+	if ( $wp_current_db_version < 20080 ) {
555
+			upgrade_340();
556
+	}
530 557
 
531
-	if ( $wp_current_db_version < 22422 )
532
-		upgrade_350();
558
+	if ( $wp_current_db_version < 22422 ) {
559
+			upgrade_350();
560
+	}
533 561
 
534
-	if ( $wp_current_db_version < 25824 )
535
-		upgrade_370();
562
+	if ( $wp_current_db_version < 25824 ) {
563
+			upgrade_370();
564
+	}
536 565
 
537
-	if ( $wp_current_db_version < 26148 )
538
-		upgrade_372();
566
+	if ( $wp_current_db_version < 26148 ) {
567
+			upgrade_372();
568
+	}
539 569
 
540
-	if ( $wp_current_db_version < 26691 )
541
-		upgrade_380();
570
+	if ( $wp_current_db_version < 26691 ) {
571
+			upgrade_380();
572
+	}
542 573
 
543
-	if ( $wp_current_db_version < 29630 )
544
-		upgrade_400();
574
+	if ( $wp_current_db_version < 29630 ) {
575
+			upgrade_400();
576
+	}
545 577
 
546
-	if ( $wp_current_db_version < 33055 )
547
-		upgrade_430();
578
+	if ( $wp_current_db_version < 33055 ) {
579
+			upgrade_430();
580
+	}
548 581
 
549
-	if ( $wp_current_db_version < 33056 )
550
-		upgrade_431();
582
+	if ( $wp_current_db_version < 33056 ) {
583
+			upgrade_431();
584
+	}
551 585
 
552
-	if ( $wp_current_db_version < 35700 )
553
-		upgrade_440();
586
+	if ( $wp_current_db_version < 35700 ) {
587
+			upgrade_440();
588
+	}
554 589
 
555
-	if ( $wp_current_db_version < 36686 )
556
-		upgrade_450();
590
+	if ( $wp_current_db_version < 36686 ) {
591
+			upgrade_450();
592
+	}
557 593
 
558
-	if ( $wp_current_db_version < 37854 )
559
-		upgrade_460();
594
+	if ( $wp_current_db_version < 37854 ) {
595
+			upgrade_460();
596
+	}
560 597
 
561 598
 	maybe_disable_link_manager();
562 599
 
@@ -609,8 +646,10 @@  discard block
 block discarded – undo
609 646
 			$done_posts[] = $done_id->post_id;
610 647
 		endforeach;
611 648
 		$catwhere = ' AND ID NOT IN (' . implode(',', $done_posts) . ')';
612
-	else:
649
+	else {
650
+		:
613 651
 		$catwhere = '';
652
+	}
614 653
 	endif;
615 654
 
616 655
 	$allposts = $wpdb->get_results("SELECT ID, post_category FROM $wpdb->posts WHERE post_category != '0' $catwhere");
@@ -727,10 +766,11 @@  discard block
 block discarded – undo
727 766
 			$post_content = addslashes(deslash($post->post_content));
728 767
 			$post_title = addslashes(deslash($post->post_title));
729 768
 			$post_excerpt = addslashes(deslash($post->post_excerpt));
730
-			if ( empty($post->guid) )
731
-				$guid = get_permalink($post->ID);
732
-			else
733
-				$guid = $post->guid;
769
+			if ( empty($post->guid) ) {
770
+							$guid = get_permalink($post->ID);
771
+			} else {
772
+							$guid = $post->guid;
773
+			}
734 774
 
735 775
 			$wpdb->update( $wpdb->posts, compact('post_title', 'post_content', 'post_excerpt', 'guid'), array('ID' => $post->ID) );
736 776
 
@@ -812,34 +852,57 @@  discard block
 block discarded – undo
812 852
 
813 853
 	$users = $wpdb->get_results("SELECT * FROM $wpdb->users");
814 854
 	foreach ( $users as $user ) :
815
-		if ( !empty( $user->user_firstname ) )
816
-			update_user_meta( $user->ID, 'first_name', wp_slash($user->user_firstname) );
817
-		if ( !empty( $user->user_lastname ) )
818
-			update_user_meta( $user->ID, 'last_name', wp_slash($user->user_lastname) );
819
-		if ( !empty( $user->user_nickname ) )
820
-			update_user_meta( $user->ID, 'nickname', wp_slash($user->user_nickname) );
821
-		if ( !empty( $user->user_level ) )
822
-			update_user_meta( $user->ID, $wpdb->prefix . 'user_level', $user->user_level );
823
-		if ( !empty( $user->user_icq ) )
824
-			update_user_meta( $user->ID, 'icq', wp_slash($user->user_icq) );
825
-		if ( !empty( $user->user_aim ) )
826
-			update_user_meta( $user->ID, 'aim', wp_slash($user->user_aim) );
827
-		if ( !empty( $user->user_msn ) )
828
-			update_user_meta( $user->ID, 'msn', wp_slash($user->user_msn) );
829
-		if ( !empty( $user->user_yim ) )
830
-			update_user_meta( $user->ID, 'yim', wp_slash($user->user_icq) );
831
-		if ( !empty( $user->user_description ) )
832
-			update_user_meta( $user->ID, 'description', wp_slash($user->user_description) );
855
+		if ( !empty( $user->user_firstname ) ) {
856
+					update_user_meta( $user->ID, 'first_name', wp_slash($user->user_firstname) );
857
+		}
858
+		if ( !empty( $user->user_lastname ) ) {
859
+					update_user_meta( $user->ID, 'last_name', wp_slash($user->user_lastname) );
860
+		}
861
+		if ( !empty( $user->user_nickname ) ) {
862
+					update_user_meta( $user->ID, 'nickname', wp_slash($user->user_nickname) );
863
+		}
864
+		if ( !empty( $user->user_level ) ) {
865
+					update_user_meta( $user->ID, $wpdb->prefix . 'user_level', $user->user_level );
866
+		}
867
+		if ( !empty( $user->user_icq ) ) {
868
+					update_user_meta( $user->ID, 'icq', wp_slash($user->user_icq) );
869
+		}
870
+		if ( !empty( $user->user_aim ) ) {
871
+					update_user_meta( $user->ID, 'aim', wp_slash($user->user_aim) );
872
+		}
873
+		if ( !empty( $user->user_msn ) ) {
874
+					update_user_meta( $user->ID, 'msn', wp_slash($user->user_msn) );
875
+		}
876
+		if ( !empty( $user->user_yim ) ) {
877
+					update_user_meta( $user->ID, 'yim', wp_slash($user->user_icq) );
878
+		}
879
+		if ( !empty( $user->user_description ) ) {
880
+					update_user_meta( $user->ID, 'description', wp_slash($user->user_description) );
881
+		}
833 882
 
834 883
 		if ( isset( $user->user_idmode ) ):
835 884
 			$idmode = $user->user_idmode;
836
-			if ($idmode == 'nickname') $id = $user->user_nickname;
837
-			if ($idmode == 'login') $id = $user->user_login;
838
-			if ($idmode == 'firstname') $id = $user->user_firstname;
839
-			if ($idmode == 'lastname') $id = $user->user_lastname;
840
-			if ($idmode == 'namefl') $id = $user->user_firstname.' '.$user->user_lastname;
841
-			if ($idmode == 'namelf') $id = $user->user_lastname.' '.$user->user_firstname;
842
-			if (!$idmode) $id = $user->user_nickname;
885
+			if ($idmode == 'nickname') {
886
+				$id = $user->user_nickname;
887
+			}
888
+			if ($idmode == 'login') {
889
+				$id = $user->user_login;
890
+			}
891
+			if ($idmode == 'firstname') {
892
+				$id = $user->user_firstname;
893
+			}
894
+			if ($idmode == 'lastname') {
895
+				$id = $user->user_lastname;
896
+			}
897
+			if ($idmode == 'namefl') {
898
+				$id = $user->user_firstname.' '.$user->user_lastname;
899
+			}
900
+			if ($idmode == 'namelf') {
901
+				$id = $user->user_lastname.' '.$user->user_firstname;
902
+			}
903
+			if (!$idmode) {
904
+				$id = $user->user_nickname;
905
+			}
843 906
 			$wpdb->update( $wpdb->users, array('display_name' => $id), array('ID' => $user->ID) );
844 907
 		endif;
845 908
 
@@ -854,15 +917,17 @@  discard block
 block discarded – undo
854 917
 	endforeach;
855 918
 	$old_user_fields = array( 'user_firstname', 'user_lastname', 'user_icq', 'user_aim', 'user_msn', 'user_yim', 'user_idmode', 'user_ip', 'user_domain', 'user_browser', 'user_description', 'user_nickname', 'user_level' );
856 919
 	$wpdb->hide_errors();
857
-	foreach ( $old_user_fields as $old )
858
-		$wpdb->query("ALTER TABLE $wpdb->users DROP $old");
920
+	foreach ( $old_user_fields as $old ) {
921
+			$wpdb->query("ALTER TABLE $wpdb->users DROP $old");
922
+	}
859 923
 	$wpdb->show_errors();
860 924
 
861 925
 	// Populate comment_count field of posts table.
862 926
 	$comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID" );
863
-	if ( is_array( $comments ) )
864
-		foreach ($comments as $comment)
927
+	if ( is_array( $comments ) ) {
928
+			foreach ($comments as $comment)
865 929
 			$wpdb->update( $wpdb->posts, array('comment_count' => $comment->c), array('ID' => $comment->comment_post_ID) );
930
+	}
866 931
 
867 932
 	/*
868 933
 	 * Some alpha versions used a post status of object instead of attachment
@@ -877,8 +942,9 @@  discard block
 block discarded – undo
877 942
 										 array( 'ID' => $object->ID ) );
878 943
 
879 944
 			$meta = get_post_meta($object->ID, 'imagedata', true);
880
-			if ( ! empty($meta['file']) )
881
-				update_attached_file( $object->ID, $meta['file'] );
945
+			if ( ! empty($meta['file']) ) {
946
+							update_attached_file( $object->ID, $meta['file'] );
947
+			}
882 948
 		}
883 949
 	}
884 950
 }
@@ -899,8 +965,10 @@  discard block
 block discarded – undo
899 965
 		// Update status and type.
900 966
 		$posts = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts");
901 967
 
902
-		if ( ! empty($posts) ) foreach ($posts as $post) {
968
+		if ( ! empty($posts) ) {
969
+			foreach ($posts as $post) {
903 970
 			$status = $post->post_status;
971
+		}
904 972
 			$type = 'post';
905 973
 
906 974
 			if ( 'static' == $status ) {
@@ -925,9 +993,10 @@  discard block
 block discarded – undo
925 993
 		$wpdb->query ("UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '$now'");
926 994
 
927 995
 		$posts = $wpdb->get_results("SELECT ID, post_date FROM $wpdb->posts WHERE post_status ='future'");
928
-		if ( !empty($posts) )
929
-			foreach ( $posts as $post )
996
+		if ( !empty($posts) ) {
997
+					foreach ( $posts as $post )
930 998
 				wp_schedule_single_event(mysql2date('U', $post->post_date, false), 'publish_future_post', array($post->ID));
999
+		}
931 1000
 	}
932 1001
 }
933 1002
 
@@ -1013,19 +1082,22 @@  discard block
 block discarded – undo
1013 1082
 	}
1014 1083
 
1015 1084
 	$select = 'post_id, category_id';
1016
-	if ( $have_tags )
1017
-		$select .= ', rel_type';
1085
+	if ( $have_tags ) {
1086
+			$select .= ', rel_type';
1087
+	}
1018 1088
 
1019 1089
 	$posts = $wpdb->get_results("SELECT $select FROM $wpdb->post2cat GROUP BY post_id, category_id");
1020 1090
 	foreach ( $posts as $post ) {
1021 1091
 		$post_id = (int) $post->post_id;
1022 1092
 		$term_id = (int) $post->category_id;
1023 1093
 		$taxonomy = 'category';
1024
-		if ( !empty($post->rel_type) && 'tag' == $post->rel_type)
1025
-			$taxonomy = 'tag';
1094
+		if ( !empty($post->rel_type) && 'tag' == $post->rel_type) {
1095
+					$taxonomy = 'tag';
1096
+		}
1026 1097
 		$tt_id = $tt_ids[$term_id][$taxonomy];
1027
-		if ( empty($tt_id) )
1028
-			continue;
1098
+		if ( empty($tt_id) ) {
1099
+					continue;
1100
+		}
1029 1101
 
1030 1102
 		$wpdb->insert( $wpdb->term_relationships, array('object_id' => $post_id, 'term_taxonomy_id' => $tt_id) );
1031 1103
 	}
@@ -1067,15 +1139,19 @@  discard block
 block discarded – undo
1067 1139
 
1068 1140
 		// Associate links to cats.
1069 1141
 		$links = $wpdb->get_results("SELECT link_id, link_category FROM $wpdb->links");
1070
-		if ( !empty($links) ) foreach ( $links as $link ) {
1142
+		if ( !empty($links) ) {
1143
+			foreach ( $links as $link ) {
1071 1144
 			if ( 0 == $link->link_category )
1072 1145
 				continue;
1073
-			if ( ! isset($link_cat_id_map[$link->link_category]) )
1074
-				continue;
1146
+		}
1147
+			if ( ! isset($link_cat_id_map[$link->link_category]) ) {
1148
+							continue;
1149
+			}
1075 1150
 			$term_id = $link_cat_id_map[$link->link_category];
1076 1151
 			$tt_id = $tt_ids[$term_id];
1077
-			if ( empty($tt_id) )
1078
-				continue;
1152
+			if ( empty($tt_id) ) {
1153
+							continue;
1154
+			}
1079 1155
 
1080 1156
 			$wpdb->insert( $wpdb->term_relationships, array('object_id' => $link->link_id, 'term_taxonomy_id' => $tt_id) );
1081 1157
 		}
@@ -1089,8 +1165,9 @@  discard block
 block discarded – undo
1089 1165
 			$term_id = (int) $link->category_id;
1090 1166
 			$taxonomy = 'link_category';
1091 1167
 			$tt_id = $tt_ids[$term_id][$taxonomy];
1092
-			if ( empty($tt_id) )
1093
-				continue;
1168
+			if ( empty($tt_id) ) {
1169
+							continue;
1170
+			}
1094 1171
 			$wpdb->insert( $wpdb->term_relationships, array('object_id' => $link_id, 'term_taxonomy_id' => $tt_id) );
1095 1172
 		}
1096 1173
 	}
@@ -1103,10 +1180,11 @@  discard block
 block discarded – undo
1103 1180
 	// Recalculate all counts
1104 1181
 	$terms = $wpdb->get_results("SELECT term_taxonomy_id, taxonomy FROM $wpdb->term_taxonomy");
1105 1182
 	foreach ( (array) $terms as $term ) {
1106
-		if ( ('post_tag' == $term->taxonomy) || ('category' == $term->taxonomy) )
1107
-			$count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term->term_taxonomy_id) );
1108
-		else
1109
-			$count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id) );
1183
+		if ( ('post_tag' == $term->taxonomy) || ('category' == $term->taxonomy) ) {
1184
+					$count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term->term_taxonomy_id) );
1185
+		} else {
1186
+					$count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id) );
1187
+		}
1110 1188
 		$wpdb->update( $wpdb->term_taxonomy, array('count' => $count), array('term_taxonomy_id' => $term->term_taxonomy_id) );
1111 1189
 	}
1112 1190
 }
@@ -1123,8 +1201,9 @@  discard block
 block discarded – undo
1123 1201
 	global $wpdb;
1124 1202
 	$old_options_fields = array( 'option_can_override', 'option_type', 'option_width', 'option_height', 'option_description', 'option_admin_level' );
1125 1203
 	$wpdb->hide_errors();
1126
-	foreach ( $old_options_fields as $old )
1127
-		$wpdb->query("ALTER TABLE $wpdb->options DROP $old");
1204
+	foreach ( $old_options_fields as $old ) {
1205
+			$wpdb->query("ALTER TABLE $wpdb->options DROP $old");
1206
+	}
1128 1207
 	$wpdb->show_errors();
1129 1208
 }
1130 1209
 
@@ -1199,9 +1278,10 @@  discard block
 block discarded – undo
1199 1278
 function upgrade_260() {
1200 1279
 	global $wp_current_db_version;
1201 1280
 
1202
-	if ( $wp_current_db_version < 8000 )
1203
-		populate_roles_260();
1204
-}
1281
+	if ( $wp_current_db_version < 8000 ) {
1282
+			populate_roles_260();
1283
+	}
1284
+	}
1205 1285
 
1206 1286
 /**
1207 1287
  * Execute changes made in WordPress 2.7.
@@ -1215,13 +1295,15 @@  discard block
 block discarded – undo
1215 1295
 function upgrade_270() {
1216 1296
 	global $wpdb, $wp_current_db_version;
1217 1297
 
1218
-	if ( $wp_current_db_version < 8980 )
1219
-		populate_roles_270();
1298
+	if ( $wp_current_db_version < 8980 ) {
1299
+			populate_roles_270();
1300
+	}
1220 1301
 
1221 1302
 	// Update post_date for unpublished posts with empty timestamp
1222
-	if ( $wp_current_db_version < 8921 )
1223
-		$wpdb->query( "UPDATE $wpdb->posts SET post_date = post_modified WHERE post_date = '0000-00-00 00:00:00'" );
1224
-}
1303
+	if ( $wp_current_db_version < 8921 ) {
1304
+			$wpdb->query( "UPDATE $wpdb->posts SET post_date = post_modified WHERE post_date = '0000-00-00 00:00:00'" );
1305
+	}
1306
+	}
1225 1307
 
1226 1308
 /**
1227 1309
  * Execute changes made in WordPress 2.8.
@@ -1235,15 +1317,17 @@  discard block
 block discarded – undo
1235 1317
 function upgrade_280() {
1236 1318
 	global $wp_current_db_version, $wpdb;
1237 1319
 
1238
-	if ( $wp_current_db_version < 10360 )
1239
-		populate_roles_280();
1320
+	if ( $wp_current_db_version < 10360 ) {
1321
+			populate_roles_280();
1322
+	}
1240 1323
 	if ( is_multisite() ) {
1241 1324
 		$start = 0;
1242 1325
 		while( $rows = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options ORDER BY option_id LIMIT $start, 20" ) ) {
1243 1326
 			foreach ( $rows as $row ) {
1244 1327
 				$value = $row->option_value;
1245
-				if ( !@unserialize( $value ) )
1246
-					$value = stripslashes( $value );
1328
+				if ( !@unserialize( $value ) ) {
1329
+									$value = stripslashes( $value );
1330
+				}
1247 1331
 				if ( $value !== $row->option_value ) {
1248 1332
 					update_option( $row->option_name, $value );
1249 1333
 				}
@@ -1286,11 +1370,13 @@  discard block
 block discarded – undo
1286 1370
 function upgrade_300() {
1287 1371
 	global $wp_current_db_version, $wpdb;
1288 1372
 
1289
-	if ( $wp_current_db_version < 15093 )
1290
-		populate_roles_300();
1373
+	if ( $wp_current_db_version < 15093 ) {
1374
+			populate_roles_300();
1375
+	}
1291 1376
 
1292
-	if ( $wp_current_db_version < 14139 && is_multisite() && is_main_site() && ! defined( 'MULTISITE' ) && get_site_option( 'siteurl' ) === false )
1293
-		add_site_option( 'siteurl', '' );
1377
+	if ( $wp_current_db_version < 14139 && is_multisite() && is_main_site() && ! defined( 'MULTISITE' ) && get_site_option( 'siteurl' ) === false ) {
1378
+			add_site_option( 'siteurl', '' );
1379
+	}
1294 1380
 
1295 1381
 	// 3.0 screen options key name changes.
1296 1382
 	if ( wp_should_upgrade_global_tables() ) {
@@ -1338,23 +1424,26 @@  discard block
 block discarded – undo
1338 1424
 		$wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key IN ('show_admin_bar_admin', 'plugins_last_view')" );
1339 1425
 	}
1340 1426
 
1341
-	if ( $wp_current_db_version >= 11548 )
1342
-		return;
1427
+	if ( $wp_current_db_version >= 11548 ) {
1428
+			return;
1429
+	}
1343 1430
 
1344 1431
 	$sidebars_widgets = get_option( 'sidebars_widgets', array() );
1345 1432
 	$_sidebars_widgets = array();
1346 1433
 
1347
-	if ( isset($sidebars_widgets['wp_inactive_widgets']) || empty($sidebars_widgets) )
1348
-		$sidebars_widgets['array_version'] = 3;
1349
-	elseif ( !isset($sidebars_widgets['array_version']) )
1350
-		$sidebars_widgets['array_version'] = 1;
1434
+	if ( isset($sidebars_widgets['wp_inactive_widgets']) || empty($sidebars_widgets) ) {
1435
+			$sidebars_widgets['array_version'] = 3;
1436
+	} elseif ( !isset($sidebars_widgets['array_version']) ) {
1437
+			$sidebars_widgets['array_version'] = 1;
1438
+	}
1351 1439
 
1352 1440
 	switch ( $sidebars_widgets['array_version'] ) {
1353 1441
 		case 1 :
1354
-			foreach ( (array) $sidebars_widgets as $index => $sidebar )
1355
-			if ( is_array($sidebar) )
1442
+			foreach ( (array) $sidebars_widgets as $index => $sidebar ) {
1443
+						if ( is_array($sidebar) )
1356 1444
 			foreach ( (array) $sidebar as $i => $name ) {
1357 1445
 				$id = strtolower($name);
1446
+			}
1358 1447
 				if ( isset($wp_registered_widgets[$id]) ) {
1359 1448
 					$_sidebars_widgets[$index][$i] = $id;
1360 1449
 					continue;
@@ -1379,8 +1468,9 @@  discard block
 block discarded – undo
1379 1468
 					}
1380 1469
 				}
1381 1470
 
1382
-				if ( $found )
1383
-					continue;
1471
+				if ( $found ) {
1472
+									continue;
1473
+				}
1384 1474
 
1385 1475
 				unset($_sidebars_widgets[$index][$i]);
1386 1476
 			}
@@ -1444,14 +1534,17 @@  discard block
 block discarded – undo
1444 1534
 function upgrade_350() {
1445 1535
 	global $wp_current_db_version, $wpdb;
1446 1536
 
1447
-	if ( $wp_current_db_version < 22006 && $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) )
1448
-		update_option( 'link_manager_enabled', 1 ); // Previously set to 0 by populate_options()
1537
+	if ( $wp_current_db_version < 22006 && $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) ) {
1538
+			update_option( 'link_manager_enabled', 1 );
1539
+	}
1540
+	// Previously set to 0 by populate_options()
1449 1541
 
1450 1542
 	if ( $wp_current_db_version < 21811 && wp_should_upgrade_global_tables() ) {
1451 1543
 		$meta_keys = array();
1452 1544
 		foreach ( array_merge( get_post_types(), get_taxonomies() ) as $name ) {
1453
-			if ( false !== strpos( $name, '-' ) )
1454
-			$meta_keys[] = 'edit_' . str_replace( '-', '_', $name ) . '_per_page';
1545
+			if ( false !== strpos( $name, '-' ) ) {
1546
+						$meta_keys[] = 'edit_' . str_replace( '-', '_', $name ) . '_per_page';
1547
+			}
1455 1548
 		}
1456 1549
 		if ( $meta_keys ) {
1457 1550
 			$meta_keys = implode( "', '", $meta_keys );
@@ -1459,9 +1552,10 @@  discard block
 block discarded – undo
1459 1552
 		}
1460 1553
 	}
1461 1554
 
1462
-	if ( $wp_current_db_version < 22422 && $term = get_term_by( 'slug', 'post-format-standard', 'post_format' ) )
1463
-		wp_delete_term( $term->term_id, 'post_format' );
1464
-}
1555
+	if ( $wp_current_db_version < 22422 && $term = get_term_by( 'slug', 'post-format-standard', 'post_format' ) ) {
1556
+			wp_delete_term( $term->term_id, 'post_format' );
1557
+	}
1558
+	}
1465 1559
 
1466 1560
 /**
1467 1561
  * Execute changes made in WordPress 3.7.
@@ -1473,9 +1567,10 @@  discard block
 block discarded – undo
1473 1567
  */
1474 1568
 function upgrade_370() {
1475 1569
 	global $wp_current_db_version;
1476
-	if ( $wp_current_db_version < 25824 )
1477
-		wp_clear_scheduled_hook( 'wp_auto_updates_maybe_update' );
1478
-}
1570
+	if ( $wp_current_db_version < 25824 ) {
1571
+			wp_clear_scheduled_hook( 'wp_auto_updates_maybe_update' );
1572
+	}
1573
+	}
1479 1574
 
1480 1575
 /**
1481 1576
  * Execute changes made in WordPress 3.7.2.
@@ -1488,9 +1583,10 @@  discard block
 block discarded – undo
1488 1583
  */
1489 1584
 function upgrade_372() {
1490 1585
 	global $wp_current_db_version;
1491
-	if ( $wp_current_db_version < 26148 )
1492
-		wp_clear_scheduled_hook( 'wp_maybe_auto_update' );
1493
-}
1586
+	if ( $wp_current_db_version < 26148 ) {
1587
+			wp_clear_scheduled_hook( 'wp_maybe_auto_update' );
1588
+	}
1589
+	}
1494 1590
 
1495 1591
 /**
1496 1592
  * Execute changes made in WordPress 3.8.0.
@@ -1738,10 +1834,11 @@  discard block
 block discarded – undo
1738 1834
 		$wpmu_sitewide_plugins = get_site_option( 'wpmu_sitewide_plugins' );
1739 1835
 		$active_sitewide_plugins = get_site_option( 'active_sitewide_plugins' );
1740 1836
 		if ( $wpmu_sitewide_plugins ) {
1741
-			if ( !$active_sitewide_plugins )
1742
-				$sitewide_plugins = (array) $wpmu_sitewide_plugins;
1743
-			else
1744
-				$sitewide_plugins = array_merge( (array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins );
1837
+			if ( !$active_sitewide_plugins ) {
1838
+							$sitewide_plugins = (array) $wpmu_sitewide_plugins;
1839
+			} else {
1840
+							$sitewide_plugins = array_merge( (array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins );
1841
+			}
1745 1842
 
1746 1843
 			update_site_option( 'active_sitewide_plugins', $sitewide_plugins );
1747 1844
 		}
@@ -1752,8 +1849,9 @@  discard block
 block discarded – undo
1752 1849
 		while( $rows = $wpdb->get_results( "SELECT meta_key, meta_value FROM {$wpdb->sitemeta} ORDER BY meta_id LIMIT $start, 20" ) ) {
1753 1850
 			foreach ( $rows as $row ) {
1754 1851
 				$value = $row->meta_value;
1755
-				if ( !@unserialize( $value ) )
1756
-					$value = stripslashes( $value );
1852
+				if ( !@unserialize( $value ) ) {
1853
+									$value = stripslashes( $value );
1854
+				}
1757 1855
 				if ( $value !== $row->meta_value ) {
1758 1856
 					update_site_option( $row->meta_key, $value );
1759 1857
 				}
@@ -1763,16 +1861,19 @@  discard block
 block discarded – undo
1763 1861
 	}
1764 1862
 
1765 1863
 	// 3.0
1766
-	if ( $wp_current_db_version < 13576 )
1767
-		update_site_option( 'global_terms_enabled', '1' );
1864
+	if ( $wp_current_db_version < 13576 ) {
1865
+			update_site_option( 'global_terms_enabled', '1' );
1866
+	}
1768 1867
 
1769 1868
 	// 3.3
1770
-	if ( $wp_current_db_version < 19390 )
1771
-		update_site_option( 'initial_db_version', $wp_current_db_version );
1869
+	if ( $wp_current_db_version < 19390 ) {
1870
+			update_site_option( 'initial_db_version', $wp_current_db_version );
1871
+	}
1772 1872
 
1773 1873
 	if ( $wp_current_db_version < 19470 ) {
1774
-		if ( false === get_site_option( 'active_sitewide_plugins' ) )
1775
-			update_site_option( 'active_sitewide_plugins', array() );
1874
+		if ( false === get_site_option( 'active_sitewide_plugins' ) ) {
1875
+					update_site_option( 'active_sitewide_plugins', array() );
1876
+		}
1776 1877
 	}
1777 1878
 
1778 1879
 	// 3.4
@@ -1784,8 +1885,9 @@  discard block
 block discarded – undo
1784 1885
 			$converted = array();
1785 1886
 			$themes = wp_get_themes();
1786 1887
 			foreach ( $themes as $stylesheet => $theme_data ) {
1787
-				if ( isset( $allowed_themes[ $theme_data->get('Name') ] ) )
1788
-					$converted[ $stylesheet ] = true;
1888
+				if ( isset( $allowed_themes[ $theme_data->get('Name') ] ) ) {
1889
+									$converted[ $stylesheet ] = true;
1890
+				}
1789 1891
 			}
1790 1892
 			update_site_option( 'allowedthemes', $converted );
1791 1893
 			delete_site_option( 'allowed_themes' );
@@ -1793,8 +1895,9 @@  discard block
 block discarded – undo
1793 1895
 	}
1794 1896
 
1795 1897
 	// 3.5
1796
-	if ( $wp_current_db_version < 21823 )
1797
-		update_site_option( 'ms_files_rewriting', '1' );
1898
+	if ( $wp_current_db_version < 21823 ) {
1899
+			update_site_option( 'ms_files_rewriting', '1' );
1900
+	}
1798 1901
 
1799 1902
 	// 3.5.2
1800 1903
 	if ( $wp_current_db_version < 24448 ) {
@@ -2025,8 +2128,9 @@  discard block
 block discarded – undo
2025 2128
 	$all_options = new stdClass;
2026 2129
 	if ( $options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ) ) {
2027 2130
 		foreach ( $options as $option ) {
2028
-			if ( 'siteurl' == $option->option_name || 'home' == $option->option_name || 'category_base' == $option->option_name )
2029
-				$option->option_value = untrailingslashit( $option->option_value );
2131
+			if ( 'siteurl' == $option->option_name || 'home' == $option->option_name || 'category_base' == $option->option_name ) {
2132
+							$option->option_value = untrailingslashit( $option->option_value );
2133
+			}
2030 2134
 			$all_options->{$option->option_name} = stripslashes( $option->option_value );
2031 2135
 		}
2032 2136
 	}
@@ -2048,19 +2152,23 @@  discard block
 block discarded – undo
2048 2152
 function __get_option($setting) {
2049 2153
 	global $wpdb;
2050 2154
 
2051
-	if ( $setting == 'home' && defined( 'WP_HOME' ) )
2052
-		return untrailingslashit( WP_HOME );
2155
+	if ( $setting == 'home' && defined( 'WP_HOME' ) ) {
2156
+			return untrailingslashit( WP_HOME );
2157
+	}
2053 2158
 
2054
-	if ( $setting == 'siteurl' && defined( 'WP_SITEURL' ) )
2055
-		return untrailingslashit( WP_SITEURL );
2159
+	if ( $setting == 'siteurl' && defined( 'WP_SITEURL' ) ) {
2160
+			return untrailingslashit( WP_SITEURL );
2161
+	}
2056 2162
 
2057 2163
 	$option = $wpdb->get_var( $wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s", $setting ) );
2058 2164
 
2059
-	if ( 'home' == $setting && '' == $option )
2060
-		return __get_option( 'siteurl' );
2165
+	if ( 'home' == $setting && '' == $option ) {
2166
+			return __get_option( 'siteurl' );
2167
+	}
2061 2168
 
2062
-	if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting || 'tag_base' == $setting )
2063
-		$option = untrailingslashit( $option );
2169
+	if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting || 'tag_base' == $setting ) {
2170
+			$option = untrailingslashit( $option );
2171
+	}
2064 2172
 
2065 2173
 	return maybe_unserialize( $option );
2066 2174
 }
@@ -2113,8 +2221,9 @@  discard block
 block discarded – undo
2113 2221
 function dbDelta( $queries = '', $execute = true ) {
2114 2222
 	global $wpdb;
2115 2223
 
2116
-	if ( in_array( $queries, array( '', 'all', 'blog', 'global', 'ms_global' ), true ) )
2117
-	    $queries = wp_get_db_schema( $queries );
2224
+	if ( in_array( $queries, array( '', 'all', 'blog', 'global', 'ms_global' ), true ) ) {
2225
+		    $queries = wp_get_db_schema( $queries );
2226
+	}
2118 2227
 
2119 2228
 	// Separate individual queries into an array
2120 2229
 	if ( !is_array($queries) ) {
@@ -2189,8 +2298,9 @@  discard block
 block discarded – undo
2189 2298
 		$tablefields = $wpdb->get_results("DESCRIBE {$table};");
2190 2299
 		$wpdb->suppress_errors( $suppress );
2191 2300
 
2192
-		if ( ! $tablefields )
2193
-			continue;
2301
+		if ( ! $tablefields ) {
2302
+					continue;
2303
+		}
2194 2304
 
2195 2305
 		// Clear the field and index arrays.
2196 2306
 		$cfields = $indices = array();
@@ -2482,7 +2592,9 @@  discard block
 block discarded – undo
2482 2592
 function make_db_current( $tables = 'all' ) {
2483 2593
 	$alterations = dbDelta( $tables );
2484 2594
 	echo "<ol>\n";
2485
-	foreach ($alterations as $alteration) echo "<li>$alteration</li>\n";
2595
+	foreach ($alterations as $alteration) {
2596
+		echo "<li>$alteration</li>\n";
2597
+	}
2486 2598
 	echo "</ol>\n";
2487 2599
 }
2488 2600
 
@@ -2517,8 +2629,9 @@  discard block
 block discarded – undo
2517 2629
 	$home_path = get_home_path();
2518 2630
 	$site_dir = WP_CONTENT_DIR . "/themes/$template";
2519 2631
 
2520
-	if (! file_exists("$home_path/index.php"))
2521
-		return false;
2632
+	if (! file_exists("$home_path/index.php")) {
2633
+			return false;
2634
+	}
2522 2635
 
2523 2636
 	/*
2524 2637
 	 * Copy files from the old locations to the site theme.
@@ -2527,25 +2640,28 @@  discard block
 block discarded – undo
2527 2640
 	$files = array('index.php' => 'index.php', 'wp-layout.css' => 'style.css', 'wp-comments.php' => 'comments.php', 'wp-comments-popup.php' => 'comments-popup.php');
2528 2641
 
2529 2642
 	foreach ($files as $oldfile => $newfile) {
2530
-		if ($oldfile == 'index.php')
2531
-			$oldpath = $home_path;
2532
-		else
2533
-			$oldpath = ABSPATH;
2643
+		if ($oldfile == 'index.php') {
2644
+					$oldpath = $home_path;
2645
+		} else {
2646
+					$oldpath = ABSPATH;
2647
+		}
2534 2648
 
2535 2649
 		// Check to make sure it's not a new index.
2536 2650
 		if ($oldfile == 'index.php') {
2537 2651
 			$index = implode('', file("$oldpath/$oldfile"));
2538 2652
 			if (strpos($index, 'WP_USE_THEMES') !== false) {
2539
-				if (! @copy(WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME . '/index.php', "$site_dir/$newfile"))
2540
-					return false;
2653
+				if (! @copy(WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME . '/index.php', "$site_dir/$newfile")) {
2654
+									return false;
2655
+				}
2541 2656
 
2542 2657
 				// Don't copy anything.
2543 2658
 				continue;
2544 2659
 			}
2545 2660
 		}
2546 2661
 
2547
-		if (! @copy("$oldpath/$oldfile", "$site_dir/$newfile"))
2548
-			return false;
2662
+		if (! @copy("$oldpath/$oldfile", "$site_dir/$newfile")) {
2663
+					return false;
2664
+		}
2549 2665
 
2550 2666
 		chmod("$site_dir/$newfile", 0777);
2551 2667
 
@@ -2555,8 +2671,9 @@  discard block
 block discarded – undo
2555 2671
 			$f = fopen("$site_dir/$newfile", 'w');
2556 2672
 
2557 2673
 			foreach ($lines as $line) {
2558
-				if (preg_match('/require.*wp-blog-header/', $line))
2559
-					$line = '//' . $line;
2674
+				if (preg_match('/require.*wp-blog-header/', $line)) {
2675
+									$line = '//' . $line;
2676
+				}
2560 2677
 
2561 2678
 				// Update stylesheet references.
2562 2679
 				$line = str_replace("<?php echo __get_option('siteurl'); ?>/wp-layout.css", "<?php bloginfo('stylesheet_url'); ?>", $line);
@@ -2606,10 +2723,12 @@  discard block
 block discarded – undo
2606 2723
 	$theme_dir = @ opendir($default_dir);
2607 2724
 	if ($theme_dir) {
2608 2725
 		while(($theme_file = readdir( $theme_dir )) !== false) {
2609
-			if (is_dir("$default_dir/$theme_file"))
2610
-				continue;
2611
-			if (! @copy("$default_dir/$theme_file", "$site_dir/$theme_file"))
2612
-				return;
2726
+			if (is_dir("$default_dir/$theme_file")) {
2727
+							continue;
2728
+			}
2729
+			if (! @copy("$default_dir/$theme_file", "$site_dir/$theme_file")) {
2730
+							return;
2731
+			}
2613 2732
 			chmod("$site_dir/$theme_file", 0777);
2614 2733
 		}
2615 2734
 	}
@@ -2621,11 +2740,17 @@  discard block
 block discarded – undo
2621 2740
 		$f = fopen("$site_dir/style.css", 'w');
2622 2741
 
2623 2742
 		foreach ($stylelines as $line) {
2624
-			if (strpos($line, 'Theme Name:') !== false) $line = 'Theme Name: ' . $theme_name;
2625
-			elseif (strpos($line, 'Theme URI:') !== false) $line = 'Theme URI: ' . __get_option('url');
2626
-			elseif (strpos($line, 'Description:') !== false) $line = 'Description: Your theme.';
2627
-			elseif (strpos($line, 'Version:') !== false) $line = 'Version: 1';
2628
-			elseif (strpos($line, 'Author:') !== false) $line = 'Author: You';
2743
+			if (strpos($line, 'Theme Name:') !== false) {
2744
+				$line = 'Theme Name: ' . $theme_name;
2745
+			} elseif (strpos($line, 'Theme URI:') !== false) {
2746
+				$line = 'Theme URI: ' . __get_option('url');
2747
+			} elseif (strpos($line, 'Description:') !== false) {
2748
+				$line = 'Description: Your theme.';
2749
+			} elseif (strpos($line, 'Version:') !== false) {
2750
+				$line = 'Version: 1';
2751
+			} elseif (strpos($line, 'Author:') !== false) {
2752
+				$line = 'Author: You';
2753
+			}
2629 2754
 			fwrite($f, $line . "\n");
2630 2755
 		}
2631 2756
 		fclose($f);
@@ -2640,10 +2765,12 @@  discard block
 block discarded – undo
2640 2765
 	$images_dir = @ opendir("$default_dir/images");
2641 2766
 	if ($images_dir) {
2642 2767
 		while(($image = readdir($images_dir)) !== false) {
2643
-			if (is_dir("$default_dir/images/$image"))
2644
-				continue;
2645
-			if (! @copy("$default_dir/images/$image", "$site_dir/images/$image"))
2646
-				return;
2768
+			if (is_dir("$default_dir/images/$image")) {
2769
+							continue;
2770
+			}
2771
+			if (! @copy("$default_dir/images/$image", "$site_dir/images/$image")) {
2772
+							return;
2773
+			}
2647 2774
 			chmod("$site_dir/images/$image", 0777);
2648 2775
 		}
2649 2776
 	}
@@ -2686,9 +2813,10 @@  discard block
 block discarded – undo
2686 2813
 			return false;
2687 2814
 		}
2688 2815
 	} else {
2689
-		if (! make_site_theme_from_default($theme_name, $template))
2690
-			// TODO: rm -rf the site theme directory.
2816
+		if (! make_site_theme_from_default($theme_name, $template)) {
2817
+					// TODO: rm -rf the site theme directory.
2691 2818
 			return false;
2819
+		}
2692 2820
 	}
2693 2821
 
2694 2822
 	// Make the new site theme active.
@@ -2739,9 +2867,10 @@  discard block
 block discarded – undo
2739 2867
 function wp_check_mysql_version() {
2740 2868
 	global $wpdb;
2741 2869
 	$result = $wpdb->check_database_version();
2742
-	if ( is_wp_error( $result ) )
2743
-		die( $result->get_error_message() );
2744
-}
2870
+	if ( is_wp_error( $result ) ) {
2871
+			die( $result->get_error_message() );
2872
+	}
2873
+	}
2745 2874
 
2746 2875
 /**
2747 2876
  * Disables the Automattic widgets plugin, which was merged into core.
@@ -2771,9 +2900,10 @@  discard block
 block discarded – undo
2771 2900
 function maybe_disable_link_manager() {
2772 2901
 	global $wp_current_db_version, $wpdb;
2773 2902
 
2774
-	if ( $wp_current_db_version >= 22006 && get_option( 'link_manager_enabled' ) && ! $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) )
2775
-		update_option( 'link_manager_enabled', 0 );
2776
-}
2903
+	if ( $wp_current_db_version >= 22006 && get_option( 'link_manager_enabled' ) && ! $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) ) {
2904
+			update_option( 'link_manager_enabled', 0 );
2905
+	}
2906
+	}
2777 2907
 
2778 2908
 /**
2779 2909
  * Runs before the schema is upgraded.
Please login to merge, or discard this patch.
src/wp-content/themes/twentyeleven/functions.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
  * @since Twenty Eleven 1.0
388 388
  *
389 389
  * @param string $more The Read More text.
390
- * @return The filtered Read More text.
390
+ * @return string filtered Read More text.
391 391
  */
392 392
 function twentyeleven_auto_excerpt_more( $more ) {
393 393
 	if ( ! is_admin() ) {
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
  *
541 541
  * @since Twenty Eleven 1.0
542 542
  *
543
- * @return string|bool URL or false when no link is present.
543
+ * @return false|string URL or false when no link is present.
544 544
  */
545 545
 function twentyeleven_url_grabber() {
546 546
 	if ( ! preg_match( '/<a\s[^>]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $matches ) )
Please login to merge, or discard this patch.
Braces   +52 added lines, -34 removed lines patch added patch discarded remove patch
@@ -39,8 +39,9 @@  discard block
 block discarded – undo
39 39
  */
40 40
 
41 41
 // Set the content width based on the theme's design and stylesheet.
42
-if ( ! isset( $content_width ) )
42
+if ( ! isset( $content_width ) ) {
43 43
 	$content_width = 584;
44
+}
44 45
 
45 46
 /*
46 47
  * Tell WordPress to run twentyeleven_setup() when the 'after_setup_theme' hook is run.
@@ -98,10 +99,11 @@  discard block
 block discarded – undo
98 99
 	add_theme_support( 'post-formats', array( 'aside', 'link', 'gallery', 'status', 'quote', 'image' ) );
99 100
 
100 101
 	$theme_options = twentyeleven_get_theme_options();
101
-	if ( 'dark' == $theme_options['color_scheme'] )
102
-		$default_background_color = '1d1d1d';
103
-	else
104
-		$default_background_color = 'e2e2e2';
102
+	if ( 'dark' == $theme_options['color_scheme'] ) {
103
+			$default_background_color = '1d1d1d';
104
+	} else {
105
+			$default_background_color = 'e2e2e2';
106
+	}
105 107
 
106 108
 	// Add support for custom backgrounds.
107 109
 	add_theme_support( 'custom-background', array(
@@ -239,8 +241,9 @@  discard block
 block discarded – undo
239 241
 	$text_color = get_header_textcolor();
240 242
 
241 243
 	// If no custom options for text are set, let's bail.
242
-	if ( $text_color == HEADER_TEXTCOLOR )
243
-		return;
244
+	if ( $text_color == HEADER_TEXTCOLOR ) {
245
+			return;
246
+	}
244 247
 
245 248
 	// If we get this far, we have custom styles. Let's do this.
246 249
 	?>
@@ -257,11 +260,14 @@  discard block
 block discarded – undo
257 260
 		}
258 261
 	<?php
259 262
 		// If the user has set a custom color for the text use that
260
-		else :
263
+		else {
264
+			:
261 265
 	?>
262 266
 		#site-title a,
263 267
 		#site-description {
264
-			color: #<?php echo $text_color; ?>;
268
+			color: #<?php echo $text_color;
269
+		}
270
+		?>;
265 271
 		}
266 272
 	<?php endif; ?>
267 273
 	</style>
@@ -425,8 +431,9 @@  discard block
 block discarded – undo
425 431
  * @return array The filtered page menu arguments.
426 432
  */
427 433
 function twentyeleven_page_menu_args( $args ) {
428
-	if ( ! isset( $args['show_home'] ) )
429
-		$args['show_home'] = true;
434
+	if ( ! isset( $args['show_home'] ) ) {
435
+			$args['show_home'] = true;
436
+	}
430 437
 	return $args;
431 438
 }
432 439
 add_filter( 'wp_page_menu_args', 'twentyeleven_page_menu_args' );
@@ -528,8 +535,9 @@  discard block
 block discarded – undo
528 535
 	$content = get_the_content();
529 536
 	$has_url = function_exists( 'get_url_in_content' ) ? get_url_in_content( $content ) : false;
530 537
 
531
-	if ( ! $has_url )
532
-		$has_url = twentyeleven_url_grabber();
538
+	if ( ! $has_url ) {
539
+			$has_url = twentyeleven_url_grabber();
540
+	}
533 541
 
534 542
 	/** This filter is documented in wp-includes/link-template.php */
535 543
 	return ( $has_url ) ? $has_url : apply_filters( 'the_permalink', get_permalink() );
@@ -543,8 +551,9 @@  discard block
 block discarded – undo
543 551
  * @return string|bool URL or false when no link is present.
544 552
  */
545 553
 function twentyeleven_url_grabber() {
546
-	if ( ! preg_match( '/<a\s[^>]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $matches ) )
547
-		return false;
554
+	if ( ! preg_match( '/<a\s[^>]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $matches ) ) {
555
+			return false;
556
+	}
548 557
 
549 558
 	return esc_url_raw( $matches[1] );
550 559
 }
@@ -557,14 +566,17 @@  discard block
 block discarded – undo
557 566
 function twentyeleven_footer_sidebar_class() {
558 567
 	$count = 0;
559 568
 
560
-	if ( is_active_sidebar( 'sidebar-3' ) )
561
-		$count++;
569
+	if ( is_active_sidebar( 'sidebar-3' ) ) {
570
+			$count++;
571
+	}
562 572
 
563
-	if ( is_active_sidebar( 'sidebar-4' ) )
564
-		$count++;
573
+	if ( is_active_sidebar( 'sidebar-4' ) ) {
574
+			$count++;
575
+	}
565 576
 
566
-	if ( is_active_sidebar( 'sidebar-5' ) )
567
-		$count++;
577
+	if ( is_active_sidebar( 'sidebar-5' ) ) {
578
+			$count++;
579
+	}
568 580
 
569 581
 	$class = '';
570 582
 
@@ -580,9 +592,10 @@  discard block
 block discarded – undo
580 592
 			break;
581 593
 	}
582 594
 
583
-	if ( $class )
584
-		echo 'class="' . esc_attr( $class ) . '"';
585
-}
595
+	if ( $class ) {
596
+			echo 'class="' . esc_attr( $class ) . '"';
597
+	}
598
+	}
586 599
 
587 600
 if ( ! function_exists( 'twentyeleven_comment' ) ) :
588 601
 /**
@@ -617,8 +630,9 @@  discard block
 block discarded – undo
617 630
 				<div class="comment-author vcard">
618 631
 					<?php
619 632
 						$avatar_size = 68;
620
-						if ( '0' != $comment->comment_parent )
621
-							$avatar_size = 39;
633
+						if ( '0' != $comment->comment_parent ) {
634
+													$avatar_size = 39;
635
+						}
622 636
 
623 637
 						echo get_avatar( $comment, $avatar_size );
624 638
 
@@ -691,11 +705,13 @@  discard block
 block discarded – undo
691 705
  */
692 706
 function twentyeleven_body_classes( $classes ) {
693 707
 
694
-	if ( function_exists( 'is_multi_author' ) && ! is_multi_author() )
695
-		$classes[] = 'single-author';
708
+	if ( function_exists( 'is_multi_author' ) && ! is_multi_author() ) {
709
+			$classes[] = 'single-author';
710
+	}
696 711
 
697
-	if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) )
698
-		$classes[] = 'singular';
712
+	if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) ) {
713
+			$classes[] = 'singular';
714
+	}
699 715
 
700 716
 	return $classes;
701 717
 }
@@ -716,14 +732,16 @@  discard block
 block discarded – undo
716 732
 
717 733
 	if ( function_exists( 'get_post_galleries' ) ) {
718 734
 		$galleries = get_post_galleries( get_the_ID(), false );
719
-		if ( isset( $galleries[0]['ids'] ) )
720
-			$images = explode( ',', $galleries[0]['ids'] );
735
+		if ( isset( $galleries[0]['ids'] ) ) {
736
+					$images = explode( ',', $galleries[0]['ids'] );
737
+		}
721 738
 	} else {
722 739
 		$pattern = get_shortcode_regex();
723 740
 		preg_match( "/$pattern/s", get_the_content(), $match );
724 741
 		$atts = shortcode_parse_atts( $match[3] );
725
-		if ( isset( $atts['ids'] ) )
726
-			$images = explode( ',', $atts['ids'] );
742
+		if ( isset( $atts['ids'] ) ) {
743
+					$images = explode( ',', $atts['ids'] );
744
+		}
727 745
 	}
728 746
 
729 747
 	if ( ! $images ) {
Please login to merge, or discard this patch.
Spacing   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -39,15 +39,15 @@  discard block
 block discarded – undo
39 39
  */
40 40
 
41 41
 // Set the content width based on the theme's design and stylesheet.
42
-if ( ! isset( $content_width ) )
42
+if ( ! isset($content_width))
43 43
 	$content_width = 584;
44 44
 
45 45
 /*
46 46
  * Tell WordPress to run twentyeleven_setup() when the 'after_setup_theme' hook is run.
47 47
  */
48
-add_action( 'after_setup_theme', 'twentyeleven_setup' );
48
+add_action('after_setup_theme', 'twentyeleven_setup');
49 49
 
50
-if ( ! function_exists( 'twentyeleven_setup' ) ):
50
+if ( ! function_exists('twentyeleven_setup')):
51 51
 /**
52 52
  * Set up theme defaults and registers support for various WordPress features.
53 53
  *
@@ -77,43 +77,43 @@  discard block
 block discarded – undo
77 77
 	 * a find and replace to change 'twentyeleven' to the name
78 78
 	 * of your theme in all the template files.
79 79
 	 */
80
-	load_theme_textdomain( 'twentyeleven', get_template_directory() . '/languages' );
80
+	load_theme_textdomain('twentyeleven', get_template_directory().'/languages');
81 81
 
82 82
 	// This theme styles the visual editor with editor-style.css to match the theme style.
83 83
 	add_editor_style();
84 84
 
85 85
 	// Load up our theme options page and related code.
86
-	require( get_template_directory() . '/inc/theme-options.php' );
86
+	require(get_template_directory().'/inc/theme-options.php');
87 87
 
88 88
 	// Grab Twenty Eleven's Ephemera widget.
89
-	require( get_template_directory() . '/inc/widgets.php' );
89
+	require(get_template_directory().'/inc/widgets.php');
90 90
 
91 91
 	// Add default posts and comments RSS feed links to <head>.
92
-	add_theme_support( 'automatic-feed-links' );
92
+	add_theme_support('automatic-feed-links');
93 93
 
94 94
 	// This theme uses wp_nav_menu() in one location.
95
-	register_nav_menu( 'primary', __( 'Primary Menu', 'twentyeleven' ) );
95
+	register_nav_menu('primary', __('Primary Menu', 'twentyeleven'));
96 96
 
97 97
 	// Add support for a variety of post formats
98
-	add_theme_support( 'post-formats', array( 'aside', 'link', 'gallery', 'status', 'quote', 'image' ) );
98
+	add_theme_support('post-formats', array('aside', 'link', 'gallery', 'status', 'quote', 'image'));
99 99
 
100 100
 	$theme_options = twentyeleven_get_theme_options();
101
-	if ( 'dark' == $theme_options['color_scheme'] )
101
+	if ('dark' == $theme_options['color_scheme'])
102 102
 		$default_background_color = '1d1d1d';
103 103
 	else
104 104
 		$default_background_color = 'e2e2e2';
105 105
 
106 106
 	// Add support for custom backgrounds.
107
-	add_theme_support( 'custom-background', array(
107
+	add_theme_support('custom-background', array(
108 108
 		/*
109 109
 		 * Let WordPress know what our default background color is.
110 110
 		 * This is dependent on our current color scheme.
111 111
 		 */
112 112
 		'default-color' => $default_background_color,
113
-	) );
113
+	));
114 114
 
115 115
 	// This theme uses Featured Images (also known as post thumbnails) for per-post/per-page Custom Header images
116
-	add_theme_support( 'post-thumbnails' );
116
+	add_theme_support('post-thumbnails');
117 117
 
118 118
 	// Add support for custom headers.
119 119
 	$custom_header_support = array(
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 		 *
128 128
 		 * @param int The default header image width in pixels. Default 1000.
129 129
 		 */
130
-		'width' => apply_filters( 'twentyeleven_header_image_width', 1000 ),
130
+		'width' => apply_filters('twentyeleven_header_image_width', 1000),
131 131
 		/**
132 132
 		 * Filter the Twenty Eleven default header image height.
133 133
 		 *
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 		 *
136 136
 		 * @param int The default header image height in pixels. Default 288.
137 137
 		 */
138
-		'height' => apply_filters( 'twentyeleven_header_image_height', 288 ),
138
+		'height' => apply_filters('twentyeleven_header_image_height', 288),
139 139
 		// Support flexible heights.
140 140
 		'flex-height' => true,
141 141
 		// Random image rotation by default.
@@ -148,15 +148,15 @@  discard block
 block discarded – undo
148 148
 		'admin-preview-callback' => 'twentyeleven_admin_header_image',
149 149
 	);
150 150
 
151
-	add_theme_support( 'custom-header', $custom_header_support );
151
+	add_theme_support('custom-header', $custom_header_support);
152 152
 
153
-	if ( ! function_exists( 'get_custom_header' ) ) {
153
+	if ( ! function_exists('get_custom_header')) {
154 154
 		// This is all for compatibility with versions of WordPress prior to 3.4.
155
-		define( 'HEADER_TEXTCOLOR', $custom_header_support['default-text-color'] );
156
-		define( 'HEADER_IMAGE', '' );
157
-		define( 'HEADER_IMAGE_WIDTH', $custom_header_support['width'] );
158
-		define( 'HEADER_IMAGE_HEIGHT', $custom_header_support['height'] );
159
-		add_custom_image_header( $custom_header_support['wp-head-callback'], $custom_header_support['admin-head-callback'], $custom_header_support['admin-preview-callback'] );
155
+		define('HEADER_TEXTCOLOR', $custom_header_support['default-text-color']);
156
+		define('HEADER_IMAGE', '');
157
+		define('HEADER_IMAGE_WIDTH', $custom_header_support['width']);
158
+		define('HEADER_IMAGE_HEIGHT', $custom_header_support['height']);
159
+		add_custom_image_header($custom_header_support['wp-head-callback'], $custom_header_support['admin-head-callback'], $custom_header_support['admin-preview-callback']);
160 160
 		add_custom_background();
161 161
 	}
162 162
 
@@ -165,74 +165,74 @@  discard block
 block discarded – undo
165 165
 	 * We want them to be the size of the header image that we just defined.
166 166
 	 * Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
167 167
 	 */
168
-	set_post_thumbnail_size( $custom_header_support['width'], $custom_header_support['height'], true );
168
+	set_post_thumbnail_size($custom_header_support['width'], $custom_header_support['height'], true);
169 169
 
170 170
 	/*
171 171
 	 * Add Twenty Eleven's custom image sizes.
172 172
 	 * Used for large feature (header) images.
173 173
 	 */
174
-	add_image_size( 'large-feature', $custom_header_support['width'], $custom_header_support['height'], true );
174
+	add_image_size('large-feature', $custom_header_support['width'], $custom_header_support['height'], true);
175 175
 	// Used for featured posts if a large-feature doesn't exist.
176
-	add_image_size( 'small-feature', 500, 300 );
176
+	add_image_size('small-feature', 500, 300);
177 177
 
178 178
 	// Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
179
-	register_default_headers( array(
179
+	register_default_headers(array(
180 180
 		'wheel' => array(
181 181
 			'url' => '%s/images/headers/wheel.jpg',
182 182
 			'thumbnail_url' => '%s/images/headers/wheel-thumbnail.jpg',
183 183
 			/* translators: header image description */
184
-			'description' => __( 'Wheel', 'twentyeleven' )
184
+			'description' => __('Wheel', 'twentyeleven')
185 185
 		),
186 186
 		'shore' => array(
187 187
 			'url' => '%s/images/headers/shore.jpg',
188 188
 			'thumbnail_url' => '%s/images/headers/shore-thumbnail.jpg',
189 189
 			/* translators: header image description */
190
-			'description' => __( 'Shore', 'twentyeleven' )
190
+			'description' => __('Shore', 'twentyeleven')
191 191
 		),
192 192
 		'trolley' => array(
193 193
 			'url' => '%s/images/headers/trolley.jpg',
194 194
 			'thumbnail_url' => '%s/images/headers/trolley-thumbnail.jpg',
195 195
 			/* translators: header image description */
196
-			'description' => __( 'Trolley', 'twentyeleven' )
196
+			'description' => __('Trolley', 'twentyeleven')
197 197
 		),
198 198
 		'pine-cone' => array(
199 199
 			'url' => '%s/images/headers/pine-cone.jpg',
200 200
 			'thumbnail_url' => '%s/images/headers/pine-cone-thumbnail.jpg',
201 201
 			/* translators: header image description */
202
-			'description' => __( 'Pine Cone', 'twentyeleven' )
202
+			'description' => __('Pine Cone', 'twentyeleven')
203 203
 		),
204 204
 		'chessboard' => array(
205 205
 			'url' => '%s/images/headers/chessboard.jpg',
206 206
 			'thumbnail_url' => '%s/images/headers/chessboard-thumbnail.jpg',
207 207
 			/* translators: header image description */
208
-			'description' => __( 'Chessboard', 'twentyeleven' )
208
+			'description' => __('Chessboard', 'twentyeleven')
209 209
 		),
210 210
 		'lanterns' => array(
211 211
 			'url' => '%s/images/headers/lanterns.jpg',
212 212
 			'thumbnail_url' => '%s/images/headers/lanterns-thumbnail.jpg',
213 213
 			/* translators: header image description */
214
-			'description' => __( 'Lanterns', 'twentyeleven' )
214
+			'description' => __('Lanterns', 'twentyeleven')
215 215
 		),
216 216
 		'willow' => array(
217 217
 			'url' => '%s/images/headers/willow.jpg',
218 218
 			'thumbnail_url' => '%s/images/headers/willow-thumbnail.jpg',
219 219
 			/* translators: header image description */
220
-			'description' => __( 'Willow', 'twentyeleven' )
220
+			'description' => __('Willow', 'twentyeleven')
221 221
 		),
222 222
 		'hanoi' => array(
223 223
 			'url' => '%s/images/headers/hanoi.jpg',
224 224
 			'thumbnail_url' => '%s/images/headers/hanoi-thumbnail.jpg',
225 225
 			/* translators: header image description */
226
-			'description' => __( 'Hanoi Plant', 'twentyeleven' )
226
+			'description' => __('Hanoi Plant', 'twentyeleven')
227 227
 		)
228
-	) );
228
+	));
229 229
 
230 230
 	// Indicate widget sidebars can use selective refresh in the Customizer.
231
-	add_theme_support( 'customize-selective-refresh-widgets' );
231
+	add_theme_support('customize-selective-refresh-widgets');
232 232
 }
233 233
 endif; // twentyeleven_setup
234 234
 
235
-if ( ! function_exists( 'twentyeleven_header_style' ) ) :
235
+if ( ! function_exists('twentyeleven_header_style')) :
236 236
 /**
237 237
  * Styles the header image and text displayed on the blog.
238 238
  *
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 	$text_color = get_header_textcolor();
243 243
 
244 244
 	// If no custom options for text are set, let's bail.
245
-	if ( $text_color == HEADER_TEXTCOLOR )
245
+	if ($text_color == HEADER_TEXTCOLOR)
246 246
 		return;
247 247
 
248 248
 	// If we get this far, we have custom styles. Let's do this.
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	<style type="text/css" id="twentyeleven-header-css">
251 251
 	<?php
252 252
 		// Has the text been hidden?
253
-		if ( 'blank' == $text_color ) :
253
+		if ('blank' == $text_color) :
254 254
 	?>
255 255
 		#site-title,
256 256
 		#site-description {
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 }
273 273
 endif; // twentyeleven_header_style
274 274
 
275
-if ( ! function_exists( 'twentyeleven_admin_header_style' ) ) :
275
+if ( ! function_exists('twentyeleven_admin_header_style')) :
276 276
 /**
277 277
  * Styles the header image displayed on the Appearance > Header admin panel.
278 278
  *
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 	}
306 306
 	<?php
307 307
 		// If the user has set a custom color for the text use that
308
-		if ( get_header_textcolor() != HEADER_TEXTCOLOR ) :
308
+		if (get_header_textcolor() != HEADER_TEXTCOLOR) :
309 309
 	?>
310 310
 		#site-title a,
311 311
 		#site-description {
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 }
323 323
 endif; // twentyeleven_admin_header_style
324 324
 
325
-if ( ! function_exists( 'twentyeleven_admin_header_image' ) ) :
325
+if ( ! function_exists('twentyeleven_admin_header_image')) :
326 326
 /**
327 327
  * Custom header image markup displayed on the Appearance > Header admin panel.
328 328
  *
@@ -336,14 +336,14 @@  discard block
 block discarded – undo
336 336
 		$color = get_header_textcolor();
337 337
 		$image = get_header_image();
338 338
 		$style = 'display: none;';
339
-		if ( $color && $color != 'blank' ) {
340
-			$style = 'color: #' . $color . ';';
339
+		if ($color && $color != 'blank') {
340
+			$style = 'color: #'.$color.';';
341 341
 		}
342 342
 		?>
343
-		<h1 class="displaying-header-text"><a id="name" style="<?php echo esc_attr( $style ); ?>" onclick="return false;" href="<?php echo esc_url( home_url( '/' ) ); ?>" tabindex="-1"><?php bloginfo( 'name' ); ?></a></h1>
344
-		<div id="desc" class="displaying-header-text" style="<?php echo esc_attr( $style ); ?>"><?php bloginfo( 'description' ); ?></div>
345
-  		<?php if ( $image ) : ?>
346
-			<img src="<?php echo esc_url( $image ); ?>" alt="" />
343
+		<h1 class="displaying-header-text"><a id="name" style="<?php echo esc_attr($style); ?>" onclick="return false;" href="<?php echo esc_url(home_url('/')); ?>" tabindex="-1"><?php bloginfo('name'); ?></a></h1>
344
+		<div id="desc" class="displaying-header-text" style="<?php echo esc_attr($style); ?>"><?php bloginfo('description'); ?></div>
345
+  		<?php if ($image) : ?>
346
+			<img src="<?php echo esc_url($image); ?>" alt="" />
347 347
 		<?php endif; ?>
348 348
 	</div>
349 349
 <?php }
@@ -361,12 +361,12 @@  discard block
 block discarded – undo
361 361
  * @param int $length The number of excerpt characters.
362 362
  * @return int The filtered number of characters.
363 363
  */
364
-function twentyeleven_excerpt_length( $length ) {
364
+function twentyeleven_excerpt_length($length) {
365 365
 	return 40;
366 366
 }
367
-add_filter( 'excerpt_length', 'twentyeleven_excerpt_length' );
367
+add_filter('excerpt_length', 'twentyeleven_excerpt_length');
368 368
 
369
-if ( ! function_exists( 'twentyeleven_continue_reading_link' ) ) :
369
+if ( ! function_exists('twentyeleven_continue_reading_link')) :
370 370
 /**
371 371
  * Return a "Continue Reading" link for excerpts
372 372
  *
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
  * @return string The "Continue Reading" HTML link.
376 376
  */
377 377
 function twentyeleven_continue_reading_link() {
378
-	return ' <a href="'. esc_url( get_permalink() ) . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) . '</a>';
378
+	return ' <a href="'.esc_url(get_permalink()).'">'.__('Continue reading <span class="meta-nav">&rarr;</span>', 'twentyeleven').'</a>';
379 379
 }
380 380
 endif; // twentyeleven_continue_reading_link
381 381
 
@@ -392,13 +392,13 @@  discard block
 block discarded – undo
392 392
  * @param string $more The Read More text.
393 393
  * @return The filtered Read More text.
394 394
  */
395
-function twentyeleven_auto_excerpt_more( $more ) {
396
-	if ( ! is_admin() ) {
397
-		return ' &hellip;' . twentyeleven_continue_reading_link();
395
+function twentyeleven_auto_excerpt_more($more) {
396
+	if ( ! is_admin()) {
397
+		return ' &hellip;'.twentyeleven_continue_reading_link();
398 398
 	}
399 399
 	return $more;
400 400
 }
401
-add_filter( 'excerpt_more', 'twentyeleven_auto_excerpt_more' );
401
+add_filter('excerpt_more', 'twentyeleven_auto_excerpt_more');
402 402
 
403 403
 /**
404 404
  * Add a pretty "Continue Reading" link to custom post excerpts.
@@ -411,13 +411,13 @@  discard block
 block discarded – undo
411 411
  * @param string $output The "Continue Reading" link.
412 412
  * @return string The filtered "Continue Reading" link.
413 413
  */
414
-function twentyeleven_custom_excerpt_more( $output ) {
415
-	if ( has_excerpt() && ! is_attachment() && ! is_admin() ) {
414
+function twentyeleven_custom_excerpt_more($output) {
415
+	if (has_excerpt() && ! is_attachment() && ! is_admin()) {
416 416
 		$output .= twentyeleven_continue_reading_link();
417 417
 	}
418 418
 	return $output;
419 419
 }
420
-add_filter( 'get_the_excerpt', 'twentyeleven_custom_excerpt_more' );
420
+add_filter('get_the_excerpt', 'twentyeleven_custom_excerpt_more');
421 421
 
422 422
 /**
423 423
  * Show a home link for the wp_nav_menu() fallback, wp_page_menu().
@@ -427,12 +427,12 @@  discard block
 block discarded – undo
427 427
  * @param array $args The page menu arguments. @see wp_page_menu()
428 428
  * @return array The filtered page menu arguments.
429 429
  */
430
-function twentyeleven_page_menu_args( $args ) {
431
-	if ( ! isset( $args['show_home'] ) )
430
+function twentyeleven_page_menu_args($args) {
431
+	if ( ! isset($args['show_home']))
432 432
 		$args['show_home'] = true;
433 433
 	return $args;
434 434
 }
435
-add_filter( 'wp_page_menu_args', 'twentyeleven_page_menu_args' );
435
+add_filter('wp_page_menu_args', 'twentyeleven_page_menu_args');
436 436
 
437 437
 /**
438 438
  * Register sidebars and widgetized areas.
@@ -443,60 +443,60 @@  discard block
 block discarded – undo
443 443
  */
444 444
 function twentyeleven_widgets_init() {
445 445
 
446
-	register_widget( 'Twenty_Eleven_Ephemera_Widget' );
446
+	register_widget('Twenty_Eleven_Ephemera_Widget');
447 447
 
448
-	register_sidebar( array(
449
-		'name' => __( 'Main Sidebar', 'twentyeleven' ),
448
+	register_sidebar(array(
449
+		'name' => __('Main Sidebar', 'twentyeleven'),
450 450
 		'id' => 'sidebar-1',
451 451
 		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
452 452
 		'after_widget' => '</aside>',
453 453
 		'before_title' => '<h3 class="widget-title">',
454 454
 		'after_title' => '</h3>',
455
-	) );
455
+	));
456 456
 
457
-	register_sidebar( array(
458
-		'name' => __( 'Showcase Sidebar', 'twentyeleven' ),
457
+	register_sidebar(array(
458
+		'name' => __('Showcase Sidebar', 'twentyeleven'),
459 459
 		'id' => 'sidebar-2',
460
-		'description' => __( 'The sidebar for the optional Showcase Template', 'twentyeleven' ),
460
+		'description' => __('The sidebar for the optional Showcase Template', 'twentyeleven'),
461 461
 		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
462 462
 		'after_widget' => '</aside>',
463 463
 		'before_title' => '<h3 class="widget-title">',
464 464
 		'after_title' => '</h3>',
465
-	) );
465
+	));
466 466
 
467
-	register_sidebar( array(
468
-		'name' => __( 'Footer Area One', 'twentyeleven' ),
467
+	register_sidebar(array(
468
+		'name' => __('Footer Area One', 'twentyeleven'),
469 469
 		'id' => 'sidebar-3',
470
-		'description' => __( 'An optional widget area for your site footer', 'twentyeleven' ),
470
+		'description' => __('An optional widget area for your site footer', 'twentyeleven'),
471 471
 		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
472 472
 		'after_widget' => '</aside>',
473 473
 		'before_title' => '<h3 class="widget-title">',
474 474
 		'after_title' => '</h3>',
475
-	) );
475
+	));
476 476
 
477
-	register_sidebar( array(
478
-		'name' => __( 'Footer Area Two', 'twentyeleven' ),
477
+	register_sidebar(array(
478
+		'name' => __('Footer Area Two', 'twentyeleven'),
479 479
 		'id' => 'sidebar-4',
480
-		'description' => __( 'An optional widget area for your site footer', 'twentyeleven' ),
480
+		'description' => __('An optional widget area for your site footer', 'twentyeleven'),
481 481
 		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
482 482
 		'after_widget' => '</aside>',
483 483
 		'before_title' => '<h3 class="widget-title">',
484 484
 		'after_title' => '</h3>',
485
-	) );
485
+	));
486 486
 
487
-	register_sidebar( array(
488
-		'name' => __( 'Footer Area Three', 'twentyeleven' ),
487
+	register_sidebar(array(
488
+		'name' => __('Footer Area Three', 'twentyeleven'),
489 489
 		'id' => 'sidebar-5',
490
-		'description' => __( 'An optional widget area for your site footer', 'twentyeleven' ),
490
+		'description' => __('An optional widget area for your site footer', 'twentyeleven'),
491 491
 		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
492 492
 		'after_widget' => '</aside>',
493 493
 		'before_title' => '<h3 class="widget-title">',
494 494
 		'after_title' => '</h3>',
495
-	) );
495
+	));
496 496
 }
497
-add_action( 'widgets_init', 'twentyeleven_widgets_init' );
497
+add_action('widgets_init', 'twentyeleven_widgets_init');
498 498
 
499
-if ( ! function_exists( 'twentyeleven_content_nav' ) ) :
499
+if ( ! function_exists('twentyeleven_content_nav')) :
500 500
 /**
501 501
  * Display navigation to next/previous pages when applicable.
502 502
  *
@@ -504,14 +504,14 @@  discard block
 block discarded – undo
504 504
  *
505 505
  * @param string $html_id The HTML id attribute.
506 506
  */
507
-function twentyeleven_content_nav( $html_id ) {
507
+function twentyeleven_content_nav($html_id) {
508 508
 	global $wp_query;
509 509
 
510
-	if ( $wp_query->max_num_pages > 1 ) : ?>
511
-		<nav id="<?php echo esc_attr( $html_id ); ?>">
512
-			<h3 class="assistive-text"><?php _e( 'Post navigation', 'twentyeleven' ); ?></h3>
513
-			<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyeleven' ) ); ?></div>
514
-			<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) ); ?></div>
510
+	if ($wp_query->max_num_pages > 1) : ?>
511
+		<nav id="<?php echo esc_attr($html_id); ?>">
512
+			<h3 class="assistive-text"><?php _e('Post navigation', 'twentyeleven'); ?></h3>
513
+			<div class="nav-previous"><?php next_posts_link(__('<span class="meta-nav">&larr;</span> Older posts', 'twentyeleven')); ?></div>
514
+			<div class="nav-next"><?php previous_posts_link(__('Newer posts <span class="meta-nav">&rarr;</span>', 'twentyeleven')); ?></div>
515 515
 		</nav><!-- #nav-above -->
516 516
 	<?php endif;
517 517
 }
@@ -529,13 +529,13 @@  discard block
 block discarded – undo
529 529
  */
530 530
 function twentyeleven_get_first_url() {
531 531
 	$content = get_the_content();
532
-	$has_url = function_exists( 'get_url_in_content' ) ? get_url_in_content( $content ) : false;
532
+	$has_url = function_exists('get_url_in_content') ? get_url_in_content($content) : false;
533 533
 
534
-	if ( ! $has_url )
534
+	if ( ! $has_url)
535 535
 		$has_url = twentyeleven_url_grabber();
536 536
 
537 537
 	/** This filter is documented in wp-includes/link-template.php */
538
-	return ( $has_url ) ? $has_url : apply_filters( 'the_permalink', get_permalink() );
538
+	return ($has_url) ? $has_url : apply_filters('the_permalink', get_permalink());
539 539
 }
540 540
 
541 541
 /**
@@ -546,10 +546,10 @@  discard block
 block discarded – undo
546 546
  * @return string|bool URL or false when no link is present.
547 547
  */
548 548
 function twentyeleven_url_grabber() {
549
-	if ( ! preg_match( '/<a\s[^>]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $matches ) )
549
+	if ( ! preg_match('/<a\s[^>]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $matches))
550 550
 		return false;
551 551
 
552
-	return esc_url_raw( $matches[1] );
552
+	return esc_url_raw($matches[1]);
553 553
 }
554 554
 
555 555
 /**
@@ -560,18 +560,18 @@  discard block
 block discarded – undo
560 560
 function twentyeleven_footer_sidebar_class() {
561 561
 	$count = 0;
562 562
 
563
-	if ( is_active_sidebar( 'sidebar-3' ) )
563
+	if (is_active_sidebar('sidebar-3'))
564 564
 		$count++;
565 565
 
566
-	if ( is_active_sidebar( 'sidebar-4' ) )
566
+	if (is_active_sidebar('sidebar-4'))
567 567
 		$count++;
568 568
 
569
-	if ( is_active_sidebar( 'sidebar-5' ) )
569
+	if (is_active_sidebar('sidebar-5'))
570 570
 		$count++;
571 571
 
572 572
 	$class = '';
573 573
 
574
-	switch ( $count ) {
574
+	switch ($count) {
575 575
 		case '1':
576 576
 			$class = 'one';
577 577
 			break;
@@ -583,11 +583,11 @@  discard block
 block discarded – undo
583 583
 			break;
584 584
 	}
585 585
 
586
-	if ( $class )
587
-		echo 'class="' . esc_attr( $class ) . '"';
586
+	if ($class)
587
+		echo 'class="'.esc_attr($class).'"';
588 588
 }
589 589
 
590
-if ( ! function_exists( 'twentyeleven_comment' ) ) :
590
+if ( ! function_exists('twentyeleven_comment')) :
591 591
 /**
592 592
  * Template for comments and pingbacks.
593 593
  *
@@ -602,14 +602,14 @@  discard block
 block discarded – undo
602 602
  * @param array  $args    An array of comment arguments. @see get_comment_reply_link()
603 603
  * @param int    $depth   The depth of the comment.
604 604
  */
605
-function twentyeleven_comment( $comment, $args, $depth ) {
605
+function twentyeleven_comment($comment, $args, $depth) {
606 606
 	$GLOBALS['comment'] = $comment;
607
-	switch ( $comment->comment_type ) :
607
+	switch ($comment->comment_type) :
608 608
 		case 'pingback' :
609 609
 		case 'trackback' :
610 610
 	?>
611 611
 	<li class="post pingback">
612
-		<p><?php _e( 'Pingback:', 'twentyeleven' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?></p>
612
+		<p><?php _e('Pingback:', 'twentyeleven'); ?> <?php comment_author_link(); ?><?php edit_comment_link(__('Edit', 'twentyeleven'), '<span class="edit-link">', '</span>'); ?></p>
613 613
 	<?php
614 614
 			break;
615 615
 		default :
@@ -620,28 +620,28 @@  discard block
 block discarded – undo
620 620
 				<div class="comment-author vcard">
621 621
 					<?php
622 622
 						$avatar_size = 68;
623
-						if ( '0' != $comment->comment_parent )
623
+						if ('0' != $comment->comment_parent)
624 624
 							$avatar_size = 39;
625 625
 
626
-						echo get_avatar( $comment, $avatar_size );
626
+						echo get_avatar($comment, $avatar_size);
627 627
 
628 628
 						/* translators: 1: comment author, 2: date and time */
629
-						printf( __( '%1$s on %2$s <span class="says">said:</span>', 'twentyeleven' ),
630
-							sprintf( '<span class="fn">%s</span>', get_comment_author_link() ),
631
-							sprintf( '<a href="%1$s"><time datetime="%2$s">%3$s</time></a>',
632
-								esc_url( get_comment_link( $comment->comment_ID ) ),
633
-								get_comment_time( 'c' ),
629
+						printf(__('%1$s on %2$s <span class="says">said:</span>', 'twentyeleven'),
630
+							sprintf('<span class="fn">%s</span>', get_comment_author_link()),
631
+							sprintf('<a href="%1$s"><time datetime="%2$s">%3$s</time></a>',
632
+								esc_url(get_comment_link($comment->comment_ID)),
633
+								get_comment_time('c'),
634 634
 								/* translators: 1: date, 2: time */
635
-								sprintf( __( '%1$s at %2$s', 'twentyeleven' ), get_comment_date(), get_comment_time() )
635
+								sprintf(__('%1$s at %2$s', 'twentyeleven'), get_comment_date(), get_comment_time())
636 636
 							)
637 637
 						);
638 638
 					?>
639 639
 
640
-					<?php edit_comment_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?>
640
+					<?php edit_comment_link(__('Edit', 'twentyeleven'), '<span class="edit-link">', '</span>'); ?>
641 641
 				</div><!-- .comment-author .vcard -->
642 642
 
643
-				<?php if ( $comment->comment_approved == '0' ) : ?>
644
-					<em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'twentyeleven' ); ?></em>
643
+				<?php if ($comment->comment_approved == '0') : ?>
644
+					<em class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation.', 'twentyeleven'); ?></em>
645 645
 					<br />
646 646
 				<?php endif; ?>
647 647
 
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
 			<div class="comment-content"><?php comment_text(); ?></div>
651 651
 
652 652
 			<div class="reply">
653
-				<?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply <span>&darr;</span>', 'twentyeleven' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
653
+				<?php comment_reply_link(array_merge($args, array('reply_text' => __('Reply <span>&darr;</span>', 'twentyeleven'), 'depth' => $depth, 'max_depth' => $args['max_depth']))); ?>
654 654
 			</div><!-- .reply -->
655 655
 		</article><!-- #comment-## -->
656 656
 
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 }
661 661
 endif; // ends check for twentyeleven_comment()
662 662
 
663
-if ( ! function_exists( 'twentyeleven_posted_on' ) ) :
663
+if ( ! function_exists('twentyeleven_posted_on')) :
664 664
 /**
665 665
  * Print HTML with meta information for the current post-date/time and author.
666 666
  *
@@ -669,13 +669,13 @@  discard block
 block discarded – undo
669 669
  * @since Twenty Eleven 1.0
670 670
  */
671 671
 function twentyeleven_posted_on() {
672
-	printf( __( '<span class="sep">Posted on </span><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>', 'twentyeleven' ),
673
-		esc_url( get_permalink() ),
674
-		esc_attr( get_the_time() ),
675
-		esc_attr( get_the_date( 'c' ) ),
676
-		esc_html( get_the_date() ),
677
-		esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
678
-		esc_attr( sprintf( __( 'View all posts by %s', 'twentyeleven' ), get_the_author() ) ),
672
+	printf(__('<span class="sep">Posted on </span><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>', 'twentyeleven'),
673
+		esc_url(get_permalink()),
674
+		esc_attr(get_the_time()),
675
+		esc_attr(get_the_date('c')),
676
+		esc_html(get_the_date()),
677
+		esc_url(get_author_posts_url(get_the_author_meta('ID'))),
678
+		esc_attr(sprintf(__('View all posts by %s', 'twentyeleven'), get_the_author())),
679 679
 		get_the_author()
680 680
 	);
681 681
 }
@@ -692,17 +692,17 @@  discard block
 block discarded – undo
692 692
  * @param array $classes Existing body classes.
693 693
  * @return array The filtered array of body classes.
694 694
  */
695
-function twentyeleven_body_classes( $classes ) {
695
+function twentyeleven_body_classes($classes) {
696 696
 
697
-	if ( function_exists( 'is_multi_author' ) && ! is_multi_author() )
697
+	if (function_exists('is_multi_author') && ! is_multi_author())
698 698
 		$classes[] = 'single-author';
699 699
 
700
-	if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) )
700
+	if (is_singular() && ! is_home() && ! is_page_template('showcase.php') && ! is_page_template('sidebar-page.php'))
701 701
 		$classes[] = 'singular';
702 702
 
703 703
 	return $classes;
704 704
 }
705
-add_filter( 'body_class', 'twentyeleven_body_classes' );
705
+add_filter('body_class', 'twentyeleven_body_classes');
706 706
 
707 707
 /**
708 708
  * Retrieve the IDs for images in a gallery.
@@ -717,20 +717,20 @@  discard block
 block discarded – undo
717 717
 function twentyeleven_get_gallery_images() {
718 718
 	$images = array();
719 719
 
720
-	if ( function_exists( 'get_post_galleries' ) ) {
721
-		$galleries = get_post_galleries( get_the_ID(), false );
722
-		if ( isset( $galleries[0]['ids'] ) )
723
-			$images = explode( ',', $galleries[0]['ids'] );
720
+	if (function_exists('get_post_galleries')) {
721
+		$galleries = get_post_galleries(get_the_ID(), false);
722
+		if (isset($galleries[0]['ids']))
723
+			$images = explode(',', $galleries[0]['ids']);
724 724
 	} else {
725 725
 		$pattern = get_shortcode_regex();
726
-		preg_match( "/$pattern/s", get_the_content(), $match );
727
-		$atts = shortcode_parse_atts( $match[3] );
728
-		if ( isset( $atts['ids'] ) )
729
-			$images = explode( ',', $atts['ids'] );
726
+		preg_match("/$pattern/s", get_the_content(), $match);
727
+		$atts = shortcode_parse_atts($match[3]);
728
+		if (isset($atts['ids']))
729
+			$images = explode(',', $atts['ids']);
730 730
 	}
731 731
 
732
-	if ( ! $images ) {
733
-		$images = get_posts( array(
732
+	if ( ! $images) {
733
+		$images = get_posts(array(
734 734
 			'fields'         => 'ids',
735 735
 			'numberposts'    => 999,
736 736
 			'order'          => 'ASC',
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
 			'post_mime_type' => 'image',
739 739
 			'post_parent'    => get_the_ID(),
740 740
 			'post_type'      => 'attachment',
741
-		) );
741
+		));
742 742
 	}
743 743
 
744 744
 	return $images;
Please login to merge, or discard this patch.
src/wp-includes/canonical.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -503,7 +503,7 @@
 block discarded – undo
503 503
  * @access private
504 504
  *
505 505
  * @param string $query_string
506
- * @param array $args_to_check
506
+ * @param string[] $args_to_check
507 507
  * @param string $url
508 508
  * @return string The altered query string
509 509
  */
Please login to merge, or discard this patch.
Spacing   +239 added lines, -239 removed lines patch added patch discarded remove patch
@@ -38,28 +38,28 @@  discard block
 block discarded – undo
38 38
  * @param bool $do_redirect Optional. Redirect to the new URL.
39 39
  * @return string|void The string of the URL, if redirect needed.
40 40
  */
41
-function redirect_canonical( $requested_url = null, $do_redirect = true ) {
41
+function redirect_canonical($requested_url = null, $do_redirect = true) {
42 42
 	global $wp_rewrite, $is_IIS, $wp_query, $wpdb, $wp;
43 43
 
44
-	if ( isset( $_SERVER['REQUEST_METHOD'] ) && ! in_array( strtoupper( $_SERVER['REQUEST_METHOD'] ), array( 'GET', 'HEAD' ) ) ) {
44
+	if (isset($_SERVER['REQUEST_METHOD']) && ! in_array(strtoupper($_SERVER['REQUEST_METHOD']), array('GET', 'HEAD'))) {
45 45
 		return;
46 46
 	}
47 47
 
48 48
 	// If we're not in wp-admin and the post has been published and preview nonce
49 49
 	// is non-existent or invalid then no need for preview in query
50
-	if ( is_preview() && get_query_var( 'p' ) && 'publish' == get_post_status( get_query_var( 'p' ) ) ) {
51
-		if ( ! isset( $_GET['preview_id'] )
52
-			|| ! isset( $_GET['preview_nonce'] )
53
-			|| ! wp_verify_nonce( $_GET['preview_nonce'], 'post_preview_' . (int) $_GET['preview_id'] ) ) {
50
+	if (is_preview() && get_query_var('p') && 'publish' == get_post_status(get_query_var('p'))) {
51
+		if ( ! isset($_GET['preview_id'])
52
+			|| ! isset($_GET['preview_nonce'])
53
+			|| ! wp_verify_nonce($_GET['preview_nonce'], 'post_preview_'.(int) $_GET['preview_id'])) {
54 54
 			$wp_query->is_preview = false;
55 55
 		}
56 56
 	}
57 57
 
58
-	if ( is_trackback() || is_search() || is_admin() || is_preview() || is_robots() || ( $is_IIS && !iis7_supports_permalinks() ) ) {
58
+	if (is_trackback() || is_search() || is_admin() || is_preview() || is_robots() || ($is_IIS && ! iis7_supports_permalinks())) {
59 59
 		return;
60 60
 	}
61 61
 
62
-	if ( ! $requested_url && isset( $_SERVER['HTTP_HOST'] ) ) {
62
+	if ( ! $requested_url && isset($_SERVER['HTTP_HOST'])) {
63 63
 		// build the URL in the address bar
64 64
 		$requested_url  = is_ssl() ? 'https://' : 'http://';
65 65
 		$requested_url .= $_SERVER['HTTP_HOST'];
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	}
68 68
 
69 69
 	$original = @parse_url($requested_url);
70
-	if ( false === $original ) {
70
+	if (false === $original) {
71 71
 		return;
72 72
 	}
73 73
 
@@ -75,170 +75,170 @@  discard block
 block discarded – undo
75 75
 	$redirect_url = false;
76 76
 
77 77
 	// Notice fixing
78
-	if ( !isset($redirect['path']) )
78
+	if ( ! isset($redirect['path']))
79 79
 		$redirect['path'] = '';
80
-	if ( !isset($redirect['query']) )
80
+	if ( ! isset($redirect['query']))
81 81
 		$redirect['query'] = '';
82 82
 
83 83
 	// If the original URL ended with non-breaking spaces, they were almost
84 84
 	// certainly inserted by accident. Let's remove them, so the reader doesn't
85 85
 	// see a 404 error with no obvious cause.
86
-	$redirect['path'] = preg_replace( '|(%C2%A0)+$|i', '', $redirect['path'] );
86
+	$redirect['path'] = preg_replace('|(%C2%A0)+$|i', '', $redirect['path']);
87 87
 
88 88
 	// It's not a preview, so remove it from URL
89
-	if ( get_query_var( 'preview' ) ) {
90
-		$redirect['query'] = remove_query_arg( 'preview', $redirect['query'] );
89
+	if (get_query_var('preview')) {
90
+		$redirect['query'] = remove_query_arg('preview', $redirect['query']);
91 91
 	}
92 92
 
93
-	if ( is_feed() && ( $id = get_query_var( 'p' ) ) ) {
94
-		if ( $redirect_url = get_post_comments_feed_link( $id, get_query_var( 'feed' ) ) ) {
95
-			$redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type', 'feed'), $redirect_url );
96
-			$redirect['path'] = parse_url( $redirect_url, PHP_URL_PATH );
93
+	if (is_feed() && ($id = get_query_var('p'))) {
94
+		if ($redirect_url = get_post_comments_feed_link($id, get_query_var('feed'))) {
95
+			$redirect['query'] = _remove_qs_args_if_not_in_url($redirect['query'], array('p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type', 'feed'), $redirect_url);
96
+			$redirect['path'] = parse_url($redirect_url, PHP_URL_PATH);
97 97
 		}
98 98
 	}
99 99
 
100
-	if ( is_singular() && 1 > $wp_query->post_count && ($id = get_query_var('p')) ) {
100
+	if (is_singular() && 1 > $wp_query->post_count && ($id = get_query_var('p'))) {
101 101
 
102
-		$vars = $wpdb->get_results( $wpdb->prepare("SELECT post_type, post_parent FROM $wpdb->posts WHERE ID = %d", $id) );
102
+		$vars = $wpdb->get_results($wpdb->prepare("SELECT post_type, post_parent FROM $wpdb->posts WHERE ID = %d", $id));
103 103
 
104
-		if ( isset($vars[0]) && $vars = $vars[0] ) {
105
-			if ( 'revision' == $vars->post_type && $vars->post_parent > 0 )
104
+		if (isset($vars[0]) && $vars = $vars[0]) {
105
+			if ('revision' == $vars->post_type && $vars->post_parent > 0)
106 106
 				$id = $vars->post_parent;
107 107
 
108
-			if ( $redirect_url = get_permalink($id) )
109
-				$redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type' ), $redirect_url );
108
+			if ($redirect_url = get_permalink($id))
109
+				$redirect['query'] = _remove_qs_args_if_not_in_url($redirect['query'], array('p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type'), $redirect_url);
110 110
 		}
111 111
 	}
112 112
 
113 113
 	// These tests give us a WP-generated permalink
114
-	if ( is_404() ) {
114
+	if (is_404()) {
115 115
 
116 116
 		// Redirect ?page_id, ?p=, ?attachment_id= to their respective url's
117
-		$id = max( get_query_var('p'), get_query_var('page_id'), get_query_var('attachment_id') );
118
-		if ( $id && $redirect_post = get_post($id) ) {
117
+		$id = max(get_query_var('p'), get_query_var('page_id'), get_query_var('attachment_id'));
118
+		if ($id && $redirect_post = get_post($id)) {
119 119
 			$post_type_obj = get_post_type_object($redirect_post->post_type);
120
-			if ( $post_type_obj->public && 'auto-draft' != $redirect_post->post_status ) {
120
+			if ($post_type_obj->public && 'auto-draft' != $redirect_post->post_status) {
121 121
 				$redirect_url = get_permalink($redirect_post);
122
-				$redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type' ), $redirect_url );
122
+				$redirect['query'] = _remove_qs_args_if_not_in_url($redirect['query'], array('p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type'), $redirect_url);
123 123
 			}
124 124
 		}
125 125
 
126
-		if ( get_query_var( 'day' ) && get_query_var( 'monthnum' ) && get_query_var( 'year' ) ) {
127
-			$year  = get_query_var( 'year' );
128
-			$month = get_query_var( 'monthnum' );
129
-			$day   = get_query_var( 'day' );
130
-			$date  = sprintf( '%04d-%02d-%02d', $year, $month, $day );
131
-			if ( ! wp_checkdate( $month, $day, $year, $date ) ) {
132
-				$redirect_url = get_month_link( $year, $month );
133
-				$redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'year', 'monthnum', 'day' ), $redirect_url );
126
+		if (get_query_var('day') && get_query_var('monthnum') && get_query_var('year')) {
127
+			$year  = get_query_var('year');
128
+			$month = get_query_var('monthnum');
129
+			$day   = get_query_var('day');
130
+			$date  = sprintf('%04d-%02d-%02d', $year, $month, $day);
131
+			if ( ! wp_checkdate($month, $day, $year, $date)) {
132
+				$redirect_url = get_month_link($year, $month);
133
+				$redirect['query'] = _remove_qs_args_if_not_in_url($redirect['query'], array('year', 'monthnum', 'day'), $redirect_url);
134 134
 			}
135
-		} elseif ( get_query_var( 'monthnum' ) && get_query_var( 'year' ) && 12 < get_query_var( 'monthnum' ) ) {
136
-			$redirect_url = get_year_link( get_query_var( 'year' ) );
137
-			$redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'year', 'monthnum' ), $redirect_url );
135
+		} elseif (get_query_var('monthnum') && get_query_var('year') && 12 < get_query_var('monthnum')) {
136
+			$redirect_url = get_year_link(get_query_var('year'));
137
+			$redirect['query'] = _remove_qs_args_if_not_in_url($redirect['query'], array('year', 'monthnum'), $redirect_url);
138 138
 		}
139 139
 
140
-		if ( ! $redirect_url ) {
141
-			if ( $redirect_url = redirect_guess_404_permalink() ) {
142
-				$redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'page', 'feed', 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type' ), $redirect_url );
140
+		if ( ! $redirect_url) {
141
+			if ($redirect_url = redirect_guess_404_permalink()) {
142
+				$redirect['query'] = _remove_qs_args_if_not_in_url($redirect['query'], array('page', 'feed', 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type'), $redirect_url);
143 143
 			}
144 144
 		}
145 145
 
146
-		if ( get_query_var( 'page' ) && $wp_query->post &&
147
-			false !== strpos( $wp_query->post->post_content, '<!--nextpage-->' ) ) {
148
-			$redirect['path'] = rtrim( $redirect['path'], (int) get_query_var( 'page' ) . '/' );
149
-			$redirect['query'] = remove_query_arg( 'page', $redirect['query'] );
150
-			$redirect_url = get_permalink( $wp_query->post->ID );
146
+		if (get_query_var('page') && $wp_query->post &&
147
+			false !== strpos($wp_query->post->post_content, '<!--nextpage-->')) {
148
+			$redirect['path'] = rtrim($redirect['path'], (int) get_query_var('page').'/');
149
+			$redirect['query'] = remove_query_arg('page', $redirect['query']);
150
+			$redirect_url = get_permalink($wp_query->post->ID);
151 151
 		}
152 152
 
153
-	} elseif ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) {
153
+	} elseif (is_object($wp_rewrite) && $wp_rewrite->using_permalinks()) {
154 154
 		// rewriting of old ?p=X, ?m=2004, ?m=200401, ?m=20040101
155
-		if ( is_attachment() &&
156
-			! array_diff( array_keys( $wp->query_vars ), array( 'attachment', 'attachment_id' ) ) &&
157
-			! $redirect_url ) {
158
-			if ( ! empty( $_GET['attachment_id'] ) ) {
159
-				$redirect_url = get_attachment_link( get_query_var( 'attachment_id' ) );
160
-				if ( $redirect_url ) {
161
-					$redirect['query'] = remove_query_arg( 'attachment_id', $redirect['query'] );
155
+		if (is_attachment() &&
156
+			! array_diff(array_keys($wp->query_vars), array('attachment', 'attachment_id')) &&
157
+			! $redirect_url) {
158
+			if ( ! empty($_GET['attachment_id'])) {
159
+				$redirect_url = get_attachment_link(get_query_var('attachment_id'));
160
+				if ($redirect_url) {
161
+					$redirect['query'] = remove_query_arg('attachment_id', $redirect['query']);
162 162
 				}
163 163
 			} else {
164 164
 				$redirect_url = get_attachment_link();
165 165
 			}
166
-		} elseif ( is_single() && !empty($_GET['p']) && ! $redirect_url ) {
167
-			if ( $redirect_url = get_permalink(get_query_var('p')) )
166
+		} elseif (is_single() && ! empty($_GET['p']) && ! $redirect_url) {
167
+			if ($redirect_url = get_permalink(get_query_var('p')))
168 168
 				$redirect['query'] = remove_query_arg(array('p', 'post_type'), $redirect['query']);
169
-		} elseif ( is_single() && !empty($_GET['name'])  && ! $redirect_url ) {
170
-			if ( $redirect_url = get_permalink( $wp_query->get_queried_object_id() ) )
169
+		} elseif (is_single() && ! empty($_GET['name']) && ! $redirect_url) {
170
+			if ($redirect_url = get_permalink($wp_query->get_queried_object_id()))
171 171
 				$redirect['query'] = remove_query_arg('name', $redirect['query']);
172
-		} elseif ( is_page() && !empty($_GET['page_id']) && ! $redirect_url ) {
173
-			if ( $redirect_url = get_permalink(get_query_var('page_id')) )
172
+		} elseif (is_page() && ! empty($_GET['page_id']) && ! $redirect_url) {
173
+			if ($redirect_url = get_permalink(get_query_var('page_id')))
174 174
 				$redirect['query'] = remove_query_arg('page_id', $redirect['query']);
175
-		} elseif ( is_page() && !is_feed() && 'page' == get_option('show_on_front') && get_queried_object_id() == get_option('page_on_front')  && ! $redirect_url ) {
175
+		} elseif (is_page() && ! is_feed() && 'page' == get_option('show_on_front') && get_queried_object_id() == get_option('page_on_front') && ! $redirect_url) {
176 176
 			$redirect_url = home_url('/');
177
-		} elseif ( is_home() && !empty($_GET['page_id']) && 'page' == get_option('show_on_front') && get_query_var('page_id') == get_option('page_for_posts')  && ! $redirect_url ) {
178
-			if ( $redirect_url = get_permalink(get_option('page_for_posts')) )
177
+		} elseif (is_home() && ! empty($_GET['page_id']) && 'page' == get_option('show_on_front') && get_query_var('page_id') == get_option('page_for_posts') && ! $redirect_url) {
178
+			if ($redirect_url = get_permalink(get_option('page_for_posts')))
179 179
 				$redirect['query'] = remove_query_arg('page_id', $redirect['query']);
180
-		} elseif ( !empty($_GET['m']) && ( is_year() || is_month() || is_day() ) ) {
180
+		} elseif ( ! empty($_GET['m']) && (is_year() || is_month() || is_day())) {
181 181
 			$m = get_query_var('m');
182
-			switch ( strlen($m) ) {
182
+			switch (strlen($m)) {
183 183
 				case 4: // Yearly
184 184
 					$redirect_url = get_year_link($m);
185 185
 					break;
186 186
 				case 6: // Monthly
187
-					$redirect_url = get_month_link( substr($m, 0, 4), substr($m, 4, 2) );
187
+					$redirect_url = get_month_link(substr($m, 0, 4), substr($m, 4, 2));
188 188
 					break;
189 189
 				case 8: // Daily
190 190
 					$redirect_url = get_day_link(substr($m, 0, 4), substr($m, 4, 2), substr($m, 6, 2));
191 191
 					break;
192 192
 			}
193
-			if ( $redirect_url )
193
+			if ($redirect_url)
194 194
 				$redirect['query'] = remove_query_arg('m', $redirect['query']);
195 195
 		// now moving on to non ?m=X year/month/day links
196
-		} elseif ( is_day() && get_query_var('year') && get_query_var('monthnum') && !empty($_GET['day']) ) {
197
-			if ( $redirect_url = get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day')) )
196
+		} elseif (is_day() && get_query_var('year') && get_query_var('monthnum') && ! empty($_GET['day'])) {
197
+			if ($redirect_url = get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day')))
198 198
 				$redirect['query'] = remove_query_arg(array('year', 'monthnum', 'day'), $redirect['query']);
199
-		} elseif ( is_month() && get_query_var('year') && !empty($_GET['monthnum']) ) {
200
-			if ( $redirect_url = get_month_link(get_query_var('year'), get_query_var('monthnum')) )
199
+		} elseif (is_month() && get_query_var('year') && ! empty($_GET['monthnum'])) {
200
+			if ($redirect_url = get_month_link(get_query_var('year'), get_query_var('monthnum')))
201 201
 				$redirect['query'] = remove_query_arg(array('year', 'monthnum'), $redirect['query']);
202
-		} elseif ( is_year() && !empty($_GET['year']) ) {
203
-			if ( $redirect_url = get_year_link(get_query_var('year')) )
202
+		} elseif (is_year() && ! empty($_GET['year'])) {
203
+			if ($redirect_url = get_year_link(get_query_var('year')))
204 204
 				$redirect['query'] = remove_query_arg('year', $redirect['query']);
205
-		} elseif ( is_author() && !empty($_GET['author']) && preg_match( '|^[0-9]+$|', $_GET['author'] ) ) {
205
+		} elseif (is_author() && ! empty($_GET['author']) && preg_match('|^[0-9]+$|', $_GET['author'])) {
206 206
 			$author = get_userdata(get_query_var('author'));
207
-			if ( ( false !== $author ) && $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_author = %d AND $wpdb->posts.post_status = 'publish' LIMIT 1", $author->ID ) ) ) {
208
-				if ( $redirect_url = get_author_posts_url($author->ID, $author->user_nicename) )
207
+			if ((false !== $author) && $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_author = %d AND $wpdb->posts.post_status = 'publish' LIMIT 1", $author->ID))) {
208
+				if ($redirect_url = get_author_posts_url($author->ID, $author->user_nicename))
209 209
 					$redirect['query'] = remove_query_arg('author', $redirect['query']);
210 210
 			}
211
-		} elseif ( is_category() || is_tag() || is_tax() ) { // Terms (Tags/categories)
211
+		} elseif (is_category() || is_tag() || is_tax()) { // Terms (Tags/categories)
212 212
 
213 213
 			$term_count = 0;
214
-			foreach ( $wp_query->tax_query->queried_terms as $tax_query )
215
-				$term_count += count( $tax_query['terms'] );
214
+			foreach ($wp_query->tax_query->queried_terms as $tax_query)
215
+				$term_count += count($tax_query['terms']);
216 216
 
217 217
 			$obj = $wp_query->get_queried_object();
218
-			if ( $term_count <= 1 && !empty($obj->term_id) && ( $tax_url = get_term_link((int)$obj->term_id, $obj->taxonomy) ) && !is_wp_error($tax_url) ) {
219
-				if ( !empty($redirect['query']) ) {
218
+			if ($term_count <= 1 && ! empty($obj->term_id) && ($tax_url = get_term_link((int) $obj->term_id, $obj->taxonomy)) && ! is_wp_error($tax_url)) {
219
+				if ( ! empty($redirect['query'])) {
220 220
 					// Strip taxonomy query vars off the url.
221
-					$qv_remove = array( 'term', 'taxonomy');
222
-					if ( is_category() ) {
221
+					$qv_remove = array('term', 'taxonomy');
222
+					if (is_category()) {
223 223
 						$qv_remove[] = 'category_name';
224 224
 						$qv_remove[] = 'cat';
225
-					} elseif ( is_tag() ) {
225
+					} elseif (is_tag()) {
226 226
 						$qv_remove[] = 'tag';
227 227
 						$qv_remove[] = 'tag_id';
228 228
 					} else { // Custom taxonomies will have a custom query var, remove those too:
229
-						$tax_obj = get_taxonomy( $obj->taxonomy );
230
-						if ( false !== $tax_obj->query_var )
229
+						$tax_obj = get_taxonomy($obj->taxonomy);
230
+						if (false !== $tax_obj->query_var)
231 231
 							$qv_remove[] = $tax_obj->query_var;
232 232
 					}
233 233
 
234
-					$rewrite_vars = array_diff( array_keys($wp_query->query), array_keys($_GET) );
234
+					$rewrite_vars = array_diff(array_keys($wp_query->query), array_keys($_GET));
235 235
 
236
-					if ( !array_diff($rewrite_vars, array_keys($_GET))  ) { // Check to see if all the Query vars are coming from the rewrite, none are set via $_GET
236
+					if ( ! array_diff($rewrite_vars, array_keys($_GET))) { // Check to see if all the Query vars are coming from the rewrite, none are set via $_GET
237 237
 						$redirect['query'] = remove_query_arg($qv_remove, $redirect['query']); //Remove all of the per-tax qv's
238 238
 
239 239
 						// Create the destination url for this taxonomy
240 240
 						$tax_url = parse_url($tax_url);
241
-						if ( ! empty($tax_url['query']) ) { // Taxonomy accessible via ?taxonomy=..&term=.. or any custom qv..
241
+						if ( ! empty($tax_url['query'])) { // Taxonomy accessible via ?taxonomy=..&term=.. or any custom qv..
242 242
 							parse_str($tax_url['query'], $query_vars);
243 243
 							$redirect['query'] = add_query_arg($query_vars, $redirect['query']);
244 244
 						} else { // Taxonomy is accessible via a "pretty-URL"
@@ -246,41 +246,41 @@  discard block
 block discarded – undo
246 246
 						}
247 247
 
248 248
 					} else { // Some query vars are set via $_GET. Unset those from $_GET that exist via the rewrite
249
-						foreach ( $qv_remove as $_qv ) {
250
-							if ( isset($rewrite_vars[$_qv]) )
249
+						foreach ($qv_remove as $_qv) {
250
+							if (isset($rewrite_vars[$_qv]))
251 251
 								$redirect['query'] = remove_query_arg($_qv, $redirect['query']);
252 252
 						}
253 253
 					}
254 254
 				}
255 255
 
256 256
 			}
257
-		} elseif ( is_single() && strpos($wp_rewrite->permalink_structure, '%category%') !== false && $cat = get_query_var( 'category_name' ) ) {
258
-			$category = get_category_by_path( $cat );
259
-			$post_terms = get_the_terms( $wp_query->get_queried_object_id(), 'category' );
260
-			if ( ( ! $category || is_wp_error( $category ) ) || ( ! is_wp_error( $post_terms ) && ! empty( $post_terms ) && ! in_array( $category, $post_terms ) ) ) {
257
+		} elseif (is_single() && strpos($wp_rewrite->permalink_structure, '%category%') !== false && $cat = get_query_var('category_name')) {
258
+			$category = get_category_by_path($cat);
259
+			$post_terms = get_the_terms($wp_query->get_queried_object_id(), 'category');
260
+			if (( ! $category || is_wp_error($category)) || ( ! is_wp_error($post_terms) && ! empty($post_terms) && ! in_array($category, $post_terms))) {
261 261
 				$redirect_url = get_permalink($wp_query->get_queried_object_id());
262 262
 			}
263 263
 		}
264 264
 
265 265
 		// Post Paging
266
-		if ( is_singular() && get_query_var('page') ) {
267
-			if ( !$redirect_url )
268
-				$redirect_url = get_permalink( get_queried_object_id() );
269
-
270
-			$page = get_query_var( 'page' );
271
-			if ( $page > 1 ) {
272
-				if ( is_front_page() ) {
273
-					$redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( "$wp_rewrite->pagination_base/$page", 'paged' );
266
+		if (is_singular() && get_query_var('page')) {
267
+			if ( ! $redirect_url)
268
+				$redirect_url = get_permalink(get_queried_object_id());
269
+
270
+			$page = get_query_var('page');
271
+			if ($page > 1) {
272
+				if (is_front_page()) {
273
+					$redirect_url = trailingslashit($redirect_url).user_trailingslashit("$wp_rewrite->pagination_base/$page", 'paged');
274 274
 				} else {
275
-					$redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( $page, 'single_paged' );
275
+					$redirect_url = trailingslashit($redirect_url).user_trailingslashit($page, 'single_paged');
276 276
 				}
277 277
 			}
278
-			$redirect['query'] = remove_query_arg( 'page', $redirect['query'] );
278
+			$redirect['query'] = remove_query_arg('page', $redirect['query']);
279 279
 		}
280 280
 
281 281
 		// paging and feeds
282
-		if ( get_query_var('paged') || is_feed() || get_query_var('cpage') ) {
283
-			while ( preg_match( "#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", $redirect['path'] ) || preg_match( '#/(comments/?)?(feed|rss|rdf|atom|rss2)(/+)?$#', $redirect['path'] ) || preg_match( "#/{$wp_rewrite->comments_pagination_base}-[0-9]+(/+)?$#", $redirect['path'] ) ) {
282
+		if (get_query_var('paged') || is_feed() || get_query_var('cpage')) {
283
+			while (preg_match("#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", $redirect['path']) || preg_match('#/(comments/?)?(feed|rss|rdf|atom|rss2)(/+)?$#', $redirect['path']) || preg_match("#/{$wp_rewrite->comments_pagination_base}-[0-9]+(/+)?$#", $redirect['path'])) {
284 284
 				// Strip off paging and feed
285 285
 				$redirect['path'] = preg_replace("#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", '/', $redirect['path']); // strip off any existing paging
286 286
 				$redirect['path'] = preg_replace('#/(comments/?)?(feed|rss2?|rdf|atom)(/+|$)#', '/', $redirect['path']); // strip off feed endings
@@ -288,16 +288,16 @@  discard block
 block discarded – undo
288 288
 			}
289 289
 
290 290
 			$addl_path = '';
291
-			if ( is_feed() && in_array( get_query_var('feed'), $wp_rewrite->feeds ) ) {
292
-				$addl_path = !empty( $addl_path ) ? trailingslashit($addl_path) : '';
293
-				if ( !is_singular() && get_query_var( 'withcomments' ) )
291
+			if (is_feed() && in_array(get_query_var('feed'), $wp_rewrite->feeds)) {
292
+				$addl_path = ! empty($addl_path) ? trailingslashit($addl_path) : '';
293
+				if ( ! is_singular() && get_query_var('withcomments'))
294 294
 					$addl_path .= 'comments/';
295
-				if ( ( 'rss' == get_default_feed() && 'feed' == get_query_var('feed') ) || 'rss' == get_query_var('feed') )
296
-					$addl_path .= user_trailingslashit( 'feed/' . ( ( get_default_feed() == 'rss2' ) ? '' : 'rss2' ), 'feed' );
295
+				if (('rss' == get_default_feed() && 'feed' == get_query_var('feed')) || 'rss' == get_query_var('feed'))
296
+					$addl_path .= user_trailingslashit('feed/'.((get_default_feed() == 'rss2') ? '' : 'rss2'), 'feed');
297 297
 				else
298
-					$addl_path .= user_trailingslashit( 'feed/' . ( ( get_default_feed() ==  get_query_var('feed') || 'feed' == get_query_var('feed') ) ? '' : get_query_var('feed') ), 'feed' );
299
-				$redirect['query'] = remove_query_arg( 'feed', $redirect['query'] );
300
-			} elseif ( is_feed() && 'old' == get_query_var('feed') ) {
298
+					$addl_path .= user_trailingslashit('feed/'.((get_default_feed() == get_query_var('feed') || 'feed' == get_query_var('feed')) ? '' : get_query_var('feed')), 'feed');
299
+				$redirect['query'] = remove_query_arg('feed', $redirect['query']);
300
+			} elseif (is_feed() && 'old' == get_query_var('feed')) {
301 301
 				$old_feed_files = array(
302 302
 					'wp-atom.php'         => 'atom',
303 303
 					'wp-commentsrss2.php' => 'comments_rss2',
@@ -306,180 +306,180 @@  discard block
 block discarded – undo
306 306
 					'wp-rss.php'          => 'rss2',
307 307
 					'wp-rss2.php'         => 'rss2',
308 308
 				);
309
-				if ( isset( $old_feed_files[ basename( $redirect['path'] ) ] ) ) {
310
-					$redirect_url = get_feed_link( $old_feed_files[ basename( $redirect['path'] ) ] );
311
-					wp_redirect( $redirect_url, 301 );
309
+				if (isset($old_feed_files[basename($redirect['path'])])) {
310
+					$redirect_url = get_feed_link($old_feed_files[basename($redirect['path'])]);
311
+					wp_redirect($redirect_url, 301);
312 312
 					die();
313 313
 				}
314 314
 			}
315 315
 
316
-			if ( get_query_var('paged') > 0 ) {
316
+			if (get_query_var('paged') > 0) {
317 317
 				$paged = get_query_var('paged');
318
-				$redirect['query'] = remove_query_arg( 'paged', $redirect['query'] );
319
-				if ( !is_feed() ) {
320
-					if ( $paged > 1 && !is_single() ) {
321
-						$addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit("$wp_rewrite->pagination_base/$paged", 'paged');
322
-					} elseif ( !is_single() ) {
323
-						$addl_path = !empty( $addl_path ) ? trailingslashit($addl_path) : '';
318
+				$redirect['query'] = remove_query_arg('paged', $redirect['query']);
319
+				if ( ! is_feed()) {
320
+					if ($paged > 1 && ! is_single()) {
321
+						$addl_path = ( ! empty($addl_path) ? trailingslashit($addl_path) : '').user_trailingslashit("$wp_rewrite->pagination_base/$paged", 'paged');
322
+					} elseif ( ! is_single()) {
323
+						$addl_path = ! empty($addl_path) ? trailingslashit($addl_path) : '';
324 324
 					}
325
-				} elseif ( $paged > 1 ) {
326
-					$redirect['query'] = add_query_arg( 'paged', $paged, $redirect['query'] );
325
+				} elseif ($paged > 1) {
326
+					$redirect['query'] = add_query_arg('paged', $paged, $redirect['query']);
327 327
 				}
328 328
 			}
329 329
 
330
-			if ( get_option( 'page_comments' ) && (
331
-				( 'newest' == get_option( 'default_comments_page' ) && get_query_var( 'cpage' ) > 0 ) ||
332
-				( 'newest' != get_option( 'default_comments_page' ) && get_query_var( 'cpage' ) > 1 )
333
-			) ) {
334
-				$addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit( $wp_rewrite->comments_pagination_base . '-' . get_query_var('cpage'), 'commentpaged' );
335
-				$redirect['query'] = remove_query_arg( 'cpage', $redirect['query'] );
330
+			if (get_option('page_comments') && (
331
+				('newest' == get_option('default_comments_page') && get_query_var('cpage') > 0) ||
332
+				('newest' != get_option('default_comments_page') && get_query_var('cpage') > 1)
333
+			)) {
334
+				$addl_path = ( ! empty($addl_path) ? trailingslashit($addl_path) : '').user_trailingslashit($wp_rewrite->comments_pagination_base.'-'.get_query_var('cpage'), 'commentpaged');
335
+				$redirect['query'] = remove_query_arg('cpage', $redirect['query']);
336 336
 			}
337 337
 
338
-			$redirect['path'] = user_trailingslashit( preg_replace('|/' . preg_quote( $wp_rewrite->index, '|' ) . '/?$|', '/', $redirect['path']) ); // strip off trailing /index.php/
339
-			if ( !empty( $addl_path ) && $wp_rewrite->using_index_permalinks() && strpos($redirect['path'], '/' . $wp_rewrite->index . '/') === false )
340
-				$redirect['path'] = trailingslashit($redirect['path']) . $wp_rewrite->index . '/';
341
-			if ( !empty( $addl_path ) )
342
-				$redirect['path'] = trailingslashit($redirect['path']) . $addl_path;
343
-			$redirect_url = $redirect['scheme'] . '://' . $redirect['host'] . $redirect['path'];
338
+			$redirect['path'] = user_trailingslashit(preg_replace('|/'.preg_quote($wp_rewrite->index, '|').'/?$|', '/', $redirect['path'])); // strip off trailing /index.php/
339
+			if ( ! empty($addl_path) && $wp_rewrite->using_index_permalinks() && strpos($redirect['path'], '/'.$wp_rewrite->index.'/') === false)
340
+				$redirect['path'] = trailingslashit($redirect['path']).$wp_rewrite->index.'/';
341
+			if ( ! empty($addl_path))
342
+				$redirect['path'] = trailingslashit($redirect['path']).$addl_path;
343
+			$redirect_url = $redirect['scheme'].'://'.$redirect['host'].$redirect['path'];
344 344
 		}
345 345
 
346
-		if ( 'wp-register.php' == basename( $redirect['path'] ) ) {
347
-			if ( is_multisite() ) {
346
+		if ('wp-register.php' == basename($redirect['path'])) {
347
+			if (is_multisite()) {
348 348
 				/** This filter is documented in wp-login.php */
349
-				$redirect_url = apply_filters( 'wp_signup_location', network_site_url( 'wp-signup.php' ) );
349
+				$redirect_url = apply_filters('wp_signup_location', network_site_url('wp-signup.php'));
350 350
 			} else {
351 351
 				$redirect_url = wp_registration_url();
352 352
 			}
353 353
 
354
-			wp_redirect( $redirect_url, 301 );
354
+			wp_redirect($redirect_url, 301);
355 355
 			die();
356 356
 		}
357 357
 	}
358 358
 
359 359
 	// tack on any additional query vars
360
-	$redirect['query'] = preg_replace( '#^\??&*?#', '', $redirect['query'] );
361
-	if ( $redirect_url && !empty($redirect['query']) ) {
362
-		parse_str( $redirect['query'], $_parsed_query );
360
+	$redirect['query'] = preg_replace('#^\??&*?#', '', $redirect['query']);
361
+	if ($redirect_url && ! empty($redirect['query'])) {
362
+		parse_str($redirect['query'], $_parsed_query);
363 363
 		$redirect = @parse_url($redirect_url);
364 364
 
365
-		if ( ! empty( $_parsed_query['name'] ) && ! empty( $redirect['query'] ) ) {
366
-			parse_str( $redirect['query'], $_parsed_redirect_query );
365
+		if ( ! empty($_parsed_query['name']) && ! empty($redirect['query'])) {
366
+			parse_str($redirect['query'], $_parsed_redirect_query);
367 367
 
368
-			if ( empty( $_parsed_redirect_query['name'] ) )
369
-				unset( $_parsed_query['name'] );
368
+			if (empty($_parsed_redirect_query['name']))
369
+				unset($_parsed_query['name']);
370 370
 		}
371 371
 
372
-		$_parsed_query = rawurlencode_deep( $_parsed_query );
373
-		$redirect_url = add_query_arg( $_parsed_query, $redirect_url );
372
+		$_parsed_query = rawurlencode_deep($_parsed_query);
373
+		$redirect_url = add_query_arg($_parsed_query, $redirect_url);
374 374
 	}
375 375
 
376
-	if ( $redirect_url )
376
+	if ($redirect_url)
377 377
 		$redirect = @parse_url($redirect_url);
378 378
 
379 379
 	// www.example.com vs example.com
380 380
 	$user_home = @parse_url(home_url());
381
-	if ( !empty($user_home['host']) )
381
+	if ( ! empty($user_home['host']))
382 382
 		$redirect['host'] = $user_home['host'];
383
-	if ( empty($user_home['path']) )
383
+	if (empty($user_home['path']))
384 384
 		$user_home['path'] = '/';
385 385
 
386 386
 	// Handle ports
387
-	if ( !empty($user_home['port']) )
387
+	if ( ! empty($user_home['port']))
388 388
 		$redirect['port'] = $user_home['port'];
389 389
 	else
390 390
 		unset($redirect['port']);
391 391
 
392 392
 	// trailing /index.php
393
-	$redirect['path'] = preg_replace('|/' . preg_quote( $wp_rewrite->index, '|' ) . '/*?$|', '/', $redirect['path']);
393
+	$redirect['path'] = preg_replace('|/'.preg_quote($wp_rewrite->index, '|').'/*?$|', '/', $redirect['path']);
394 394
 
395 395
 	// Remove trailing spaces from the path
396
-	$redirect['path'] = preg_replace( '#(%20| )+$#', '', $redirect['path'] );
396
+	$redirect['path'] = preg_replace('#(%20| )+$#', '', $redirect['path']);
397 397
 
398
-	if ( !empty( $redirect['query'] ) ) {
398
+	if ( ! empty($redirect['query'])) {
399 399
 		// Remove trailing spaces from certain terminating query string args
400
-		$redirect['query'] = preg_replace( '#((p|page_id|cat|tag)=[^&]*?)(%20| )+$#', '$1', $redirect['query'] );
400
+		$redirect['query'] = preg_replace('#((p|page_id|cat|tag)=[^&]*?)(%20| )+$#', '$1', $redirect['query']);
401 401
 
402 402
 		// Clean up empty query strings
403
-		$redirect['query'] = trim(preg_replace( '#(^|&)(p|page_id|cat|tag)=?(&|$)#', '&', $redirect['query']), '&');
403
+		$redirect['query'] = trim(preg_replace('#(^|&)(p|page_id|cat|tag)=?(&|$)#', '&', $redirect['query']), '&');
404 404
 
405 405
 		// Redirect obsolete feeds
406
-		$redirect['query'] = preg_replace( '#(^|&)feed=rss(&|$)#', '$1feed=rss2$2', $redirect['query'] );
406
+		$redirect['query'] = preg_replace('#(^|&)feed=rss(&|$)#', '$1feed=rss2$2', $redirect['query']);
407 407
 
408 408
 		// Remove redundant leading ampersands
409
-		$redirect['query'] = preg_replace( '#^\??&*?#', '', $redirect['query'] );
409
+		$redirect['query'] = preg_replace('#^\??&*?#', '', $redirect['query']);
410 410
 	}
411 411
 
412 412
 	// strip /index.php/ when we're not using PATHINFO permalinks
413
-	if ( !$wp_rewrite->using_index_permalinks() )
414
-		$redirect['path'] = str_replace( '/' . $wp_rewrite->index . '/', '/', $redirect['path'] );
413
+	if ( ! $wp_rewrite->using_index_permalinks())
414
+		$redirect['path'] = str_replace('/'.$wp_rewrite->index.'/', '/', $redirect['path']);
415 415
 
416 416
 	// trailing slashes
417
-	if ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() && !is_404() && (!is_front_page() || ( is_front_page() && (get_query_var('paged') > 1) ) ) ) {
417
+	if (is_object($wp_rewrite) && $wp_rewrite->using_permalinks() && ! is_404() && ( ! is_front_page() || (is_front_page() && (get_query_var('paged') > 1)))) {
418 418
 		$user_ts_type = '';
419
-		if ( get_query_var('paged') > 0 ) {
419
+		if (get_query_var('paged') > 0) {
420 420
 			$user_ts_type = 'paged';
421 421
 		} else {
422
-			foreach ( array('single', 'category', 'page', 'day', 'month', 'year', 'home') as $type ) {
423
-				$func = 'is_' . $type;
424
-				if ( call_user_func($func) ) {
422
+			foreach (array('single', 'category', 'page', 'day', 'month', 'year', 'home') as $type) {
423
+				$func = 'is_'.$type;
424
+				if (call_user_func($func)) {
425 425
 					$user_ts_type = $type;
426 426
 					break;
427 427
 				}
428 428
 			}
429 429
 		}
430 430
 		$redirect['path'] = user_trailingslashit($redirect['path'], $user_ts_type);
431
-	} elseif ( is_front_page() ) {
431
+	} elseif (is_front_page()) {
432 432
 		$redirect['path'] = trailingslashit($redirect['path']);
433 433
 	}
434 434
 
435 435
 	// Strip multiple slashes out of the URL
436
-	if ( strpos($redirect['path'], '//') > -1 )
436
+	if (strpos($redirect['path'], '//') > -1)
437 437
 		$redirect['path'] = preg_replace('|/+|', '/', $redirect['path']);
438 438
 
439 439
 	// Always trailing slash the Front Page URL
440
-	if ( trailingslashit( $redirect['path'] ) == trailingslashit( $user_home['path'] ) )
440
+	if (trailingslashit($redirect['path']) == trailingslashit($user_home['path']))
441 441
 		$redirect['path'] = trailingslashit($redirect['path']);
442 442
 
443 443
 	// Ignore differences in host capitalization, as this can lead to infinite redirects
444 444
 	// Only redirect no-www <=> yes-www
445
-	if ( strtolower($original['host']) == strtolower($redirect['host']) ||
446
-		( strtolower($original['host']) != 'www.' . strtolower($redirect['host']) && 'www.' . strtolower($original['host']) != strtolower($redirect['host']) ) )
445
+	if (strtolower($original['host']) == strtolower($redirect['host']) ||
446
+		(strtolower($original['host']) != 'www.'.strtolower($redirect['host']) && 'www.'.strtolower($original['host']) != strtolower($redirect['host'])))
447 447
 		$redirect['host'] = $original['host'];
448 448
 
449
-	$compare_original = array( $original['host'], $original['path'] );
449
+	$compare_original = array($original['host'], $original['path']);
450 450
 
451
-	if ( !empty( $original['port'] ) )
451
+	if ( ! empty($original['port']))
452 452
 		$compare_original[] = $original['port'];
453 453
 
454
-	if ( !empty( $original['query'] ) )
454
+	if ( ! empty($original['query']))
455 455
 		$compare_original[] = $original['query'];
456 456
 
457
-	$compare_redirect = array( $redirect['host'], $redirect['path'] );
457
+	$compare_redirect = array($redirect['host'], $redirect['path']);
458 458
 
459
-	if ( !empty( $redirect['port'] ) )
459
+	if ( ! empty($redirect['port']))
460 460
 		$compare_redirect[] = $redirect['port'];
461 461
 
462
-	if ( !empty( $redirect['query'] ) )
462
+	if ( ! empty($redirect['query']))
463 463
 		$compare_redirect[] = $redirect['query'];
464 464
 
465
-	if ( $compare_original !== $compare_redirect ) {
466
-		$redirect_url = $redirect['scheme'] . '://' . $redirect['host'];
467
-		if ( !empty($redirect['port']) )
468
-			$redirect_url .= ':' . $redirect['port'];
465
+	if ($compare_original !== $compare_redirect) {
466
+		$redirect_url = $redirect['scheme'].'://'.$redirect['host'];
467
+		if ( ! empty($redirect['port']))
468
+			$redirect_url .= ':'.$redirect['port'];
469 469
 		$redirect_url .= $redirect['path'];
470
-		if ( !empty($redirect['query']) )
471
-			$redirect_url .= '?' . $redirect['query'];
470
+		if ( ! empty($redirect['query']))
471
+			$redirect_url .= '?'.$redirect['query'];
472 472
 	}
473 473
 
474
-	if ( ! $redirect_url || $redirect_url == $requested_url ) {
474
+	if ( ! $redirect_url || $redirect_url == $requested_url) {
475 475
 		return;
476 476
 	}
477 477
 
478 478
 	// Hex encoded octets are case-insensitive.
479
-	if ( false !== strpos($requested_url, '%') ) {
480
-		if ( !function_exists('lowercase_octets') ) {
479
+	if (false !== strpos($requested_url, '%')) {
480
+		if ( ! function_exists('lowercase_octets')) {
481 481
 			function lowercase_octets($matches) {
482
-				return strtolower( $matches[0] );
482
+				return strtolower($matches[0]);
483 483
 			}
484 484
 		}
485 485
 		$requested_url = preg_replace_callback('|%[a-fA-F0-9][a-fA-F0-9]|', 'lowercase_octets', $requested_url);
@@ -495,16 +495,16 @@  discard block
 block discarded – undo
495 495
 	 * @param string $redirect_url  The redirect URL.
496 496
 	 * @param string $requested_url The requested URL.
497 497
 	 */
498
-	$redirect_url = apply_filters( 'redirect_canonical', $redirect_url, $requested_url );
498
+	$redirect_url = apply_filters('redirect_canonical', $redirect_url, $requested_url);
499 499
 
500 500
 	// yes, again -- in case the filter aborted the request
501
-	if ( ! $redirect_url || strip_fragment_from_url( $redirect_url ) == strip_fragment_from_url( $requested_url ) ) {
501
+	if ( ! $redirect_url || strip_fragment_from_url($redirect_url) == strip_fragment_from_url($requested_url)) {
502 502
 		return;
503 503
 	}
504 504
 
505
-	if ( $do_redirect ) {
505
+	if ($do_redirect) {
506 506
 		// protect against chained redirects
507
-		if ( !redirect_canonical($redirect_url, false) ) {
507
+		if ( ! redirect_canonical($redirect_url, false)) {
508 508
 			wp_redirect($redirect_url, 301);
509 509
 			exit();
510 510
 		} else {
@@ -529,16 +529,16 @@  discard block
 block discarded – undo
529 529
  * @param string $url
530 530
  * @return string The altered query string
531 531
  */
532
-function _remove_qs_args_if_not_in_url( $query_string, Array $args_to_check, $url ) {
533
-	$parsed_url = @parse_url( $url );
534
-	if ( ! empty( $parsed_url['query'] ) ) {
535
-		parse_str( $parsed_url['query'], $parsed_query );
536
-		foreach ( $args_to_check as $qv ) {
537
-			if ( !isset( $parsed_query[$qv] ) )
538
-				$query_string = remove_query_arg( $qv, $query_string );
532
+function _remove_qs_args_if_not_in_url($query_string, Array $args_to_check, $url) {
533
+	$parsed_url = @parse_url($url);
534
+	if ( ! empty($parsed_url['query'])) {
535
+		parse_str($parsed_url['query'], $parsed_query);
536
+		foreach ($args_to_check as $qv) {
537
+			if ( ! isset($parsed_query[$qv]))
538
+				$query_string = remove_query_arg($qv, $query_string);
539 539
 		}
540 540
 	} else {
541
-		$query_string = remove_query_arg( $args_to_check, $query_string );
541
+		$query_string = remove_query_arg($args_to_check, $query_string);
542 542
 	}
543 543
 	return $query_string;
544 544
 }
@@ -551,17 +551,17 @@  discard block
 block discarded – undo
551 551
  * @param string $url The URL to strip.
552 552
  * @return string The altered URL.
553 553
  */
554
-function strip_fragment_from_url( $url ) {
555
-	$parsed_url = @parse_url( $url );
556
-	if ( ! empty( $parsed_url['host'] ) ) {
554
+function strip_fragment_from_url($url) {
555
+	$parsed_url = @parse_url($url);
556
+	if ( ! empty($parsed_url['host'])) {
557 557
 		// This mirrors code in redirect_canonical(). It does not handle every case.
558
-		$url = $parsed_url['scheme'] . '://' . $parsed_url['host'];
559
-		if ( ! empty( $parsed_url['port'] ) ) {
560
-			$url .= ':' . $parsed_url['port'];
558
+		$url = $parsed_url['scheme'].'://'.$parsed_url['host'];
559
+		if ( ! empty($parsed_url['port'])) {
560
+			$url .= ':'.$parsed_url['port'];
561 561
 		}
562 562
 		$url .= $parsed_url['path'];
563
-		if ( ! empty( $parsed_url['query'] ) ) {
564
-			$url .= '?' . $parsed_url['query'];
563
+		if ( ! empty($parsed_url['query'])) {
564
+			$url .= '?'.$parsed_url['query'];
565 565
 		}
566 566
 	}
567 567
 
@@ -580,31 +580,31 @@  discard block
 block discarded – undo
580 580
 function redirect_guess_404_permalink() {
581 581
 	global $wpdb;
582 582
 
583
-	if ( get_query_var('name') ) {
584
-		$where = $wpdb->prepare("post_name LIKE %s", $wpdb->esc_like( get_query_var('name') ) . '%');
583
+	if (get_query_var('name')) {
584
+		$where = $wpdb->prepare("post_name LIKE %s", $wpdb->esc_like(get_query_var('name')).'%');
585 585
 
586 586
 		// if any of post_type, year, monthnum, or day are set, use them to refine the query
587
-		if ( get_query_var('post_type') )
587
+		if (get_query_var('post_type'))
588 588
 			$where .= $wpdb->prepare(" AND post_type = %s", get_query_var('post_type'));
589 589
 		else
590
-			$where .= " AND post_type IN ('" . implode( "', '", get_post_types( array( 'public' => true ) ) ) . "')";
590
+			$where .= " AND post_type IN ('".implode("', '", get_post_types(array('public' => true)))."')";
591 591
 
592
-		if ( get_query_var('year') )
592
+		if (get_query_var('year'))
593 593
 			$where .= $wpdb->prepare(" AND YEAR(post_date) = %d", get_query_var('year'));
594
-		if ( get_query_var('monthnum') )
594
+		if (get_query_var('monthnum'))
595 595
 			$where .= $wpdb->prepare(" AND MONTH(post_date) = %d", get_query_var('monthnum'));
596
-		if ( get_query_var('day') )
596
+		if (get_query_var('day'))
597 597
 			$where .= $wpdb->prepare(" AND DAYOFMONTH(post_date) = %d", get_query_var('day'));
598 598
 
599 599
 		$post_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE $where AND post_status = 'publish'");
600
-		if ( ! $post_id )
600
+		if ( ! $post_id)
601 601
 			return false;
602
-		if ( get_query_var( 'feed' ) )
603
-			return get_post_comments_feed_link( $post_id, get_query_var( 'feed' ) );
604
-		elseif ( get_query_var( 'page' ) && 1 < get_query_var( 'page' ) )
605
-			return trailingslashit( get_permalink( $post_id ) ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' );
602
+		if (get_query_var('feed'))
603
+			return get_post_comments_feed_link($post_id, get_query_var('feed'));
604
+		elseif (get_query_var('page') && 1 < get_query_var('page'))
605
+			return trailingslashit(get_permalink($post_id)).user_trailingslashit(get_query_var('page'), 'single_paged');
606 606
 		else
607
-			return get_permalink( $post_id );
607
+			return get_permalink($post_id);
608 608
 	}
609 609
 
610 610
 	return false;
@@ -622,28 +622,28 @@  discard block
 block discarded – undo
622 622
  */
623 623
 function wp_redirect_admin_locations() {
624 624
 	global $wp_rewrite;
625
-	if ( ! ( is_404() && $wp_rewrite->using_permalinks() ) )
625
+	if ( ! (is_404() && $wp_rewrite->using_permalinks()))
626 626
 		return;
627 627
 
628 628
 	$admins = array(
629
-		home_url( 'wp-admin', 'relative' ),
630
-		home_url( 'dashboard', 'relative' ),
631
-		home_url( 'admin', 'relative' ),
632
-		site_url( 'dashboard', 'relative' ),
633
-		site_url( 'admin', 'relative' ),
629
+		home_url('wp-admin', 'relative'),
630
+		home_url('dashboard', 'relative'),
631
+		home_url('admin', 'relative'),
632
+		site_url('dashboard', 'relative'),
633
+		site_url('admin', 'relative'),
634 634
 	);
635
-	if ( in_array( untrailingslashit( $_SERVER['REQUEST_URI'] ), $admins ) ) {
636
-		wp_redirect( admin_url() );
635
+	if (in_array(untrailingslashit($_SERVER['REQUEST_URI']), $admins)) {
636
+		wp_redirect(admin_url());
637 637
 		exit;
638 638
 	}
639 639
 
640 640
 	$logins = array(
641
-		home_url( 'wp-login.php', 'relative' ),
642
-		home_url( 'login', 'relative' ),
643
-		site_url( 'login', 'relative' ),
641
+		home_url('wp-login.php', 'relative'),
642
+		home_url('login', 'relative'),
643
+		site_url('login', 'relative'),
644 644
 	);
645
-	if ( in_array( untrailingslashit( $_SERVER['REQUEST_URI'] ), $logins ) ) {
646
-		wp_redirect( wp_login_url() );
645
+	if (in_array(untrailingslashit($_SERVER['REQUEST_URI']), $logins)) {
646
+		wp_redirect(wp_login_url());
647 647
 		exit;
648 648
 	}
649 649
 }
Please login to merge, or discard this patch.
Braces   +143 added lines, -99 removed lines patch added patch discarded remove patch
@@ -75,10 +75,12 @@  discard block
 block discarded – undo
75 75
 	$redirect_url = false;
76 76
 
77 77
 	// Notice fixing
78
-	if ( !isset($redirect['path']) )
79
-		$redirect['path'] = '';
80
-	if ( !isset($redirect['query']) )
81
-		$redirect['query'] = '';
78
+	if ( !isset($redirect['path']) ) {
79
+			$redirect['path'] = '';
80
+	}
81
+	if ( !isset($redirect['query']) ) {
82
+			$redirect['query'] = '';
83
+	}
82 84
 
83 85
 	// If the original URL ended with non-breaking spaces, they were almost
84 86
 	// certainly inserted by accident. Let's remove them, so the reader doesn't
@@ -102,11 +104,13 @@  discard block
 block discarded – undo
102 104
 		$vars = $wpdb->get_results( $wpdb->prepare("SELECT post_type, post_parent FROM $wpdb->posts WHERE ID = %d", $id) );
103 105
 
104 106
 		if ( isset($vars[0]) && $vars = $vars[0] ) {
105
-			if ( 'revision' == $vars->post_type && $vars->post_parent > 0 )
106
-				$id = $vars->post_parent;
107
+			if ( 'revision' == $vars->post_type && $vars->post_parent > 0 ) {
108
+							$id = $vars->post_parent;
109
+			}
107 110
 
108
-			if ( $redirect_url = get_permalink($id) )
109
-				$redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type' ), $redirect_url );
111
+			if ( $redirect_url = get_permalink($id) ) {
112
+							$redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type' ), $redirect_url );
113
+			}
110 114
 		}
111 115
 	}
112 116
 
@@ -164,19 +168,23 @@  discard block
 block discarded – undo
164 168
 				$redirect_url = get_attachment_link();
165 169
 			}
166 170
 		} elseif ( is_single() && !empty($_GET['p']) && ! $redirect_url ) {
167
-			if ( $redirect_url = get_permalink(get_query_var('p')) )
168
-				$redirect['query'] = remove_query_arg(array('p', 'post_type'), $redirect['query']);
171
+			if ( $redirect_url = get_permalink(get_query_var('p')) ) {
172
+							$redirect['query'] = remove_query_arg(array('p', 'post_type'), $redirect['query']);
173
+			}
169 174
 		} elseif ( is_single() && !empty($_GET['name'])  && ! $redirect_url ) {
170
-			if ( $redirect_url = get_permalink( $wp_query->get_queried_object_id() ) )
171
-				$redirect['query'] = remove_query_arg('name', $redirect['query']);
175
+			if ( $redirect_url = get_permalink( $wp_query->get_queried_object_id() ) ) {
176
+							$redirect['query'] = remove_query_arg('name', $redirect['query']);
177
+			}
172 178
 		} elseif ( is_page() && !empty($_GET['page_id']) && ! $redirect_url ) {
173
-			if ( $redirect_url = get_permalink(get_query_var('page_id')) )
174
-				$redirect['query'] = remove_query_arg('page_id', $redirect['query']);
179
+			if ( $redirect_url = get_permalink(get_query_var('page_id')) ) {
180
+							$redirect['query'] = remove_query_arg('page_id', $redirect['query']);
181
+			}
175 182
 		} elseif ( is_page() && !is_feed() && 'page' == get_option('show_on_front') && get_queried_object_id() == get_option('page_on_front')  && ! $redirect_url ) {
176 183
 			$redirect_url = home_url('/');
177 184
 		} elseif ( is_home() && !empty($_GET['page_id']) && 'page' == get_option('show_on_front') && get_query_var('page_id') == get_option('page_for_posts')  && ! $redirect_url ) {
178
-			if ( $redirect_url = get_permalink(get_option('page_for_posts')) )
179
-				$redirect['query'] = remove_query_arg('page_id', $redirect['query']);
185
+			if ( $redirect_url = get_permalink(get_option('page_for_posts')) ) {
186
+							$redirect['query'] = remove_query_arg('page_id', $redirect['query']);
187
+			}
180 188
 		} elseif ( !empty($_GET['m']) && ( is_year() || is_month() || is_day() ) ) {
181 189
 			$m = get_query_var('m');
182 190
 			switch ( strlen($m) ) {
@@ -190,29 +198,35 @@  discard block
 block discarded – undo
190 198
 					$redirect_url = get_day_link(substr($m, 0, 4), substr($m, 4, 2), substr($m, 6, 2));
191 199
 					break;
192 200
 			}
193
-			if ( $redirect_url )
194
-				$redirect['query'] = remove_query_arg('m', $redirect['query']);
201
+			if ( $redirect_url ) {
202
+							$redirect['query'] = remove_query_arg('m', $redirect['query']);
203
+			}
195 204
 		// now moving on to non ?m=X year/month/day links
196 205
 		} elseif ( is_day() && get_query_var('year') && get_query_var('monthnum') && !empty($_GET['day']) ) {
197
-			if ( $redirect_url = get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day')) )
198
-				$redirect['query'] = remove_query_arg(array('year', 'monthnum', 'day'), $redirect['query']);
206
+			if ( $redirect_url = get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day')) ) {
207
+							$redirect['query'] = remove_query_arg(array('year', 'monthnum', 'day'), $redirect['query']);
208
+			}
199 209
 		} elseif ( is_month() && get_query_var('year') && !empty($_GET['monthnum']) ) {
200
-			if ( $redirect_url = get_month_link(get_query_var('year'), get_query_var('monthnum')) )
201
-				$redirect['query'] = remove_query_arg(array('year', 'monthnum'), $redirect['query']);
210
+			if ( $redirect_url = get_month_link(get_query_var('year'), get_query_var('monthnum')) ) {
211
+							$redirect['query'] = remove_query_arg(array('year', 'monthnum'), $redirect['query']);
212
+			}
202 213
 		} elseif ( is_year() && !empty($_GET['year']) ) {
203
-			if ( $redirect_url = get_year_link(get_query_var('year')) )
204
-				$redirect['query'] = remove_query_arg('year', $redirect['query']);
214
+			if ( $redirect_url = get_year_link(get_query_var('year')) ) {
215
+							$redirect['query'] = remove_query_arg('year', $redirect['query']);
216
+			}
205 217
 		} elseif ( is_author() && !empty($_GET['author']) && preg_match( '|^[0-9]+$|', $_GET['author'] ) ) {
206 218
 			$author = get_userdata(get_query_var('author'));
207 219
 			if ( ( false !== $author ) && $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_author = %d AND $wpdb->posts.post_status = 'publish' LIMIT 1", $author->ID ) ) ) {
208
-				if ( $redirect_url = get_author_posts_url($author->ID, $author->user_nicename) )
209
-					$redirect['query'] = remove_query_arg('author', $redirect['query']);
220
+				if ( $redirect_url = get_author_posts_url($author->ID, $author->user_nicename) ) {
221
+									$redirect['query'] = remove_query_arg('author', $redirect['query']);
222
+				}
210 223
 			}
211 224
 		} elseif ( is_category() || is_tag() || is_tax() ) { // Terms (Tags/categories)
212 225
 
213 226
 			$term_count = 0;
214
-			foreach ( $wp_query->tax_query->queried_terms as $tax_query )
215
-				$term_count += count( $tax_query['terms'] );
227
+			foreach ( $wp_query->tax_query->queried_terms as $tax_query ) {
228
+							$term_count += count( $tax_query['terms'] );
229
+			}
216 230
 
217 231
 			$obj = $wp_query->get_queried_object();
218 232
 			if ( $term_count <= 1 && !empty($obj->term_id) && ( $tax_url = get_term_link((int)$obj->term_id, $obj->taxonomy) ) && !is_wp_error($tax_url) ) {
@@ -227,8 +241,9 @@  discard block
 block discarded – undo
227 241
 						$qv_remove[] = 'tag_id';
228 242
 					} else { // Custom taxonomies will have a custom query var, remove those too:
229 243
 						$tax_obj = get_taxonomy( $obj->taxonomy );
230
-						if ( false !== $tax_obj->query_var )
231
-							$qv_remove[] = $tax_obj->query_var;
244
+						if ( false !== $tax_obj->query_var ) {
245
+													$qv_remove[] = $tax_obj->query_var;
246
+						}
232 247
 					}
233 248
 
234 249
 					$rewrite_vars = array_diff( array_keys($wp_query->query), array_keys($_GET) );
@@ -247,8 +262,9 @@  discard block
 block discarded – undo
247 262
 
248 263
 					} else { // Some query vars are set via $_GET. Unset those from $_GET that exist via the rewrite
249 264
 						foreach ( $qv_remove as $_qv ) {
250
-							if ( isset($rewrite_vars[$_qv]) )
251
-								$redirect['query'] = remove_query_arg($_qv, $redirect['query']);
265
+							if ( isset($rewrite_vars[$_qv]) ) {
266
+															$redirect['query'] = remove_query_arg($_qv, $redirect['query']);
267
+							}
252 268
 						}
253 269
 					}
254 270
 				}
@@ -264,8 +280,9 @@  discard block
 block discarded – undo
264 280
 
265 281
 		// Post Paging
266 282
 		if ( is_singular() && get_query_var('page') ) {
267
-			if ( !$redirect_url )
268
-				$redirect_url = get_permalink( get_queried_object_id() );
283
+			if ( !$redirect_url ) {
284
+							$redirect_url = get_permalink( get_queried_object_id() );
285
+			}
269 286
 
270 287
 			$page = get_query_var( 'page' );
271 288
 			if ( $page > 1 ) {
@@ -290,12 +307,14 @@  discard block
 block discarded – undo
290 307
 			$addl_path = '';
291 308
 			if ( is_feed() && in_array( get_query_var('feed'), $wp_rewrite->feeds ) ) {
292 309
 				$addl_path = !empty( $addl_path ) ? trailingslashit($addl_path) : '';
293
-				if ( !is_singular() && get_query_var( 'withcomments' ) )
294
-					$addl_path .= 'comments/';
295
-				if ( ( 'rss' == get_default_feed() && 'feed' == get_query_var('feed') ) || 'rss' == get_query_var('feed') )
296
-					$addl_path .= user_trailingslashit( 'feed/' . ( ( get_default_feed() == 'rss2' ) ? '' : 'rss2' ), 'feed' );
297
-				else
298
-					$addl_path .= user_trailingslashit( 'feed/' . ( ( get_default_feed() ==  get_query_var('feed') || 'feed' == get_query_var('feed') ) ? '' : get_query_var('feed') ), 'feed' );
310
+				if ( !is_singular() && get_query_var( 'withcomments' ) ) {
311
+									$addl_path .= 'comments/';
312
+				}
313
+				if ( ( 'rss' == get_default_feed() && 'feed' == get_query_var('feed') ) || 'rss' == get_query_var('feed') ) {
314
+									$addl_path .= user_trailingslashit( 'feed/' . ( ( get_default_feed() == 'rss2' ) ? '' : 'rss2' ), 'feed' );
315
+				} else {
316
+									$addl_path .= user_trailingslashit( 'feed/' . ( ( get_default_feed() ==  get_query_var('feed') || 'feed' == get_query_var('feed') ) ? '' : get_query_var('feed') ), 'feed' );
317
+				}
299 318
 				$redirect['query'] = remove_query_arg( 'feed', $redirect['query'] );
300 319
 			} elseif ( is_feed() && 'old' == get_query_var('feed') ) {
301 320
 				$old_feed_files = array(
@@ -336,10 +355,12 @@  discard block
 block discarded – undo
336 355
 			}
337 356
 
338 357
 			$redirect['path'] = user_trailingslashit( preg_replace('|/' . preg_quote( $wp_rewrite->index, '|' ) . '/?$|', '/', $redirect['path']) ); // strip off trailing /index.php/
339
-			if ( !empty( $addl_path ) && $wp_rewrite->using_index_permalinks() && strpos($redirect['path'], '/' . $wp_rewrite->index . '/') === false )
340
-				$redirect['path'] = trailingslashit($redirect['path']) . $wp_rewrite->index . '/';
341
-			if ( !empty( $addl_path ) )
342
-				$redirect['path'] = trailingslashit($redirect['path']) . $addl_path;
358
+			if ( !empty( $addl_path ) && $wp_rewrite->using_index_permalinks() && strpos($redirect['path'], '/' . $wp_rewrite->index . '/') === false ) {
359
+							$redirect['path'] = trailingslashit($redirect['path']) . $wp_rewrite->index . '/';
360
+			}
361
+			if ( !empty( $addl_path ) ) {
362
+							$redirect['path'] = trailingslashit($redirect['path']) . $addl_path;
363
+			}
343 364
 			$redirect_url = $redirect['scheme'] . '://' . $redirect['host'] . $redirect['path'];
344 365
 		}
345 366
 
@@ -365,29 +386,34 @@  discard block
 block discarded – undo
365 386
 		if ( ! empty( $_parsed_query['name'] ) && ! empty( $redirect['query'] ) ) {
366 387
 			parse_str( $redirect['query'], $_parsed_redirect_query );
367 388
 
368
-			if ( empty( $_parsed_redirect_query['name'] ) )
369
-				unset( $_parsed_query['name'] );
389
+			if ( empty( $_parsed_redirect_query['name'] ) ) {
390
+							unset( $_parsed_query['name'] );
391
+			}
370 392
 		}
371 393
 
372 394
 		$_parsed_query = rawurlencode_deep( $_parsed_query );
373 395
 		$redirect_url = add_query_arg( $_parsed_query, $redirect_url );
374 396
 	}
375 397
 
376
-	if ( $redirect_url )
377
-		$redirect = @parse_url($redirect_url);
398
+	if ( $redirect_url ) {
399
+			$redirect = @parse_url($redirect_url);
400
+	}
378 401
 
379 402
 	// www.example.com vs example.com
380 403
 	$user_home = @parse_url(home_url());
381
-	if ( !empty($user_home['host']) )
382
-		$redirect['host'] = $user_home['host'];
383
-	if ( empty($user_home['path']) )
384
-		$user_home['path'] = '/';
404
+	if ( !empty($user_home['host']) ) {
405
+			$redirect['host'] = $user_home['host'];
406
+	}
407
+	if ( empty($user_home['path']) ) {
408
+			$user_home['path'] = '/';
409
+	}
385 410
 
386 411
 	// Handle ports
387
-	if ( !empty($user_home['port']) )
388
-		$redirect['port'] = $user_home['port'];
389
-	else
390
-		unset($redirect['port']);
412
+	if ( !empty($user_home['port']) ) {
413
+			$redirect['port'] = $user_home['port'];
414
+	} else {
415
+			unset($redirect['port']);
416
+	}
391 417
 
392 418
 	// trailing /index.php
393 419
 	$redirect['path'] = preg_replace('|/' . preg_quote( $wp_rewrite->index, '|' ) . '/*?$|', '/', $redirect['path']);
@@ -410,8 +436,9 @@  discard block
 block discarded – undo
410 436
 	}
411 437
 
412 438
 	// strip /index.php/ when we're not using PATHINFO permalinks
413
-	if ( !$wp_rewrite->using_index_permalinks() )
414
-		$redirect['path'] = str_replace( '/' . $wp_rewrite->index . '/', '/', $redirect['path'] );
439
+	if ( !$wp_rewrite->using_index_permalinks() ) {
440
+			$redirect['path'] = str_replace( '/' . $wp_rewrite->index . '/', '/', $redirect['path'] );
441
+	}
415 442
 
416 443
 	// trailing slashes
417 444
 	if ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() && !is_404() && (!is_front_page() || ( is_front_page() && (get_query_var('paged') > 1) ) ) ) {
@@ -433,42 +460,51 @@  discard block
 block discarded – undo
433 460
 	}
434 461
 
435 462
 	// Strip multiple slashes out of the URL
436
-	if ( strpos($redirect['path'], '//') > -1 )
437
-		$redirect['path'] = preg_replace('|/+|', '/', $redirect['path']);
463
+	if ( strpos($redirect['path'], '//') > -1 ) {
464
+			$redirect['path'] = preg_replace('|/+|', '/', $redirect['path']);
465
+	}
438 466
 
439 467
 	// Always trailing slash the Front Page URL
440
-	if ( trailingslashit( $redirect['path'] ) == trailingslashit( $user_home['path'] ) )
441
-		$redirect['path'] = trailingslashit($redirect['path']);
468
+	if ( trailingslashit( $redirect['path'] ) == trailingslashit( $user_home['path'] ) ) {
469
+			$redirect['path'] = trailingslashit($redirect['path']);
470
+	}
442 471
 
443 472
 	// Ignore differences in host capitalization, as this can lead to infinite redirects
444 473
 	// Only redirect no-www <=> yes-www
445 474
 	if ( strtolower($original['host']) == strtolower($redirect['host']) ||
446
-		( strtolower($original['host']) != 'www.' . strtolower($redirect['host']) && 'www.' . strtolower($original['host']) != strtolower($redirect['host']) ) )
447
-		$redirect['host'] = $original['host'];
475
+		( strtolower($original['host']) != 'www.' . strtolower($redirect['host']) && 'www.' . strtolower($original['host']) != strtolower($redirect['host']) ) ) {
476
+			$redirect['host'] = $original['host'];
477
+	}
448 478
 
449 479
 	$compare_original = array( $original['host'], $original['path'] );
450 480
 
451
-	if ( !empty( $original['port'] ) )
452
-		$compare_original[] = $original['port'];
481
+	if ( !empty( $original['port'] ) ) {
482
+			$compare_original[] = $original['port'];
483
+	}
453 484
 
454
-	if ( !empty( $original['query'] ) )
455
-		$compare_original[] = $original['query'];
485
+	if ( !empty( $original['query'] ) ) {
486
+			$compare_original[] = $original['query'];
487
+	}
456 488
 
457 489
 	$compare_redirect = array( $redirect['host'], $redirect['path'] );
458 490
 
459
-	if ( !empty( $redirect['port'] ) )
460
-		$compare_redirect[] = $redirect['port'];
491
+	if ( !empty( $redirect['port'] ) ) {
492
+			$compare_redirect[] = $redirect['port'];
493
+	}
461 494
 
462
-	if ( !empty( $redirect['query'] ) )
463
-		$compare_redirect[] = $redirect['query'];
495
+	if ( !empty( $redirect['query'] ) ) {
496
+			$compare_redirect[] = $redirect['query'];
497
+	}
464 498
 
465 499
 	if ( $compare_original !== $compare_redirect ) {
466 500
 		$redirect_url = $redirect['scheme'] . '://' . $redirect['host'];
467
-		if ( !empty($redirect['port']) )
468
-			$redirect_url .= ':' . $redirect['port'];
501
+		if ( !empty($redirect['port']) ) {
502
+					$redirect_url .= ':' . $redirect['port'];
503
+		}
469 504
 		$redirect_url .= $redirect['path'];
470
-		if ( !empty($redirect['query']) )
471
-			$redirect_url .= '?' . $redirect['query'];
505
+		if ( !empty($redirect['query']) ) {
506
+					$redirect_url .= '?' . $redirect['query'];
507
+		}
472 508
 	}
473 509
 
474 510
 	if ( ! $redirect_url || $redirect_url == $requested_url ) {
@@ -534,8 +570,9 @@  discard block
 block discarded – undo
534 570
 	if ( ! empty( $parsed_url['query'] ) ) {
535 571
 		parse_str( $parsed_url['query'], $parsed_query );
536 572
 		foreach ( $args_to_check as $qv ) {
537
-			if ( !isset( $parsed_query[$qv] ) )
538
-				$query_string = remove_query_arg( $qv, $query_string );
573
+			if ( !isset( $parsed_query[$qv] ) ) {
574
+							$query_string = remove_query_arg( $qv, $query_string );
575
+			}
539 576
 		}
540 577
 	} else {
541 578
 		$query_string = remove_query_arg( $args_to_check, $query_string );
@@ -584,27 +621,33 @@  discard block
 block discarded – undo
584 621
 		$where = $wpdb->prepare("post_name LIKE %s", $wpdb->esc_like( get_query_var('name') ) . '%');
585 622
 
586 623
 		// if any of post_type, year, monthnum, or day are set, use them to refine the query
587
-		if ( get_query_var('post_type') )
588
-			$where .= $wpdb->prepare(" AND post_type = %s", get_query_var('post_type'));
589
-		else
590
-			$where .= " AND post_type IN ('" . implode( "', '", get_post_types( array( 'public' => true ) ) ) . "')";
591
-
592
-		if ( get_query_var('year') )
593
-			$where .= $wpdb->prepare(" AND YEAR(post_date) = %d", get_query_var('year'));
594
-		if ( get_query_var('monthnum') )
595
-			$where .= $wpdb->prepare(" AND MONTH(post_date) = %d", get_query_var('monthnum'));
596
-		if ( get_query_var('day') )
597
-			$where .= $wpdb->prepare(" AND DAYOFMONTH(post_date) = %d", get_query_var('day'));
624
+		if ( get_query_var('post_type') ) {
625
+					$where .= $wpdb->prepare(" AND post_type = %s", get_query_var('post_type'));
626
+		} else {
627
+					$where .= " AND post_type IN ('" . implode( "', '", get_post_types( array( 'public' => true ) ) ) . "')";
628
+		}
629
+
630
+		if ( get_query_var('year') ) {
631
+					$where .= $wpdb->prepare(" AND YEAR(post_date) = %d", get_query_var('year'));
632
+		}
633
+		if ( get_query_var('monthnum') ) {
634
+					$where .= $wpdb->prepare(" AND MONTH(post_date) = %d", get_query_var('monthnum'));
635
+		}
636
+		if ( get_query_var('day') ) {
637
+					$where .= $wpdb->prepare(" AND DAYOFMONTH(post_date) = %d", get_query_var('day'));
638
+		}
598 639
 
599 640
 		$post_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE $where AND post_status = 'publish'");
600
-		if ( ! $post_id )
601
-			return false;
602
-		if ( get_query_var( 'feed' ) )
603
-			return get_post_comments_feed_link( $post_id, get_query_var( 'feed' ) );
604
-		elseif ( get_query_var( 'page' ) && 1 < get_query_var( 'page' ) )
605
-			return trailingslashit( get_permalink( $post_id ) ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' );
606
-		else
607
-			return get_permalink( $post_id );
641
+		if ( ! $post_id ) {
642
+					return false;
643
+		}
644
+		if ( get_query_var( 'feed' ) ) {
645
+					return get_post_comments_feed_link( $post_id, get_query_var( 'feed' ) );
646
+		} elseif ( get_query_var( 'page' ) && 1 < get_query_var( 'page' ) ) {
647
+					return trailingslashit( get_permalink( $post_id ) ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' );
648
+		} else {
649
+					return get_permalink( $post_id );
650
+		}
608 651
 	}
609 652
 
610 653
 	return false;
@@ -622,8 +665,9 @@  discard block
 block discarded – undo
622 665
  */
623 666
 function wp_redirect_admin_locations() {
624 667
 	global $wp_rewrite;
625
-	if ( ! ( is_404() && $wp_rewrite->using_permalinks() ) )
626
-		return;
668
+	if ( ! ( is_404() && $wp_rewrite->using_permalinks() ) ) {
669
+			return;
670
+	}
627 671
 
628 672
 	$admins = array(
629 673
 		home_url( 'wp-admin', 'relative' ),
Please login to merge, or discard this patch.
src/wp-includes/category-template.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -686,7 +686,7 @@
 block discarded – undo
686 686
  * Default topic count scaling for tag links
687 687
  *
688 688
  * @param int $count number of posts with that tag
689
- * @return int scaled count
689
+ * @return double scaled count
690 690
  */
691 691
 function default_topic_count_scale( $count ) {
692 692
 	return round(log10($count + 1) * 100);
Please login to merge, or discard this patch.
Braces   +116 added lines, -83 removed lines patch added patch discarded remove patch
@@ -17,13 +17,15 @@  discard block
 block discarded – undo
17 17
  * @return string Link on success, empty string if category does not exist.
18 18
  */
19 19
 function get_category_link( $category ) {
20
-	if ( ! is_object( $category ) )
21
-		$category = (int) $category;
20
+	if ( ! is_object( $category ) ) {
21
+			$category = (int) $category;
22
+	}
22 23
 
23 24
 	$category = get_term_link( $category, 'category' );
24 25
 
25
-	if ( is_wp_error( $category ) )
26
-		return '';
26
+	if ( is_wp_error( $category ) ) {
27
+			return '';
28
+	}
27 29
 
28 30
 	return $category;
29 31
 }
@@ -43,23 +45,26 @@  discard block
 block discarded – undo
43 45
 function get_category_parents( $id, $link = false, $separator = '/', $nicename = false, $visited = array() ) {
44 46
 	$chain = '';
45 47
 	$parent = get_term( $id, 'category' );
46
-	if ( is_wp_error( $parent ) )
47
-		return $parent;
48
+	if ( is_wp_error( $parent ) ) {
49
+			return $parent;
50
+	}
48 51
 
49
-	if ( $nicename )
50
-		$name = $parent->slug;
51
-	else
52
-		$name = $parent->name;
52
+	if ( $nicename ) {
53
+			$name = $parent->slug;
54
+	} else {
55
+			$name = $parent->name;
56
+	}
53 57
 
54 58
 	if ( $parent->parent && ( $parent->parent != $parent->term_id ) && !in_array( $parent->parent, $visited ) ) {
55 59
 		$visited[] = $parent->parent;
56 60
 		$chain .= get_category_parents( $parent->parent, $link, $separator, $nicename, $visited );
57 61
 	}
58 62
 
59
-	if ( $link )
60
-		$chain .= '<a href="' . esc_url( get_category_link( $parent->term_id ) ) . '">'.$name.'</a>' . $separator;
61
-	else
62
-		$chain .= $name.$separator;
63
+	if ( $link ) {
64
+			$chain .= '<a href="' . esc_url( get_category_link( $parent->term_id ) ) . '">'.$name.'</a>' . $separator;
65
+	} else {
66
+			$chain .= $name.$separator;
67
+	}
63 68
 	return $chain;
64 69
 }
65 70
 
@@ -78,8 +83,9 @@  discard block
 block discarded – undo
78 83
  */
79 84
 function get_the_category( $id = false ) {
80 85
 	$categories = get_the_terms( $id, 'category' );
81
-	if ( ! $categories || is_wp_error( $categories ) )
82
-		$categories = array();
86
+	if ( ! $categories || is_wp_error( $categories ) ) {
87
+			$categories = array();
88
+	}
83 89
 
84 90
 	$categories = array_values( $categories );
85 91
 
@@ -130,13 +136,14 @@  discard block
 block discarded – undo
130 136
  * @return int
131 137
  */
132 138
 function _usort_terms_by_ID( $a, $b ) {
133
-	if ( $a->term_id > $b->term_id )
134
-		return 1;
135
-	elseif ( $a->term_id < $b->term_id )
136
-		return -1;
137
-	else
138
-		return 0;
139
-}
139
+	if ( $a->term_id > $b->term_id ) {
140
+			return 1;
141
+	} elseif ( $a->term_id < $b->term_id ) {
142
+			return -1;
143
+	} else {
144
+			return 0;
145
+	}
146
+	}
140 147
 
141 148
 /**
142 149
  * Retrieve category name based on category ID.
@@ -150,8 +157,9 @@  discard block
 block discarded – undo
150 157
 	$cat_ID = (int) $cat_ID;
151 158
 	$category = get_term( $cat_ID, 'category' );
152 159
 
153
-	if ( is_wp_error( $category ) )
154
-		return $category;
160
+	if ( is_wp_error( $category ) ) {
161
+			return $category;
162
+	}
155 163
 
156 164
 	return ( $category ) ? $category->name : '';
157 165
 }
@@ -200,14 +208,16 @@  discard block
 block discarded – undo
200 208
 			$thelist .= "\n\t<li>";
201 209
 			switch ( strtolower( $parents ) ) {
202 210
 				case 'multiple':
203
-					if ( $category->parent )
204
-						$thelist .= get_category_parents( $category->parent, true, $separator );
211
+					if ( $category->parent ) {
212
+											$thelist .= get_category_parents( $category->parent, true, $separator );
213
+					}
205 214
 					$thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>' . $category->name.'</a></li>';
206 215
 					break;
207 216
 				case 'single':
208 217
 					$thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '"  ' . $rel . '>';
209
-					if ( $category->parent )
210
-						$thelist .= get_category_parents( $category->parent, false, $separator );
218
+					if ( $category->parent ) {
219
+											$thelist .= get_category_parents( $category->parent, false, $separator );
220
+					}
211 221
 					$thelist .= $category->name.'</a></li>';
212 222
 					break;
213 223
 				case '':
@@ -219,18 +229,21 @@  discard block
 block discarded – undo
219 229
 	} else {
220 230
 		$i = 0;
221 231
 		foreach ( $categories as $category ) {
222
-			if ( 0 < $i )
223
-				$thelist .= $separator;
232
+			if ( 0 < $i ) {
233
+							$thelist .= $separator;
234
+			}
224 235
 			switch ( strtolower( $parents ) ) {
225 236
 				case 'multiple':
226
-					if ( $category->parent )
227
-						$thelist .= get_category_parents( $category->parent, true, $separator );
237
+					if ( $category->parent ) {
238
+											$thelist .= get_category_parents( $category->parent, true, $separator );
239
+					}
228 240
 					$thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>' . $category->name.'</a>';
229 241
 					break;
230 242
 				case 'single':
231 243
 					$thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>';
232
-					if ( $category->parent )
233
-						$thelist .= get_category_parents( $category->parent, false, $separator );
244
+					if ( $category->parent ) {
245
+											$thelist .= get_category_parents( $category->parent, false, $separator );
246
+					}
234 247
 					$thelist .= "$category->name</a>";
235 248
 					break;
236 249
 				case '':
@@ -273,8 +286,9 @@  discard block
 block discarded – undo
273 286
  * @return bool True if the current post is in any of the given categories.
274 287
  */
275 288
 function in_category( $category, $post = null ) {
276
-	if ( empty( $category ) )
277
-		return false;
289
+	if ( empty( $category ) ) {
290
+			return false;
291
+	}
278 292
 
279 293
 	return has_category( $category, $post );
280 294
 }
@@ -552,8 +566,9 @@  discard block
 block discarded – undo
552 566
 
553 567
 	$r = wp_parse_args( $args, $defaults );
554 568
 
555
-	if ( !isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] )
556
-		$r['pad_counts'] = true;
569
+	if ( !isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] ) {
570
+			$r['pad_counts'] = true;
571
+	}
557 572
 
558 573
 	// Descendants of exclusions should be excluded too.
559 574
 	if ( true == $r['hierarchical'] ) {
@@ -571,8 +586,9 @@  discard block
 block discarded – undo
571 586
 		$r['exclude'] = '';
572 587
 	}
573 588
 
574
-	if ( ! isset( $r['class'] ) )
575
-		$r['class'] = ( 'category' == $r['taxonomy'] ) ? 'categories' : $r['taxonomy'];
589
+	if ( ! isset( $r['class'] ) ) {
590
+			$r['class'] = ( 'category' == $r['taxonomy'] ) ? 'categories' : $r['taxonomy'];
591
+	}
576 592
 
577 593
 	if ( ! taxonomy_exists( $r['taxonomy'] ) ) {
578 594
 		return false;
@@ -646,8 +662,9 @@  discard block
 block discarded – undo
646 662
 		$output .= walk_category_tree( $categories, $depth, $r );
647 663
 	}
648 664
 
649
-	if ( $r['title_li'] && 'list' == $r['style'] )
650
-		$output .= '</ul></li>';
665
+	if ( $r['title_li'] && 'list' == $r['style'] ) {
666
+			$output .= '</ul></li>';
667
+	}
651 668
 
652 669
 	/**
653 670
 	 * Filter the HTML output of a taxonomy list.
@@ -711,16 +728,19 @@  discard block
 block discarded – undo
711 728
 
712 729
 	$tags = get_terms( $args['taxonomy'], array_merge( $args, array( 'orderby' => 'count', 'order' => 'DESC' ) ) ); // Always query top tags
713 730
 
714
-	if ( empty( $tags ) || is_wp_error( $tags ) )
715
-		return;
731
+	if ( empty( $tags ) || is_wp_error( $tags ) ) {
732
+			return;
733
+	}
716 734
 
717 735
 	foreach ( $tags as $key => $tag ) {
718
-		if ( 'edit' == $args['link'] )
719
-			$link = get_edit_term_link( $tag->term_id, $tag->taxonomy, $args['post_type'] );
720
-		else
721
-			$link = get_term_link( intval($tag->term_id), $tag->taxonomy );
722
-		if ( is_wp_error( $link ) )
723
-			return;
736
+		if ( 'edit' == $args['link'] ) {
737
+					$link = get_edit_term_link( $tag->term_id, $tag->taxonomy, $args['post_type'] );
738
+		} else {
739
+					$link = get_term_link( intval($tag->term_id), $tag->taxonomy );
740
+		}
741
+		if ( is_wp_error( $link ) ) {
742
+					return;
743
+		}
724 744
 
725 745
 		$tags[ $key ]->link = $link;
726 746
 		$tags[ $key ]->id = $tag->term_id;
@@ -738,8 +758,9 @@  discard block
 block discarded – undo
738 758
 	 */
739 759
 	$return = apply_filters( 'wp_tag_cloud', $return, $args );
740 760
 
741
-	if ( 'array' == $args['format'] || empty($args['echo']) )
742
-		return $return;
761
+	if ( 'array' == $args['format'] || empty($args['echo']) ) {
762
+			return $return;
763
+	}
743 764
 
744 765
 	echo $return;
745 766
 }
@@ -856,8 +877,9 @@  discard block
 block discarded – undo
856 877
 		}
857 878
 	}
858 879
 
859
-	if ( $args['number'] > 0 )
860
-		$tags = array_slice( $tags, 0, $args['number'] );
880
+	if ( $args['number'] > 0 ) {
881
+			$tags = array_slice( $tags, 0, $args['number'] );
882
+	}
861 883
 
862 884
 	$counts = array();
863 885
 	$real_counts = array(); // For the alt tag
@@ -868,11 +890,13 @@  discard block
 block discarded – undo
868 890
 
869 891
 	$min_count = min( $counts );
870 892
 	$spread = max( $counts ) - $min_count;
871
-	if ( $spread <= 0 )
872
-		$spread = 1;
893
+	if ( $spread <= 0 ) {
894
+			$spread = 1;
895
+	}
873 896
 	$font_spread = $args['largest'] - $args['smallest'];
874
-	if ( $font_spread < 0 )
875
-		$font_spread = 1;
897
+	if ( $font_spread < 0 ) {
898
+			$font_spread = 1;
899
+	}
876 900
 	$font_step = $font_spread / $spread;
877 901
 
878 902
 	// Assemble the data that will be used to generate the tag cloud markup.
@@ -950,11 +974,10 @@  discard block
 block discarded – undo
950 974
 		 * @param array        $args   An array of wp_generate_tag_cloud() arguments.
951 975
 		 */
952 976
 		return apply_filters( 'wp_generate_tag_cloud', $return, $tags, $args );
977
+	} else {
978
+			return $return;
979
+	}
953 980
 	}
954
-
955
-	else
956
-		return $return;
957
-}
958 981
 
959 982
 /**
960 983
  * Serves as a callback for comparing objects based on name.
@@ -1045,13 +1068,15 @@  discard block
 block discarded – undo
1045 1068
  * @return string Link on success, empty string if tag does not exist.
1046 1069
  */
1047 1070
 function get_tag_link( $tag ) {
1048
-	if ( ! is_object( $tag ) )
1049
-		$tag = (int) $tag;
1071
+	if ( ! is_object( $tag ) ) {
1072
+			$tag = (int) $tag;
1073
+	}
1050 1074
 
1051 1075
 	$tag = get_term_link( $tag, 'post_tag' );
1052 1076
 
1053
-	if ( is_wp_error( $tag ) )
1054
-		return '';
1077
+	if ( is_wp_error( $tag ) ) {
1078
+			return '';
1079
+	}
1055 1080
 
1056 1081
 	return $tag;
1057 1082
 }
@@ -1115,8 +1140,9 @@  discard block
 block discarded – undo
1115 1140
  * @param string $after Optional. After list.
1116 1141
  */
1117 1142
 function the_tags( $before = null, $sep = ', ', $after = '' ) {
1118
-	if ( null === $before )
1119
-		$before = __('Tags: ');
1143
+	if ( null === $before ) {
1144
+			$before = __('Tags: ');
1145
+	}
1120 1146
 	echo get_the_tag_list($before, $sep, $after);
1121 1147
 }
1122 1148
 
@@ -1164,8 +1190,9 @@  discard block
 block discarded – undo
1164 1190
  *                              or the post does not exist, WP_Error on failure.
1165 1191
  */
1166 1192
 function get_the_terms( $post, $taxonomy ) {
1167
-	if ( ! $post = get_post( $post ) )
1168
-		return false;
1193
+	if ( ! $post = get_post( $post ) ) {
1194
+			return false;
1195
+	}
1169 1196
 
1170 1197
 	$terms = get_object_term_cache( $post->ID, $taxonomy );
1171 1198
 	if ( false === $terms ) {
@@ -1194,8 +1221,9 @@  discard block
 block discarded – undo
1194 1221
 	 */
1195 1222
 	$terms = apply_filters( 'get_the_terms', $terms, $post->ID, $taxonomy );
1196 1223
 
1197
-	if ( empty( $terms ) )
1198
-		return false;
1224
+	if ( empty( $terms ) ) {
1225
+			return false;
1226
+	}
1199 1227
 
1200 1228
 	return $terms;
1201 1229
 }
@@ -1215,11 +1243,13 @@  discard block
 block discarded – undo
1215 1243
 function get_the_term_list( $id, $taxonomy, $before = '', $sep = '', $after = '' ) {
1216 1244
 	$terms = get_the_terms( $id, $taxonomy );
1217 1245
 
1218
-	if ( is_wp_error( $terms ) )
1219
-		return $terms;
1246
+	if ( is_wp_error( $terms ) ) {
1247
+			return $terms;
1248
+	}
1220 1249
 
1221
-	if ( empty( $terms ) )
1222
-		return false;
1250
+	if ( empty( $terms ) ) {
1251
+			return false;
1252
+	}
1223 1253
 
1224 1254
 	$links = array();
1225 1255
 
@@ -1261,8 +1291,9 @@  discard block
 block discarded – undo
1261 1291
 function the_terms( $id, $taxonomy, $before = '', $sep = ', ', $after = '' ) {
1262 1292
 	$term_list = get_the_term_list( $id, $taxonomy, $before, $sep, $after );
1263 1293
 
1264
-	if ( is_wp_error( $term_list ) )
1265
-		return false;
1294
+	if ( is_wp_error( $term_list ) ) {
1295
+			return false;
1296
+	}
1266 1297
 
1267 1298
 	/**
1268 1299
 	 * Filter the list of terms to display.
@@ -1329,12 +1360,14 @@  discard block
 block discarded – undo
1329 1360
 function has_term( $term = '', $taxonomy = '', $post = null ) {
1330 1361
 	$post = get_post($post);
1331 1362
 
1332
-	if ( !$post )
1333
-		return false;
1363
+	if ( !$post ) {
1364
+			return false;
1365
+	}
1334 1366
 
1335 1367
 	$r = is_object_in_term( $post->ID, $taxonomy, $term );
1336
-	if ( is_wp_error( $r ) )
1337
-		return false;
1368
+	if ( is_wp_error( $r ) ) {
1369
+			return false;
1370
+	}
1338 1371
 
1339 1372
 	return $r;
1340 1373
 }
Please login to merge, or discard this patch.
Spacing   +256 added lines, -256 removed lines patch added patch discarded remove patch
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
  * @param int|object $category Category ID or object.
17 17
  * @return string Link on success, empty string if category does not exist.
18 18
  */
19
-function get_category_link( $category ) {
20
-	if ( ! is_object( $category ) )
19
+function get_category_link($category) {
20
+	if ( ! is_object($category))
21 21
 		$category = (int) $category;
22 22
 
23
-	$category = get_term_link( $category, 'category' );
23
+	$category = get_term_link($category, 'category');
24 24
 
25
-	if ( is_wp_error( $category ) )
25
+	if (is_wp_error($category))
26 26
 		return '';
27 27
 
28 28
 	return $category;
@@ -40,24 +40,24 @@  discard block
 block discarded – undo
40 40
  * @param array $visited Optional. Already linked to categories to prevent duplicates.
41 41
  * @return string|WP_Error A list of category parents on success, WP_Error on failure.
42 42
  */
43
-function get_category_parents( $id, $link = false, $separator = '/', $nicename = false, $visited = array() ) {
43
+function get_category_parents($id, $link = false, $separator = '/', $nicename = false, $visited = array()) {
44 44
 	$chain = '';
45
-	$parent = get_term( $id, 'category' );
46
-	if ( is_wp_error( $parent ) )
45
+	$parent = get_term($id, 'category');
46
+	if (is_wp_error($parent))
47 47
 		return $parent;
48 48
 
49
-	if ( $nicename )
49
+	if ($nicename)
50 50
 		$name = $parent->slug;
51 51
 	else
52 52
 		$name = $parent->name;
53 53
 
54
-	if ( $parent->parent && ( $parent->parent != $parent->term_id ) && !in_array( $parent->parent, $visited ) ) {
54
+	if ($parent->parent && ($parent->parent != $parent->term_id) && ! in_array($parent->parent, $visited)) {
55 55
 		$visited[] = $parent->parent;
56
-		$chain .= get_category_parents( $parent->parent, $link, $separator, $nicename, $visited );
56
+		$chain .= get_category_parents($parent->parent, $link, $separator, $nicename, $visited);
57 57
 	}
58 58
 
59
-	if ( $link )
60
-		$chain .= '<a href="' . esc_url( get_category_link( $parent->term_id ) ) . '">'.$name.'</a>' . $separator;
59
+	if ($link)
60
+		$chain .= '<a href="'.esc_url(get_category_link($parent->term_id)).'">'.$name.'</a>'.$separator;
61 61
 	else
62 62
 		$chain .= $name.$separator;
63 63
 	return $chain;
@@ -76,15 +76,15 @@  discard block
 block discarded – undo
76 76
  * @param int $id Optional, default to current post ID. The post ID.
77 77
  * @return array Array of WP_Term objects, one for each category assigned to the post.
78 78
  */
79
-function get_the_category( $id = false ) {
80
-	$categories = get_the_terms( $id, 'category' );
81
-	if ( ! $categories || is_wp_error( $categories ) )
79
+function get_the_category($id = false) {
80
+	$categories = get_the_terms($id, 'category');
81
+	if ( ! $categories || is_wp_error($categories))
82 82
 		$categories = array();
83 83
 
84
-	$categories = array_values( $categories );
84
+	$categories = array_values($categories);
85 85
 
86
-	foreach ( array_keys( $categories ) as $key ) {
87
-		_make_cat_compat( $categories[$key] );
86
+	foreach (array_keys($categories) as $key) {
87
+		_make_cat_compat($categories[$key]);
88 88
 	}
89 89
 
90 90
 	/**
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 * @param array $categories An array of categories to return for the post.
97 97
 	 * @param int   $id         ID of the post.
98 98
 	 */
99
-	return apply_filters( 'get_the_categories', $categories, $id );
99
+	return apply_filters('get_the_categories', $categories, $id);
100 100
 }
101 101
 
102 102
 /**
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
  * @param object $b
113 113
  * @return int
114 114
  */
115
-function _usort_terms_by_name( $a, $b ) {
116
-	return strcmp( $a->name, $b->name );
115
+function _usort_terms_by_name($a, $b) {
116
+	return strcmp($a->name, $b->name);
117 117
 }
118 118
 
119 119
 /**
@@ -129,10 +129,10 @@  discard block
 block discarded – undo
129 129
  * @param object $b
130 130
  * @return int
131 131
  */
132
-function _usort_terms_by_ID( $a, $b ) {
133
-	if ( $a->term_id > $b->term_id )
132
+function _usort_terms_by_ID($a, $b) {
133
+	if ($a->term_id > $b->term_id)
134 134
 		return 1;
135
-	elseif ( $a->term_id < $b->term_id )
135
+	elseif ($a->term_id < $b->term_id)
136 136
 		return -1;
137 137
 	else
138 138
 		return 0;
@@ -146,14 +146,14 @@  discard block
 block discarded – undo
146 146
  * @param int $cat_ID Category ID.
147 147
  * @return string|WP_Error Category name on success, WP_Error on failure.
148 148
  */
149
-function get_the_category_by_ID( $cat_ID ) {
149
+function get_the_category_by_ID($cat_ID) {
150 150
 	$cat_ID = (int) $cat_ID;
151
-	$category = get_term( $cat_ID, 'category' );
151
+	$category = get_term($cat_ID, 'category');
152 152
 
153
-	if ( is_wp_error( $category ) )
153
+	if (is_wp_error($category))
154 154
 		return $category;
155 155
 
156
-	return ( $category ) ? $category->name : '';
156
+	return ($category) ? $category->name : '';
157 157
 }
158 158
 
159 159
 /**
@@ -168,11 +168,11 @@  discard block
 block discarded – undo
168 168
  * @param int $post_id Optional. Post ID to retrieve categories.
169 169
  * @return string
170 170
  */
171
-function get_the_category_list( $separator = '', $parents='', $post_id = false ) {
171
+function get_the_category_list($separator = '', $parents = '', $post_id = false) {
172 172
 	global $wp_rewrite;
173
-	if ( ! is_object_in_taxonomy( get_post_type( $post_id ), 'category' ) ) {
173
+	if ( ! is_object_in_taxonomy(get_post_type($post_id), 'category')) {
174 174
 		/** This filter is documented in wp-includes/category-template.php */
175
-		return apply_filters( 'the_category', '', $separator, $parents );
175
+		return apply_filters('the_category', '', $separator, $parents);
176 176
 	}
177 177
 
178 178
 	/**
@@ -184,58 +184,58 @@  discard block
 block discarded – undo
184 184
 	 * @param int|bool $post_id    ID of the post we're retrieving categories for. When `false`, we assume the
185 185
 	 *                             current post in the loop.
186 186
 	 */
187
-	$categories = apply_filters( 'the_category_list', get_the_category( $post_id ), $post_id );
187
+	$categories = apply_filters('the_category_list', get_the_category($post_id), $post_id);
188 188
 
189
-	if ( empty( $categories ) ) {
189
+	if (empty($categories)) {
190 190
 		/** This filter is documented in wp-includes/category-template.php */
191
-		return apply_filters( 'the_category', __( 'Uncategorized' ), $separator, $parents );
191
+		return apply_filters('the_category', __('Uncategorized'), $separator, $parents);
192 192
 	}
193 193
 
194
-	$rel = ( is_object( $wp_rewrite ) && $wp_rewrite->using_permalinks() ) ? 'rel="category tag"' : 'rel="category"';
194
+	$rel = (is_object($wp_rewrite) && $wp_rewrite->using_permalinks()) ? 'rel="category tag"' : 'rel="category"';
195 195
 
196 196
 	$thelist = '';
197
-	if ( '' == $separator ) {
197
+	if ('' == $separator) {
198 198
 		$thelist .= '<ul class="post-categories">';
199
-		foreach ( $categories as $category ) {
199
+		foreach ($categories as $category) {
200 200
 			$thelist .= "\n\t<li>";
201
-			switch ( strtolower( $parents ) ) {
201
+			switch (strtolower($parents)) {
202 202
 				case 'multiple':
203
-					if ( $category->parent )
204
-						$thelist .= get_category_parents( $category->parent, true, $separator );
205
-					$thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>' . $category->name.'</a></li>';
203
+					if ($category->parent)
204
+						$thelist .= get_category_parents($category->parent, true, $separator);
205
+					$thelist .= '<a href="'.esc_url(get_category_link($category->term_id)).'" '.$rel.'>'.$category->name.'</a></li>';
206 206
 					break;
207 207
 				case 'single':
208
-					$thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '"  ' . $rel . '>';
209
-					if ( $category->parent )
210
-						$thelist .= get_category_parents( $category->parent, false, $separator );
208
+					$thelist .= '<a href="'.esc_url(get_category_link($category->term_id)).'"  '.$rel.'>';
209
+					if ($category->parent)
210
+						$thelist .= get_category_parents($category->parent, false, $separator);
211 211
 					$thelist .= $category->name.'</a></li>';
212 212
 					break;
213 213
 				case '':
214 214
 				default:
215
-					$thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>' . $category->name.'</a></li>';
215
+					$thelist .= '<a href="'.esc_url(get_category_link($category->term_id)).'" '.$rel.'>'.$category->name.'</a></li>';
216 216
 			}
217 217
 		}
218 218
 		$thelist .= '</ul>';
219 219
 	} else {
220 220
 		$i = 0;
221
-		foreach ( $categories as $category ) {
222
-			if ( 0 < $i )
221
+		foreach ($categories as $category) {
222
+			if (0 < $i)
223 223
 				$thelist .= $separator;
224
-			switch ( strtolower( $parents ) ) {
224
+			switch (strtolower($parents)) {
225 225
 				case 'multiple':
226
-					if ( $category->parent )
227
-						$thelist .= get_category_parents( $category->parent, true, $separator );
228
-					$thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>' . $category->name.'</a>';
226
+					if ($category->parent)
227
+						$thelist .= get_category_parents($category->parent, true, $separator);
228
+					$thelist .= '<a href="'.esc_url(get_category_link($category->term_id)).'" '.$rel.'>'.$category->name.'</a>';
229 229
 					break;
230 230
 				case 'single':
231
-					$thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>';
232
-					if ( $category->parent )
233
-						$thelist .= get_category_parents( $category->parent, false, $separator );
231
+					$thelist .= '<a href="'.esc_url(get_category_link($category->term_id)).'" '.$rel.'>';
232
+					if ($category->parent)
233
+						$thelist .= get_category_parents($category->parent, false, $separator);
234 234
 					$thelist .= "$category->name</a>";
235 235
 					break;
236 236
 				case '':
237 237
 				default:
238
-					$thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>' . $category->name.'</a>';
238
+					$thelist .= '<a href="'.esc_url(get_category_link($category->term_id)).'" '.$rel.'>'.$category->name.'</a>';
239 239
 			}
240 240
 			++$i;
241 241
 		}
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 	 * @param string $parents   How to display the category parents. Accepts 'multiple',
252 252
 	 *                          'single', or empty.
253 253
 	 */
254
-	return apply_filters( 'the_category', $thelist, $separator, $parents );
254
+	return apply_filters('the_category', $thelist, $separator, $parents);
255 255
 }
256 256
 
257 257
 /**
@@ -272,11 +272,11 @@  discard block
 block discarded – undo
272 272
  * @param int|object $post Optional. Post to check instead of the current post. (since 2.7.0)
273 273
  * @return bool True if the current post is in any of the given categories.
274 274
  */
275
-function in_category( $category, $post = null ) {
276
-	if ( empty( $category ) )
275
+function in_category($category, $post = null) {
276
+	if (empty($category))
277 277
 		return false;
278 278
 
279
-	return has_category( $category, $post );
279
+	return has_category($category, $post);
280 280
 }
281 281
 
282 282
 /**
@@ -288,8 +288,8 @@  discard block
 block discarded – undo
288 288
  * @param string $parents Optional. How to display the parents.
289 289
  * @param int $post_id Optional. Post ID to retrieve categories.
290 290
  */
291
-function the_category( $separator = '', $parents='', $post_id = false ) {
292
-	echo get_the_category_list( $separator, $parents, $post_id );
291
+function the_category($separator = '', $parents = '', $post_id = false) {
292
+	echo get_the_category_list($separator, $parents, $post_id);
293 293
 }
294 294
 
295 295
 /**
@@ -300,8 +300,8 @@  discard block
 block discarded – undo
300 300
  * @param int $category Optional. Category ID. Will use global category ID by default.
301 301
  * @return string Category description, available.
302 302
  */
303
-function category_description( $category = 0 ) {
304
-	return term_description( $category, 'category' );
303
+function category_description($category = 0) {
304
+	return term_description($category, 'category');
305 305
 }
306 306
 
307 307
 /**
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
  * }
358 358
  * @return string HTML content only if 'echo' argument is 0.
359 359
  */
360
-function wp_dropdown_categories( $args = '' ) {
360
+function wp_dropdown_categories($args = '') {
361 361
 	$defaults = array(
362 362
 		'show_option_all'   => '',
363 363
 		'show_option_none'  => '',
@@ -382,13 +382,13 @@  discard block
 block discarded – undo
382 382
 		'required'          => false,
383 383
 	);
384 384
 
385
-	$defaults['selected'] = ( is_category() ) ? get_query_var( 'cat' ) : 0;
385
+	$defaults['selected'] = (is_category()) ? get_query_var('cat') : 0;
386 386
 
387 387
 	// Back compat.
388
-	if ( isset( $args['type'] ) && 'link' == $args['type'] ) {
388
+	if (isset($args['type']) && 'link' == $args['type']) {
389 389
 		/* translators: 1: "type => link", 2: "taxonomy => link_category" alternative */
390
-		_deprecated_argument( __FUNCTION__, '3.0',
391
-			sprintf( __( '%1$s is deprecated. Use %2$s instead.' ),
390
+		_deprecated_argument(__FUNCTION__, '3.0',
391
+			sprintf(__('%1$s is deprecated. Use %2$s instead.'),
392 392
 				'<code>type => link</code>',
393 393
 				'<code>taxonomy => link_category</code>'
394 394
 			)
@@ -396,36 +396,36 @@  discard block
 block discarded – undo
396 396
 		$args['taxonomy'] = 'link_category';
397 397
 	}
398 398
 
399
-	$r = wp_parse_args( $args, $defaults );
399
+	$r = wp_parse_args($args, $defaults);
400 400
 	$option_none_value = $r['option_none_value'];
401 401
 
402
-	if ( ! isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] ) {
402
+	if ( ! isset($r['pad_counts']) && $r['show_count'] && $r['hierarchical']) {
403 403
 		$r['pad_counts'] = true;
404 404
 	}
405 405
 
406 406
 	$tab_index = $r['tab_index'];
407 407
 
408 408
 	$tab_index_attribute = '';
409
-	if ( (int) $tab_index > 0 ) {
409
+	if ((int) $tab_index > 0) {
410 410
 		$tab_index_attribute = " tabindex=\"$tab_index\"";
411 411
 	}
412 412
 
413 413
 	// Avoid clashes with the 'name' param of get_terms().
414 414
 	$get_terms_args = $r;
415
-	unset( $get_terms_args['name'] );
416
-	$categories = get_terms( $r['taxonomy'], $get_terms_args );
415
+	unset($get_terms_args['name']);
416
+	$categories = get_terms($r['taxonomy'], $get_terms_args);
417 417
 
418
-	$name = esc_attr( $r['name'] );
419
-	$class = esc_attr( $r['class'] );
420
-	$id = $r['id'] ? esc_attr( $r['id'] ) : $name;
418
+	$name = esc_attr($r['name']);
419
+	$class = esc_attr($r['class']);
420
+	$id = $r['id'] ? esc_attr($r['id']) : $name;
421 421
 	$required = $r['required'] ? 'required' : '';
422 422
 
423
-	if ( ! $r['hide_if_empty'] || ! empty( $categories ) ) {
423
+	if ( ! $r['hide_if_empty'] || ! empty($categories)) {
424 424
 		$output = "<select $required name='$name' id='$id' class='$class' $tab_index_attribute>\n";
425 425
 	} else {
426 426
 		$output = '';
427 427
 	}
428
-	if ( empty( $categories ) && ! $r['hide_if_empty'] && ! empty( $r['show_option_none'] ) ) {
428
+	if (empty($categories) && ! $r['hide_if_empty'] && ! empty($r['show_option_none'])) {
429 429
 
430 430
 		/**
431 431
 		 * Filters a taxonomy drop-down display element.
@@ -441,37 +441,37 @@  discard block
 block discarded – undo
441 441
 		 *
442 442
 		 * @param string $element Taxonomy element to list.
443 443
 		 */
444
-		$show_option_none = apply_filters( 'list_cats', $r['show_option_none'] );
445
-		$output .= "\t<option value='" . esc_attr( $option_none_value ) . "' selected='selected'>$show_option_none</option>\n";
444
+		$show_option_none = apply_filters('list_cats', $r['show_option_none']);
445
+		$output .= "\t<option value='".esc_attr($option_none_value)."' selected='selected'>$show_option_none</option>\n";
446 446
 	}
447 447
 
448
-	if ( ! empty( $categories ) ) {
448
+	if ( ! empty($categories)) {
449 449
 
450
-		if ( $r['show_option_all'] ) {
450
+		if ($r['show_option_all']) {
451 451
 
452 452
 			/** This filter is documented in wp-includes/category-template.php */
453
-			$show_option_all = apply_filters( 'list_cats', $r['show_option_all'] );
454
-			$selected = ( '0' === strval($r['selected']) ) ? " selected='selected'" : '';
453
+			$show_option_all = apply_filters('list_cats', $r['show_option_all']);
454
+			$selected = ('0' === strval($r['selected'])) ? " selected='selected'" : '';
455 455
 			$output .= "\t<option value='0'$selected>$show_option_all</option>\n";
456 456
 		}
457 457
 
458
-		if ( $r['show_option_none'] ) {
458
+		if ($r['show_option_none']) {
459 459
 
460 460
 			/** This filter is documented in wp-includes/category-template.php */
461
-			$show_option_none = apply_filters( 'list_cats', $r['show_option_none'] );
462
-			$selected = selected( $option_none_value, $r['selected'], false );
463
-			$output .= "\t<option value='" . esc_attr( $option_none_value ) . "'$selected>$show_option_none</option>\n";
461
+			$show_option_none = apply_filters('list_cats', $r['show_option_none']);
462
+			$selected = selected($option_none_value, $r['selected'], false);
463
+			$output .= "\t<option value='".esc_attr($option_none_value)."'$selected>$show_option_none</option>\n";
464 464
 		}
465 465
 
466
-		if ( $r['hierarchical'] ) {
467
-			$depth = $r['depth'];  // Walk the full depth.
466
+		if ($r['hierarchical']) {
467
+			$depth = $r['depth']; // Walk the full depth.
468 468
 		} else {
469 469
 			$depth = -1; // Flat.
470 470
 		}
471
-		$output .= walk_category_dropdown_tree( $categories, $depth, $r );
471
+		$output .= walk_category_dropdown_tree($categories, $depth, $r);
472 472
 	}
473 473
 
474
-	if ( ! $r['hide_if_empty'] || ! empty( $categories ) ) {
474
+	if ( ! $r['hide_if_empty'] || ! empty($categories)) {
475 475
 		$output .= "</select>\n";
476 476
 	}
477 477
 	/**
@@ -482,9 +482,9 @@  discard block
 block discarded – undo
482 482
 	 * @param string $output HTML output.
483 483
 	 * @param array  $r      Arguments used to build the drop-down.
484 484
 	 */
485
-	$output = apply_filters( 'wp_dropdown_cats', $output, $r );
485
+	$output = apply_filters('wp_dropdown_cats', $output, $r);
486 486
 
487
-	if ( $r['echo'] ) {
487
+	if ($r['echo']) {
488 488
 		echo $output;
489 489
 	}
490 490
 	return $output;
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
  * }
542 542
  * @return false|string HTML content only if 'echo' argument is 0.
543 543
  */
544
-function wp_list_categories( $args = '' ) {
544
+function wp_list_categories($args = '') {
545 545
 	$defaults = array(
546 546
 		'child_of'            => 0,
547 547
 		'current_category'    => 0,
@@ -560,110 +560,110 @@  discard block
 block discarded – undo
560 560
 		'separator'           => '<br />',
561 561
 		'show_count'          => 0,
562 562
 		'show_option_all'     => '',
563
-		'show_option_none'    => __( 'No categories' ),
563
+		'show_option_none'    => __('No categories'),
564 564
 		'style'               => 'list',
565 565
 		'taxonomy'            => 'category',
566
-		'title_li'            => __( 'Categories' ),
566
+		'title_li'            => __('Categories'),
567 567
 		'use_desc_for_title'  => 1,
568 568
 	);
569 569
 
570
-	$r = wp_parse_args( $args, $defaults );
570
+	$r = wp_parse_args($args, $defaults);
571 571
 
572
-	if ( !isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] )
572
+	if ( ! isset($r['pad_counts']) && $r['show_count'] && $r['hierarchical'])
573 573
 		$r['pad_counts'] = true;
574 574
 
575 575
 	// Descendants of exclusions should be excluded too.
576
-	if ( true == $r['hierarchical'] ) {
576
+	if (true == $r['hierarchical']) {
577 577
 		$exclude_tree = array();
578 578
 
579
-		if ( $r['exclude_tree'] ) {
580
-			$exclude_tree = array_merge( $exclude_tree, wp_parse_id_list( $r['exclude_tree'] ) );
579
+		if ($r['exclude_tree']) {
580
+			$exclude_tree = array_merge($exclude_tree, wp_parse_id_list($r['exclude_tree']));
581 581
 		}
582 582
 
583
-		if ( $r['exclude'] ) {
584
-			$exclude_tree = array_merge( $exclude_tree, wp_parse_id_list( $r['exclude'] ) );
583
+		if ($r['exclude']) {
584
+			$exclude_tree = array_merge($exclude_tree, wp_parse_id_list($r['exclude']));
585 585
 		}
586 586
 
587 587
 		$r['exclude_tree'] = $exclude_tree;
588 588
 		$r['exclude'] = '';
589 589
 	}
590 590
 
591
-	if ( ! isset( $r['class'] ) )
592
-		$r['class'] = ( 'category' == $r['taxonomy'] ) ? 'categories' : $r['taxonomy'];
591
+	if ( ! isset($r['class']))
592
+		$r['class'] = ('category' == $r['taxonomy']) ? 'categories' : $r['taxonomy'];
593 593
 
594
-	if ( ! taxonomy_exists( $r['taxonomy'] ) ) {
594
+	if ( ! taxonomy_exists($r['taxonomy'])) {
595 595
 		return false;
596 596
 	}
597 597
 
598 598
 	$show_option_all = $r['show_option_all'];
599 599
 	$show_option_none = $r['show_option_none'];
600 600
 
601
-	$categories = get_categories( $r );
601
+	$categories = get_categories($r);
602 602
 
603 603
 	$output = '';
604
-	if ( $r['title_li'] && 'list' == $r['style'] && ( ! empty( $categories ) || ! $r['hide_title_if_empty'] ) ) {
605
-		$output = '<li class="' . esc_attr( $r['class'] ) . '">' . $r['title_li'] . '<ul>';
604
+	if ($r['title_li'] && 'list' == $r['style'] && ( ! empty($categories) || ! $r['hide_title_if_empty'])) {
605
+		$output = '<li class="'.esc_attr($r['class']).'">'.$r['title_li'].'<ul>';
606 606
 	}
607
-	if ( empty( $categories ) ) {
608
-		if ( ! empty( $show_option_none ) ) {
609
-			if ( 'list' == $r['style'] ) {
610
-				$output .= '<li class="cat-item-none">' . $show_option_none . '</li>';
607
+	if (empty($categories)) {
608
+		if ( ! empty($show_option_none)) {
609
+			if ('list' == $r['style']) {
610
+				$output .= '<li class="cat-item-none">'.$show_option_none.'</li>';
611 611
 			} else {
612 612
 				$output .= $show_option_none;
613 613
 			}
614 614
 		}
615 615
 	} else {
616
-		if ( ! empty( $show_option_all ) ) {
616
+		if ( ! empty($show_option_all)) {
617 617
 
618 618
 			$posts_page = '';
619 619
 
620 620
 			// For taxonomies that belong only to custom post types, point to a valid archive.
621
-			$taxonomy_object = get_taxonomy( $r['taxonomy'] );
622
-			if ( ! in_array( 'post', $taxonomy_object->object_type ) && ! in_array( 'page', $taxonomy_object->object_type ) ) {
623
-				foreach ( $taxonomy_object->object_type as $object_type ) {
624
-					$_object_type = get_post_type_object( $object_type );
621
+			$taxonomy_object = get_taxonomy($r['taxonomy']);
622
+			if ( ! in_array('post', $taxonomy_object->object_type) && ! in_array('page', $taxonomy_object->object_type)) {
623
+				foreach ($taxonomy_object->object_type as $object_type) {
624
+					$_object_type = get_post_type_object($object_type);
625 625
 
626 626
 					// Grab the first one.
627
-					if ( ! empty( $_object_type->has_archive ) ) {
628
-						$posts_page = get_post_type_archive_link( $object_type );
627
+					if ( ! empty($_object_type->has_archive)) {
628
+						$posts_page = get_post_type_archive_link($object_type);
629 629
 						break;
630 630
 					}
631 631
 				}
632 632
 			}
633 633
 
634 634
 			// Fallback for the 'All' link is the posts page.
635
-			if ( ! $posts_page ) {
636
-				if ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) ) {
637
-					$posts_page = get_permalink( get_option( 'page_for_posts' ) );
635
+			if ( ! $posts_page) {
636
+				if ('page' == get_option('show_on_front') && get_option('page_for_posts')) {
637
+					$posts_page = get_permalink(get_option('page_for_posts'));
638 638
 				} else {
639
-					$posts_page = home_url( '/' );
639
+					$posts_page = home_url('/');
640 640
 				}
641 641
 			}
642 642
 
643
-			$posts_page = esc_url( $posts_page );
644
-			if ( 'list' == $r['style'] ) {
643
+			$posts_page = esc_url($posts_page);
644
+			if ('list' == $r['style']) {
645 645
 				$output .= "<li class='cat-item-all'><a href='$posts_page'>$show_option_all</a></li>";
646 646
 			} else {
647 647
 				$output .= "<a href='$posts_page'>$show_option_all</a>";
648 648
 			}
649 649
 		}
650 650
 
651
-		if ( empty( $r['current_category'] ) && ( is_category() || is_tax() || is_tag() ) ) {
651
+		if (empty($r['current_category']) && (is_category() || is_tax() || is_tag())) {
652 652
 			$current_term_object = get_queried_object();
653
-			if ( $current_term_object && $r['taxonomy'] === $current_term_object->taxonomy ) {
653
+			if ($current_term_object && $r['taxonomy'] === $current_term_object->taxonomy) {
654 654
 				$r['current_category'] = get_queried_object_id();
655 655
 			}
656 656
 		}
657 657
 
658
-		if ( $r['hierarchical'] ) {
658
+		if ($r['hierarchical']) {
659 659
 			$depth = $r['depth'];
660 660
 		} else {
661 661
 			$depth = -1; // Flat.
662 662
 		}
663
-		$output .= walk_category_tree( $categories, $depth, $r );
663
+		$output .= walk_category_tree($categories, $depth, $r);
664 664
 	}
665 665
 
666
-	if ( $r['title_li'] && 'list' == $r['style'] )
666
+	if ($r['title_li'] && 'list' == $r['style'])
667 667
 		$output .= '</ul></li>';
668 668
 
669 669
 	/**
@@ -674,9 +674,9 @@  discard block
 block discarded – undo
674 674
 	 * @param string $output HTML output.
675 675
 	 * @param array  $args   An array of taxonomy-listing arguments.
676 676
 	 */
677
-	$html = apply_filters( 'wp_list_categories', $output, $args );
677
+	$html = apply_filters('wp_list_categories', $output, $args);
678 678
 
679
-	if ( $r['echo'] ) {
679
+	if ($r['echo']) {
680 680
 		echo $html;
681 681
 	} else {
682 682
 		return $html;
@@ -717,32 +717,32 @@  discard block
 block discarded – undo
717 717
  * @return void|array Generated tag cloud, only if no failures and 'array' is set for the 'format' argument.
718 718
  *                    Otherwise, this function outputs the tag cloud.
719 719
  */
720
-function wp_tag_cloud( $args = '' ) {
720
+function wp_tag_cloud($args = '') {
721 721
 	$defaults = array(
722 722
 		'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
723 723
 		'format' => 'flat', 'separator' => "\n", 'orderby' => 'name', 'order' => 'ASC',
724 724
 		'exclude' => '', 'include' => '', 'link' => 'view', 'taxonomy' => 'post_tag', 'post_type' => '', 'echo' => true
725 725
 	);
726
-	$args = wp_parse_args( $args, $defaults );
726
+	$args = wp_parse_args($args, $defaults);
727 727
 
728
-	$tags = get_terms( $args['taxonomy'], array_merge( $args, array( 'orderby' => 'count', 'order' => 'DESC' ) ) ); // Always query top tags
728
+	$tags = get_terms($args['taxonomy'], array_merge($args, array('orderby' => 'count', 'order' => 'DESC'))); // Always query top tags
729 729
 
730
-	if ( empty( $tags ) || is_wp_error( $tags ) )
730
+	if (empty($tags) || is_wp_error($tags))
731 731
 		return;
732 732
 
733
-	foreach ( $tags as $key => $tag ) {
734
-		if ( 'edit' == $args['link'] )
735
-			$link = get_edit_term_link( $tag->term_id, $tag->taxonomy, $args['post_type'] );
733
+	foreach ($tags as $key => $tag) {
734
+		if ('edit' == $args['link'])
735
+			$link = get_edit_term_link($tag->term_id, $tag->taxonomy, $args['post_type']);
736 736
 		else
737
-			$link = get_term_link( intval($tag->term_id), $tag->taxonomy );
738
-		if ( is_wp_error( $link ) )
737
+			$link = get_term_link(intval($tag->term_id), $tag->taxonomy);
738
+		if (is_wp_error($link))
739 739
 			return;
740 740
 
741
-		$tags[ $key ]->link = $link;
742
-		$tags[ $key ]->id = $tag->term_id;
741
+		$tags[$key]->link = $link;
742
+		$tags[$key]->id = $tag->term_id;
743 743
 	}
744 744
 
745
-	$return = wp_generate_tag_cloud( $tags, $args ); // Here's where those top tags get sorted according to $args
745
+	$return = wp_generate_tag_cloud($tags, $args); // Here's where those top tags get sorted according to $args
746 746
 
747 747
 	/**
748 748
 	 * Filters the tag cloud output.
@@ -752,9 +752,9 @@  discard block
 block discarded – undo
752 752
 	 * @param string $return HTML output of the tag cloud.
753 753
 	 * @param array  $args   An array of tag cloud arguments.
754 754
 	 */
755
-	$return = apply_filters( 'wp_tag_cloud', $return, $args );
755
+	$return = apply_filters('wp_tag_cloud', $return, $args);
756 756
 
757
-	if ( 'array' == $args['format'] || empty($args['echo']) )
757
+	if ('array' == $args['format'] || empty($args['echo']))
758 758
 		return $return;
759 759
 
760 760
 	echo $return;
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
  * @param int $count number of posts with that tag
767 767
  * @return int scaled count
768 768
  */
769
-function default_topic_count_scale( $count ) {
769
+function default_topic_count_scale($count) {
770 770
 	return round(log10($count + 1) * 100);
771 771
 }
772 772
 
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
  * }
814 814
  * @return string|array Tag cloud as a string or an array, depending on 'format' argument.
815 815
  */
816
-function wp_generate_tag_cloud( $tags, $args = '' ) {
816
+function wp_generate_tag_cloud($tags, $args = '') {
817 817
 	$defaults = array(
818 818
 		'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 0,
819 819
 		'format' => 'flat', 'separator' => "\n", 'orderby' => 'name', 'order' => 'ASC',
@@ -821,31 +821,31 @@  discard block
 block discarded – undo
821 821
 		'topic_count_scale_callback' => 'default_topic_count_scale', 'filter' => 1,
822 822
 	);
823 823
 
824
-	$args = wp_parse_args( $args, $defaults );
824
+	$args = wp_parse_args($args, $defaults);
825 825
 
826
-	$return = ( 'array' === $args['format'] ) ? array() : '';
826
+	$return = ('array' === $args['format']) ? array() : '';
827 827
 
828
-	if ( empty( $tags ) ) {
828
+	if (empty($tags)) {
829 829
 		return $return;
830 830
 	}
831 831
 
832 832
 	// Juggle topic count tooltips:
833
-	if ( isset( $args['topic_count_text'] ) ) {
833
+	if (isset($args['topic_count_text'])) {
834 834
 		// First look for nooped plural support via topic_count_text.
835 835
 		$translate_nooped_plural = $args['topic_count_text'];
836
-	} elseif ( ! empty( $args['topic_count_text_callback'] ) ) {
836
+	} elseif ( ! empty($args['topic_count_text_callback'])) {
837 837
 		// Look for the alternative callback style. Ignore the previous default.
838
-		if ( $args['topic_count_text_callback'] === 'default_topic_count_text' ) {
839
-			$translate_nooped_plural = _n_noop( '%s topic', '%s topics' );
838
+		if ($args['topic_count_text_callback'] === 'default_topic_count_text') {
839
+			$translate_nooped_plural = _n_noop('%s topic', '%s topics');
840 840
 		} else {
841 841
 			$translate_nooped_plural = false;
842 842
 		}
843
-	} elseif ( isset( $args['single_text'] ) && isset( $args['multiple_text'] ) ) {
843
+	} elseif (isset($args['single_text']) && isset($args['multiple_text'])) {
844 844
 		// If no callback exists, look for the old-style single_text and multiple_text arguments.
845
-		$translate_nooped_plural = _n_noop( $args['single_text'], $args['multiple_text'] );
845
+		$translate_nooped_plural = _n_noop($args['single_text'], $args['multiple_text']);
846 846
 	} else {
847 847
 		// This is the default for when no callback, plural, or argument is passed in.
848
-		$translate_nooped_plural = _n_noop( '%s topic', '%s topics' );
848
+		$translate_nooped_plural = _n_noop('%s topic', '%s topics');
849 849
 	}
850 850
 
851 851
 	/**
@@ -856,62 +856,62 @@  discard block
 block discarded – undo
856 856
 	 * @param array $tags Ordered array of terms.
857 857
 	 * @param array $args An array of tag cloud arguments.
858 858
 	 */
859
-	$tags_sorted = apply_filters( 'tag_cloud_sort', $tags, $args );
860
-	if ( empty( $tags_sorted ) ) {
859
+	$tags_sorted = apply_filters('tag_cloud_sort', $tags, $args);
860
+	if (empty($tags_sorted)) {
861 861
 		return $return;
862 862
 	}
863 863
 
864
-	if ( $tags_sorted !== $tags ) {
864
+	if ($tags_sorted !== $tags) {
865 865
 		$tags = $tags_sorted;
866
-		unset( $tags_sorted );
866
+		unset($tags_sorted);
867 867
 	} else {
868
-		if ( 'RAND' === $args['order'] ) {
869
-			shuffle( $tags );
868
+		if ('RAND' === $args['order']) {
869
+			shuffle($tags);
870 870
 		} else {
871 871
 			// SQL cannot save you; this is a second (potentially different) sort on a subset of data.
872
-			if ( 'name' === $args['orderby'] ) {
873
-				uasort( $tags, '_wp_object_name_sort_cb' );
872
+			if ('name' === $args['orderby']) {
873
+				uasort($tags, '_wp_object_name_sort_cb');
874 874
 			} else {
875
-				uasort( $tags, '_wp_object_count_sort_cb' );
875
+				uasort($tags, '_wp_object_count_sort_cb');
876 876
 			}
877 877
 
878
-			if ( 'DESC' === $args['order'] ) {
879
-				$tags = array_reverse( $tags, true );
878
+			if ('DESC' === $args['order']) {
879
+				$tags = array_reverse($tags, true);
880 880
 			}
881 881
 		}
882 882
 	}
883 883
 
884
-	if ( $args['number'] > 0 )
885
-		$tags = array_slice( $tags, 0, $args['number'] );
884
+	if ($args['number'] > 0)
885
+		$tags = array_slice($tags, 0, $args['number']);
886 886
 
887 887
 	$counts = array();
888 888
 	$real_counts = array(); // For the alt tag
889
-	foreach ( (array) $tags as $key => $tag ) {
890
-		$real_counts[ $key ] = $tag->count;
891
-		$counts[ $key ] = call_user_func( $args['topic_count_scale_callback'], $tag->count );
889
+	foreach ((array) $tags as $key => $tag) {
890
+		$real_counts[$key] = $tag->count;
891
+		$counts[$key] = call_user_func($args['topic_count_scale_callback'], $tag->count);
892 892
 	}
893 893
 
894
-	$min_count = min( $counts );
895
-	$spread = max( $counts ) - $min_count;
896
-	if ( $spread <= 0 )
894
+	$min_count = min($counts);
895
+	$spread = max($counts) - $min_count;
896
+	if ($spread <= 0)
897 897
 		$spread = 1;
898 898
 	$font_spread = $args['largest'] - $args['smallest'];
899
-	if ( $font_spread < 0 )
899
+	if ($font_spread < 0)
900 900
 		$font_spread = 1;
901 901
 	$font_step = $font_spread / $spread;
902 902
 
903 903
 	// Assemble the data that will be used to generate the tag cloud markup.
904 904
 	$tags_data = array();
905
-	foreach ( $tags as $key => $tag ) {
906
-		$tag_id = isset( $tag->id ) ? $tag->id : $key;
905
+	foreach ($tags as $key => $tag) {
906
+		$tag_id = isset($tag->id) ? $tag->id : $key;
907 907
 
908
-		$count = $counts[ $key ];
909
-		$real_count = $real_counts[ $key ];
908
+		$count = $counts[$key];
909
+		$real_count = $real_counts[$key];
910 910
 
911
-		if ( $translate_nooped_plural ) {
912
-			$title = sprintf( translate_nooped_plural( $translate_nooped_plural, $real_count ), number_format_i18n( $real_count ) );
911
+		if ($translate_nooped_plural) {
912
+			$title = sprintf(translate_nooped_plural($translate_nooped_plural, $real_count), number_format_i18n($real_count));
913 913
 		} else {
914
-			$title = call_user_func( $args['topic_count_text_callback'], $real_count, $tag, $args );
914
+			$title = call_user_func($args['topic_count_text_callback'], $real_count, $tag, $args);
915 915
 		}
916 916
 
917 917
 		$tags_data[] = array(
@@ -921,8 +921,8 @@  discard block
 block discarded – undo
921 921
 			'title'      => $title,
922 922
 			'slug'       => $tag->slug,
923 923
 			'real_count' => $real_count,
924
-			'class'	     => 'tag-link-' . $tag_id,
925
-			'font_size'  => $args['smallest'] + ( $count - $min_count ) * $font_step,
924
+			'class'	     => 'tag-link-'.$tag_id,
925
+			'font_size'  => $args['smallest'] + ($count - $min_count) * $font_step,
926 926
 		);
927 927
 	}
928 928
 
@@ -933,31 +933,31 @@  discard block
 block discarded – undo
933 933
 	 *
934 934
 	 * @param array $tags_data An array of term data for term used to generate the tag cloud.
935 935
 	 */
936
-	$tags_data = apply_filters( 'wp_generate_tag_cloud_data', $tags_data );
936
+	$tags_data = apply_filters('wp_generate_tag_cloud_data', $tags_data);
937 937
 
938 938
 	$a = array();
939 939
 
940 940
 	// generate the output links array
941
-	foreach ( $tags_data as $key => $tag_data ) {
942
-		$class = $tag_data['class'] . ' tag-link-position-' . ( $key + 1 );
943
-		$a[] = "<a href='" . esc_url( $tag_data['url'] ) . "' class='" . esc_attr( $class ) . "' title='" . esc_attr( $tag_data['title'] ) . "' style='font-size: " . esc_attr( str_replace( ',', '.', $tag_data['font_size'] ) . $args['unit'] ) . ";'>" . esc_html( $tag_data['name'] ) . "</a>";
941
+	foreach ($tags_data as $key => $tag_data) {
942
+		$class = $tag_data['class'].' tag-link-position-'.($key + 1);
943
+		$a[] = "<a href='".esc_url($tag_data['url'])."' class='".esc_attr($class)."' title='".esc_attr($tag_data['title'])."' style='font-size: ".esc_attr(str_replace(',', '.', $tag_data['font_size']).$args['unit']).";'>".esc_html($tag_data['name'])."</a>";
944 944
 	}
945 945
 
946
-	switch ( $args['format'] ) {
946
+	switch ($args['format']) {
947 947
 		case 'array' :
948
-			$return =& $a;
948
+			$return = & $a;
949 949
 			break;
950 950
 		case 'list' :
951 951
 			$return = "<ul class='wp-tag-cloud'>\n\t<li>";
952
-			$return .= join( "</li>\n\t<li>", $a );
952
+			$return .= join("</li>\n\t<li>", $a);
953 953
 			$return .= "</li>\n</ul>\n";
954 954
 			break;
955 955
 		default :
956
-			$return = join( $args['separator'], $a );
956
+			$return = join($args['separator'], $a);
957 957
 			break;
958 958
 	}
959 959
 
960
-	if ( $args['filter'] ) {
960
+	if ($args['filter']) {
961 961
 		/**
962 962
 		 * Filters the generated output of a tag cloud.
963 963
 		 *
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
 		 * @param array        $tags   An array of terms used in the tag cloud.
975 975
 		 * @param array        $args   An array of wp_generate_tag_cloud() arguments.
976 976
 		 */
977
-		return apply_filters( 'wp_generate_tag_cloud', $return, $tags, $args );
977
+		return apply_filters('wp_generate_tag_cloud', $return, $tags, $args);
978 978
 	}
979 979
 
980 980
 	else
@@ -994,8 +994,8 @@  discard block
 block discarded – undo
994 994
  * @return int Negative number if `$a->name` is less than `$b->name`, zero if they are equal,
995 995
  *             or greater than zero if `$a->name` is greater than `$b->name`.
996 996
  */
997
-function _wp_object_name_sort_cb( $a, $b ) {
998
-	return strnatcasecmp( $a->name, $b->name );
997
+function _wp_object_name_sort_cb($a, $b) {
998
+	return strnatcasecmp($a->name, $b->name);
999 999
 }
1000 1000
 
1001 1001
 /**
@@ -1010,8 +1010,8 @@  discard block
 block discarded – undo
1010 1010
  * @param object $b The second object to compare.
1011 1011
  * @return bool Whether the count value for `$a` is greater than the count value for `$b`.
1012 1012
  */
1013
-function _wp_object_count_sort_cb( $a, $b ) {
1014
-	return ( $a->count > $b->count );
1013
+function _wp_object_count_sort_cb($a, $b) {
1014
+	return ($a->count > $b->count);
1015 1015
 }
1016 1016
 
1017 1017
 //
@@ -1029,12 +1029,12 @@  discard block
 block discarded – undo
1029 1029
 function walk_category_tree() {
1030 1030
 	$args = func_get_args();
1031 1031
 	// the user's options are the third parameter
1032
-	if ( empty( $args[2]['walker'] ) || ! ( $args[2]['walker'] instanceof Walker ) ) {
1032
+	if (empty($args[2]['walker']) || ! ($args[2]['walker'] instanceof Walker)) {
1033 1033
 		$walker = new Walker_Category;
1034 1034
 	} else {
1035 1035
 		$walker = $args[2]['walker'];
1036 1036
 	}
1037
-	return call_user_func_array( array( $walker, 'walk' ), $args );
1037
+	return call_user_func_array(array($walker, 'walk'), $args);
1038 1038
 }
1039 1039
 
1040 1040
 /**
@@ -1048,12 +1048,12 @@  discard block
 block discarded – undo
1048 1048
 function walk_category_dropdown_tree() {
1049 1049
 	$args = func_get_args();
1050 1050
 	// the user's options are the third parameter
1051
-	if ( empty( $args[2]['walker'] ) || ! ( $args[2]['walker'] instanceof Walker ) ) {
1051
+	if (empty($args[2]['walker']) || ! ($args[2]['walker'] instanceof Walker)) {
1052 1052
 		$walker = new Walker_CategoryDropdown;
1053 1053
 	} else {
1054 1054
 		$walker = $args[2]['walker'];
1055 1055
 	}
1056
-	return call_user_func_array( array( $walker, 'walk' ), $args );
1056
+	return call_user_func_array(array($walker, 'walk'), $args);
1057 1057
 }
1058 1058
 
1059 1059
 //
@@ -1069,13 +1069,13 @@  discard block
 block discarded – undo
1069 1069
  * @param int|object $tag Tag ID or object.
1070 1070
  * @return string Link on success, empty string if tag does not exist.
1071 1071
  */
1072
-function get_tag_link( $tag ) {
1073
-	if ( ! is_object( $tag ) )
1072
+function get_tag_link($tag) {
1073
+	if ( ! is_object($tag))
1074 1074
 		$tag = (int) $tag;
1075 1075
 
1076
-	$tag = get_term_link( $tag, 'post_tag' );
1076
+	$tag = get_term_link($tag, 'post_tag');
1077 1077
 
1078
-	if ( is_wp_error( $tag ) )
1078
+	if (is_wp_error($tag))
1079 1079
 		return '';
1080 1080
 
1081 1081
 	return $tag;
@@ -1089,7 +1089,7 @@  discard block
 block discarded – undo
1089 1089
  * @param int $id Post ID.
1090 1090
  * @return array|false|WP_Error Array of tag objects on success, false on failure.
1091 1091
  */
1092
-function get_the_tags( $id = 0 ) {
1092
+function get_the_tags($id = 0) {
1093 1093
 
1094 1094
 	/**
1095 1095
 	 * Filters the array of tags for the given post.
@@ -1100,7 +1100,7 @@  discard block
 block discarded – undo
1100 1100
 	 *
1101 1101
 	 * @param array $terms An array of tags for the given post.
1102 1102
 	 */
1103
-	return apply_filters( 'get_the_tags', get_the_terms( $id, 'post_tag' ) );
1103
+	return apply_filters('get_the_tags', get_the_terms($id, 'post_tag'));
1104 1104
 }
1105 1105
 
1106 1106
 /**
@@ -1114,7 +1114,7 @@  discard block
 block discarded – undo
1114 1114
  * @param int $id Optional. Post ID. Defaults to the current post.
1115 1115
  * @return string|false|WP_Error A list of tags on success, false if there are no terms, WP_Error on failure.
1116 1116
  */
1117
-function get_the_tag_list( $before = '', $sep = '', $after = '', $id = 0 ) {
1117
+function get_the_tag_list($before = '', $sep = '', $after = '', $id = 0) {
1118 1118
 
1119 1119
 	/**
1120 1120
 	 * Filters the tags list for a given post.
@@ -1127,7 +1127,7 @@  discard block
 block discarded – undo
1127 1127
 	 * @param string $after    String to use after tags.
1128 1128
 	 * @param int    $id       Post ID.
1129 1129
 	 */
1130
-	return apply_filters( 'the_tags', get_the_term_list( $id, 'post_tag', $before, $sep, $after ), $before, $sep, $after, $id );
1130
+	return apply_filters('the_tags', get_the_term_list($id, 'post_tag', $before, $sep, $after), $before, $sep, $after, $id);
1131 1131
 }
1132 1132
 
1133 1133
 /**
@@ -1139,8 +1139,8 @@  discard block
 block discarded – undo
1139 1139
  * @param string $sep Optional. Separate items using this.
1140 1140
  * @param string $after Optional. After list.
1141 1141
  */
1142
-function the_tags( $before = null, $sep = ', ', $after = '' ) {
1143
-	if ( null === $before )
1142
+function the_tags($before = null, $sep = ', ', $after = '') {
1143
+	if (null === $before)
1144 1144
 		$before = __('Tags: ');
1145 1145
 	echo get_the_tag_list($before, $sep, $after);
1146 1146
 }
@@ -1153,8 +1153,8 @@  discard block
 block discarded – undo
1153 1153
  * @param int $tag Optional. Tag ID. Will use global tag ID by default.
1154 1154
  * @return string Tag description, available.
1155 1155
  */
1156
-function tag_description( $tag = 0 ) {
1157
-	return term_description( $tag );
1156
+function tag_description($tag = 0) {
1157
+	return term_description($tag);
1158 1158
 }
1159 1159
 
1160 1160
 /**
@@ -1166,16 +1166,16 @@  discard block
 block discarded – undo
1166 1166
  * @param string $taxonomy Optional taxonomy name. Defaults to 'post_tag'.
1167 1167
  * @return string Term description, available.
1168 1168
  */
1169
-function term_description( $term = 0, $taxonomy = 'post_tag' ) {
1170
-	if ( ! $term && ( is_tax() || is_tag() || is_category() ) ) {
1169
+function term_description($term = 0, $taxonomy = 'post_tag') {
1170
+	if ( ! $term && (is_tax() || is_tag() || is_category())) {
1171 1171
 		$term = get_queried_object();
1172
-		if ( $term ) {
1172
+		if ($term) {
1173 1173
 			$taxonomy = $term->taxonomy;
1174 1174
 			$term = $term->term_id;
1175 1175
 		}
1176 1176
 	}
1177
-	$description = get_term_field( 'description', $term, $taxonomy );
1178
-	return is_wp_error( $description ) ? '' : $description;
1177
+	$description = get_term_field('description', $term, $taxonomy);
1178
+	return is_wp_error($description) ? '' : $description;
1179 1179
 }
1180 1180
 
1181 1181
 /**
@@ -1188,16 +1188,16 @@  discard block
 block discarded – undo
1188 1188
  * @return array|false|WP_Error Array of WP_Term objects on success, false if there are no terms
1189 1189
  *                              or the post does not exist, WP_Error on failure.
1190 1190
  */
1191
-function get_the_terms( $post, $taxonomy ) {
1192
-	if ( ! $post = get_post( $post ) )
1191
+function get_the_terms($post, $taxonomy) {
1192
+	if ( ! $post = get_post($post))
1193 1193
 		return false;
1194 1194
 
1195
-	$terms = get_object_term_cache( $post->ID, $taxonomy );
1196
-	if ( false === $terms ) {
1197
-		$terms = wp_get_object_terms( $post->ID, $taxonomy );
1198
-		if ( ! is_wp_error( $terms ) ) {
1199
-			$term_ids = wp_list_pluck( $terms, 'term_id' );
1200
-			wp_cache_add( $post->ID, $term_ids, $taxonomy . '_relationships' );
1195
+	$terms = get_object_term_cache($post->ID, $taxonomy);
1196
+	if (false === $terms) {
1197
+		$terms = wp_get_object_terms($post->ID, $taxonomy);
1198
+		if ( ! is_wp_error($terms)) {
1199
+			$term_ids = wp_list_pluck($terms, 'term_id');
1200
+			wp_cache_add($post->ID, $term_ids, $taxonomy.'_relationships');
1201 1201
 		}
1202 1202
 	}
1203 1203
 
@@ -1210,9 +1210,9 @@  discard block
 block discarded – undo
1210 1210
 	 * @param int            $post_id  Post ID.
1211 1211
 	 * @param string         $taxonomy Name of the taxonomy.
1212 1212
 	 */
1213
-	$terms = apply_filters( 'get_the_terms', $terms, $post->ID, $taxonomy );
1213
+	$terms = apply_filters('get_the_terms', $terms, $post->ID, $taxonomy);
1214 1214
 
1215
-	if ( empty( $terms ) )
1215
+	if (empty($terms))
1216 1216
 		return false;
1217 1217
 
1218 1218
 	return $terms;
@@ -1230,23 +1230,23 @@  discard block
 block discarded – undo
1230 1230
  * @param string $after Optional. After list.
1231 1231
  * @return string|false|WP_Error A list of terms on success, false if there are no terms, WP_Error on failure.
1232 1232
  */
1233
-function get_the_term_list( $id, $taxonomy, $before = '', $sep = '', $after = '' ) {
1234
-	$terms = get_the_terms( $id, $taxonomy );
1233
+function get_the_term_list($id, $taxonomy, $before = '', $sep = '', $after = '') {
1234
+	$terms = get_the_terms($id, $taxonomy);
1235 1235
 
1236
-	if ( is_wp_error( $terms ) )
1236
+	if (is_wp_error($terms))
1237 1237
 		return $terms;
1238 1238
 
1239
-	if ( empty( $terms ) )
1239
+	if (empty($terms))
1240 1240
 		return false;
1241 1241
 
1242 1242
 	$links = array();
1243 1243
 
1244
-	foreach ( $terms as $term ) {
1245
-		$link = get_term_link( $term, $taxonomy );
1246
-		if ( is_wp_error( $link ) ) {
1244
+	foreach ($terms as $term) {
1245
+		$link = get_term_link($term, $taxonomy);
1246
+		if (is_wp_error($link)) {
1247 1247
 			return $link;
1248 1248
 		}
1249
-		$links[] = '<a href="' . esc_url( $link ) . '" rel="tag">' . $term->name . '</a>';
1249
+		$links[] = '<a href="'.esc_url($link).'" rel="tag">'.$term->name.'</a>';
1250 1250
 	}
1251 1251
 
1252 1252
 	/**
@@ -1259,9 +1259,9 @@  discard block
 block discarded – undo
1259 1259
 	 *
1260 1260
 	 * @param array $links An array of term links.
1261 1261
 	 */
1262
-	$term_links = apply_filters( "term_links-$taxonomy", $links );
1262
+	$term_links = apply_filters("term_links-$taxonomy", $links);
1263 1263
 
1264
-	return $before . join( $sep, $term_links ) . $after;
1264
+	return $before.join($sep, $term_links).$after;
1265 1265
 }
1266 1266
 
1267 1267
 /**
@@ -1276,10 +1276,10 @@  discard block
 block discarded – undo
1276 1276
  * @param string $after Optional. After list.
1277 1277
  * @return false|void False on WordPress error.
1278 1278
  */
1279
-function the_terms( $id, $taxonomy, $before = '', $sep = ', ', $after = '' ) {
1280
-	$term_list = get_the_term_list( $id, $taxonomy, $before, $sep, $after );
1279
+function the_terms($id, $taxonomy, $before = '', $sep = ', ', $after = '') {
1280
+	$term_list = get_the_term_list($id, $taxonomy, $before, $sep, $after);
1281 1281
 
1282
-	if ( is_wp_error( $term_list ) )
1282
+	if (is_wp_error($term_list))
1283 1283
 		return false;
1284 1284
 
1285 1285
 	/**
@@ -1293,7 +1293,7 @@  discard block
 block discarded – undo
1293 1293
 	 * @param string $sep       String to use between the terms.
1294 1294
 	 * @param string $after     String to use after the terms.
1295 1295
 	 */
1296
-	echo apply_filters( 'the_terms', $term_list, $taxonomy, $before, $sep, $after );
1296
+	echo apply_filters('the_terms', $term_list, $taxonomy, $before, $sep, $after);
1297 1297
 }
1298 1298
 
1299 1299
 /**
@@ -1305,8 +1305,8 @@  discard block
 block discarded – undo
1305 1305
  * @param int|object $post Optional. Post to check instead of the current post.
1306 1306
  * @return bool True if the current post has any of the given categories (or any category, if no category specified).
1307 1307
  */
1308
-function has_category( $category = '', $post = null ) {
1309
-	return has_term( $category, 'category', $post );
1308
+function has_category($category = '', $post = null) {
1309
+	return has_term($category, 'category', $post);
1310 1310
 }
1311 1311
 
1312 1312
 /**
@@ -1326,8 +1326,8 @@  discard block
 block discarded – undo
1326 1326
  * @param int|object $post Optional. Post to check instead of the current post. (since 2.7.0)
1327 1327
  * @return bool True if the current post has any of the given tags (or any tag, if no tag specified).
1328 1328
  */
1329
-function has_tag( $tag = '', $post = null ) {
1330
-	return has_term( $tag, 'post_tag', $post );
1329
+function has_tag($tag = '', $post = null) {
1330
+	return has_term($tag, 'post_tag', $post);
1331 1331
 }
1332 1332
 
1333 1333
 /**
@@ -1344,14 +1344,14 @@  discard block
 block discarded – undo
1344 1344
  * @param int|object $post Optional. Post to check instead of the current post.
1345 1345
  * @return bool True if the current post has any of the given tags (or any tag, if no tag specified).
1346 1346
  */
1347
-function has_term( $term = '', $taxonomy = '', $post = null ) {
1347
+function has_term($term = '', $taxonomy = '', $post = null) {
1348 1348
 	$post = get_post($post);
1349 1349
 
1350
-	if ( !$post )
1350
+	if ( ! $post)
1351 1351
 		return false;
1352 1352
 
1353
-	$r = is_object_in_term( $post->ID, $taxonomy, $term );
1354
-	if ( is_wp_error( $r ) )
1353
+	$r = is_object_in_term($post->ID, $taxonomy, $term);
1354
+	if (is_wp_error($r))
1355 1355
 		return false;
1356 1356
 
1357 1357
 	return $r;
Please login to merge, or discard this patch.
src/wp-includes/class-IXR.php 4 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -1048,6 +1048,12 @@
 block discarded – undo
1048 1048
 		self::__construct();
1049 1049
 	}
1050 1050
 
1051
+    /**
1052
+     * @param string $method
1053
+     * @param string $callback
1054
+     * @param string[] $args
1055
+     * @param string $help
1056
+     */
1051 1057
     function addCallback($method, $callback, $args, $help)
1052 1058
     {
1053 1059
         $this->callbacks[$method] = $callback;
Please login to merge, or discard this patch.
Braces   +10 added lines, -8 removed lines patch added patch discarded remove patch
@@ -534,17 +534,19 @@
 block discarded – undo
534 534
     function output($xml)
535 535
     {
536 536
         $charset = function_exists('get_option') ? get_option('blog_charset') : '';
537
-        if ($charset)
538
-            $xml = '<?xml version="1.0" encoding="'.$charset.'"?>'."\n".$xml;
539
-        else
540
-            $xml = '<?xml version="1.0"?>'."\n".$xml;
537
+        if ($charset) {
538
+                    $xml = '<?xml version="1.0" encoding="'.$charset.'"?>'."\n".$xml;
539
+        } else {
540
+                    $xml = '<?xml version="1.0"?>'."\n".$xml;
541
+        }
541 542
         $length = strlen($xml);
542 543
         header('Connection: close');
543 544
         header('Content-Length: '.$length);
544
-        if ($charset)
545
-            header('Content-Type: text/xml; charset='.$charset);
546
-        else
547
-            header('Content-Type: text/xml');
545
+        if ($charset) {
546
+                    header('Content-Type: text/xml; charset='.$charset);
547
+        } else {
548
+                    header('Content-Type: text/xml');
549
+        }
548 550
         header('Date: '.date('r'));
549 551
         echo $xml;
550 552
         exit;
Please login to merge, or discard this patch.
Indentation   +923 added lines, -923 removed lines patch added patch discarded remove patch
@@ -46,31 +46,31 @@  discard block
 block discarded – undo
46 46
  * @since 1.5.0
47 47
  */
48 48
 class IXR_Value {
49
-    var $data;
50
-    var $type;
49
+	var $data;
50
+	var $type;
51 51
 
52 52
 	/**
53 53
 	 * PHP5 constructor.
54 54
 	 */
55 55
 	function __construct( $data, $type = false )
56
-    {
57
-        $this->data = $data;
58
-        if (!$type) {
59
-            $type = $this->calculateType();
60
-        }
61
-        $this->type = $type;
62
-        if ($type == 'struct') {
63
-            // Turn all the values in the array in to new IXR_Value objects
64
-            foreach ($this->data as $key => $value) {
65
-                $this->data[$key] = new IXR_Value($value);
66
-            }
67
-        }
68
-        if ($type == 'array') {
69
-            for ($i = 0, $j = count($this->data); $i < $j; $i++) {
70
-                $this->data[$i] = new IXR_Value($this->data[$i]);
71
-            }
72
-        }
73
-    }
56
+	{
57
+		$this->data = $data;
58
+		if (!$type) {
59
+			$type = $this->calculateType();
60
+		}
61
+		$this->type = $type;
62
+		if ($type == 'struct') {
63
+			// Turn all the values in the array in to new IXR_Value objects
64
+			foreach ($this->data as $key => $value) {
65
+				$this->data[$key] = new IXR_Value($value);
66
+			}
67
+		}
68
+		if ($type == 'array') {
69
+			for ($i = 0, $j = count($this->data); $i < $j; $i++) {
70
+				$this->data[$i] = new IXR_Value($this->data[$i]);
71
+			}
72
+		}
73
+	}
74 74
 
75 75
 	/**
76 76
 	 * PHP4 constructor.
@@ -79,102 +79,102 @@  discard block
 block discarded – undo
79 79
 		self::__construct( $data, $type );
80 80
 	}
81 81
 
82
-    function calculateType()
83
-    {
84
-        if ($this->data === true || $this->data === false) {
85
-            return 'boolean';
86
-        }
87
-        if (is_integer($this->data)) {
88
-            return 'int';
89
-        }
90
-        if (is_double($this->data)) {
91
-            return 'double';
92
-        }
93
-
94
-        // Deal with IXR object types base64 and date
95
-        if (is_object($this->data) && is_a($this->data, 'IXR_Date')) {
96
-            return 'date';
97
-        }
98
-        if (is_object($this->data) && is_a($this->data, 'IXR_Base64')) {
99
-            return 'base64';
100
-        }
101
-
102
-        // If it is a normal PHP object convert it in to a struct
103
-        if (is_object($this->data)) {
104
-            $this->data = get_object_vars($this->data);
105
-            return 'struct';
106
-        }
107
-        if (!is_array($this->data)) {
108
-            return 'string';
109
-        }
110
-
111
-        // We have an array - is it an array or a struct?
112
-        if ($this->isStruct($this->data)) {
113
-            return 'struct';
114
-        } else {
115
-            return 'array';
116
-        }
117
-    }
118
-
119
-    function getXml()
120
-    {
121
-        // Return XML for this value
122
-        switch ($this->type) {
123
-            case 'boolean':
124
-                return '<boolean>'.(($this->data) ? '1' : '0').'</boolean>';
125
-                break;
126
-            case 'int':
127
-                return '<int>'.$this->data.'</int>';
128
-                break;
129
-            case 'double':
130
-                return '<double>'.$this->data.'</double>';
131
-                break;
132
-            case 'string':
133
-                return '<string>'.htmlspecialchars($this->data).'</string>';
134
-                break;
135
-            case 'array':
136
-                $return = '<array><data>'."\n";
137
-                foreach ($this->data as $item) {
138
-                    $return .= '  <value>'.$item->getXml()."</value>\n";
139
-                }
140
-                $return .= '</data></array>';
141
-                return $return;
142
-                break;
143
-            case 'struct':
144
-                $return = '<struct>'."\n";
145
-                foreach ($this->data as $name => $value) {
82
+	function calculateType()
83
+	{
84
+		if ($this->data === true || $this->data === false) {
85
+			return 'boolean';
86
+		}
87
+		if (is_integer($this->data)) {
88
+			return 'int';
89
+		}
90
+		if (is_double($this->data)) {
91
+			return 'double';
92
+		}
93
+
94
+		// Deal with IXR object types base64 and date
95
+		if (is_object($this->data) && is_a($this->data, 'IXR_Date')) {
96
+			return 'date';
97
+		}
98
+		if (is_object($this->data) && is_a($this->data, 'IXR_Base64')) {
99
+			return 'base64';
100
+		}
101
+
102
+		// If it is a normal PHP object convert it in to a struct
103
+		if (is_object($this->data)) {
104
+			$this->data = get_object_vars($this->data);
105
+			return 'struct';
106
+		}
107
+		if (!is_array($this->data)) {
108
+			return 'string';
109
+		}
110
+
111
+		// We have an array - is it an array or a struct?
112
+		if ($this->isStruct($this->data)) {
113
+			return 'struct';
114
+		} else {
115
+			return 'array';
116
+		}
117
+	}
118
+
119
+	function getXml()
120
+	{
121
+		// Return XML for this value
122
+		switch ($this->type) {
123
+			case 'boolean':
124
+				return '<boolean>'.(($this->data) ? '1' : '0').'</boolean>';
125
+				break;
126
+			case 'int':
127
+				return '<int>'.$this->data.'</int>';
128
+				break;
129
+			case 'double':
130
+				return '<double>'.$this->data.'</double>';
131
+				break;
132
+			case 'string':
133
+				return '<string>'.htmlspecialchars($this->data).'</string>';
134
+				break;
135
+			case 'array':
136
+				$return = '<array><data>'."\n";
137
+				foreach ($this->data as $item) {
138
+					$return .= '  <value>'.$item->getXml()."</value>\n";
139
+				}
140
+				$return .= '</data></array>';
141
+				return $return;
142
+				break;
143
+			case 'struct':
144
+				$return = '<struct>'."\n";
145
+				foreach ($this->data as $name => $value) {
146 146
 					$name = htmlspecialchars($name);
147
-                    $return .= "  <member><name>$name</name><value>";
148
-                    $return .= $value->getXml()."</value></member>\n";
149
-                }
150
-                $return .= '</struct>';
151
-                return $return;
152
-                break;
153
-            case 'date':
154
-            case 'base64':
155
-                return $this->data->getXml();
156
-                break;
157
-        }
158
-        return false;
159
-    }
160
-
161
-    /**
162
-     * Checks whether or not the supplied array is a struct or not
163
-     *
164
-     * @param array $array
165
-     * @return bool
166
-     */
167
-    function isStruct($array)
168
-    {
169
-        $expected = 0;
170
-        foreach ($array as $key => $value) {
171
-            if ((string)$key !== (string)$expected) {
172
-                return true;
173
-            }
174
-            $expected++;
175
-        }
176
-        return false;
177
-    }
147
+					$return .= "  <member><name>$name</name><value>";
148
+					$return .= $value->getXml()."</value></member>\n";
149
+				}
150
+				$return .= '</struct>';
151
+				return $return;
152
+				break;
153
+			case 'date':
154
+			case 'base64':
155
+				return $this->data->getXml();
156
+				break;
157
+		}
158
+		return false;
159
+	}
160
+
161
+	/**
162
+	 * Checks whether or not the supplied array is a struct or not
163
+	 *
164
+	 * @param array $array
165
+	 * @return bool
166
+	 */
167
+	function isStruct($array)
168
+	{
169
+		$expected = 0;
170
+		foreach ($array as $key => $value) {
171
+			if ((string)$key !== (string)$expected) {
172
+				return true;
173
+			}
174
+			$expected++;
175
+		}
176
+		return false;
177
+	}
178 178
 }
179 179
 
180 180
 /**
@@ -186,31 +186,31 @@  discard block
 block discarded – undo
186 186
  */
187 187
 class IXR_Message
188 188
 {
189
-    var $message;
190
-    var $messageType;  // methodCall / methodResponse / fault
191
-    var $faultCode;
192
-    var $faultString;
193
-    var $methodName;
194
-    var $params;
195
-
196
-    // Current variable stacks
197
-    var $_arraystructs = array();   // The stack used to keep track of the current array/struct
198
-    var $_arraystructstypes = array(); // Stack keeping track of if things are structs or array
199
-    var $_currentStructName = array();  // A stack as well
200
-    var $_param;
201
-    var $_value;
202
-    var $_currentTag;
203
-    var $_currentTagContents;
204
-    // The XML parser
205
-    var $_parser;
189
+	var $message;
190
+	var $messageType;  // methodCall / methodResponse / fault
191
+	var $faultCode;
192
+	var $faultString;
193
+	var $methodName;
194
+	var $params;
195
+
196
+	// Current variable stacks
197
+	var $_arraystructs = array();   // The stack used to keep track of the current array/struct
198
+	var $_arraystructstypes = array(); // Stack keeping track of if things are structs or array
199
+	var $_currentStructName = array();  // A stack as well
200
+	var $_param;
201
+	var $_value;
202
+	var $_currentTag;
203
+	var $_currentTagContents;
204
+	// The XML parser
205
+	var $_parser;
206 206
 
207 207
 	/**
208 208
 	 * PHP5 constructor.
209 209
 	 */
210
-    function __construct( $message )
211
-    {
212
-        $this->message =& $message;
213
-    }
210
+	function __construct( $message )
211
+	{
212
+		$this->message =& $message;
213
+	}
214 214
 
215 215
 	/**
216 216
 	 * PHP4 constructor.
@@ -219,190 +219,190 @@  discard block
 block discarded – undo
219 219
 		self::__construct( $message );
220 220
 	}
221 221
 
222
-    function parse()
223
-    {
224
-        // first remove the XML declaration
225
-        // merged from WP #10698 - this method avoids the RAM usage of preg_replace on very large messages
226
-        $header = preg_replace( '/<\?xml.*?\?'.'>/s', '', substr( $this->message, 0, 100 ), 1 );
227
-        $this->message = trim( substr_replace( $this->message, $header, 0, 100 ) );
228
-        if ( '' == $this->message ) {
229
-            return false;
230
-        }
231
-
232
-        // Then remove the DOCTYPE
233
-        $header = preg_replace( '/^<!DOCTYPE[^>]*+>/i', '', substr( $this->message, 0, 200 ), 1 );
234
-        $this->message = trim( substr_replace( $this->message, $header, 0, 200 ) );
235
-        if ( '' == $this->message ) {
236
-            return false;
237
-        }
238
-
239
-        // Check that the root tag is valid
240
-        $root_tag = substr( $this->message, 0, strcspn( substr( $this->message, 0, 20 ), "> \t\r\n" ) );
241
-        if ( '<!DOCTYPE' === strtoupper( $root_tag ) ) {
242
-            return false;
243
-        }
244
-        if ( ! in_array( $root_tag, array( '<methodCall', '<methodResponse', '<fault' ) ) ) {
245
-            return false;
246
-        }
247
-
248
-        // Bail if there are too many elements to parse
249
-        $element_limit = 30000;
250
-        if ( function_exists( 'apply_filters' ) ) {
251
-            /**
252
-             * Filters the number of elements to parse in an XML-RPC response.
253
-             *
254
-             * @since 4.0.0
255
-             *
256
-             * @param int $element_limit Default elements limit.
257
-             */
258
-            $element_limit = apply_filters( 'xmlrpc_element_limit', $element_limit );
259
-        }
260
-        if ( $element_limit && 2 * $element_limit < substr_count( $this->message, '<' ) ) {
261
-            return false;
262
-        }
263
-
264
-        $this->_parser = xml_parser_create();
265
-        // Set XML parser to take the case of tags in to account
266
-        xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, false);
267
-        // Set XML parser callback functions
268
-        xml_set_object($this->_parser, $this);
269
-        xml_set_element_handler($this->_parser, 'tag_open', 'tag_close');
270
-        xml_set_character_data_handler($this->_parser, 'cdata');
271
-
272
-        // 256Kb, parse in chunks to avoid the RAM usage on very large messages
273
-        $chunk_size = 262144;
274
-
275
-        /**
276
-         * Filters the chunk size that can be used to parse an XML-RPC reponse message.
277
-         *
278
-         * @since 4.4.0
279
-         *
280
-         * @param int $chunk_size Chunk size to parse in bytes.
281
-         */
282
-        $chunk_size = apply_filters( 'xmlrpc_chunk_parsing_size', $chunk_size );
283
-
284
-        $final = false;
285
-        do {
286
-            if (strlen($this->message) <= $chunk_size) {
287
-                $final = true;
288
-            }
289
-            $part = substr($this->message, 0, $chunk_size);
290
-            $this->message = substr($this->message, $chunk_size);
291
-            if (!xml_parse($this->_parser, $part, $final)) {
292
-                return false;
293
-            }
294
-            if ($final) {
295
-                break;
296
-            }
297
-        } while (true);
298
-        xml_parser_free($this->_parser);
299
-
300
-        // Grab the error messages, if any
301
-        if ($this->messageType == 'fault') {
302
-            $this->faultCode = $this->params[0]['faultCode'];
303
-            $this->faultString = $this->params[0]['faultString'];
304
-        }
305
-        return true;
306
-    }
307
-
308
-    function tag_open($parser, $tag, $attr)
309
-    {
310
-        $this->_currentTagContents = '';
311
-        $this->currentTag = $tag;
312
-        switch($tag) {
313
-            case 'methodCall':
314
-            case 'methodResponse':
315
-            case 'fault':
316
-                $this->messageType = $tag;
317
-                break;
318
-                /* Deal with stacks of arrays and structs */
319
-            case 'data':    // data is to all intents and puposes more interesting than array
320
-                $this->_arraystructstypes[] = 'array';
321
-                $this->_arraystructs[] = array();
322
-                break;
323
-            case 'struct':
324
-                $this->_arraystructstypes[] = 'struct';
325
-                $this->_arraystructs[] = array();
326
-                break;
327
-        }
328
-    }
329
-
330
-    function cdata($parser, $cdata)
331
-    {
332
-        $this->_currentTagContents .= $cdata;
333
-    }
334
-
335
-    function tag_close($parser, $tag)
336
-    {
337
-        $valueFlag = false;
338
-        switch($tag) {
339
-            case 'int':
340
-            case 'i4':
341
-                $value = (int)trim($this->_currentTagContents);
342
-                $valueFlag = true;
343
-                break;
344
-            case 'double':
345
-                $value = (double)trim($this->_currentTagContents);
346
-                $valueFlag = true;
347
-                break;
348
-            case 'string':
349
-                $value = (string)trim($this->_currentTagContents);
350
-                $valueFlag = true;
351
-                break;
352
-            case 'dateTime.iso8601':
353
-                $value = new IXR_Date(trim($this->_currentTagContents));
354
-                $valueFlag = true;
355
-                break;
356
-            case 'value':
357
-                // "If no type is indicated, the type is string."
358
-                if (trim($this->_currentTagContents) != '') {
359
-                    $value = (string)$this->_currentTagContents;
360
-                    $valueFlag = true;
361
-                }
362
-                break;
363
-            case 'boolean':
364
-                $value = (boolean)trim($this->_currentTagContents);
365
-                $valueFlag = true;
366
-                break;
367
-            case 'base64':
368
-                $value = base64_decode($this->_currentTagContents);
369
-                $valueFlag = true;
370
-                break;
371
-                /* Deal with stacks of arrays and structs */
372
-            case 'data':
373
-            case 'struct':
374
-                $value = array_pop($this->_arraystructs);
375
-                array_pop($this->_arraystructstypes);
376
-                $valueFlag = true;
377
-                break;
378
-            case 'member':
379
-                array_pop($this->_currentStructName);
380
-                break;
381
-            case 'name':
382
-                $this->_currentStructName[] = trim($this->_currentTagContents);
383
-                break;
384
-            case 'methodName':
385
-                $this->methodName = trim($this->_currentTagContents);
386
-                break;
387
-        }
388
-
389
-        if ($valueFlag) {
390
-            if (count($this->_arraystructs) > 0) {
391
-                // Add value to struct or array
392
-                if ($this->_arraystructstypes[count($this->_arraystructstypes)-1] == 'struct') {
393
-                    // Add to struct
394
-                    $this->_arraystructs[count($this->_arraystructs)-1][$this->_currentStructName[count($this->_currentStructName)-1]] = $value;
395
-                } else {
396
-                    // Add to array
397
-                    $this->_arraystructs[count($this->_arraystructs)-1][] = $value;
398
-                }
399
-            } else {
400
-                // Just add as a parameter
401
-                $this->params[] = $value;
402
-            }
403
-        }
404
-        $this->_currentTagContents = '';
405
-    }
222
+	function parse()
223
+	{
224
+		// first remove the XML declaration
225
+		// merged from WP #10698 - this method avoids the RAM usage of preg_replace on very large messages
226
+		$header = preg_replace( '/<\?xml.*?\?'.'>/s', '', substr( $this->message, 0, 100 ), 1 );
227
+		$this->message = trim( substr_replace( $this->message, $header, 0, 100 ) );
228
+		if ( '' == $this->message ) {
229
+			return false;
230
+		}
231
+
232
+		// Then remove the DOCTYPE
233
+		$header = preg_replace( '/^<!DOCTYPE[^>]*+>/i', '', substr( $this->message, 0, 200 ), 1 );
234
+		$this->message = trim( substr_replace( $this->message, $header, 0, 200 ) );
235
+		if ( '' == $this->message ) {
236
+			return false;
237
+		}
238
+
239
+		// Check that the root tag is valid
240
+		$root_tag = substr( $this->message, 0, strcspn( substr( $this->message, 0, 20 ), "> \t\r\n" ) );
241
+		if ( '<!DOCTYPE' === strtoupper( $root_tag ) ) {
242
+			return false;
243
+		}
244
+		if ( ! in_array( $root_tag, array( '<methodCall', '<methodResponse', '<fault' ) ) ) {
245
+			return false;
246
+		}
247
+
248
+		// Bail if there are too many elements to parse
249
+		$element_limit = 30000;
250
+		if ( function_exists( 'apply_filters' ) ) {
251
+			/**
252
+			 * Filters the number of elements to parse in an XML-RPC response.
253
+			 *
254
+			 * @since 4.0.0
255
+			 *
256
+			 * @param int $element_limit Default elements limit.
257
+			 */
258
+			$element_limit = apply_filters( 'xmlrpc_element_limit', $element_limit );
259
+		}
260
+		if ( $element_limit && 2 * $element_limit < substr_count( $this->message, '<' ) ) {
261
+			return false;
262
+		}
263
+
264
+		$this->_parser = xml_parser_create();
265
+		// Set XML parser to take the case of tags in to account
266
+		xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, false);
267
+		// Set XML parser callback functions
268
+		xml_set_object($this->_parser, $this);
269
+		xml_set_element_handler($this->_parser, 'tag_open', 'tag_close');
270
+		xml_set_character_data_handler($this->_parser, 'cdata');
271
+
272
+		// 256Kb, parse in chunks to avoid the RAM usage on very large messages
273
+		$chunk_size = 262144;
274
+
275
+		/**
276
+		 * Filters the chunk size that can be used to parse an XML-RPC reponse message.
277
+		 *
278
+		 * @since 4.4.0
279
+		 *
280
+		 * @param int $chunk_size Chunk size to parse in bytes.
281
+		 */
282
+		$chunk_size = apply_filters( 'xmlrpc_chunk_parsing_size', $chunk_size );
283
+
284
+		$final = false;
285
+		do {
286
+			if (strlen($this->message) <= $chunk_size) {
287
+				$final = true;
288
+			}
289
+			$part = substr($this->message, 0, $chunk_size);
290
+			$this->message = substr($this->message, $chunk_size);
291
+			if (!xml_parse($this->_parser, $part, $final)) {
292
+				return false;
293
+			}
294
+			if ($final) {
295
+				break;
296
+			}
297
+		} while (true);
298
+		xml_parser_free($this->_parser);
299
+
300
+		// Grab the error messages, if any
301
+		if ($this->messageType == 'fault') {
302
+			$this->faultCode = $this->params[0]['faultCode'];
303
+			$this->faultString = $this->params[0]['faultString'];
304
+		}
305
+		return true;
306
+	}
307
+
308
+	function tag_open($parser, $tag, $attr)
309
+	{
310
+		$this->_currentTagContents = '';
311
+		$this->currentTag = $tag;
312
+		switch($tag) {
313
+			case 'methodCall':
314
+			case 'methodResponse':
315
+			case 'fault':
316
+				$this->messageType = $tag;
317
+				break;
318
+				/* Deal with stacks of arrays and structs */
319
+			case 'data':    // data is to all intents and puposes more interesting than array
320
+				$this->_arraystructstypes[] = 'array';
321
+				$this->_arraystructs[] = array();
322
+				break;
323
+			case 'struct':
324
+				$this->_arraystructstypes[] = 'struct';
325
+				$this->_arraystructs[] = array();
326
+				break;
327
+		}
328
+	}
329
+
330
+	function cdata($parser, $cdata)
331
+	{
332
+		$this->_currentTagContents .= $cdata;
333
+	}
334
+
335
+	function tag_close($parser, $tag)
336
+	{
337
+		$valueFlag = false;
338
+		switch($tag) {
339
+			case 'int':
340
+			case 'i4':
341
+				$value = (int)trim($this->_currentTagContents);
342
+				$valueFlag = true;
343
+				break;
344
+			case 'double':
345
+				$value = (double)trim($this->_currentTagContents);
346
+				$valueFlag = true;
347
+				break;
348
+			case 'string':
349
+				$value = (string)trim($this->_currentTagContents);
350
+				$valueFlag = true;
351
+				break;
352
+			case 'dateTime.iso8601':
353
+				$value = new IXR_Date(trim($this->_currentTagContents));
354
+				$valueFlag = true;
355
+				break;
356
+			case 'value':
357
+				// "If no type is indicated, the type is string."
358
+				if (trim($this->_currentTagContents) != '') {
359
+					$value = (string)$this->_currentTagContents;
360
+					$valueFlag = true;
361
+				}
362
+				break;
363
+			case 'boolean':
364
+				$value = (boolean)trim($this->_currentTagContents);
365
+				$valueFlag = true;
366
+				break;
367
+			case 'base64':
368
+				$value = base64_decode($this->_currentTagContents);
369
+				$valueFlag = true;
370
+				break;
371
+				/* Deal with stacks of arrays and structs */
372
+			case 'data':
373
+			case 'struct':
374
+				$value = array_pop($this->_arraystructs);
375
+				array_pop($this->_arraystructstypes);
376
+				$valueFlag = true;
377
+				break;
378
+			case 'member':
379
+				array_pop($this->_currentStructName);
380
+				break;
381
+			case 'name':
382
+				$this->_currentStructName[] = trim($this->_currentTagContents);
383
+				break;
384
+			case 'methodName':
385
+				$this->methodName = trim($this->_currentTagContents);
386
+				break;
387
+		}
388
+
389
+		if ($valueFlag) {
390
+			if (count($this->_arraystructs) > 0) {
391
+				// Add value to struct or array
392
+				if ($this->_arraystructstypes[count($this->_arraystructstypes)-1] == 'struct') {
393
+					// Add to struct
394
+					$this->_arraystructs[count($this->_arraystructs)-1][$this->_currentStructName[count($this->_currentStructName)-1]] = $value;
395
+				} else {
396
+					// Add to array
397
+					$this->_arraystructs[count($this->_arraystructs)-1][] = $value;
398
+				}
399
+			} else {
400
+				// Just add as a parameter
401
+				$this->params[] = $value;
402
+			}
403
+		}
404
+		$this->_currentTagContents = '';
405
+	}
406 406
 }
407 407
 
408 408
 /**
@@ -413,25 +413,25 @@  discard block
 block discarded – undo
413 413
  */
414 414
 class IXR_Server
415 415
 {
416
-    var $data;
417
-    var $callbacks = array();
418
-    var $message;
419
-    var $capabilities;
416
+	var $data;
417
+	var $callbacks = array();
418
+	var $message;
419
+	var $capabilities;
420 420
 
421 421
 	/**
422 422
 	 * PHP5 constructor.
423 423
 	 */
424
-    function __construct( $callbacks = false, $data = false, $wait = false )
425
-    {
426
-        $this->setCapabilities();
427
-        if ($callbacks) {
428
-            $this->callbacks = $callbacks;
429
-        }
430
-        $this->setCallbacks();
431
-        if (!$wait) {
432
-            $this->serve($data);
433
-        }
434
-    }
424
+	function __construct( $callbacks = false, $data = false, $wait = false )
425
+	{
426
+		$this->setCapabilities();
427
+		if ($callbacks) {
428
+			$this->callbacks = $callbacks;
429
+		}
430
+		$this->setCallbacks();
431
+		if (!$wait) {
432
+			$this->serve($data);
433
+		}
434
+	}
435 435
 
436 436
 	/**
437 437
 	 * PHP4 constructor.
@@ -440,46 +440,46 @@  discard block
 block discarded – undo
440 440
 		self::__construct( $callbacks, $data, $wait );
441 441
 	}
442 442
 
443
-    function serve($data = false)
444
-    {
445
-        if (!$data) {
446
-            if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] !== 'POST') {
447
-                if ( function_exists( 'status_header' ) ) {
448
-                    status_header( 405 ); // WP #20986
449
-                    header( 'Allow: POST' );
450
-                }
451
-                header('Content-Type: text/plain'); // merged from WP #9093
452
-                die('XML-RPC server accepts POST requests only.');
453
-            }
454
-
455
-            global $HTTP_RAW_POST_DATA;
456
-            if (empty($HTTP_RAW_POST_DATA)) {
457
-                // workaround for a bug in PHP 5.2.2 - http://bugs.php.net/bug.php?id=41293
458
-                $data = file_get_contents('php://input');
459
-            } else {
460
-                $data =& $HTTP_RAW_POST_DATA;
461
-            }
462
-        }
463
-        $this->message = new IXR_Message($data);
464
-        if (!$this->message->parse()) {
465
-            $this->error(-32700, 'parse error. not well formed');
466
-        }
467
-        if ($this->message->messageType != 'methodCall') {
468
-            $this->error(-32600, 'server error. invalid xml-rpc. not conforming to spec. Request must be a methodCall');
469
-        }
470
-        $result = $this->call($this->message->methodName, $this->message->params);
471
-
472
-        // Is the result an error?
473
-        if (is_a($result, 'IXR_Error')) {
474
-            $this->error($result);
475
-        }
476
-
477
-        // Encode the result
478
-        $r = new IXR_Value($result);
479
-        $resultxml = $r->getXml();
480
-
481
-        // Create the XML
482
-        $xml = <<<EOD
443
+	function serve($data = false)
444
+	{
445
+		if (!$data) {
446
+			if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] !== 'POST') {
447
+				if ( function_exists( 'status_header' ) ) {
448
+					status_header( 405 ); // WP #20986
449
+					header( 'Allow: POST' );
450
+				}
451
+				header('Content-Type: text/plain'); // merged from WP #9093
452
+				die('XML-RPC server accepts POST requests only.');
453
+			}
454
+
455
+			global $HTTP_RAW_POST_DATA;
456
+			if (empty($HTTP_RAW_POST_DATA)) {
457
+				// workaround for a bug in PHP 5.2.2 - http://bugs.php.net/bug.php?id=41293
458
+				$data = file_get_contents('php://input');
459
+			} else {
460
+				$data =& $HTTP_RAW_POST_DATA;
461
+			}
462
+		}
463
+		$this->message = new IXR_Message($data);
464
+		if (!$this->message->parse()) {
465
+			$this->error(-32700, 'parse error. not well formed');
466
+		}
467
+		if ($this->message->messageType != 'methodCall') {
468
+			$this->error(-32600, 'server error. invalid xml-rpc. not conforming to spec. Request must be a methodCall');
469
+		}
470
+		$result = $this->call($this->message->methodName, $this->message->params);
471
+
472
+		// Is the result an error?
473
+		if (is_a($result, 'IXR_Error')) {
474
+			$this->error($result);
475
+		}
476
+
477
+		// Encode the result
478
+		$r = new IXR_Value($result);
479
+		$resultxml = $r->getXml();
480
+
481
+		// Create the XML
482
+		$xml = <<<EOD
483 483
 <methodResponse>
484 484
   <params>
485 485
     <param>
@@ -491,142 +491,142 @@  discard block
 block discarded – undo
491 491
 </methodResponse>
492 492
 
493 493
 EOD;
494
-      // Send it
495
-      $this->output($xml);
496
-    }
497
-
498
-    function call($methodname, $args)
499
-    {
500
-        if (!$this->hasMethod($methodname)) {
501
-            return new IXR_Error(-32601, 'server error. requested method '.$methodname.' does not exist.');
502
-        }
503
-        $method = $this->callbacks[$methodname];
504
-
505
-        // Perform the callback and send the response
506
-        if (count($args) == 1) {
507
-            // If only one parameter just send that instead of the whole array
508
-            $args = $args[0];
509
-        }
510
-
511
-        // Are we dealing with a function or a method?
512
-        if (is_string($method) && substr($method, 0, 5) == 'this:') {
513
-            // It's a class method - check it exists
514
-            $method = substr($method, 5);
515
-            if (!method_exists($this, $method)) {
516
-                return new IXR_Error(-32601, 'server error. requested class method "'.$method.'" does not exist.');
517
-            }
518
-
519
-            //Call the method
520
-            $result = $this->$method($args);
521
-        } else {
522
-            // It's a function - does it exist?
523
-            if (is_array($method)) {
524
-                if (!is_callable(array($method[0], $method[1]))) {
525
-                    return new IXR_Error(-32601, 'server error. requested object method "'.$method[1].'" does not exist.');
526
-                }
527
-            } else if (!function_exists($method)) {
528
-                return new IXR_Error(-32601, 'server error. requested function "'.$method.'" does not exist.');
529
-            }
530
-
531
-            // Call the function
532
-            $result = call_user_func($method, $args);
533
-        }
534
-        return $result;
535
-    }
536
-
537
-    function error($error, $message = false)
538
-    {
539
-        // Accepts either an error object or an error code and message
540
-        if ($message && !is_object($error)) {
541
-            $error = new IXR_Error($error, $message);
542
-        }
543
-        $this->output($error->getXml());
544
-    }
545
-
546
-    function output($xml)
547
-    {
548
-        $charset = function_exists('get_option') ? get_option('blog_charset') : '';
549
-        if ($charset)
550
-            $xml = '<?xml version="1.0" encoding="'.$charset.'"?>'."\n".$xml;
551
-        else
552
-            $xml = '<?xml version="1.0"?>'."\n".$xml;
553
-        $length = strlen($xml);
554
-        header('Connection: close');
555
-        if ($charset)
556
-            header('Content-Type: text/xml; charset='.$charset);
557
-        else
558
-            header('Content-Type: text/xml');
559
-        header('Date: '.date('r'));
560
-        echo $xml;
561
-        exit;
562
-    }
563
-
564
-    function hasMethod($method)
565
-    {
566
-        return in_array($method, array_keys($this->callbacks));
567
-    }
568
-
569
-    function setCapabilities()
570
-    {
571
-        // Initialises capabilities array
572
-        $this->capabilities = array(
573
-            'xmlrpc' => array(
574
-                'specUrl' => 'http://www.xmlrpc.com/spec',
575
-                'specVersion' => 1
576
-        ),
577
-            'faults_interop' => array(
578
-                'specUrl' => 'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php',
579
-                'specVersion' => 20010516
580
-        ),
581
-            'system.multicall' => array(
582
-                'specUrl' => 'http://www.xmlrpc.com/discuss/msgReader$1208',
583
-                'specVersion' => 1
584
-        ),
585
-        );
586
-    }
587
-
588
-    function getCapabilities($args)
589
-    {
590
-        return $this->capabilities;
591
-    }
592
-
593
-    function setCallbacks()
594
-    {
595
-        $this->callbacks['system.getCapabilities'] = 'this:getCapabilities';
596
-        $this->callbacks['system.listMethods'] = 'this:listMethods';
597
-        $this->callbacks['system.multicall'] = 'this:multiCall';
598
-    }
599
-
600
-    function listMethods($args)
601
-    {
602
-        // Returns a list of methods - uses array_reverse to ensure user defined
603
-        // methods are listed before server defined methods
604
-        return array_reverse(array_keys($this->callbacks));
605
-    }
606
-
607
-    function multiCall($methodcalls)
608
-    {
609
-        // See http://www.xmlrpc.com/discuss/msgReader$1208
610
-        $return = array();
611
-        foreach ($methodcalls as $call) {
612
-            $method = $call['methodName'];
613
-            $params = $call['params'];
614
-            if ($method == 'system.multicall') {
615
-                $result = new IXR_Error(-32600, 'Recursive calls to system.multicall are forbidden');
616
-            } else {
617
-                $result = $this->call($method, $params);
618
-            }
619
-            if (is_a($result, 'IXR_Error')) {
620
-                $return[] = array(
621
-                    'faultCode' => $result->code,
622
-                    'faultString' => $result->message
623
-                );
624
-            } else {
625
-                $return[] = array($result);
626
-            }
627
-        }
628
-        return $return;
629
-    }
494
+	  // Send it
495
+	  $this->output($xml);
496
+	}
497
+
498
+	function call($methodname, $args)
499
+	{
500
+		if (!$this->hasMethod($methodname)) {
501
+			return new IXR_Error(-32601, 'server error. requested method '.$methodname.' does not exist.');
502
+		}
503
+		$method = $this->callbacks[$methodname];
504
+
505
+		// Perform the callback and send the response
506
+		if (count($args) == 1) {
507
+			// If only one parameter just send that instead of the whole array
508
+			$args = $args[0];
509
+		}
510
+
511
+		// Are we dealing with a function or a method?
512
+		if (is_string($method) && substr($method, 0, 5) == 'this:') {
513
+			// It's a class method - check it exists
514
+			$method = substr($method, 5);
515
+			if (!method_exists($this, $method)) {
516
+				return new IXR_Error(-32601, 'server error. requested class method "'.$method.'" does not exist.');
517
+			}
518
+
519
+			//Call the method
520
+			$result = $this->$method($args);
521
+		} else {
522
+			// It's a function - does it exist?
523
+			if (is_array($method)) {
524
+				if (!is_callable(array($method[0], $method[1]))) {
525
+					return new IXR_Error(-32601, 'server error. requested object method "'.$method[1].'" does not exist.');
526
+				}
527
+			} else if (!function_exists($method)) {
528
+				return new IXR_Error(-32601, 'server error. requested function "'.$method.'" does not exist.');
529
+			}
530
+
531
+			// Call the function
532
+			$result = call_user_func($method, $args);
533
+		}
534
+		return $result;
535
+	}
536
+
537
+	function error($error, $message = false)
538
+	{
539
+		// Accepts either an error object or an error code and message
540
+		if ($message && !is_object($error)) {
541
+			$error = new IXR_Error($error, $message);
542
+		}
543
+		$this->output($error->getXml());
544
+	}
545
+
546
+	function output($xml)
547
+	{
548
+		$charset = function_exists('get_option') ? get_option('blog_charset') : '';
549
+		if ($charset)
550
+			$xml = '<?xml version="1.0" encoding="'.$charset.'"?>'."\n".$xml;
551
+		else
552
+			$xml = '<?xml version="1.0"?>'."\n".$xml;
553
+		$length = strlen($xml);
554
+		header('Connection: close');
555
+		if ($charset)
556
+			header('Content-Type: text/xml; charset='.$charset);
557
+		else
558
+			header('Content-Type: text/xml');
559
+		header('Date: '.date('r'));
560
+		echo $xml;
561
+		exit;
562
+	}
563
+
564
+	function hasMethod($method)
565
+	{
566
+		return in_array($method, array_keys($this->callbacks));
567
+	}
568
+
569
+	function setCapabilities()
570
+	{
571
+		// Initialises capabilities array
572
+		$this->capabilities = array(
573
+			'xmlrpc' => array(
574
+				'specUrl' => 'http://www.xmlrpc.com/spec',
575
+				'specVersion' => 1
576
+		),
577
+			'faults_interop' => array(
578
+				'specUrl' => 'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php',
579
+				'specVersion' => 20010516
580
+		),
581
+			'system.multicall' => array(
582
+				'specUrl' => 'http://www.xmlrpc.com/discuss/msgReader$1208',
583
+				'specVersion' => 1
584
+		),
585
+		);
586
+	}
587
+
588
+	function getCapabilities($args)
589
+	{
590
+		return $this->capabilities;
591
+	}
592
+
593
+	function setCallbacks()
594
+	{
595
+		$this->callbacks['system.getCapabilities'] = 'this:getCapabilities';
596
+		$this->callbacks['system.listMethods'] = 'this:listMethods';
597
+		$this->callbacks['system.multicall'] = 'this:multiCall';
598
+	}
599
+
600
+	function listMethods($args)
601
+	{
602
+		// Returns a list of methods - uses array_reverse to ensure user defined
603
+		// methods are listed before server defined methods
604
+		return array_reverse(array_keys($this->callbacks));
605
+	}
606
+
607
+	function multiCall($methodcalls)
608
+	{
609
+		// See http://www.xmlrpc.com/discuss/msgReader$1208
610
+		$return = array();
611
+		foreach ($methodcalls as $call) {
612
+			$method = $call['methodName'];
613
+			$params = $call['params'];
614
+			if ($method == 'system.multicall') {
615
+				$result = new IXR_Error(-32600, 'Recursive calls to system.multicall are forbidden');
616
+			} else {
617
+				$result = $this->call($method, $params);
618
+			}
619
+			if (is_a($result, 'IXR_Error')) {
620
+				$return[] = array(
621
+					'faultCode' => $result->code,
622
+					'faultString' => $result->message
623
+				);
624
+			} else {
625
+				$return[] = array($result);
626
+			}
627
+		}
628
+		return $return;
629
+	}
630 630
 }
631 631
 
632 632
 /**
@@ -637,32 +637,32 @@  discard block
 block discarded – undo
637 637
  */
638 638
 class IXR_Request
639 639
 {
640
-    var $method;
641
-    var $args;
642
-    var $xml;
640
+	var $method;
641
+	var $args;
642
+	var $xml;
643 643
 
644 644
 	/**
645 645
 	 * PHP5 constructor.
646 646
 	 */
647
-    function __construct($method, $args)
648
-    {
649
-        $this->method = $method;
650
-        $this->args = $args;
651
-        $this->xml = <<<EOD
647
+	function __construct($method, $args)
648
+	{
649
+		$this->method = $method;
650
+		$this->args = $args;
651
+		$this->xml = <<<EOD
652 652
 <?xml version="1.0"?>
653 653
 <methodCall>
654 654
 <methodName>{$this->method}</methodName>
655 655
 <params>
656 656
 
657 657
 EOD;
658
-        foreach ($this->args as $arg) {
659
-            $this->xml .= '<param><value>';
660
-            $v = new IXR_Value($arg);
661
-            $this->xml .= $v->getXml();
662
-            $this->xml .= "</value></param>\n";
663
-        }
664
-        $this->xml .= '</params></methodCall>';
665
-    }
658
+		foreach ($this->args as $arg) {
659
+			$this->xml .= '<param><value>';
660
+			$v = new IXR_Value($arg);
661
+			$this->xml .= $v->getXml();
662
+			$this->xml .= "</value></param>\n";
663
+		}
664
+		$this->xml .= '</params></methodCall>';
665
+	}
666 666
 
667 667
 	/**
668 668
 	 * PHP4 constructor.
@@ -671,15 +671,15 @@  discard block
 block discarded – undo
671 671
 		self::__construct( $method, $args );
672 672
 	}
673 673
 
674
-    function getLength()
675
-    {
676
-        return strlen($this->xml);
677
-    }
674
+	function getLength()
675
+	{
676
+		return strlen($this->xml);
677
+	}
678 678
 
679
-    function getXml()
680
-    {
681
-        return $this->xml;
682
-    }
679
+	function getXml()
680
+	{
681
+		return $this->xml;
682
+	}
683 683
 }
684 684
 
685 685
 /**
@@ -691,47 +691,47 @@  discard block
 block discarded – undo
691 691
  */
692 692
 class IXR_Client
693 693
 {
694
-    var $server;
695
-    var $port;
696
-    var $path;
697
-    var $useragent;
698
-    var $response;
699
-    var $message = false;
700
-    var $debug = false;
701
-    var $timeout;
702
-    var $headers = array();
703
-
704
-    // Storage place for an error message
705
-    var $error = false;
694
+	var $server;
695
+	var $port;
696
+	var $path;
697
+	var $useragent;
698
+	var $response;
699
+	var $message = false;
700
+	var $debug = false;
701
+	var $timeout;
702
+	var $headers = array();
703
+
704
+	// Storage place for an error message
705
+	var $error = false;
706 706
 
707 707
 	/**
708 708
 	 * PHP5 constructor.
709 709
 	 */
710
-    function __construct( $server, $path = false, $port = 80, $timeout = 15 )
711
-    {
712
-        if (!$path) {
713
-            // Assume we have been given a URL instead
714
-            $bits = parse_url($server);
715
-            $this->server = $bits['host'];
716
-            $this->port = isset($bits['port']) ? $bits['port'] : 80;
717
-            $this->path = isset($bits['path']) ? $bits['path'] : '/';
718
-
719
-            // Make absolutely sure we have a path
720
-            if (!$this->path) {
721
-                $this->path = '/';
722
-            }
723
-
724
-            if ( ! empty( $bits['query'] ) ) {
725
-                $this->path .= '?' . $bits['query'];
726
-            }
727
-        } else {
728
-            $this->server = $server;
729
-            $this->path = $path;
730
-            $this->port = $port;
731
-        }
732
-        $this->useragent = 'The Incutio XML-RPC PHP Library';
733
-        $this->timeout = $timeout;
734
-    }
710
+	function __construct( $server, $path = false, $port = 80, $timeout = 15 )
711
+	{
712
+		if (!$path) {
713
+			// Assume we have been given a URL instead
714
+			$bits = parse_url($server);
715
+			$this->server = $bits['host'];
716
+			$this->port = isset($bits['port']) ? $bits['port'] : 80;
717
+			$this->path = isset($bits['path']) ? $bits['path'] : '/';
718
+
719
+			// Make absolutely sure we have a path
720
+			if (!$this->path) {
721
+				$this->path = '/';
722
+			}
723
+
724
+			if ( ! empty( $bits['query'] ) ) {
725
+				$this->path .= '?' . $bits['query'];
726
+			}
727
+		} else {
728
+			$this->server = $server;
729
+			$this->path = $path;
730
+			$this->port = $port;
731
+		}
732
+		$this->useragent = 'The Incutio XML-RPC PHP Library';
733
+		$this->timeout = $timeout;
734
+	}
735 735
 
736 736
 	/**
737 737
 	 * PHP4 constructor.
@@ -740,111 +740,111 @@  discard block
 block discarded – undo
740 740
 		self::__construct( $server, $path, $port, $timeout );
741 741
 	}
742 742
 
743
-    function query()
744
-    {
745
-        $args = func_get_args();
746
-        $method = array_shift($args);
747
-        $request = new IXR_Request($method, $args);
748
-        $length = $request->getLength();
749
-        $xml = $request->getXml();
750
-        $r = "\r\n";
751
-        $request  = "POST {$this->path} HTTP/1.0$r";
752
-
753
-        // Merged from WP #8145 - allow custom headers
754
-        $this->headers['Host']          = $this->server;
755
-        $this->headers['Content-Type']  = 'text/xml';
756
-        $this->headers['User-Agent']    = $this->useragent;
757
-        $this->headers['Content-Length']= $length;
758
-
759
-        foreach( $this->headers as $header => $value ) {
760
-            $request .= "{$header}: {$value}{$r}";
761
-        }
762
-        $request .= $r;
763
-
764
-        $request .= $xml;
765
-
766
-        // Now send the request
767
-        if ($this->debug) {
768
-            echo '<pre class="ixr_request">'.htmlspecialchars($request)."\n</pre>\n\n";
769
-        }
770
-
771
-        if ($this->timeout) {
772
-            $fp = @fsockopen($this->server, $this->port, $errno, $errstr, $this->timeout);
773
-        } else {
774
-            $fp = @fsockopen($this->server, $this->port, $errno, $errstr);
775
-        }
776
-        if (!$fp) {
777
-            $this->error = new IXR_Error(-32300, 'transport error - could not open socket');
778
-            return false;
779
-        }
780
-        fputs($fp, $request);
781
-        $contents = '';
782
-        $debugContents = '';
783
-        $gotFirstLine = false;
784
-        $gettingHeaders = true;
785
-        while (!feof($fp)) {
786
-            $line = fgets($fp, 4096);
787
-            if (!$gotFirstLine) {
788
-                // Check line for '200'
789
-                if (strstr($line, '200') === false) {
790
-                    $this->error = new IXR_Error(-32300, 'transport error - HTTP status code was not 200');
791
-                    return false;
792
-                }
793
-                $gotFirstLine = true;
794
-            }
795
-            if (trim($line) == '') {
796
-                $gettingHeaders = false;
797
-            }
798
-            if (!$gettingHeaders) {
799
-            	// merged from WP #12559 - remove trim
800
-                $contents .= $line;
801
-            }
802
-            if ($this->debug) {
803
-            	$debugContents .= $line;
804
-            }
805
-        }
806
-        if ($this->debug) {
807
-            echo '<pre class="ixr_response">'.htmlspecialchars($debugContents)."\n</pre>\n\n";
808
-        }
809
-
810
-        // Now parse what we've got back
811
-        $this->message = new IXR_Message($contents);
812
-        if (!$this->message->parse()) {
813
-            // XML error
814
-            $this->error = new IXR_Error(-32700, 'parse error. not well formed');
815
-            return false;
816
-        }
817
-
818
-        // Is the message a fault?
819
-        if ($this->message->messageType == 'fault') {
820
-            $this->error = new IXR_Error($this->message->faultCode, $this->message->faultString);
821
-            return false;
822
-        }
823
-
824
-        // Message must be OK
825
-        return true;
826
-    }
827
-
828
-    function getResponse()
829
-    {
830
-        // methodResponses can only have one param - return that
831
-        return $this->message->params[0];
832
-    }
833
-
834
-    function isError()
835
-    {
836
-        return (is_object($this->error));
837
-    }
838
-
839
-    function getErrorCode()
840
-    {
841
-        return $this->error->code;
842
-    }
843
-
844
-    function getErrorMessage()
845
-    {
846
-        return $this->error->message;
847
-    }
743
+	function query()
744
+	{
745
+		$args = func_get_args();
746
+		$method = array_shift($args);
747
+		$request = new IXR_Request($method, $args);
748
+		$length = $request->getLength();
749
+		$xml = $request->getXml();
750
+		$r = "\r\n";
751
+		$request  = "POST {$this->path} HTTP/1.0$r";
752
+
753
+		// Merged from WP #8145 - allow custom headers
754
+		$this->headers['Host']          = $this->server;
755
+		$this->headers['Content-Type']  = 'text/xml';
756
+		$this->headers['User-Agent']    = $this->useragent;
757
+		$this->headers['Content-Length']= $length;
758
+
759
+		foreach( $this->headers as $header => $value ) {
760
+			$request .= "{$header}: {$value}{$r}";
761
+		}
762
+		$request .= $r;
763
+
764
+		$request .= $xml;
765
+
766
+		// Now send the request
767
+		if ($this->debug) {
768
+			echo '<pre class="ixr_request">'.htmlspecialchars($request)."\n</pre>\n\n";
769
+		}
770
+
771
+		if ($this->timeout) {
772
+			$fp = @fsockopen($this->server, $this->port, $errno, $errstr, $this->timeout);
773
+		} else {
774
+			$fp = @fsockopen($this->server, $this->port, $errno, $errstr);
775
+		}
776
+		if (!$fp) {
777
+			$this->error = new IXR_Error(-32300, 'transport error - could not open socket');
778
+			return false;
779
+		}
780
+		fputs($fp, $request);
781
+		$contents = '';
782
+		$debugContents = '';
783
+		$gotFirstLine = false;
784
+		$gettingHeaders = true;
785
+		while (!feof($fp)) {
786
+			$line = fgets($fp, 4096);
787
+			if (!$gotFirstLine) {
788
+				// Check line for '200'
789
+				if (strstr($line, '200') === false) {
790
+					$this->error = new IXR_Error(-32300, 'transport error - HTTP status code was not 200');
791
+					return false;
792
+				}
793
+				$gotFirstLine = true;
794
+			}
795
+			if (trim($line) == '') {
796
+				$gettingHeaders = false;
797
+			}
798
+			if (!$gettingHeaders) {
799
+				// merged from WP #12559 - remove trim
800
+				$contents .= $line;
801
+			}
802
+			if ($this->debug) {
803
+				$debugContents .= $line;
804
+			}
805
+		}
806
+		if ($this->debug) {
807
+			echo '<pre class="ixr_response">'.htmlspecialchars($debugContents)."\n</pre>\n\n";
808
+		}
809
+
810
+		// Now parse what we've got back
811
+		$this->message = new IXR_Message($contents);
812
+		if (!$this->message->parse()) {
813
+			// XML error
814
+			$this->error = new IXR_Error(-32700, 'parse error. not well formed');
815
+			return false;
816
+		}
817
+
818
+		// Is the message a fault?
819
+		if ($this->message->messageType == 'fault') {
820
+			$this->error = new IXR_Error($this->message->faultCode, $this->message->faultString);
821
+			return false;
822
+		}
823
+
824
+		// Message must be OK
825
+		return true;
826
+	}
827
+
828
+	function getResponse()
829
+	{
830
+		// methodResponses can only have one param - return that
831
+		return $this->message->params[0];
832
+	}
833
+
834
+	function isError()
835
+	{
836
+		return (is_object($this->error));
837
+	}
838
+
839
+	function getErrorCode()
840
+	{
841
+		return $this->error->code;
842
+	}
843
+
844
+	function getErrorMessage()
845
+	{
846
+		return $this->error->message;
847
+	}
848 848
 }
849 849
 
850 850
 
@@ -856,17 +856,17 @@  discard block
 block discarded – undo
856 856
  */
857 857
 class IXR_Error
858 858
 {
859
-    var $code;
860
-    var $message;
859
+	var $code;
860
+	var $message;
861 861
 
862 862
 	/**
863 863
 	 * PHP5 constructor.
864 864
 	 */
865
-    function __construct( $code, $message )
866
-    {
867
-        $this->code = $code;
868
-        $this->message = htmlspecialchars($message);
869
-    }
865
+	function __construct( $code, $message )
866
+	{
867
+		$this->code = $code;
868
+		$this->message = htmlspecialchars($message);
869
+	}
870 870
 
871 871
 	/**
872 872
 	 * PHP4 constructor.
@@ -875,9 +875,9 @@  discard block
 block discarded – undo
875 875
 		self::__construct( $code, $message );
876 876
 	}
877 877
 
878
-    function getXml()
879
-    {
880
-        $xml = <<<EOD
878
+	function getXml()
879
+	{
880
+		$xml = <<<EOD
881 881
 <methodResponse>
882 882
   <fault>
883 883
     <value>
@@ -896,8 +896,8 @@  discard block
 block discarded – undo
896 896
 </methodResponse>
897 897
 
898 898
 EOD;
899
-        return $xml;
900
-    }
899
+		return $xml;
900
+	}
901 901
 }
902 902
 
903 903
 /**
@@ -907,26 +907,26 @@  discard block
 block discarded – undo
907 907
  * @since 1.5.0
908 908
  */
909 909
 class IXR_Date {
910
-    var $year;
911
-    var $month;
912
-    var $day;
913
-    var $hour;
914
-    var $minute;
915
-    var $second;
916
-    var $timezone;
910
+	var $year;
911
+	var $month;
912
+	var $day;
913
+	var $hour;
914
+	var $minute;
915
+	var $second;
916
+	var $timezone;
917 917
 
918 918
 	/**
919 919
 	 * PHP5 constructor.
920 920
 	 */
921
-    function __construct( $time )
922
-    {
923
-        // $time can be a PHP timestamp or an ISO one
924
-        if (is_numeric($time)) {
925
-            $this->parseTimestamp($time);
926
-        } else {
927
-            $this->parseIso($time);
928
-        }
929
-    }
921
+	function __construct( $time )
922
+	{
923
+		// $time can be a PHP timestamp or an ISO one
924
+		if (is_numeric($time)) {
925
+			$this->parseTimestamp($time);
926
+		} else {
927
+			$this->parseIso($time);
928
+		}
929
+	}
930 930
 
931 931
 	/**
932 932
 	 * PHP4 constructor.
@@ -935,42 +935,42 @@  discard block
 block discarded – undo
935 935
 		self::__construct( $time );
936 936
 	}
937 937
 
938
-    function parseTimestamp($timestamp)
939
-    {
940
-        $this->year = date('Y', $timestamp);
941
-        $this->month = date('m', $timestamp);
942
-        $this->day = date('d', $timestamp);
943
-        $this->hour = date('H', $timestamp);
944
-        $this->minute = date('i', $timestamp);
945
-        $this->second = date('s', $timestamp);
946
-        $this->timezone = '';
947
-    }
948
-
949
-    function parseIso($iso)
950
-    {
951
-        $this->year = substr($iso, 0, 4);
952
-        $this->month = substr($iso, 4, 2);
953
-        $this->day = substr($iso, 6, 2);
954
-        $this->hour = substr($iso, 9, 2);
955
-        $this->minute = substr($iso, 12, 2);
956
-        $this->second = substr($iso, 15, 2);
957
-        $this->timezone = substr($iso, 17);
958
-    }
959
-
960
-    function getIso()
961
-    {
962
-        return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second.$this->timezone;
963
-    }
964
-
965
-    function getXml()
966
-    {
967
-        return '<dateTime.iso8601>'.$this->getIso().'</dateTime.iso8601>';
968
-    }
969
-
970
-    function getTimestamp()
971
-    {
972
-        return mktime($this->hour, $this->minute, $this->second, $this->month, $this->day, $this->year);
973
-    }
938
+	function parseTimestamp($timestamp)
939
+	{
940
+		$this->year = date('Y', $timestamp);
941
+		$this->month = date('m', $timestamp);
942
+		$this->day = date('d', $timestamp);
943
+		$this->hour = date('H', $timestamp);
944
+		$this->minute = date('i', $timestamp);
945
+		$this->second = date('s', $timestamp);
946
+		$this->timezone = '';
947
+	}
948
+
949
+	function parseIso($iso)
950
+	{
951
+		$this->year = substr($iso, 0, 4);
952
+		$this->month = substr($iso, 4, 2);
953
+		$this->day = substr($iso, 6, 2);
954
+		$this->hour = substr($iso, 9, 2);
955
+		$this->minute = substr($iso, 12, 2);
956
+		$this->second = substr($iso, 15, 2);
957
+		$this->timezone = substr($iso, 17);
958
+	}
959
+
960
+	function getIso()
961
+	{
962
+		return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second.$this->timezone;
963
+	}
964
+
965
+	function getXml()
966
+	{
967
+		return '<dateTime.iso8601>'.$this->getIso().'</dateTime.iso8601>';
968
+	}
969
+
970
+	function getTimestamp()
971
+	{
972
+		return mktime($this->hour, $this->minute, $this->second, $this->month, $this->day, $this->year);
973
+	}
974 974
 }
975 975
 
976 976
 /**
@@ -981,15 +981,15 @@  discard block
 block discarded – undo
981 981
  */
982 982
 class IXR_Base64
983 983
 {
984
-    var $data;
984
+	var $data;
985 985
 
986 986
 	/**
987 987
 	 * PHP5 constructor.
988 988
 	 */
989
-    function __construct( $data )
990
-    {
991
-        $this->data = $data;
992
-    }
989
+	function __construct( $data )
990
+	{
991
+		$this->data = $data;
992
+	}
993 993
 
994 994
 	/**
995 995
 	 * PHP4 constructor.
@@ -998,10 +998,10 @@  discard block
 block discarded – undo
998 998
 		self::__construct( $data );
999 999
 	}
1000 1000
 
1001
-    function getXml()
1002
-    {
1003
-        return '<base64>'.base64_encode($this->data).'</base64>';
1004
-    }
1001
+	function getXml()
1002
+	{
1003
+		return '<base64>'.base64_encode($this->data).'</base64>';
1004
+	}
1005 1005
 }
1006 1006
 
1007 1007
 /**
@@ -1012,45 +1012,45 @@  discard block
 block discarded – undo
1012 1012
  */
1013 1013
 class IXR_IntrospectionServer extends IXR_Server
1014 1014
 {
1015
-    var $signatures;
1016
-    var $help;
1015
+	var $signatures;
1016
+	var $help;
1017 1017
 
1018 1018
 	/**
1019 1019
 	 * PHP5 constructor.
1020 1020
 	 */
1021
-    function __construct()
1022
-    {
1023
-        $this->setCallbacks();
1024
-        $this->setCapabilities();
1025
-        $this->capabilities['introspection'] = array(
1026
-            'specUrl' => 'http://xmlrpc.usefulinc.com/doc/reserved.html',
1027
-            'specVersion' => 1
1028
-        );
1029
-        $this->addCallback(
1030
-            'system.methodSignature',
1031
-            'this:methodSignature',
1032
-            array('array', 'string'),
1033
-            'Returns an array describing the return type and required parameters of a method'
1034
-        );
1035
-        $this->addCallback(
1036
-            'system.getCapabilities',
1037
-            'this:getCapabilities',
1038
-            array('struct'),
1039
-            'Returns a struct describing the XML-RPC specifications supported by this server'
1040
-        );
1041
-        $this->addCallback(
1042
-            'system.listMethods',
1043
-            'this:listMethods',
1044
-            array('array'),
1045
-            'Returns an array of available methods on this server'
1046
-        );
1047
-        $this->addCallback(
1048
-            'system.methodHelp',
1049
-            'this:methodHelp',
1050
-            array('string', 'string'),
1051
-            'Returns a documentation string for the specified method'
1052
-        );
1053
-    }
1021
+	function __construct()
1022
+	{
1023
+		$this->setCallbacks();
1024
+		$this->setCapabilities();
1025
+		$this->capabilities['introspection'] = array(
1026
+			'specUrl' => 'http://xmlrpc.usefulinc.com/doc/reserved.html',
1027
+			'specVersion' => 1
1028
+		);
1029
+		$this->addCallback(
1030
+			'system.methodSignature',
1031
+			'this:methodSignature',
1032
+			array('array', 'string'),
1033
+			'Returns an array describing the return type and required parameters of a method'
1034
+		);
1035
+		$this->addCallback(
1036
+			'system.getCapabilities',
1037
+			'this:getCapabilities',
1038
+			array('struct'),
1039
+			'Returns a struct describing the XML-RPC specifications supported by this server'
1040
+		);
1041
+		$this->addCallback(
1042
+			'system.listMethods',
1043
+			'this:listMethods',
1044
+			array('array'),
1045
+			'Returns an array of available methods on this server'
1046
+		);
1047
+		$this->addCallback(
1048
+			'system.methodHelp',
1049
+			'this:methodHelp',
1050
+			array('string', 'string'),
1051
+			'Returns a documentation string for the specified method'
1052
+		);
1053
+	}
1054 1054
 
1055 1055
 	/**
1056 1056
 	 * PHP4 constructor.
@@ -1059,122 +1059,122 @@  discard block
 block discarded – undo
1059 1059
 		self::__construct();
1060 1060
 	}
1061 1061
 
1062
-    function addCallback($method, $callback, $args, $help)
1063
-    {
1064
-        $this->callbacks[$method] = $callback;
1065
-        $this->signatures[$method] = $args;
1066
-        $this->help[$method] = $help;
1067
-    }
1068
-
1069
-    function call($methodname, $args)
1070
-    {
1071
-        // Make sure it's in an array
1072
-        if ($args && !is_array($args)) {
1073
-            $args = array($args);
1074
-        }
1075
-
1076
-        // Over-rides default call method, adds signature check
1077
-        if (!$this->hasMethod($methodname)) {
1078
-            return new IXR_Error(-32601, 'server error. requested method "'.$this->message->methodName.'" not specified.');
1079
-        }
1080
-        $method = $this->callbacks[$methodname];
1081
-        $signature = $this->signatures[$methodname];
1082
-        $returnType = array_shift($signature);
1083
-
1084
-        // Check the number of arguments
1085
-        if (count($args) != count($signature)) {
1086
-            return new IXR_Error(-32602, 'server error. wrong number of method parameters');
1087
-        }
1088
-
1089
-        // Check the argument types
1090
-        $ok = true;
1091
-        $argsbackup = $args;
1092
-        for ($i = 0, $j = count($args); $i < $j; $i++) {
1093
-            $arg = array_shift($args);
1094
-            $type = array_shift($signature);
1095
-            switch ($type) {
1096
-                case 'int':
1097
-                case 'i4':
1098
-                    if (is_array($arg) || !is_int($arg)) {
1099
-                        $ok = false;
1100
-                    }
1101
-                    break;
1102
-                case 'base64':
1103
-                case 'string':
1104
-                    if (!is_string($arg)) {
1105
-                        $ok = false;
1106
-                    }
1107
-                    break;
1108
-                case 'boolean':
1109
-                    if ($arg !== false && $arg !== true) {
1110
-                        $ok = false;
1111
-                    }
1112
-                    break;
1113
-                case 'float':
1114
-                case 'double':
1115
-                    if (!is_float($arg)) {
1116
-                        $ok = false;
1117
-                    }
1118
-                    break;
1119
-                case 'date':
1120
-                case 'dateTime.iso8601':
1121
-                    if (!is_a($arg, 'IXR_Date')) {
1122
-                        $ok = false;
1123
-                    }
1124
-                    break;
1125
-            }
1126
-            if (!$ok) {
1127
-                return new IXR_Error(-32602, 'server error. invalid method parameters');
1128
-            }
1129
-        }
1130
-        // It passed the test - run the "real" method call
1131
-        return parent::call($methodname, $argsbackup);
1132
-    }
1133
-
1134
-    function methodSignature($method)
1135
-    {
1136
-        if (!$this->hasMethod($method)) {
1137
-            return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.');
1138
-        }
1139
-        // We should be returning an array of types
1140
-        $types = $this->signatures[$method];
1141
-        $return = array();
1142
-        foreach ($types as $type) {
1143
-            switch ($type) {
1144
-                case 'string':
1145
-                    $return[] = 'string';
1146
-                    break;
1147
-                case 'int':
1148
-                case 'i4':
1149
-                    $return[] = 42;
1150
-                    break;
1151
-                case 'double':
1152
-                    $return[] = 3.1415;
1153
-                    break;
1154
-                case 'dateTime.iso8601':
1155
-                    $return[] = new IXR_Date(time());
1156
-                    break;
1157
-                case 'boolean':
1158
-                    $return[] = true;
1159
-                    break;
1160
-                case 'base64':
1161
-                    $return[] = new IXR_Base64('base64');
1162
-                    break;
1163
-                case 'array':
1164
-                    $return[] = array('array');
1165
-                    break;
1166
-                case 'struct':
1167
-                    $return[] = array('struct' => 'struct');
1168
-                    break;
1169
-            }
1170
-        }
1171
-        return $return;
1172
-    }
1173
-
1174
-    function methodHelp($method)
1175
-    {
1176
-        return $this->help[$method];
1177
-    }
1062
+	function addCallback($method, $callback, $args, $help)
1063
+	{
1064
+		$this->callbacks[$method] = $callback;
1065
+		$this->signatures[$method] = $args;
1066
+		$this->help[$method] = $help;
1067
+	}
1068
+
1069
+	function call($methodname, $args)
1070
+	{
1071
+		// Make sure it's in an array
1072
+		if ($args && !is_array($args)) {
1073
+			$args = array($args);
1074
+		}
1075
+
1076
+		// Over-rides default call method, adds signature check
1077
+		if (!$this->hasMethod($methodname)) {
1078
+			return new IXR_Error(-32601, 'server error. requested method "'.$this->message->methodName.'" not specified.');
1079
+		}
1080
+		$method = $this->callbacks[$methodname];
1081
+		$signature = $this->signatures[$methodname];
1082
+		$returnType = array_shift($signature);
1083
+
1084
+		// Check the number of arguments
1085
+		if (count($args) != count($signature)) {
1086
+			return new IXR_Error(-32602, 'server error. wrong number of method parameters');
1087
+		}
1088
+
1089
+		// Check the argument types
1090
+		$ok = true;
1091
+		$argsbackup = $args;
1092
+		for ($i = 0, $j = count($args); $i < $j; $i++) {
1093
+			$arg = array_shift($args);
1094
+			$type = array_shift($signature);
1095
+			switch ($type) {
1096
+				case 'int':
1097
+				case 'i4':
1098
+					if (is_array($arg) || !is_int($arg)) {
1099
+						$ok = false;
1100
+					}
1101
+					break;
1102
+				case 'base64':
1103
+				case 'string':
1104
+					if (!is_string($arg)) {
1105
+						$ok = false;
1106
+					}
1107
+					break;
1108
+				case 'boolean':
1109
+					if ($arg !== false && $arg !== true) {
1110
+						$ok = false;
1111
+					}
1112
+					break;
1113
+				case 'float':
1114
+				case 'double':
1115
+					if (!is_float($arg)) {
1116
+						$ok = false;
1117
+					}
1118
+					break;
1119
+				case 'date':
1120
+				case 'dateTime.iso8601':
1121
+					if (!is_a($arg, 'IXR_Date')) {
1122
+						$ok = false;
1123
+					}
1124
+					break;
1125
+			}
1126
+			if (!$ok) {
1127
+				return new IXR_Error(-32602, 'server error. invalid method parameters');
1128
+			}
1129
+		}
1130
+		// It passed the test - run the "real" method call
1131
+		return parent::call($methodname, $argsbackup);
1132
+	}
1133
+
1134
+	function methodSignature($method)
1135
+	{
1136
+		if (!$this->hasMethod($method)) {
1137
+			return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.');
1138
+		}
1139
+		// We should be returning an array of types
1140
+		$types = $this->signatures[$method];
1141
+		$return = array();
1142
+		foreach ($types as $type) {
1143
+			switch ($type) {
1144
+				case 'string':
1145
+					$return[] = 'string';
1146
+					break;
1147
+				case 'int':
1148
+				case 'i4':
1149
+					$return[] = 42;
1150
+					break;
1151
+				case 'double':
1152
+					$return[] = 3.1415;
1153
+					break;
1154
+				case 'dateTime.iso8601':
1155
+					$return[] = new IXR_Date(time());
1156
+					break;
1157
+				case 'boolean':
1158
+					$return[] = true;
1159
+					break;
1160
+				case 'base64':
1161
+					$return[] = new IXR_Base64('base64');
1162
+					break;
1163
+				case 'array':
1164
+					$return[] = array('array');
1165
+					break;
1166
+				case 'struct':
1167
+					$return[] = array('struct' => 'struct');
1168
+					break;
1169
+			}
1170
+		}
1171
+		return $return;
1172
+	}
1173
+
1174
+	function methodHelp($method)
1175
+	{
1176
+		return $this->help[$method];
1177
+	}
1178 1178
 }
1179 1179
 
1180 1180
 /**
@@ -1185,16 +1185,16 @@  discard block
 block discarded – undo
1185 1185
  */
1186 1186
 class IXR_ClientMulticall extends IXR_Client
1187 1187
 {
1188
-    var $calls = array();
1188
+	var $calls = array();
1189 1189
 
1190 1190
 	/**
1191 1191
 	 * PHP5 constructor.
1192 1192
 	 */
1193
-    function __construct( $server, $path = false, $port = 80 )
1194
-    {
1195
-        parent::IXR_Client($server, $path, $port);
1196
-        $this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)';
1197
-    }
1193
+	function __construct( $server, $path = false, $port = 80 )
1194
+	{
1195
+		parent::IXR_Client($server, $path, $port);
1196
+		$this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)';
1197
+	}
1198 1198
 
1199 1199
 	/**
1200 1200
 	 * PHP4 constructor.
@@ -1203,20 +1203,20 @@  discard block
 block discarded – undo
1203 1203
 		self::__construct( $server, $path, $port );
1204 1204
 	}
1205 1205
 
1206
-    function addCall()
1207
-    {
1208
-        $args = func_get_args();
1209
-        $methodName = array_shift($args);
1210
-        $struct = array(
1211
-            'methodName' => $methodName,
1212
-            'params' => $args
1213
-        );
1214
-        $this->calls[] = $struct;
1215
-    }
1216
-
1217
-    function query()
1218
-    {
1219
-        // Prepare multicall, then call the parent::query() method
1220
-        return parent::query('system.multicall', $this->calls);
1221
-    }
1206
+	function addCall()
1207
+	{
1208
+		$args = func_get_args();
1209
+		$methodName = array_shift($args);
1210
+		$struct = array(
1211
+			'methodName' => $methodName,
1212
+			'params' => $args
1213
+		);
1214
+		$this->calls[] = $struct;
1215
+	}
1216
+
1217
+	function query()
1218
+	{
1219
+		// Prepare multicall, then call the parent::query() method
1220
+		return parent::query('system.multicall', $this->calls);
1221
+	}
1222 1222
 }
Please login to merge, or discard this patch.
Spacing   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
 	/**
53 53
 	 * PHP5 constructor.
54 54
 	 */
55
-	function __construct( $data, $type = false )
55
+	function __construct($data, $type = false)
56 56
     {
57 57
         $this->data = $data;
58
-        if (!$type) {
58
+        if ( ! $type) {
59 59
             $type = $this->calculateType();
60 60
         }
61 61
         $this->type = $type;
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
 	/**
76 76
 	 * PHP4 constructor.
77 77
 	 */
78
-	public function IXR_Value( $data, $type = false ) {
79
-		self::__construct( $data, $type );
78
+	public function IXR_Value($data, $type = false) {
79
+		self::__construct($data, $type);
80 80
 	}
81 81
 
82 82
     function calculateType()
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
             $this->data = get_object_vars($this->data);
105 105
             return 'struct';
106 106
         }
107
-        if (!is_array($this->data)) {
107
+        if ( ! is_array($this->data)) {
108 108
             return 'string';
109 109
         }
110 110
 
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
     {
169 169
         $expected = 0;
170 170
         foreach ($array as $key => $value) {
171
-            if ((string)$key !== (string)$expected) {
171
+            if ((string) $key !== (string) $expected) {
172 172
                 return true;
173 173
             }
174 174
             $expected++;
@@ -187,16 +187,16 @@  discard block
 block discarded – undo
187 187
 class IXR_Message
188 188
 {
189 189
     var $message;
190
-    var $messageType;  // methodCall / methodResponse / fault
190
+    var $messageType; // methodCall / methodResponse / fault
191 191
     var $faultCode;
192 192
     var $faultString;
193 193
     var $methodName;
194 194
     var $params;
195 195
 
196 196
     // Current variable stacks
197
-    var $_arraystructs = array();   // The stack used to keep track of the current array/struct
197
+    var $_arraystructs = array(); // The stack used to keep track of the current array/struct
198 198
     var $_arraystructstypes = array(); // Stack keeping track of if things are structs or array
199
-    var $_currentStructName = array();  // A stack as well
199
+    var $_currentStructName = array(); // A stack as well
200 200
     var $_param;
201 201
     var $_value;
202 202
     var $_currentTag;
@@ -207,47 +207,47 @@  discard block
 block discarded – undo
207 207
 	/**
208 208
 	 * PHP5 constructor.
209 209
 	 */
210
-    function __construct( $message )
210
+    function __construct($message)
211 211
     {
212
-        $this->message =& $message;
212
+        $this->message = & $message;
213 213
     }
214 214
 
215 215
 	/**
216 216
 	 * PHP4 constructor.
217 217
 	 */
218
-	public function IXR_Message( $message ) {
219
-		self::__construct( $message );
218
+	public function IXR_Message($message) {
219
+		self::__construct($message);
220 220
 	}
221 221
 
222 222
     function parse()
223 223
     {
224 224
         // first remove the XML declaration
225 225
         // merged from WP #10698 - this method avoids the RAM usage of preg_replace on very large messages
226
-        $header = preg_replace( '/<\?xml.*?\?'.'>/s', '', substr( $this->message, 0, 100 ), 1 );
227
-        $this->message = trim( substr_replace( $this->message, $header, 0, 100 ) );
228
-        if ( '' == $this->message ) {
226
+        $header = preg_replace('/<\?xml.*?\?'.'>/s', '', substr($this->message, 0, 100), 1);
227
+        $this->message = trim(substr_replace($this->message, $header, 0, 100));
228
+        if ('' == $this->message) {
229 229
             return false;
230 230
         }
231 231
 
232 232
         // Then remove the DOCTYPE
233
-        $header = preg_replace( '/^<!DOCTYPE[^>]*+>/i', '', substr( $this->message, 0, 200 ), 1 );
234
-        $this->message = trim( substr_replace( $this->message, $header, 0, 200 ) );
235
-        if ( '' == $this->message ) {
233
+        $header = preg_replace('/^<!DOCTYPE[^>]*+>/i', '', substr($this->message, 0, 200), 1);
234
+        $this->message = trim(substr_replace($this->message, $header, 0, 200));
235
+        if ('' == $this->message) {
236 236
             return false;
237 237
         }
238 238
 
239 239
         // Check that the root tag is valid
240
-        $root_tag = substr( $this->message, 0, strcspn( substr( $this->message, 0, 20 ), "> \t\r\n" ) );
241
-        if ( '<!DOCTYPE' === strtoupper( $root_tag ) ) {
240
+        $root_tag = substr($this->message, 0, strcspn(substr($this->message, 0, 20), "> \t\r\n"));
241
+        if ('<!DOCTYPE' === strtoupper($root_tag)) {
242 242
             return false;
243 243
         }
244
-        if ( ! in_array( $root_tag, array( '<methodCall', '<methodResponse', '<fault' ) ) ) {
244
+        if ( ! in_array($root_tag, array('<methodCall', '<methodResponse', '<fault'))) {
245 245
             return false;
246 246
         }
247 247
 
248 248
         // Bail if there are too many elements to parse
249 249
         $element_limit = 30000;
250
-        if ( function_exists( 'apply_filters' ) ) {
250
+        if (function_exists('apply_filters')) {
251 251
             /**
252 252
              * Filters the number of elements to parse in an XML-RPC response.
253 253
              *
@@ -255,9 +255,9 @@  discard block
 block discarded – undo
255 255
              *
256 256
              * @param int $element_limit Default elements limit.
257 257
              */
258
-            $element_limit = apply_filters( 'xmlrpc_element_limit', $element_limit );
258
+            $element_limit = apply_filters('xmlrpc_element_limit', $element_limit);
259 259
         }
260
-        if ( $element_limit && 2 * $element_limit < substr_count( $this->message, '<' ) ) {
260
+        if ($element_limit && 2 * $element_limit < substr_count($this->message, '<')) {
261 261
             return false;
262 262
         }
263 263
 
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
          *
280 280
          * @param int $chunk_size Chunk size to parse in bytes.
281 281
          */
282
-        $chunk_size = apply_filters( 'xmlrpc_chunk_parsing_size', $chunk_size );
282
+        $chunk_size = apply_filters('xmlrpc_chunk_parsing_size', $chunk_size);
283 283
 
284 284
         $final = false;
285 285
         do {
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
             }
289 289
             $part = substr($this->message, 0, $chunk_size);
290 290
             $this->message = substr($this->message, $chunk_size);
291
-            if (!xml_parse($this->_parser, $part, $final)) {
291
+            if ( ! xml_parse($this->_parser, $part, $final)) {
292 292
                 return false;
293 293
             }
294 294
             if ($final) {
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
     {
310 310
         $this->_currentTagContents = '';
311 311
         $this->currentTag = $tag;
312
-        switch($tag) {
312
+        switch ($tag) {
313 313
             case 'methodCall':
314 314
             case 'methodResponse':
315 315
             case 'fault':
@@ -335,18 +335,18 @@  discard block
 block discarded – undo
335 335
     function tag_close($parser, $tag)
336 336
     {
337 337
         $valueFlag = false;
338
-        switch($tag) {
338
+        switch ($tag) {
339 339
             case 'int':
340 340
             case 'i4':
341
-                $value = (int)trim($this->_currentTagContents);
341
+                $value = (int) trim($this->_currentTagContents);
342 342
                 $valueFlag = true;
343 343
                 break;
344 344
             case 'double':
345
-                $value = (double)trim($this->_currentTagContents);
345
+                $value = (double) trim($this->_currentTagContents);
346 346
                 $valueFlag = true;
347 347
                 break;
348 348
             case 'string':
349
-                $value = (string)trim($this->_currentTagContents);
349
+                $value = (string) trim($this->_currentTagContents);
350 350
                 $valueFlag = true;
351 351
                 break;
352 352
             case 'dateTime.iso8601':
@@ -356,12 +356,12 @@  discard block
 block discarded – undo
356 356
             case 'value':
357 357
                 // "If no type is indicated, the type is string."
358 358
                 if (trim($this->_currentTagContents) != '') {
359
-                    $value = (string)$this->_currentTagContents;
359
+                    $value = (string) $this->_currentTagContents;
360 360
                     $valueFlag = true;
361 361
                 }
362 362
                 break;
363 363
             case 'boolean':
364
-                $value = (boolean)trim($this->_currentTagContents);
364
+                $value = (boolean) trim($this->_currentTagContents);
365 365
                 $valueFlag = true;
366 366
                 break;
367 367
             case 'base64':
@@ -389,12 +389,12 @@  discard block
 block discarded – undo
389 389
         if ($valueFlag) {
390 390
             if (count($this->_arraystructs) > 0) {
391 391
                 // Add value to struct or array
392
-                if ($this->_arraystructstypes[count($this->_arraystructstypes)-1] == 'struct') {
392
+                if ($this->_arraystructstypes[count($this->_arraystructstypes) - 1] == 'struct') {
393 393
                     // Add to struct
394
-                    $this->_arraystructs[count($this->_arraystructs)-1][$this->_currentStructName[count($this->_currentStructName)-1]] = $value;
394
+                    $this->_arraystructs[count($this->_arraystructs) - 1][$this->_currentStructName[count($this->_currentStructName) - 1]] = $value;
395 395
                 } else {
396 396
                     // Add to array
397
-                    $this->_arraystructs[count($this->_arraystructs)-1][] = $value;
397
+                    $this->_arraystructs[count($this->_arraystructs) - 1][] = $value;
398 398
                 }
399 399
             } else {
400 400
                 // Just add as a parameter
@@ -421,14 +421,14 @@  discard block
 block discarded – undo
421 421
 	/**
422 422
 	 * PHP5 constructor.
423 423
 	 */
424
-    function __construct( $callbacks = false, $data = false, $wait = false )
424
+    function __construct($callbacks = false, $data = false, $wait = false)
425 425
     {
426 426
         $this->setCapabilities();
427 427
         if ($callbacks) {
428 428
             $this->callbacks = $callbacks;
429 429
         }
430 430
         $this->setCallbacks();
431
-        if (!$wait) {
431
+        if ( ! $wait) {
432 432
             $this->serve($data);
433 433
         }
434 434
     }
@@ -436,17 +436,17 @@  discard block
 block discarded – undo
436 436
 	/**
437 437
 	 * PHP4 constructor.
438 438
 	 */
439
-	public function IXR_Server( $callbacks = false, $data = false, $wait = false ) {
440
-		self::__construct( $callbacks, $data, $wait );
439
+	public function IXR_Server($callbacks = false, $data = false, $wait = false) {
440
+		self::__construct($callbacks, $data, $wait);
441 441
 	}
442 442
 
443 443
     function serve($data = false)
444 444
     {
445
-        if (!$data) {
445
+        if ( ! $data) {
446 446
             if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] !== 'POST') {
447
-                if ( function_exists( 'status_header' ) ) {
448
-                    status_header( 405 ); // WP #20986
449
-                    header( 'Allow: POST' );
447
+                if (function_exists('status_header')) {
448
+                    status_header(405); // WP #20986
449
+                    header('Allow: POST');
450 450
                 }
451 451
                 header('Content-Type: text/plain'); // merged from WP #9093
452 452
                 die('XML-RPC server accepts POST requests only.');
@@ -457,11 +457,11 @@  discard block
 block discarded – undo
457 457
                 // workaround for a bug in PHP 5.2.2 - http://bugs.php.net/bug.php?id=41293
458 458
                 $data = file_get_contents('php://input');
459 459
             } else {
460
-                $data =& $HTTP_RAW_POST_DATA;
460
+                $data = & $HTTP_RAW_POST_DATA;
461 461
             }
462 462
         }
463 463
         $this->message = new IXR_Message($data);
464
-        if (!$this->message->parse()) {
464
+        if ( ! $this->message->parse()) {
465 465
             $this->error(-32700, 'parse error. not well formed');
466 466
         }
467 467
         if ($this->message->messageType != 'methodCall') {
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 
498 498
     function call($methodname, $args)
499 499
     {
500
-        if (!$this->hasMethod($methodname)) {
500
+        if ( ! $this->hasMethod($methodname)) {
501 501
             return new IXR_Error(-32601, 'server error. requested method '.$methodname.' does not exist.');
502 502
         }
503 503
         $method = $this->callbacks[$methodname];
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
         if (is_string($method) && substr($method, 0, 5) == 'this:') {
513 513
             // It's a class method - check it exists
514 514
             $method = substr($method, 5);
515
-            if (!method_exists($this, $method)) {
515
+            if ( ! method_exists($this, $method)) {
516 516
                 return new IXR_Error(-32601, 'server error. requested class method "'.$method.'" does not exist.');
517 517
             }
518 518
 
@@ -521,10 +521,10 @@  discard block
 block discarded – undo
521 521
         } else {
522 522
             // It's a function - does it exist?
523 523
             if (is_array($method)) {
524
-                if (!is_callable(array($method[0], $method[1]))) {
524
+                if ( ! is_callable(array($method[0], $method[1]))) {
525 525
                     return new IXR_Error(-32601, 'server error. requested object method "'.$method[1].'" does not exist.');
526 526
                 }
527
-            } else if (!function_exists($method)) {
527
+            } else if ( ! function_exists($method)) {
528 528
                 return new IXR_Error(-32601, 'server error. requested function "'.$method.'" does not exist.');
529 529
             }
530 530
 
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
     function error($error, $message = false)
538 538
     {
539 539
         // Accepts either an error object or an error code and message
540
-        if ($message && !is_object($error)) {
540
+        if ($message && ! is_object($error)) {
541 541
             $error = new IXR_Error($error, $message);
542 542
         }
543 543
         $this->output($error->getXml());
@@ -667,8 +667,8 @@  discard block
 block discarded – undo
667 667
 	/**
668 668
 	 * PHP4 constructor.
669 669
 	 */
670
-	public function IXR_Request( $method, $args ) {
671
-		self::__construct( $method, $args );
670
+	public function IXR_Request($method, $args) {
671
+		self::__construct($method, $args);
672 672
 	}
673 673
 
674 674
     function getLength()
@@ -707,9 +707,9 @@  discard block
 block discarded – undo
707 707
 	/**
708 708
 	 * PHP5 constructor.
709 709
 	 */
710
-    function __construct( $server, $path = false, $port = 80, $timeout = 15 )
710
+    function __construct($server, $path = false, $port = 80, $timeout = 15)
711 711
     {
712
-        if (!$path) {
712
+        if ( ! $path) {
713 713
             // Assume we have been given a URL instead
714 714
             $bits = parse_url($server);
715 715
             $this->server = $bits['host'];
@@ -717,12 +717,12 @@  discard block
 block discarded – undo
717 717
             $this->path = isset($bits['path']) ? $bits['path'] : '/';
718 718
 
719 719
             // Make absolutely sure we have a path
720
-            if (!$this->path) {
720
+            if ( ! $this->path) {
721 721
                 $this->path = '/';
722 722
             }
723 723
 
724
-            if ( ! empty( $bits['query'] ) ) {
725
-                $this->path .= '?' . $bits['query'];
724
+            if ( ! empty($bits['query'])) {
725
+                $this->path .= '?'.$bits['query'];
726 726
             }
727 727
         } else {
728 728
             $this->server = $server;
@@ -736,8 +736,8 @@  discard block
 block discarded – undo
736 736
 	/**
737 737
 	 * PHP4 constructor.
738 738
 	 */
739
-	public function IXR_Client( $server, $path = false, $port = 80, $timeout = 15 ) {
740
-		self::__construct( $server, $path, $port, $timeout );
739
+	public function IXR_Client($server, $path = false, $port = 80, $timeout = 15) {
740
+		self::__construct($server, $path, $port, $timeout);
741 741
 	}
742 742
 
743 743
     function query()
@@ -748,15 +748,15 @@  discard block
 block discarded – undo
748 748
         $length = $request->getLength();
749 749
         $xml = $request->getXml();
750 750
         $r = "\r\n";
751
-        $request  = "POST {$this->path} HTTP/1.0$r";
751
+        $request = "POST {$this->path} HTTP/1.0$r";
752 752
 
753 753
         // Merged from WP #8145 - allow custom headers
754 754
         $this->headers['Host']          = $this->server;
755 755
         $this->headers['Content-Type']  = 'text/xml';
756 756
         $this->headers['User-Agent']    = $this->useragent;
757
-        $this->headers['Content-Length']= $length;
757
+        $this->headers['Content-Length'] = $length;
758 758
 
759
-        foreach( $this->headers as $header => $value ) {
759
+        foreach ($this->headers as $header => $value) {
760 760
             $request .= "{$header}: {$value}{$r}";
761 761
         }
762 762
         $request .= $r;
@@ -773,7 +773,7 @@  discard block
 block discarded – undo
773 773
         } else {
774 774
             $fp = @fsockopen($this->server, $this->port, $errno, $errstr);
775 775
         }
776
-        if (!$fp) {
776
+        if ( ! $fp) {
777 777
             $this->error = new IXR_Error(-32300, 'transport error - could not open socket');
778 778
             return false;
779 779
         }
@@ -782,9 +782,9 @@  discard block
 block discarded – undo
782 782
         $debugContents = '';
783 783
         $gotFirstLine = false;
784 784
         $gettingHeaders = true;
785
-        while (!feof($fp)) {
785
+        while ( ! feof($fp)) {
786 786
             $line = fgets($fp, 4096);
787
-            if (!$gotFirstLine) {
787
+            if ( ! $gotFirstLine) {
788 788
                 // Check line for '200'
789 789
                 if (strstr($line, '200') === false) {
790 790
                     $this->error = new IXR_Error(-32300, 'transport error - HTTP status code was not 200');
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
             if (trim($line) == '') {
796 796
                 $gettingHeaders = false;
797 797
             }
798
-            if (!$gettingHeaders) {
798
+            if ( ! $gettingHeaders) {
799 799
             	// merged from WP #12559 - remove trim
800 800
                 $contents .= $line;
801 801
             }
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
 
810 810
         // Now parse what we've got back
811 811
         $this->message = new IXR_Message($contents);
812
-        if (!$this->message->parse()) {
812
+        if ( ! $this->message->parse()) {
813 813
             // XML error
814 814
             $this->error = new IXR_Error(-32700, 'parse error. not well formed');
815 815
             return false;
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
 	/**
863 863
 	 * PHP5 constructor.
864 864
 	 */
865
-    function __construct( $code, $message )
865
+    function __construct($code, $message)
866 866
     {
867 867
         $this->code = $code;
868 868
         $this->message = htmlspecialchars($message);
@@ -871,8 +871,8 @@  discard block
 block discarded – undo
871 871
 	/**
872 872
 	 * PHP4 constructor.
873 873
 	 */
874
-	public function IXR_Error( $code, $message ) {
875
-		self::__construct( $code, $message );
874
+	public function IXR_Error($code, $message) {
875
+		self::__construct($code, $message);
876 876
 	}
877 877
 
878 878
     function getXml()
@@ -918,7 +918,7 @@  discard block
 block discarded – undo
918 918
 	/**
919 919
 	 * PHP5 constructor.
920 920
 	 */
921
-    function __construct( $time )
921
+    function __construct($time)
922 922
     {
923 923
         // $time can be a PHP timestamp or an ISO one
924 924
         if (is_numeric($time)) {
@@ -931,8 +931,8 @@  discard block
 block discarded – undo
931 931
 	/**
932 932
 	 * PHP4 constructor.
933 933
 	 */
934
-	public function IXR_Date( $time ) {
935
-		self::__construct( $time );
934
+	public function IXR_Date($time) {
935
+		self::__construct($time);
936 936
 	}
937 937
 
938 938
     function parseTimestamp($timestamp)
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
 	/**
987 987
 	 * PHP5 constructor.
988 988
 	 */
989
-    function __construct( $data )
989
+    function __construct($data)
990 990
     {
991 991
         $this->data = $data;
992 992
     }
@@ -994,8 +994,8 @@  discard block
 block discarded – undo
994 994
 	/**
995 995
 	 * PHP4 constructor.
996 996
 	 */
997
-	public function IXR_Base64( $data ) {
998
-		self::__construct( $data );
997
+	public function IXR_Base64($data) {
998
+		self::__construct($data);
999 999
 	}
1000 1000
 
1001 1001
     function getXml()
@@ -1069,12 +1069,12 @@  discard block
 block discarded – undo
1069 1069
     function call($methodname, $args)
1070 1070
     {
1071 1071
         // Make sure it's in an array
1072
-        if ($args && !is_array($args)) {
1072
+        if ($args && ! is_array($args)) {
1073 1073
             $args = array($args);
1074 1074
         }
1075 1075
 
1076 1076
         // Over-rides default call method, adds signature check
1077
-        if (!$this->hasMethod($methodname)) {
1077
+        if ( ! $this->hasMethod($methodname)) {
1078 1078
             return new IXR_Error(-32601, 'server error. requested method "'.$this->message->methodName.'" not specified.');
1079 1079
         }
1080 1080
         $method = $this->callbacks[$methodname];
@@ -1095,13 +1095,13 @@  discard block
 block discarded – undo
1095 1095
             switch ($type) {
1096 1096
                 case 'int':
1097 1097
                 case 'i4':
1098
-                    if (is_array($arg) || !is_int($arg)) {
1098
+                    if (is_array($arg) || ! is_int($arg)) {
1099 1099
                         $ok = false;
1100 1100
                     }
1101 1101
                     break;
1102 1102
                 case 'base64':
1103 1103
                 case 'string':
1104
-                    if (!is_string($arg)) {
1104
+                    if ( ! is_string($arg)) {
1105 1105
                         $ok = false;
1106 1106
                     }
1107 1107
                     break;
@@ -1112,18 +1112,18 @@  discard block
 block discarded – undo
1112 1112
                     break;
1113 1113
                 case 'float':
1114 1114
                 case 'double':
1115
-                    if (!is_float($arg)) {
1115
+                    if ( ! is_float($arg)) {
1116 1116
                         $ok = false;
1117 1117
                     }
1118 1118
                     break;
1119 1119
                 case 'date':
1120 1120
                 case 'dateTime.iso8601':
1121
-                    if (!is_a($arg, 'IXR_Date')) {
1121
+                    if ( ! is_a($arg, 'IXR_Date')) {
1122 1122
                         $ok = false;
1123 1123
                     }
1124 1124
                     break;
1125 1125
             }
1126
-            if (!$ok) {
1126
+            if ( ! $ok) {
1127 1127
                 return new IXR_Error(-32602, 'server error. invalid method parameters');
1128 1128
             }
1129 1129
         }
@@ -1133,7 +1133,7 @@  discard block
 block discarded – undo
1133 1133
 
1134 1134
     function methodSignature($method)
1135 1135
     {
1136
-        if (!$this->hasMethod($method)) {
1136
+        if ( ! $this->hasMethod($method)) {
1137 1137
             return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.');
1138 1138
         }
1139 1139
         // We should be returning an array of types
@@ -1190,7 +1190,7 @@  discard block
 block discarded – undo
1190 1190
 	/**
1191 1191
 	 * PHP5 constructor.
1192 1192
 	 */
1193
-    function __construct( $server, $path = false, $port = 80 )
1193
+    function __construct($server, $path = false, $port = 80)
1194 1194
     {
1195 1195
         parent::IXR_Client($server, $path, $port);
1196 1196
         $this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)';
@@ -1199,8 +1199,8 @@  discard block
 block discarded – undo
1199 1199
 	/**
1200 1200
 	 * PHP4 constructor.
1201 1201
 	 */
1202
-	public function IXR_ClientMulticall( $server, $path = false, $port = 80 ) {
1203
-		self::__construct( $server, $path, $port );
1202
+	public function IXR_ClientMulticall($server, $path = false, $port = 80) {
1203
+		self::__construct($server, $path, $port);
1204 1204
 	}
1205 1205
 
1206 1206
     function addCall()
Please login to merge, or discard this patch.