Passed
Push — main ( 16d49b...d78e29 )
by TARIQ
111:03
created
brighty/wp-admin/post.php 1 patch
Switch Indentation   +263 added lines, -263 removed lines patch added patch discarded remove patch
@@ -70,108 +70,108 @@  discard block
 block discarded – undo
70 70
 }
71 71
 
72 72
 switch ( $action ) {
73
-	case 'post-quickdraft-save':
74
-		// Check nonce and capabilities.
75
-		$nonce     = $_REQUEST['_wpnonce'];
76
-		$error_msg = false;
77
-
78
-		// For output of the Quick Draft dashboard widget.
79
-		require_once ABSPATH . 'wp-admin/includes/dashboard.php';
80
-
81
-		if ( ! wp_verify_nonce( $nonce, 'add-post' ) ) {
82
-			$error_msg = __( 'Unable to submit this form, please refresh and try again.' );
83
-		}
84
-
85
-		if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) {
86
-			exit;
87
-		}
88
-
89
-		if ( $error_msg ) {
90
-			return wp_dashboard_quick_press( $error_msg );
91
-		}
92
-
93
-		$post = get_post( $_REQUEST['post_ID'] );
94
-		check_admin_referer( 'add-' . $post->post_type );
95
-
96
-		$_POST['comment_status'] = get_default_comment_status( $post->post_type );
97
-		$_POST['ping_status']    = get_default_comment_status( $post->post_type, 'pingback' );
98
-
99
-		// Wrap Quick Draft content in the Paragraph block.
100
-		if ( false === strpos( $_POST['content'], '<!-- wp:paragraph -->' ) ) {
101
-			$_POST['content'] = sprintf(
102
-				'<!-- wp:paragraph -->%s<!-- /wp:paragraph -->',
103
-				str_replace( array( "\r\n", "\r", "\n" ), '<br />', $_POST['content'] )
104
-			);
105
-		}
106
-
107
-		edit_post();
108
-		wp_dashboard_quick_press();
109
-		exit;
110
-
111
-	case 'postajaxpost':
112
-	case 'post':
113
-		check_admin_referer( 'add-' . $post_type );
114
-		$post_id = 'postajaxpost' === $action ? edit_post() : write_post();
115
-		redirect_post( $post_id );
116
-		exit;
117
-
118
-	case 'edit':
119
-		$editing = true;
120
-
121
-		if ( empty( $post_id ) ) {
122
-			wp_redirect( admin_url( 'post.php' ) );
123
-			exit;
124
-		}
125
-
126
-		if ( ! $post ) {
127
-			wp_die( __( 'You attempted to edit an item that does not exist. Perhaps it was deleted?' ) );
128
-		}
129
-
130
-		if ( ! $post_type_object ) {
131
-			wp_die( __( 'Invalid post type.' ) );
132
-		}
133
-
134
-		if ( ! in_array( $typenow, get_post_types( array( 'show_ui' => true ) ), true ) ) {
135
-			wp_die( __( 'Sorry, you are not allowed to edit posts in this post type.' ) );
136
-		}
137
-
138
-		if ( ! current_user_can( 'edit_post', $post_id ) ) {
139
-			wp_die( __( 'Sorry, you are not allowed to edit this item.' ) );
140
-		}
141
-
142
-		if ( 'trash' === $post->post_status ) {
143
-			wp_die( __( 'You cannot edit this item because it is in the Trash. Please restore it and try again.' ) );
144
-		}
145
-
146
-		if ( ! empty( $_GET['get-post-lock'] ) ) {
147
-			check_admin_referer( 'lock-post_' . $post_id );
148
-			wp_set_post_lock( $post_id );
149
-			wp_redirect( get_edit_post_link( $post_id, 'url' ) );
150
-			exit;
151
-		}
152
-
153
-		$post_type = $post->post_type;
154
-		if ( 'post' === $post_type ) {
155
-			$parent_file   = 'edit.php';
156
-			$submenu_file  = 'edit.php';
157
-			$post_new_file = 'post-new.php';
158
-		} elseif ( 'attachment' === $post_type ) {
159
-			$parent_file   = 'upload.php';
160
-			$submenu_file  = 'upload.php';
161
-			$post_new_file = 'media-new.php';
162
-		} else {
163
-			if ( isset( $post_type_object ) && $post_type_object->show_in_menu && true !== $post_type_object->show_in_menu ) {
164
-				$parent_file = $post_type_object->show_in_menu;
165
-			} else {
166
-				$parent_file = "edit.php?post_type=$post_type";
167
-			}
168
-			$submenu_file  = "edit.php?post_type=$post_type";
169
-			$post_new_file = "post-new.php?post_type=$post_type";
170
-		}
171
-
172
-		$title = $post_type_object->labels->edit_item;
173
-
174
-		/**
73
+	    case 'post-quickdraft-save':
74
+		    // Check nonce and capabilities.
75
+		    $nonce     = $_REQUEST['_wpnonce'];
76
+		    $error_msg = false;
77
+
78
+		    // For output of the Quick Draft dashboard widget.
79
+		    require_once ABSPATH . 'wp-admin/includes/dashboard.php';
80
+
81
+		    if ( ! wp_verify_nonce( $nonce, 'add-post' ) ) {
82
+			    $error_msg = __( 'Unable to submit this form, please refresh and try again.' );
83
+		    }
84
+
85
+		    if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) {
86
+			    exit;
87
+		    }
88
+
89
+		    if ( $error_msg ) {
90
+			    return wp_dashboard_quick_press( $error_msg );
91
+		    }
92
+
93
+		    $post = get_post( $_REQUEST['post_ID'] );
94
+		    check_admin_referer( 'add-' . $post->post_type );
95
+
96
+		    $_POST['comment_status'] = get_default_comment_status( $post->post_type );
97
+		    $_POST['ping_status']    = get_default_comment_status( $post->post_type, 'pingback' );
98
+
99
+		    // Wrap Quick Draft content in the Paragraph block.
100
+		    if ( false === strpos( $_POST['content'], '<!-- wp:paragraph -->' ) ) {
101
+			    $_POST['content'] = sprintf(
102
+				    '<!-- wp:paragraph -->%s<!-- /wp:paragraph -->',
103
+				    str_replace( array( "\r\n", "\r", "\n" ), '<br />', $_POST['content'] )
104
+			    );
105
+		    }
106
+
107
+		    edit_post();
108
+		    wp_dashboard_quick_press();
109
+		    exit;
110
+
111
+	    case 'postajaxpost':
112
+	    case 'post':
113
+		    check_admin_referer( 'add-' . $post_type );
114
+		    $post_id = 'postajaxpost' === $action ? edit_post() : write_post();
115
+		    redirect_post( $post_id );
116
+		    exit;
117
+
118
+	    case 'edit':
119
+		    $editing = true;
120
+
121
+		    if ( empty( $post_id ) ) {
122
+			    wp_redirect( admin_url( 'post.php' ) );
123
+			    exit;
124
+		    }
125
+
126
+		    if ( ! $post ) {
127
+			    wp_die( __( 'You attempted to edit an item that does not exist. Perhaps it was deleted?' ) );
128
+		    }
129
+
130
+		    if ( ! $post_type_object ) {
131
+			    wp_die( __( 'Invalid post type.' ) );
132
+		    }
133
+
134
+		    if ( ! in_array( $typenow, get_post_types( array( 'show_ui' => true ) ), true ) ) {
135
+			    wp_die( __( 'Sorry, you are not allowed to edit posts in this post type.' ) );
136
+		    }
137
+
138
+		    if ( ! current_user_can( 'edit_post', $post_id ) ) {
139
+			    wp_die( __( 'Sorry, you are not allowed to edit this item.' ) );
140
+		    }
141
+
142
+		    if ( 'trash' === $post->post_status ) {
143
+			    wp_die( __( 'You cannot edit this item because it is in the Trash. Please restore it and try again.' ) );
144
+		    }
145
+
146
+		    if ( ! empty( $_GET['get-post-lock'] ) ) {
147
+			    check_admin_referer( 'lock-post_' . $post_id );
148
+			    wp_set_post_lock( $post_id );
149
+			    wp_redirect( get_edit_post_link( $post_id, 'url' ) );
150
+			    exit;
151
+		    }
152
+
153
+		    $post_type = $post->post_type;
154
+		    if ( 'post' === $post_type ) {
155
+			    $parent_file   = 'edit.php';
156
+			    $submenu_file  = 'edit.php';
157
+			    $post_new_file = 'post-new.php';
158
+		    } elseif ( 'attachment' === $post_type ) {
159
+			    $parent_file   = 'upload.php';
160
+			    $submenu_file  = 'upload.php';
161
+			    $post_new_file = 'media-new.php';
162
+		    } else {
163
+			    if ( isset( $post_type_object ) && $post_type_object->show_in_menu && true !== $post_type_object->show_in_menu ) {
164
+				    $parent_file = $post_type_object->show_in_menu;
165
+			    } else {
166
+				    $parent_file = "edit.php?post_type=$post_type";
167
+			    }
168
+			    $submenu_file  = "edit.php?post_type=$post_type";
169
+			    $post_new_file = "post-new.php?post_type=$post_type";
170
+		    }
171
+
172
+		    $title = $post_type_object->labels->edit_item;
173
+
174
+		    /**
175 175
 		 * Allows replacement of the editor.
176 176
 		 *
177 177
 		 * @since 4.9.0
@@ -179,179 +179,179 @@  discard block
 block discarded – undo
179 179
 		 * @param bool    $replace Whether to replace the editor. Default false.
180 180
 		 * @param WP_Post $post    Post object.
181 181
 		 */
182
-		if ( true === apply_filters( 'replace_editor', false, $post ) ) {
183
-			break;
184
-		}
185
-
186
-		if ( use_block_editor_for_post( $post ) ) {
187
-			require ABSPATH . 'wp-admin/edit-form-blocks.php';
188
-			break;
189
-		}
190
-
191
-		if ( ! wp_check_post_lock( $post->ID ) ) {
192
-			$active_post_lock = wp_set_post_lock( $post->ID );
193
-
194
-			if ( 'attachment' !== $post_type ) {
195
-				wp_enqueue_script( 'autosave' );
196
-			}
197
-		}
198
-
199
-		$post = get_post( $post_id, OBJECT, 'edit' );
200
-
201
-		if ( post_type_supports( $post_type, 'comments' ) ) {
202
-			wp_enqueue_script( 'admin-comments' );
203
-			enqueue_comment_hotkeys_js();
204
-		}
205
-
206
-		require ABSPATH . 'wp-admin/edit-form-advanced.php';
182
+		    if ( true === apply_filters( 'replace_editor', false, $post ) ) {
183
+			    break;
184
+		    }
207 185
 
208
-		break;
186
+		    if ( use_block_editor_for_post( $post ) ) {
187
+			    require ABSPATH . 'wp-admin/edit-form-blocks.php';
188
+			    break;
189
+		    }
209 190
 
210
-	case 'editattachment':
211
-		check_admin_referer( 'update-post_' . $post_id );
191
+		    if ( ! wp_check_post_lock( $post->ID ) ) {
192
+			    $active_post_lock = wp_set_post_lock( $post->ID );
212 193
 
213
-		// Don't let these be changed.
214
-		unset( $_POST['guid'] );
215
-		$_POST['post_type'] = 'attachment';
194
+			    if ( 'attachment' !== $post_type ) {
195
+				    wp_enqueue_script( 'autosave' );
196
+			    }
197
+		    }
216 198
 
217
-		// Update the thumbnail filename.
218
-		$newmeta          = wp_get_attachment_metadata( $post_id, true );
219
-		$newmeta['thumb'] = wp_basename( $_POST['thumb'] );
199
+		    $post = get_post( $post_id, OBJECT, 'edit' );
220 200
 
221
-		wp_update_attachment_metadata( $post_id, $newmeta );
201
+		    if ( post_type_supports( $post_type, 'comments' ) ) {
202
+			    wp_enqueue_script( 'admin-comments' );
203
+			    enqueue_comment_hotkeys_js();
204
+		    }
205
+
206
+		    require ABSPATH . 'wp-admin/edit-form-advanced.php';
222 207
 
223
-		// Intentional fall-through to trigger the edit_post() call.
224
-	case 'editpost':
225
-		check_admin_referer( 'update-post_' . $post_id );
208
+		    break;
209
+
210
+	    case 'editattachment':
211
+		    check_admin_referer( 'update-post_' . $post_id );
226 212
 
227
-		$post_id = edit_post();
213
+		    // Don't let these be changed.
214
+		    unset( $_POST['guid'] );
215
+		    $_POST['post_type'] = 'attachment';
228 216
 
229
-		// Session cookie flag that the post was saved.
230
-		if ( isset( $_COOKIE['wp-saving-post'] ) && $_COOKIE['wp-saving-post'] === $post_id . '-check' ) {
231
-			setcookie( 'wp-saving-post', $post_id . '-saved', time() + DAY_IN_SECONDS, ADMIN_COOKIE_PATH, COOKIE_DOMAIN, is_ssl() );
232
-		}
233
-
234
-		redirect_post( $post_id ); // Send user on their way while we keep working.
217
+		    // Update the thumbnail filename.
218
+		    $newmeta          = wp_get_attachment_metadata( $post_id, true );
219
+		    $newmeta['thumb'] = wp_basename( $_POST['thumb'] );
235 220
 
236
-		exit;
221
+		    wp_update_attachment_metadata( $post_id, $newmeta );
222
+
223
+		    // Intentional fall-through to trigger the edit_post() call.
224
+	    case 'editpost':
225
+		    check_admin_referer( 'update-post_' . $post_id );
226
+
227
+		    $post_id = edit_post();
228
+
229
+		    // Session cookie flag that the post was saved.
230
+		    if ( isset( $_COOKIE['wp-saving-post'] ) && $_COOKIE['wp-saving-post'] === $post_id . '-check' ) {
231
+			    setcookie( 'wp-saving-post', $post_id . '-saved', time() + DAY_IN_SECONDS, ADMIN_COOKIE_PATH, COOKIE_DOMAIN, is_ssl() );
232
+		    }
233
+
234
+		    redirect_post( $post_id ); // Send user on their way while we keep working.
235
+
236
+		    exit;
237
+
238
+	    case 'trash':
239
+		    check_admin_referer( 'trash-post_' . $post_id );
237 240
 
238
-	case 'trash':
239
-		check_admin_referer( 'trash-post_' . $post_id );
241
+		    if ( ! $post ) {
242
+			    wp_die( __( 'The item you are trying to move to the Trash no longer exists.' ) );
243
+		    }
240 244
 
241
-		if ( ! $post ) {
242
-			wp_die( __( 'The item you are trying to move to the Trash no longer exists.' ) );
243
-		}
244
-
245
-		if ( ! $post_type_object ) {
246
-			wp_die( __( 'Invalid post type.' ) );
247
-		}
245
+		    if ( ! $post_type_object ) {
246
+			    wp_die( __( 'Invalid post type.' ) );
247
+		    }
248
+
249
+		    if ( ! current_user_can( 'delete_post', $post_id ) ) {
250
+			    wp_die( __( 'Sorry, you are not allowed to move this item to the Trash.' ) );
251
+		    }
248 252
 
249
-		if ( ! current_user_can( 'delete_post', $post_id ) ) {
250
-			wp_die( __( 'Sorry, you are not allowed to move this item to the Trash.' ) );
251
-		}
252
-
253
-		$user_id = wp_check_post_lock( $post_id );
254
-		if ( $user_id ) {
255
-			$user = get_userdata( $user_id );
256
-			/* translators: %s: User's display name. */
257
-			wp_die( sprintf( __( 'You cannot move this item to the Trash. %s is currently editing.' ), $user->display_name ) );
258
-		}
259
-
260
-		if ( ! wp_trash_post( $post_id ) ) {
261
-			wp_die( __( 'Error in moving the item to Trash.' ) );
262
-		}
263
-
264
-		wp_redirect(
265
-			add_query_arg(
266
-				array(
267
-					'trashed' => 1,
268
-					'ids'     => $post_id,
269
-				),
270
-				$sendback
271
-			)
272
-		);
273
-		exit;
274
-
275
-	case 'untrash':
276
-		check_admin_referer( 'untrash-post_' . $post_id );
277
-
278
-		if ( ! $post ) {
279
-			wp_die( __( 'The item you are trying to restore from the Trash no longer exists.' ) );
280
-		}
281
-
282
-		if ( ! $post_type_object ) {
283
-			wp_die( __( 'Invalid post type.' ) );
284
-		}
253
+		    $user_id = wp_check_post_lock( $post_id );
254
+		    if ( $user_id ) {
255
+			    $user = get_userdata( $user_id );
256
+			    /* translators: %s: User's display name. */
257
+			    wp_die( sprintf( __( 'You cannot move this item to the Trash. %s is currently editing.' ), $user->display_name ) );
258
+		    }
259
+
260
+		    if ( ! wp_trash_post( $post_id ) ) {
261
+			    wp_die( __( 'Error in moving the item to Trash.' ) );
262
+		    }
263
+
264
+		    wp_redirect(
265
+			    add_query_arg(
266
+				    array(
267
+					    'trashed' => 1,
268
+					    'ids'     => $post_id,
269
+				    ),
270
+				    $sendback
271
+			    )
272
+		    );
273
+		    exit;
274
+
275
+	    case 'untrash':
276
+		    check_admin_referer( 'untrash-post_' . $post_id );
277
+
278
+		    if ( ! $post ) {
279
+			    wp_die( __( 'The item you are trying to restore from the Trash no longer exists.' ) );
280
+		    }
281
+
282
+		    if ( ! $post_type_object ) {
283
+			    wp_die( __( 'Invalid post type.' ) );
284
+		    }
285 285
 
286
-		if ( ! current_user_can( 'delete_post', $post_id ) ) {
287
-			wp_die( __( 'Sorry, you are not allowed to restore this item from the Trash.' ) );
288
-		}
289
-
290
-		if ( ! wp_untrash_post( $post_id ) ) {
291
-			wp_die( __( 'Error in restoring the item from Trash.' ) );
292
-		}
293
-
294
-		$sendback = add_query_arg(
295
-			array(
296
-				'untrashed' => 1,
297
-				'ids'       => $post_id,
298
-			),
299
-			$sendback
300
-		);
301
-		wp_redirect( $sendback );
302
-		exit;
303
-
304
-	case 'delete':
305
-		check_admin_referer( 'delete-post_' . $post_id );
306
-
307
-		if ( ! $post ) {
308
-			wp_die( __( 'This item has already been deleted.' ) );
309
-		}
310
-
311
-		if ( ! $post_type_object ) {
312
-			wp_die( __( 'Invalid post type.' ) );
313
-		}
314
-
315
-		if ( ! current_user_can( 'delete_post', $post_id ) ) {
316
-			wp_die( __( 'Sorry, you are not allowed to delete this item.' ) );
317
-		}
318
-
319
-		if ( 'attachment' === $post->post_type ) {
320
-			$force = ( ! MEDIA_TRASH );
321
-			if ( ! wp_delete_attachment( $post_id, $force ) ) {
322
-				wp_die( __( 'Error in deleting the attachment.' ) );
323
-			}
324
-		} else {
325
-			if ( ! wp_delete_post( $post_id, true ) ) {
326
-				wp_die( __( 'Error in deleting the item.' ) );
327
-			}
328
-		}
329
-
330
-		wp_redirect( add_query_arg( 'deleted', 1, $sendback ) );
331
-		exit;
332
-
333
-	case 'preview':
334
-		check_admin_referer( 'update-post_' . $post_id );
335
-
336
-		$url = post_preview();
337
-
338
-		wp_redirect( $url );
339
-		exit;
340
-
341
-	case 'toggle-custom-fields':
342
-		check_admin_referer( 'toggle-custom-fields', 'toggle-custom-fields-nonce' );
343
-
344
-		$current_user_id = get_current_user_id();
345
-		if ( $current_user_id ) {
346
-			$enable_custom_fields = (bool) get_user_meta( $current_user_id, 'enable_custom_fields', true );
347
-			update_user_meta( $current_user_id, 'enable_custom_fields', ! $enable_custom_fields );
348
-		}
286
+		    if ( ! current_user_can( 'delete_post', $post_id ) ) {
287
+			    wp_die( __( 'Sorry, you are not allowed to restore this item from the Trash.' ) );
288
+		    }
349 289
 
350
-		wp_safe_redirect( wp_get_referer() );
351
-		exit;
290
+		    if ( ! wp_untrash_post( $post_id ) ) {
291
+			    wp_die( __( 'Error in restoring the item from Trash.' ) );
292
+		    }
352 293
 
353
-	default:
354
-		/**
294
+		    $sendback = add_query_arg(
295
+			    array(
296
+				    'untrashed' => 1,
297
+				    'ids'       => $post_id,
298
+			    ),
299
+			    $sendback
300
+		    );
301
+		    wp_redirect( $sendback );
302
+		    exit;
303
+
304
+	    case 'delete':
305
+		    check_admin_referer( 'delete-post_' . $post_id );
306
+
307
+		    if ( ! $post ) {
308
+			    wp_die( __( 'This item has already been deleted.' ) );
309
+		    }
310
+
311
+		    if ( ! $post_type_object ) {
312
+			    wp_die( __( 'Invalid post type.' ) );
313
+		    }
314
+
315
+		    if ( ! current_user_can( 'delete_post', $post_id ) ) {
316
+			    wp_die( __( 'Sorry, you are not allowed to delete this item.' ) );
317
+		    }
318
+
319
+		    if ( 'attachment' === $post->post_type ) {
320
+			    $force = ( ! MEDIA_TRASH );
321
+			    if ( ! wp_delete_attachment( $post_id, $force ) ) {
322
+				    wp_die( __( 'Error in deleting the attachment.' ) );
323
+			    }
324
+		    } else {
325
+			    if ( ! wp_delete_post( $post_id, true ) ) {
326
+				    wp_die( __( 'Error in deleting the item.' ) );
327
+			    }
328
+		    }
329
+
330
+		    wp_redirect( add_query_arg( 'deleted', 1, $sendback ) );
331
+		    exit;
332
+
333
+	    case 'preview':
334
+		    check_admin_referer( 'update-post_' . $post_id );
335
+
336
+		    $url = post_preview();
337
+
338
+		    wp_redirect( $url );
339
+		    exit;
340
+
341
+	    case 'toggle-custom-fields':
342
+		    check_admin_referer( 'toggle-custom-fields', 'toggle-custom-fields-nonce' );
343
+
344
+		    $current_user_id = get_current_user_id();
345
+		    if ( $current_user_id ) {
346
+			    $enable_custom_fields = (bool) get_user_meta( $current_user_id, 'enable_custom_fields', true );
347
+			    update_user_meta( $current_user_id, 'enable_custom_fields', ! $enable_custom_fields );
348
+		    }
349
+
350
+		    wp_safe_redirect( wp_get_referer() );
351
+		    exit;
352
+
353
+	    default:
354
+		    /**
355 355
 		 * Fires for a given custom post action request.
356 356
 		 *
357 357
 		 * The dynamic portion of the hook name, `$action`, refers to the custom post action.
@@ -360,10 +360,10 @@  discard block
 block discarded – undo
360 360
 		 *
361 361
 		 * @param int $post_id Post ID sent with the request.
362 362
 		 */
363
-		do_action( "post_action_{$action}", $post_id );
363
+		    do_action( "post_action_{$action}", $post_id );
364 364
 
365
-		wp_redirect( admin_url( 'edit.php' ) );
366
-		exit;
365
+		    wp_redirect( admin_url( 'edit.php' ) );
366
+		    exit;
367 367
 } // End switch.
368 368
 
369 369
 require_once ABSPATH . 'wp-admin/admin-footer.php';
Please login to merge, or discard this patch.
brighty/wp-admin/comment.php 1 patch
Switch Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -52,83 +52,83 @@  discard block
 block discarded – undo
52 52
 
53 53
 switch ( $action ) {
54 54
 
55
-	case 'editcomment':
56
-		// Used in the HTML title tag.
57
-		$title = __( 'Edit Comment' );
58
-
59
-		get_current_screen()->add_help_tab(
60
-			array(
61
-				'id'      => 'overview',
62
-				'title'   => __( 'Overview' ),
63
-				'content' =>
64
-					'<p>' . __( 'You can edit the information left in a comment if needed. This is often useful when you notice that a commenter has made a typographical error.' ) . '</p>' .
65
-					'<p>' . __( 'You can also moderate the comment from this screen using the Status box, where you can also change the timestamp of the comment.' ) . '</p>',
66
-			)
67
-		);
68
-
69
-		get_current_screen()->set_help_sidebar(
70
-			'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
71
-			'<p>' . __( '<a href="https://wordpress.org/support/article/comments-screen/">Documentation on Comments</a>' ) . '</p>' .
72
-			'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
73
-		);
74
-
75
-		wp_enqueue_script( 'comment' );
76
-		require_once ABSPATH . 'wp-admin/admin-header.php';
77
-
78
-		if ( ! $comment ) {
79
-			comment_footer_die( __( 'Invalid comment ID.' ) . sprintf( ' <a href="%s">' . __( 'Go back' ) . '</a>.', 'javascript:history.go(-1)' ) );
80
-		}
81
-
82
-		if ( ! current_user_can( 'edit_comment', $comment_id ) ) {
83
-			comment_footer_die( __( 'Sorry, you are not allowed to edit this comment.' ) );
84
-		}
85
-
86
-		if ( 'trash' === $comment->comment_approved ) {
87
-			comment_footer_die( __( 'This comment is in the Trash. Please move it out of the Trash if you want to edit it.' ) );
88
-		}
89
-
90
-		$comment = get_comment_to_edit( $comment_id );
91
-
92
-		require ABSPATH . 'wp-admin/edit-form-comment.php';
93
-
94
-		break;
95
-
96
-	case 'delete':
97
-	case 'approve':
98
-	case 'trash':
99
-	case 'spam':
100
-		// Used in the HTML title tag.
101
-		$title = __( 'Moderate Comment' );
102
-
103
-		if ( ! $comment ) {
104
-			wp_redirect( admin_url( 'edit-comments.php?error=1' ) );
105
-			die();
106
-		}
107
-
108
-		if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) {
109
-			wp_redirect( admin_url( 'edit-comments.php?error=2' ) );
110
-			die();
111
-		}
112
-
113
-		// No need to re-approve/re-trash/re-spam a comment.
114
-		if ( str_replace( '1', 'approve', $comment->comment_approved ) === $action ) {
115
-			wp_redirect( admin_url( 'edit-comments.php?same=' . $comment_id ) );
116
-			die();
117
-		}
118
-
119
-		require_once ABSPATH . 'wp-admin/admin-header.php';
120
-
121
-		$formaction    = $action . 'comment';
122
-		$nonce_action  = ( 'approve' === $action ) ? 'approve-comment_' : 'delete-comment_';
123
-		$nonce_action .= $comment_id;
124
-
125
-		?>
55
+	    case 'editcomment':
56
+		    // Used in the HTML title tag.
57
+		    $title = __( 'Edit Comment' );
58
+
59
+		    get_current_screen()->add_help_tab(
60
+			    array(
61
+				    'id'      => 'overview',
62
+				    'title'   => __( 'Overview' ),
63
+				    'content' =>
64
+					    '<p>' . __( 'You can edit the information left in a comment if needed. This is often useful when you notice that a commenter has made a typographical error.' ) . '</p>' .
65
+					    '<p>' . __( 'You can also moderate the comment from this screen using the Status box, where you can also change the timestamp of the comment.' ) . '</p>',
66
+			    )
67
+		    );
68
+
69
+		    get_current_screen()->set_help_sidebar(
70
+			    '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
71
+			    '<p>' . __( '<a href="https://wordpress.org/support/article/comments-screen/">Documentation on Comments</a>' ) . '</p>' .
72
+			    '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
73
+		    );
74
+
75
+		    wp_enqueue_script( 'comment' );
76
+		    require_once ABSPATH . 'wp-admin/admin-header.php';
77
+
78
+		    if ( ! $comment ) {
79
+			    comment_footer_die( __( 'Invalid comment ID.' ) . sprintf( ' <a href="%s">' . __( 'Go back' ) . '</a>.', 'javascript:history.go(-1)' ) );
80
+		    }
81
+
82
+		    if ( ! current_user_can( 'edit_comment', $comment_id ) ) {
83
+			    comment_footer_die( __( 'Sorry, you are not allowed to edit this comment.' ) );
84
+		    }
85
+
86
+		    if ( 'trash' === $comment->comment_approved ) {
87
+			    comment_footer_die( __( 'This comment is in the Trash. Please move it out of the Trash if you want to edit it.' ) );
88
+		    }
89
+
90
+		    $comment = get_comment_to_edit( $comment_id );
91
+
92
+		    require ABSPATH . 'wp-admin/edit-form-comment.php';
93
+
94
+		    break;
95
+
96
+	    case 'delete':
97
+	    case 'approve':
98
+	    case 'trash':
99
+	    case 'spam':
100
+		    // Used in the HTML title tag.
101
+		    $title = __( 'Moderate Comment' );
102
+
103
+		    if ( ! $comment ) {
104
+			    wp_redirect( admin_url( 'edit-comments.php?error=1' ) );
105
+			    die();
106
+		    }
107
+
108
+		    if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) {
109
+			    wp_redirect( admin_url( 'edit-comments.php?error=2' ) );
110
+			    die();
111
+		    }
112
+
113
+		    // No need to re-approve/re-trash/re-spam a comment.
114
+		    if ( str_replace( '1', 'approve', $comment->comment_approved ) === $action ) {
115
+			    wp_redirect( admin_url( 'edit-comments.php?same=' . $comment_id ) );
116
+			    die();
117
+		    }
118
+
119
+		    require_once ABSPATH . 'wp-admin/admin-header.php';
120
+
121
+		    $formaction    = $action . 'comment';
122
+		    $nonce_action  = ( 'approve' === $action ) ? 'approve-comment_' : 'delete-comment_';
123
+		    $nonce_action .= $comment_id;
124
+
125
+		    ?>
126 126
 	<div class="wrap">
127 127
 
128 128
 	<h1><?php echo esc_html( $title ); ?></h1>
129 129
 
130 130
 		<?php
131
-		switch ( $action ) {
131
+		    switch ( $action ) {
132 132
 			case 'spam':
133 133
 				$caution_msg = __( 'You are about to mark the following comment as spam:' );
134 134
 				$button      = _x( 'Mark as spam', 'comment' );
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 				$caution_msg = __( 'You are about to approve the following comment:' );
146 146
 				$button      = __( 'Approve comment' );
147 147
 				break;
148
-		}
148
+		    }
149 149
 
150 150
 		if ( '0' !== $comment->comment_approved ) { // If not unapproved.
151 151
 			$message = '';
@@ -257,44 +257,44 @@  discard block
 block discarded – undo
257 257
 		<?php
258 258
 		break;
259 259
 
260
-	case 'deletecomment':
261
-	case 'trashcomment':
262
-	case 'untrashcomment':
263
-	case 'spamcomment':
264
-	case 'unspamcomment':
265
-	case 'approvecomment':
266
-	case 'unapprovecomment':
267
-		$comment_id = absint( $_REQUEST['c'] );
268
-
269
-		if ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ), true ) ) {
270
-			check_admin_referer( 'approve-comment_' . $comment_id );
271
-		} else {
272
-			check_admin_referer( 'delete-comment_' . $comment_id );
273
-		}
274
-
275
-		$noredir = isset( $_REQUEST['noredir'] );
276
-
277
-		$comment = get_comment( $comment_id );
278
-		if ( ! $comment ) {
279
-			comment_footer_die( __( 'Invalid comment ID.' ) . sprintf( ' <a href="%s">' . __( 'Go back' ) . '</a>.', 'edit-comments.php' ) );
280
-		}
281
-		if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) {
282
-			comment_footer_die( __( 'Sorry, you are not allowed to edit comments on this post.' ) );
283
-		}
284
-
285
-		if ( wp_get_referer() && ! $noredir && false === strpos( wp_get_referer(), 'comment.php' ) ) {
286
-			$redir = wp_get_referer();
287
-		} elseif ( wp_get_original_referer() && ! $noredir ) {
288
-			$redir = wp_get_original_referer();
289
-		} elseif ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ), true ) ) {
290
-			$redir = admin_url( 'edit-comments.php?p=' . absint( $comment->comment_post_ID ) );
291
-		} else {
292
-			$redir = admin_url( 'edit-comments.php' );
293
-		}
294
-
295
-		$redir = remove_query_arg( array( 'spammed', 'unspammed', 'trashed', 'untrashed', 'deleted', 'ids', 'approved', 'unapproved' ), $redir );
296
-
297
-		switch ( $action ) {
260
+	    case 'deletecomment':
261
+	    case 'trashcomment':
262
+	    case 'untrashcomment':
263
+	    case 'spamcomment':
264
+	    case 'unspamcomment':
265
+	    case 'approvecomment':
266
+	    case 'unapprovecomment':
267
+		    $comment_id = absint( $_REQUEST['c'] );
268
+
269
+		    if ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ), true ) ) {
270
+			    check_admin_referer( 'approve-comment_' . $comment_id );
271
+		    } else {
272
+			    check_admin_referer( 'delete-comment_' . $comment_id );
273
+		    }
274
+
275
+		    $noredir = isset( $_REQUEST['noredir'] );
276
+
277
+		    $comment = get_comment( $comment_id );
278
+		    if ( ! $comment ) {
279
+			    comment_footer_die( __( 'Invalid comment ID.' ) . sprintf( ' <a href="%s">' . __( 'Go back' ) . '</a>.', 'edit-comments.php' ) );
280
+		    }
281
+		    if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) {
282
+			    comment_footer_die( __( 'Sorry, you are not allowed to edit comments on this post.' ) );
283
+		    }
284
+
285
+		    if ( wp_get_referer() && ! $noredir && false === strpos( wp_get_referer(), 'comment.php' ) ) {
286
+			    $redir = wp_get_referer();
287
+		    } elseif ( wp_get_original_referer() && ! $noredir ) {
288
+			    $redir = wp_get_original_referer();
289
+		    } elseif ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ), true ) ) {
290
+			    $redir = admin_url( 'edit-comments.php?p=' . absint( $comment->comment_post_ID ) );
291
+		    } else {
292
+			    $redir = admin_url( 'edit-comments.php' );
293
+		    }
294
+
295
+		    $redir = remove_query_arg( array( 'spammed', 'unspammed', 'trashed', 'untrashed', 'deleted', 'ids', 'approved', 'unapproved' ), $redir );
296
+
297
+		    switch ( $action ) {
298 298
 			case 'deletecomment':
299 299
 				wp_delete_comment( $comment );
300 300
 				$redir = add_query_arg( array( 'deleted' => '1' ), $redir );
@@ -335,25 +335,25 @@  discard block
 block discarded – undo
335 335
 				wp_set_comment_status( $comment, 'hold' );
336 336
 				$redir = add_query_arg( array( 'unapproved' => 1 ), $redir );
337 337
 				break;
338
-		}
338
+		    }
339 339
 
340 340
 		wp_redirect( $redir );
341 341
 		die;
342 342
 
343
-	case 'editedcomment':
344
-		$comment_id      = absint( $_POST['comment_ID'] );
345
-		$comment_post_id = absint( $_POST['comment_post_ID'] );
343
+	    case 'editedcomment':
344
+		    $comment_id      = absint( $_POST['comment_ID'] );
345
+		    $comment_post_id = absint( $_POST['comment_post_ID'] );
346 346
 
347
-		check_admin_referer( 'update-comment_' . $comment_id );
347
+		    check_admin_referer( 'update-comment_' . $comment_id );
348 348
 
349
-		$updated = edit_comment();
350
-		if ( is_wp_error( $updated ) ) {
351
-			wp_die( $updated->get_error_message() );
352
-		}
349
+		    $updated = edit_comment();
350
+		    if ( is_wp_error( $updated ) ) {
351
+			    wp_die( $updated->get_error_message() );
352
+		    }
353 353
 
354
-		$location = ( empty( $_POST['referredby'] ) ? "edit-comments.php?p=$comment_post_id" : $_POST['referredby'] ) . '#comment-' . $comment_id;
354
+		    $location = ( empty( $_POST['referredby'] ) ? "edit-comments.php?p=$comment_post_id" : $_POST['referredby'] ) . '#comment-' . $comment_id;
355 355
 
356
-		/**
356
+		    /**
357 357
 		 * Filters the URI the user is redirected to after editing a comment in the admin.
358 358
 		 *
359 359
 		 * @since 2.1.0
@@ -361,13 +361,13 @@  discard block
 block discarded – undo
361 361
 		 * @param string $location The URI the user will be redirected to.
362 362
 		 * @param int $comment_id The ID of the comment being edited.
363 363
 		 */
364
-		$location = apply_filters( 'comment_edit_redirect', $location, $comment_id );
364
+		    $location = apply_filters( 'comment_edit_redirect', $location, $comment_id );
365 365
 
366
-		wp_redirect( $location );
367
-		exit;
366
+		    wp_redirect( $location );
367
+		    exit;
368 368
 
369
-	default:
370
-		wp_die( __( 'Unknown action.' ) );
369
+	    default:
370
+		    wp_die( __( 'Unknown action.' ) );
371 371
 
372 372
 } // End switch.
373 373
 
Please login to merge, or discard this patch.
brighty/wp-admin/user-edit.php 1 patch
Switch Indentation   +305 added lines, -305 removed lines patch added patch discarded remove patch
@@ -125,15 +125,15 @@  discard block
 block discarded – undo
125 125
 }
126 126
 
127 127
 switch ( $action ) {
128
-	case 'update':
129
-		check_admin_referer( 'update-user_' . $user_id );
128
+	    case 'update':
129
+		    check_admin_referer( 'update-user_' . $user_id );
130 130
 
131
-		if ( ! current_user_can( 'edit_user', $user_id ) ) {
132
-			wp_die( __( 'Sorry, you are not allowed to edit this user.' ) );
133
-		}
131
+		    if ( ! current_user_can( 'edit_user', $user_id ) ) {
132
+			    wp_die( __( 'Sorry, you are not allowed to edit this user.' ) );
133
+		    }
134 134
 
135
-		if ( IS_PROFILE_PAGE ) {
136
-			/**
135
+		    if ( IS_PROFILE_PAGE ) {
136
+			    /**
137 137
 			 * Fires before the page loads on the 'Profile' editing screen.
138 138
 			 *
139 139
 			 * The action only fires if the current user is editing their own profile.
@@ -142,86 +142,86 @@  discard block
 block discarded – undo
142 142
 			 *
143 143
 			 * @param int $user_id The user ID.
144 144
 			 */
145
-			do_action( 'personal_options_update', $user_id );
146
-		} else {
147
-			/**
145
+			    do_action( 'personal_options_update', $user_id );
146
+		    } else {
147
+			    /**
148 148
 			 * Fires before the page loads on the 'Edit User' screen.
149 149
 			 *
150 150
 			 * @since 2.7.0
151 151
 			 *
152 152
 			 * @param int $user_id The user ID.
153 153
 			 */
154
-			do_action( 'edit_user_profile_update', $user_id );
155
-		}
156
-
157
-		// Update the email address in signups, if present.
158
-		if ( is_multisite() ) {
159
-			$user = get_userdata( $user_id );
160
-
161
-			if ( $user->user_login && isset( $_POST['email'] ) && is_email( $_POST['email'] ) && $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $user->user_login ) ) ) {
162
-				$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $_POST['email'], $user_login ) );
163
-			}
164
-		}
165
-
166
-		// Update the user.
167
-		$errors = edit_user( $user_id );
168
-
169
-		// Grant or revoke super admin status if requested.
170
-		if ( is_multisite() && is_network_admin()
171
-			&& ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' )
172
-			&& ! isset( $super_admins ) && empty( $_POST['super_admin'] ) === is_super_admin( $user_id )
173
-		) {
174
-			empty( $_POST['super_admin'] ) ? revoke_super_admin( $user_id ) : grant_super_admin( $user_id );
175
-		}
176
-
177
-		if ( ! is_wp_error( $errors ) ) {
178
-			$redirect = add_query_arg( 'updated', true, get_edit_user_link( $user_id ) );
179
-			if ( $wp_http_referer ) {
180
-				$redirect = add_query_arg( 'wp_http_referer', urlencode( $wp_http_referer ), $redirect );
181
-			}
182
-			wp_redirect( $redirect );
183
-			exit;
184
-		}
185
-
186
-		// Intentional fall-through to display $errors.
187
-	default:
188
-		$profile_user = get_user_to_edit( $user_id );
189
-
190
-		if ( ! current_user_can( 'edit_user', $user_id ) ) {
191
-			wp_die( __( 'Sorry, you are not allowed to edit this user.' ) );
192
-		}
193
-
194
-		$title    = sprintf( $title, $profile_user->display_name );
195
-		$sessions = WP_Session_Tokens::get_instance( $profile_user->ID );
196
-
197
-		require_once ABSPATH . 'wp-admin/admin-header.php';
198
-		?>
199
-
154
+			    do_action( 'edit_user_profile_update', $user_id );
155
+		    }
156
+
157
+		    // Update the email address in signups, if present.
158
+		    if ( is_multisite() ) {
159
+			    $user = get_userdata( $user_id );
160
+
161
+			    if ( $user->user_login && isset( $_POST['email'] ) && is_email( $_POST['email'] ) && $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $user->user_login ) ) ) {
162
+				    $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $_POST['email'], $user_login ) );
163
+			    }
164
+		    }
165
+
166
+		    // Update the user.
167
+		    $errors = edit_user( $user_id );
168
+
169
+		    // Grant or revoke super admin status if requested.
170
+		    if ( is_multisite() && is_network_admin()
171
+			    && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' )
172
+			    && ! isset( $super_admins ) && empty( $_POST['super_admin'] ) === is_super_admin( $user_id )
173
+		    ) {
174
+			    empty( $_POST['super_admin'] ) ? revoke_super_admin( $user_id ) : grant_super_admin( $user_id );
175
+		    }
176
+
177
+		    if ( ! is_wp_error( $errors ) ) {
178
+			    $redirect = add_query_arg( 'updated', true, get_edit_user_link( $user_id ) );
179
+			    if ( $wp_http_referer ) {
180
+				    $redirect = add_query_arg( 'wp_http_referer', urlencode( $wp_http_referer ), $redirect );
181
+			    }
182
+			    wp_redirect( $redirect );
183
+			    exit;
184
+		    }
185
+
186
+		    // Intentional fall-through to display $errors.
187
+	    default:
188
+		    $profile_user = get_user_to_edit( $user_id );
189
+
190
+		    if ( ! current_user_can( 'edit_user', $user_id ) ) {
191
+			    wp_die( __( 'Sorry, you are not allowed to edit this user.' ) );
192
+		    }
193
+
194
+		    $title    = sprintf( $title, $profile_user->display_name );
195
+		    $sessions = WP_Session_Tokens::get_instance( $profile_user->ID );
196
+
197
+		    require_once ABSPATH . 'wp-admin/admin-header.php';
198
+		    ?>
199
+    
200 200
 		<?php if ( ! IS_PROFILE_PAGE && is_super_admin( $profile_user->ID ) && current_user_can( 'manage_network_options' ) ) : ?>
201
-			<div class="notice notice-info"><p><strong><?php _e( 'Important:' ); ?></strong> <?php _e( 'This user has super admin privileges.' ); ?></p></div>
201
+    			<div class="notice notice-info"><p><strong><?php _e( 'Important:' ); ?></strong> <?php _e( 'This user has super admin privileges.' ); ?></p></div>
202 202
 		<?php endif; ?>
203
-
203
+    
204 204
 		<?php if ( isset( $_GET['updated'] ) ) : ?>
205
-			<div id="message" class="updated notice is-dismissible">
205
+    			<div id="message" class="updated notice is-dismissible">
206 206
 				<?php if ( IS_PROFILE_PAGE ) : ?>
207
-					<p><strong><?php _e( 'Profile updated.' ); ?></strong></p>
207
+    					<p><strong><?php _e( 'Profile updated.' ); ?></strong></p>
208 208
 				<?php else : ?>
209
-					<p><strong><?php _e( 'User updated.' ); ?></strong></p>
209
+    					<p><strong><?php _e( 'User updated.' ); ?></strong></p>
210 210
 				<?php endif; ?>
211
-				<?php if ( $wp_http_referer && false === strpos( $wp_http_referer, 'user-new.php' ) && ! IS_PROFILE_PAGE ) : ?>
212
-					<p><a href="<?php echo esc_url( wp_validate_redirect( esc_url_raw( $wp_http_referer ), self_admin_url( 'users.php' ) ) ); ?>"><?php _e( '&larr; Go to Users' ); ?></a></p>
211
+    				<?php if ( $wp_http_referer && false === strpos( $wp_http_referer, 'user-new.php' ) && ! IS_PROFILE_PAGE ) : ?>
212
+    					<p><a href="<?php echo esc_url( wp_validate_redirect( esc_url_raw( $wp_http_referer ), self_admin_url( 'users.php' ) ) ); ?>"><?php _e( '&larr; Go to Users' ); ?></a></p>
213 213
 				<?php endif; ?>
214
-			</div>
214
+    			</div>
215 215
 		<?php endif; ?>
216
-
216
+    
217 217
 		<?php if ( isset( $_GET['error'] ) ) : ?>
218
-			<div class="notice notice-error">
218
+    			<div class="notice notice-error">
219 219
 			<?php if ( 'new-email' === $_GET['error'] ) : ?>
220
-				<p><?php _e( 'Error while saving the new email address. Please try again.' ); ?></p>
220
+    				<p><?php _e( 'Error while saving the new email address. Please try again.' ); ?></p>
221 221
 			<?php endif; ?>
222
-			</div>
222
+    			</div>
223 223
 		<?php endif; ?>
224
-
224
+    
225 225
 		<?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?>
226 226
 			<div class="error">
227 227
 				<p><?php echo implode( "</p>\n<p>", $errors->get_error_messages() ); ?></p>
@@ -231,31 +231,31 @@  discard block
 block discarded – undo
231 231
 		<div class="wrap" id="profile-page">
232 232
 			<h1 class="wp-heading-inline">
233 233
 					<?php echo esc_html( $title ); ?>
234
-			</h1>
234
+    			</h1>
235 235
 
236 236
 			<?php if ( ! IS_PROFILE_PAGE ) : ?>
237
-				<?php if ( current_user_can( 'create_users' ) ) : ?>
238
-					<a href="user-new.php" class="page-title-action"><?php echo esc_html_x( 'Add New', 'user' ); ?></a>
237
+    				<?php if ( current_user_can( 'create_users' ) ) : ?>
238
+    					<a href="user-new.php" class="page-title-action"><?php echo esc_html_x( 'Add New', 'user' ); ?></a>
239 239
 				<?php elseif ( is_multisite() && current_user_can( 'promote_users' ) ) : ?>
240
-					<a href="user-new.php" class="page-title-action"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a>
240
+    					<a href="user-new.php" class="page-title-action"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a>
241 241
 				<?php endif; ?>
242
-			<?php endif; ?>
242
+    			<?php endif; ?>
243 243
 
244 244
 			<hr class="wp-header-end">
245 245
 
246 246
 			<form id="your-profile" action="<?php echo esc_url( self_admin_url( IS_PROFILE_PAGE ? 'profile.php' : 'user-edit.php' ) ); ?>" method="post" novalidate="novalidate"
247 247
 				<?php
248
-				/**
248
+				    /**
249 249
 				 * Fires inside the your-profile form tag on the user editing screen.
250 250
 				 *
251 251
 				 * @since 3.0.0
252 252
 				 */
253
-				do_action( 'user_edit_form_tag' );
254
-				?>
255
-				>
253
+				    do_action( 'user_edit_form_tag' );
254
+				    ?>
255
+    				>
256 256
 				<?php wp_nonce_field( 'update-user_' . $user_id ); ?>
257
-				<?php if ( $wp_http_referer ) : ?>
258
-					<input type="hidden" name="wp_http_referer" value="<?php echo esc_url( $wp_http_referer ); ?>" />
257
+    				<?php if ( $wp_http_referer ) : ?>
258
+    					<input type="hidden" name="wp_http_referer" value="<?php echo esc_url( $wp_http_referer ); ?>" />
259 259
 				<?php endif; ?>
260 260
 				<p>
261 261
 					<input type="hidden" name="from" value="profile" />
@@ -275,20 +275,20 @@  discard block
 block discarded – undo
275 275
 							</td>
276 276
 						</tr>
277 277
 					<?php endif; ?>
278
-
278
+    
279 279
 					<?php
280
-					$show_syntax_highlighting_preference = (
281
-					// For Custom HTML widget and Additional CSS in Customizer.
282
-					user_can( $profile_user, 'edit_theme_options' )
283
-					||
284
-					// Edit plugins.
285
-					user_can( $profile_user, 'edit_plugins' )
286
-					||
287
-					// Edit themes.
288
-					user_can( $profile_user, 'edit_themes' )
289
-					);
290
-					?>
291
-
280
+					    $show_syntax_highlighting_preference = (
281
+					    // For Custom HTML widget and Additional CSS in Customizer.
282
+					    user_can( $profile_user, 'edit_theme_options' )
283
+					    ||
284
+					    // Edit plugins.
285
+					    user_can( $profile_user, 'edit_plugins' )
286
+					    ||
287
+					    // Edit themes.
288
+					    user_can( $profile_user, 'edit_themes' )
289
+					    );
290
+					    ?>
291
+    
292 292
 					<?php if ( $show_syntax_highlighting_preference ) : ?>
293 293
 					<tr class="user-syntax-highlighting-wrap">
294 294
 						<th scope="row"><?php _e( 'Syntax Highlighting' ); ?></th>
@@ -299,13 +299,13 @@  discard block
 block discarded – undo
299 299
 						</td>
300 300
 					</tr>
301 301
 					<?php endif; ?>
302
-
302
+    
303 303
 					<?php if ( count( $_wp_admin_css_colors ) > 1 && has_action( 'admin_color_scheme_picker' ) ) : ?>
304 304
 					<tr class="user-admin-color-wrap">
305 305
 						<th scope="row"><?php _e( 'Admin Color Scheme' ); ?></th>
306 306
 						<td>
307 307
 							<?php
308
-							/**
308
+							    /**
309 309
 							 * Fires in the 'Admin Color Scheme' section of the user editing screen.
310 310
 							 *
311 311
 							 * The section is only enabled if a callback is hooked to the action,
@@ -316,12 +316,12 @@  discard block
 block discarded – undo
316 316
 							 *
317 317
 							 * @param int $user_id The user ID.
318 318
 							 */
319
-							do_action( 'admin_color_scheme_picker', $user_id );
320
-							?>
319
+							    do_action( 'admin_color_scheme_picker', $user_id );
320
+							    ?>
321 321
 						</td>
322 322
 					</tr>
323 323
 					<?php endif; // End if count ( $_wp_admin_css_colors ) > 1 ?>
324
-
324
+    
325 325
 					<?php if ( ! ( IS_PROFILE_PAGE && ! $user_can_edit ) ) : ?>
326 326
 					<tr class="user-comment-shortcuts-wrap">
327 327
 						<th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th>
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 							<label for="comment_shortcuts">
330 330
 								<input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php checked( 'true', $profile_user->comment_shortcuts ); ?> />
331 331
 								<?php _e( 'Enable keyboard shortcuts for comment moderation.' ); ?>
332
-							</label>
332
+    							</label>
333 333
 							<?php _e( '<a href="https://wordpress.org/support/article/keyboard-shortcuts/" target="_blank">More information</a>' ); ?>
334 334
 						</td>
335 335
 					</tr>
@@ -346,52 +346,52 @@  discard block
 block discarded – undo
346 346
 					</tr>
347 347
 
348 348
 					<?php $languages = get_available_languages(); ?>
349
-					<?php if ( $languages ) : ?>
349
+    					<?php if ( $languages ) : ?>
350 350
 					<tr class="user-language-wrap">
351 351
 						<th scope="row">
352 352
 							<?php /* translators: The user language selection field label. */ ?>
353
-							<label for="locale"><?php _e( 'Language' ); ?><span class="dashicons dashicons-translation" aria-hidden="true"></span></label>
353
+    							<label for="locale"><?php _e( 'Language' ); ?><span class="dashicons dashicons-translation" aria-hidden="true"></span></label>
354 354
 						</th>
355 355
 						<td>
356 356
 							<?php
357
-								$user_locale = $profile_user->locale;
358
-
359
-							if ( 'en_US' === $user_locale ) {
360
-								$user_locale = '';
361
-							} elseif ( '' === $user_locale || ! in_array( $user_locale, $languages, true ) ) {
362
-								$user_locale = 'site-default';
363
-							}
364
-
365
-							wp_dropdown_languages(
366
-								array(
367
-									'name'      => 'locale',
368
-									'id'        => 'locale',
369
-									'selected'  => $user_locale,
370
-									'languages' => $languages,
371
-									'show_available_translations' => false,
372
-									'show_option_site_default' => true,
373
-								)
374
-							);
375
-							?>
357
+								    $user_locale = $profile_user->locale;
358
+
359
+							    if ( 'en_US' === $user_locale ) {
360
+								    $user_locale = '';
361
+							    } elseif ( '' === $user_locale || ! in_array( $user_locale, $languages, true ) ) {
362
+								    $user_locale = 'site-default';
363
+							    }
364
+
365
+							    wp_dropdown_languages(
366
+								    array(
367
+									    'name'      => 'locale',
368
+									    'id'        => 'locale',
369
+									    'selected'  => $user_locale,
370
+									    'languages' => $languages,
371
+									    'show_available_translations' => false,
372
+									    'show_option_site_default' => true,
373
+								    )
374
+							    );
375
+							    ?>
376 376
 						</td>
377 377
 					</tr>
378 378
 					<?php endif; ?>
379
-
379
+    
380 380
 					<?php
381
-					/**
381
+					    /**
382 382
 					 * Fires at the end of the 'Personal Options' settings table on the user editing screen.
383 383
 					 *
384 384
 					 * @since 2.7.0
385 385
 					 *
386 386
 					 * @param WP_User $profile_user The current WP_User object.
387 387
 					 */
388
-					do_action( 'personal_options', $profile_user );
389
-					?>
388
+					    do_action( 'personal_options', $profile_user );
389
+					    ?>
390 390
 
391 391
 				</table>
392 392
 				<?php
393
-				if ( IS_PROFILE_PAGE ) {
394
-					/**
393
+				    if ( IS_PROFILE_PAGE ) {
394
+					    /**
395 395
 					 * Fires after the 'Personal Options' settings table on the 'Profile' editing screen.
396 396
 					 *
397 397
 					 * The action only fires if the current user is editing their own profile.
@@ -400,9 +400,9 @@  discard block
 block discarded – undo
400 400
 					 *
401 401
 					 * @param WP_User $profile_user The current WP_User object.
402 402
 					 */
403
-					do_action( 'profile_personal_options', $profile_user );
404
-				}
405
-				?>
403
+					    do_action( 'profile_personal_options', $profile_user );
404
+				    }
405
+				    ?>
406 406
 
407 407
 				<h2><?php _e( 'Name' ); ?></h2>
408 408
 
@@ -418,33 +418,33 @@  discard block
 block discarded – undo
418 418
 							<td>
419 419
 								<select name="role" id="role">
420 420
 									<?php
421
-									// Compare user role against currently editable roles.
422
-									$user_roles = array_intersect( array_values( $profile_user->roles ), array_keys( get_editable_roles() ) );
423
-									$user_role  = reset( $user_roles );
424
-
425
-									// Print the full list of roles with the primary one selected.
426
-									wp_dropdown_roles( $user_role );
427
-
428
-									// Print the 'no role' option. Make it selected if the user has no role yet.
429
-									if ( $user_role ) {
430
-										echo '<option value="">' . __( '&mdash; No role for this site &mdash;' ) . '</option>';
431
-									} else {
432
-										echo '<option value="" selected="selected">' . __( '&mdash; No role for this site &mdash;' ) . '</option>';
433
-									}
434
-									?>
421
+									    // Compare user role against currently editable roles.
422
+									    $user_roles = array_intersect( array_values( $profile_user->roles ), array_keys( get_editable_roles() ) );
423
+									    $user_role  = reset( $user_roles );
424
+
425
+									    // Print the full list of roles with the primary one selected.
426
+									    wp_dropdown_roles( $user_role );
427
+
428
+									    // Print the 'no role' option. Make it selected if the user has no role yet.
429
+									    if ( $user_role ) {
430
+										    echo '<option value="">' . __( '&mdash; No role for this site &mdash;' ) . '</option>';
431
+									    } else {
432
+										    echo '<option value="" selected="selected">' . __( '&mdash; No role for this site &mdash;' ) . '</option>';
433
+									    }
434
+									    ?>
435 435
 							</select>
436 436
 							</td>
437 437
 						</tr>
438 438
 					<?php endif; // End if ! IS_PROFILE_PAGE. ?>
439
-
439
+    
440 440
 					<?php if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && ! isset( $super_admins ) ) : ?>
441 441
 						<tr class="user-super-admin-wrap">
442 442
 							<th><?php _e( 'Super Admin' ); ?></th>
443 443
 							<td>
444 444
 								<?php if ( 0 !== strcasecmp( $profile_user->user_email, get_site_option( 'admin_email' ) ) || ! is_super_admin( $profile_user->ID ) ) : ?>
445
-									<p><label><input type="checkbox" id="super_admin" name="super_admin"<?php checked( is_super_admin( $profile_user->ID ) ); ?> /> <?php _e( 'Grant this user super admin privileges for the Network.' ); ?></label></p>
445
+    									<p><label><input type="checkbox" id="super_admin" name="super_admin"<?php checked( is_super_admin( $profile_user->ID ) ); ?> /> <?php _e( 'Grant this user super admin privileges for the Network.' ); ?></label></p>
446 446
 								<?php else : ?>
447
-									<p><?php _e( 'Super admin privileges cannot be removed because this user has the network admin email.' ); ?></p>
447
+    									<p><?php _e( 'Super admin privileges cannot be removed because this user has the network admin email.' ); ?></p>
448 448
 								<?php endif; ?>
449 449
 							</td>
450 450
 						</tr>
@@ -472,33 +472,33 @@  discard block
 block discarded – undo
472 472
 						<td>
473 473
 							<select name="display_name" id="display_name">
474 474
 								<?php
475
-									$public_display                     = array();
476
-									$public_display['display_nickname'] = $profile_user->nickname;
477
-									$public_display['display_username'] = $profile_user->user_login;
475
+									    $public_display                     = array();
476
+									    $public_display['display_nickname'] = $profile_user->nickname;
477
+									    $public_display['display_username'] = $profile_user->user_login;
478 478
 
479
-								if ( ! empty( $profile_user->first_name ) ) {
480
-									$public_display['display_firstname'] = $profile_user->first_name;
481
-								}
479
+								    if ( ! empty( $profile_user->first_name ) ) {
480
+									    $public_display['display_firstname'] = $profile_user->first_name;
481
+								    }
482 482
 
483
-								if ( ! empty( $profile_user->last_name ) ) {
484
-									$public_display['display_lastname'] = $profile_user->last_name;
485
-								}
483
+								    if ( ! empty( $profile_user->last_name ) ) {
484
+									    $public_display['display_lastname'] = $profile_user->last_name;
485
+								    }
486 486
 
487
-								if ( ! empty( $profile_user->first_name ) && ! empty( $profile_user->last_name ) ) {
488
-									$public_display['display_firstlast'] = $profile_user->first_name . ' ' . $profile_user->last_name;
489
-									$public_display['display_lastfirst'] = $profile_user->last_name . ' ' . $profile_user->first_name;
490
-								}
487
+								    if ( ! empty( $profile_user->first_name ) && ! empty( $profile_user->last_name ) ) {
488
+									    $public_display['display_firstlast'] = $profile_user->first_name . ' ' . $profile_user->last_name;
489
+									    $public_display['display_lastfirst'] = $profile_user->last_name . ' ' . $profile_user->first_name;
490
+								    }
491 491
 
492
-								if ( ! in_array( $profile_user->display_name, $public_display, true ) ) { // Only add this if it isn't duplicated elsewhere.
493
-									$public_display = array( 'display_displayname' => $profile_user->display_name ) + $public_display;
494
-								}
492
+								    if ( ! in_array( $profile_user->display_name, $public_display, true ) ) { // Only add this if it isn't duplicated elsewhere.
493
+									    $public_display = array( 'display_displayname' => $profile_user->display_name ) + $public_display;
494
+								    }
495 495
 
496
-								$public_display = array_map( 'trim', $public_display );
497
-								$public_display = array_unique( $public_display );
496
+								    $public_display = array_map( 'trim', $public_display );
497
+								    $public_display = array_unique( $public_display );
498 498
 
499
-								?>
500
-								<?php foreach ( $public_display as $id => $item ) : ?>
501
-									<option <?php selected( $profile_user->display_name, $item ); ?>><?php echo $item; ?></option>
499
+								    ?>
500
+    								<?php foreach ( $public_display as $id => $item ) : ?>
501
+    									<option <?php selected( $profile_user->display_name, $item ); ?>><?php echo $item; ?></option>
502 502
 								<?php endforeach; ?>
503 503
 							</select>
504 504
 						</td>
@@ -513,27 +513,27 @@  discard block
 block discarded – undo
513 513
 						<td>
514 514
 							<input type="email" name="email" id="email" aria-describedby="email-description" value="<?php echo esc_attr( $profile_user->user_email ); ?>" class="regular-text ltr" />
515 515
 							<?php if ( $profile_user->ID === $current_user->ID ) : ?>
516
-								<p class="description" id="email-description">
516
+    								<p class="description" id="email-description">
517 517
 									<?php _e( 'If you change this, an email will be sent at your new address to confirm it. <strong>The new address will not become active until confirmed.</strong>' ); ?>
518
-								</p>
518
+    								</p>
519 519
 							<?php endif; ?>
520
-
520
+    
521 521
 							<?php $new_email = get_user_meta( $current_user->ID, '_new_email', true ); ?>
522
-							<?php if ( $new_email && $new_email['newemail'] !== $current_user->user_email && $profile_user->ID === $current_user->ID ) : ?>
522
+    							<?php if ( $new_email && $new_email['newemail'] !== $current_user->user_email && $profile_user->ID === $current_user->ID ) : ?>
523 523
 							<div class="updated inline">
524 524
 								<p>
525 525
 									<?php
526
-									printf(
527
-										/* translators: %s: New email. */
528
-										__( 'There is a pending change of your email to %s.' ),
529
-										'<code>' . esc_html( $new_email['newemail'] ) . '</code>'
530
-									);
531
-									printf(
532
-										' <a href="%1$s">%2$s</a>',
533
-										esc_url( wp_nonce_url( self_admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ), 'dismiss-' . $current_user->ID . '_new_email' ) ),
534
-										__( 'Cancel' )
535
-									);
536
-									?>
526
+									    printf(
527
+										    /* translators: %s: New email. */
528
+										    __( 'There is a pending change of your email to %s.' ),
529
+										    '<code>' . esc_html( $new_email['newemail'] ) . '</code>'
530
+									    );
531
+									    printf(
532
+										    ' <a href="%1$s">%2$s</a>',
533
+										    esc_url( wp_nonce_url( self_admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ), 'dismiss-' . $current_user->ID . '_new_email' ) ),
534
+										    __( 'Cancel' )
535
+									    );
536
+									    ?>
537 537
 								</p>
538 538
 							</div>
539 539
 							<?php endif; ?>
@@ -546,11 +546,11 @@  discard block
 block discarded – undo
546 546
 					</tr>
547 547
 
548 548
 					<?php foreach ( wp_get_user_contact_methods( $profile_user ) as $name => $desc ) : ?>
549
-					<tr class="user-<?php echo $name; ?>-wrap">
549
+    					<tr class="user-<?php echo $name; ?>-wrap">
550 550
 						<th>
551 551
 							<label for="<?php echo $name; ?>">
552 552
 							<?php
553
-							/**
553
+							    /**
554 554
 							 * Filters a user contactmethod label.
555 555
 							 *
556 556
 							 * The dynamic portion of the hook name, `$name`, refers to
@@ -560,8 +560,8 @@  discard block
 block discarded – undo
560 560
 							 *
561 561
 							 * @param string $desc The translatable label for the contact method.
562 562
 							 */
563
-							echo apply_filters( "user_{$name}_label", $desc );
564
-							?>
563
+							    echo apply_filters( "user_{$name}_label", $desc );
564
+							    ?>
565 565
 							</label>
566 566
 						</th>
567 567
 						<td>
@@ -585,19 +585,19 @@  discard block
 block discarded – undo
585 585
 							<th><?php _e( 'Profile Picture' ); ?></th>
586 586
 							<td>
587 587
 								<?php echo get_avatar( $user_id ); ?>
588
-								<p class="description">
588
+    								<p class="description">
589 589
 									<?php
590
-									if ( IS_PROFILE_PAGE ) {
591
-										$description = sprintf(
592
-											/* translators: %s: Gravatar URL. */
593
-											__( '<a href="%s">You can change your profile picture on Gravatar</a>.' ),
594
-											__( 'https://en.gravatar.com/' )
595
-										);
596
-									} else {
597
-										$description = '';
598
-									}
599
-
600
-									/**
590
+									    if ( IS_PROFILE_PAGE ) {
591
+										    $description = sprintf(
592
+											    /* translators: %s: Gravatar URL. */
593
+											    __( '<a href="%s">You can change your profile picture on Gravatar</a>.' ),
594
+											    __( 'https://en.gravatar.com/' )
595
+										    );
596
+									    } else {
597
+										    $description = '';
598
+									    }
599
+
600
+									    /**
601 601
 									 * Filters the user profile picture description displayed under the Gravatar.
602 602
 									 *
603 603
 									 * @since 4.4.0
@@ -606,14 +606,14 @@  discard block
 block discarded – undo
606 606
 									 * @param string  $description  The description that will be printed.
607 607
 									 * @param WP_User $profile_user The current WP_User object.
608 608
 									 */
609
-									echo apply_filters( 'user_profile_picture_description', $description, $profile_user );
610
-									?>
609
+									    echo apply_filters( 'user_profile_picture_description', $description, $profile_user );
610
+									    ?>
611 611
 								</p>
612 612
 							</td>
613 613
 						</tr>
614 614
 					<?php endif; ?>
615
-					<?php
616
-					/**
615
+    					<?php
616
+					    /**
617 617
 					 * Filters the display of the password fields.
618 618
 					 *
619 619
 					 * @since 1.5.1
@@ -623,9 +623,9 @@  discard block
 block discarded – undo
623 623
 					 * @param bool    $show         Whether to show the password fields. Default true.
624 624
 					 * @param WP_User $profile_user User object for the current user to edit.
625 625
 					 */
626
-					$show_password_fields = apply_filters( 'show_password_fields', true, $profile_user );
627
-					?>
628
-					<?php if ( $show_password_fields ) : ?>
626
+					    $show_password_fields = apply_filters( 'show_password_fields', true, $profile_user );
627
+					    ?>
628
+    					<?php if ( $show_password_fields ) : ?>
629 629
 						</table>
630 630
 
631 631
 						<h2><?php _e( 'Account Management' ); ?></h2>
@@ -657,9 +657,9 @@  discard block
 block discarded – undo
657 657
 								<td>
658 658
 								<input name="pass2" type="password" id="pass2" class="regular-text" value="" autocomplete="new-password" aria-describedby="pass2-desc" />
659 659
 									<?php if ( IS_PROFILE_PAGE ) : ?>
660
-										<p class="description" id="pass2-desc"><?php _e( 'Type your new password again.' ); ?></p>
660
+    										<p class="description" id="pass2-desc"><?php _e( 'Type your new password again.' ); ?></p>
661 661
 									<?php else : ?>
662
-										<p class="description" id="pass2-desc"><?php _e( 'Type the new password again.' ); ?></p>
662
+    										<p class="description" id="pass2-desc"><?php _e( 'Type the new password again.' ); ?></p>
663 663
 									<?php endif; ?>
664 664
 								</td>
665 665
 							</tr>
@@ -673,9 +673,9 @@  discard block
 block discarded – undo
673 673
 								</td>
674 674
 							</tr>
675 675
 							<?php endif; // End Show Password Fields. ?>
676
-
676
+    
677 677
 							<?php // Allow admins to send reset password link. ?>
678
-							<?php if ( ! IS_PROFILE_PAGE ) : ?>
678
+    							<?php if ( ! IS_PROFILE_PAGE ) : ?>
679 679
 								<tr class="user-generate-reset-link-wrap hide-if-no-js">
680 680
 									<th><?php _e( 'Password Reset' ); ?></th>
681 681
 									<td>
@@ -686,17 +686,17 @@  discard block
 block discarded – undo
686 686
 										</div>
687 687
 										<p class="description">
688 688
 											<?php
689
-											printf(
690
-												/* translators: %s: User's display name. */
691
-												__( 'Send %s a link to reset their password. This will not change their password, nor will it force a change.' ),
692
-												esc_html( $profile_user->display_name )
693
-											);
694
-											?>
689
+											    printf(
690
+												    /* translators: %s: User's display name. */
691
+												    __( 'Send %s a link to reset their password. This will not change their password, nor will it force a change.' ),
692
+												    esc_html( $profile_user->display_name )
693
+											    );
694
+											    ?>
695 695
 										</p>
696 696
 									</td>
697 697
 								</tr>
698 698
 							<?php endif; ?>
699
-
699
+    
700 700
 							<?php if ( IS_PROFILE_PAGE && count( $sessions->get_all() ) === 1 ) : ?>
701 701
 								<tr class="user-sessions-wrap hide-if-no-js">
702 702
 									<th><?php _e( 'Sessions' ); ?></th>
@@ -724,57 +724,57 @@  discard block
 block discarded – undo
724 724
 										<p><button type="button" class="button" id="destroy-sessions"><?php _e( 'Log Out Everywhere' ); ?></button></p>
725 725
 										<p class="description">
726 726
 											<?php
727
-											/* translators: %s: User's display name. */
728
-											printf( __( 'Log %s out of all locations.' ), $profile_user->display_name );
729
-											?>
727
+											    /* translators: %s: User's display name. */
728
+											    printf( __( 'Log %s out of all locations.' ), $profile_user->display_name );
729
+											    ?>
730 730
 										</p>
731 731
 									</td>
732 732
 								</tr>
733 733
 							<?php endif; ?>
734
-						</table>
734
+    						</table>
735 735
 
736 736
 					<?php if ( wp_is_application_passwords_available_for_user( $user_id ) || ! wp_is_application_passwords_supported() ) : ?>
737 737
 						<div class="application-passwords hide-if-no-js" id="application-passwords-section">
738 738
 							<h2><?php _e( 'Application Passwords' ); ?></h2>
739 739
 							<p><?php _e( 'Application passwords allow authentication via non-interactive systems, such as XML-RPC or the REST API, without providing your actual password. Application passwords can be easily revoked. They cannot be used for traditional logins to your website.' ); ?></p>
740 740
 							<?php if ( wp_is_application_passwords_available_for_user( $user_id ) ) : ?>
741
-								<?php
742
-								if ( is_multisite() ) :
743
-									$blogs       = get_blogs_of_user( $user_id, true );
744
-									$blogs_count = count( $blogs );
745
-
746
-									if ( $blogs_count > 1 ) :
747
-										?>
748
-										<p>
741
+    								<?php
742
+								    if ( is_multisite() ) :
743
+									    $blogs       = get_blogs_of_user( $user_id, true );
744
+									    $blogs_count = count( $blogs );
745
+
746
+									    if ( $blogs_count > 1 ) :
747
+										    ?>
748
+    										<p>
749 749
 											<?php
750
-											/* translators: 1: URL to my-sites.php, 2: Number of sites the user has. */
751
-											$message = _n(
752
-												'Application passwords grant access to <a href="%1$s">the %2$s site in this installation that you have permissions on</a>.',
753
-												'Application passwords grant access to <a href="%1$s">all %2$s sites in this installation that you have permissions on</a>.',
754
-												$blogs_count
755
-											);
756
-
757
-											if ( is_super_admin( $user_id ) ) {
758
-												/* translators: 1: URL to my-sites.php, 2: Number of sites the user has. */
759
-												$message = _n(
760
-													'Application passwords grant access to <a href="%1$s">the %2$s site on the network as you have Super Admin rights</a>.',
761
-													'Application passwords grant access to <a href="%1$s">all %2$s sites on the network as you have Super Admin rights</a>.',
762
-													$blogs_count
763
-												);
764
-											}
765
-
766
-											printf(
767
-												$message,
768
-												admin_url( 'my-sites.php' ),
769
-												number_format_i18n( $blogs_count )
770
-											);
771
-											?>
772
-										</p>
750
+											    /* translators: 1: URL to my-sites.php, 2: Number of sites the user has. */
751
+											    $message = _n(
752
+												    'Application passwords grant access to <a href="%1$s">the %2$s site in this installation that you have permissions on</a>.',
753
+												    'Application passwords grant access to <a href="%1$s">all %2$s sites in this installation that you have permissions on</a>.',
754
+												    $blogs_count
755
+											    );
756
+
757
+											    if ( is_super_admin( $user_id ) ) {
758
+												    /* translators: 1: URL to my-sites.php, 2: Number of sites the user has. */
759
+												    $message = _n(
760
+													    'Application passwords grant access to <a href="%1$s">the %2$s site on the network as you have Super Admin rights</a>.',
761
+													    'Application passwords grant access to <a href="%1$s">all %2$s sites on the network as you have Super Admin rights</a>.',
762
+													    $blogs_count
763
+												    );
764
+											    }
765
+
766
+											    printf(
767
+												    $message,
768
+												    admin_url( 'my-sites.php' ),
769
+												    number_format_i18n( $blogs_count )
770
+											    );
771
+											    ?>
772
+    										</p>
773 773
 										<?php
774
-									endif;
775
-								endif;
776
-								?>
777
-
774
+									    endif;
775
+								    endif;
776
+								    ?>
777
+    
778 778
 								<?php if ( ! wp_is_site_protected_by_basic_auth( 'front' ) ) : ?>
779 779
 									<div class="create-application-password form-wrap">
780 780
 										<div class="form-field">
@@ -784,15 +784,15 @@  discard block
 block discarded – undo
784 784
 										</div>
785 785
 
786 786
 										<?php
787
-										/**
787
+										    /**
788 788
 										 * Fires in the create Application Passwords form.
789 789
 										 *
790 790
 										 * @since 5.6.0
791 791
 										 *
792 792
 										 * @param WP_User $profile_user The current WP_User object.
793 793
 										 */
794
-										do_action( 'wp_create_application_password_form', $profile_user );
795
-										?>
794
+										    do_action( 'wp_create_application_password_form', $profile_user );
795
+										    ?>
796 796
 
797 797
 										<button type="button" name="do_new_application_password" id="do_new_application_password" class="button button-secondary"><?php _e( 'Add New Application Password' ); ?></button>
798 798
 									</div>
@@ -804,29 +804,29 @@  discard block
 block discarded – undo
804 804
 
805 805
 								<div class="application-passwords-list-table-wrapper">
806 806
 									<?php
807
-									$application_passwords_list_table = _get_list_table( 'WP_Application_Passwords_List_Table', array( 'screen' => 'application-passwords-user' ) );
808
-									$application_passwords_list_table->prepare_items();
809
-									$application_passwords_list_table->display();
810
-									?>
811
-								</div>
807
+									    $application_passwords_list_table = _get_list_table( 'WP_Application_Passwords_List_Table', array( 'screen' => 'application-passwords-user' ) );
808
+									    $application_passwords_list_table->prepare_items();
809
+									    $application_passwords_list_table->display();
810
+									    ?>
811
+    								</div>
812 812
 							<?php elseif ( ! wp_is_application_passwords_supported() ) : ?>
813
-								<p><?php _e( 'The application password feature requires HTTPS, which is not enabled on this site.' ); ?></p>
813
+    								<p><?php _e( 'The application password feature requires HTTPS, which is not enabled on this site.' ); ?></p>
814 814
 								<p>
815 815
 									<?php
816
-									printf(
817
-										/* translators: %s: Documentation URL. */
818
-										__( 'If this is a development website you can <a href="%s" target="_blank">set the environment type accordingly</a> to enable application passwords.' ),
819
-										__( 'https://wordpress.org/support/article/editing-wp-config-php/#wp_environment_type' )
820
-									);
821
-									?>
822
-								</p>
816
+									    printf(
817
+										    /* translators: %s: Documentation URL. */
818
+										    __( 'If this is a development website you can <a href="%s" target="_blank">set the environment type accordingly</a> to enable application passwords.' ),
819
+										    __( 'https://wordpress.org/support/article/editing-wp-config-php/#wp_environment_type' )
820
+									    );
821
+									    ?>
822
+    								</p>
823 823
 							<?php endif; ?>
824
-						</div>
824
+    						</div>
825 825
 					<?php endif; // End Application Passwords. ?>
826
-
826
+    
827 827
 					<?php
828
-					if ( IS_PROFILE_PAGE ) {
829
-						/**
828
+					    if ( IS_PROFILE_PAGE ) {
829
+						    /**
830 830
 						 * Fires after the 'About Yourself' settings table on the 'Profile' editing screen.
831 831
 						 *
832 832
 						 * The action only fires if the current user is editing their own profile.
@@ -835,21 +835,21 @@  discard block
 block discarded – undo
835 835
 						 *
836 836
 						 * @param WP_User $profile_user The current WP_User object.
837 837
 						 */
838
-						do_action( 'show_user_profile', $profile_user );
839
-					} else {
840
-						/**
838
+						    do_action( 'show_user_profile', $profile_user );
839
+					    } else {
840
+						    /**
841 841
 						 * Fires after the 'About the User' settings table on the 'Edit User' screen.
842 842
 						 *
843 843
 						 * @since 2.0.0
844 844
 						 *
845 845
 						 * @param WP_User $profile_user The current WP_User object.
846 846
 						 */
847
-						do_action( 'edit_user_profile', $profile_user );
848
-					}
849
-					?>
850
-
847
+						    do_action( 'edit_user_profile', $profile_user );
848
+					    }
849
+					    ?>
850
+    
851 851
 					<?php
852
-					/**
852
+					    /**
853 853
 					 * Filters whether to display additional capabilities for the user.
854 854
 					 *
855 855
 					 * The 'Additional Capabilities' section will only be enabled if
@@ -861,34 +861,34 @@  discard block
 block discarded – undo
861 861
 					 * @param bool    $enable      Whether to display the capabilities. Default true.
862 862
 					 * @param WP_User $profile_user The current WP_User object.
863 863
 					 */
864
-					$display_additional_caps = apply_filters( 'additional_capabilities_display', true, $profile_user );
865
-					?>
866
-
864
+					    $display_additional_caps = apply_filters( 'additional_capabilities_display', true, $profile_user );
865
+					    ?>
866
+    
867 867
 				<?php if ( count( $profile_user->caps ) > count( $profile_user->roles ) && ( true === $display_additional_caps ) ) : ?>
868
-					<h2><?php _e( 'Additional Capabilities' ); ?></h2>
868
+    					<h2><?php _e( 'Additional Capabilities' ); ?></h2>
869 869
 
870 870
 					<table class="form-table" role="presentation">
871 871
 						<tr class="user-capabilities-wrap">
872 872
 							<th scope="row"><?php _e( 'Capabilities' ); ?></th>
873 873
 							<td>
874 874
 								<?php
875
-								$output = '';
876
-								foreach ( $profile_user->caps as $cap => $value ) {
877
-									if ( ! $wp_roles->is_role( $cap ) ) {
878
-										if ( '' !== $output ) {
879
-											$output .= ', ';
880
-										}
881
-
882
-										if ( $value ) {
883
-											$output .= $cap;
884
-										} else {
885
-											/* translators: %s: Capability name. */
886
-											$output .= sprintf( __( 'Denied: %s' ), $cap );
887
-										}
888
-									}
889
-								}
890
-								echo $output;
891
-								?>
875
+								    $output = '';
876
+								    foreach ( $profile_user->caps as $cap => $value ) {
877
+									    if ( ! $wp_roles->is_role( $cap ) ) {
878
+										    if ( '' !== $output ) {
879
+											    $output .= ', ';
880
+										    }
881
+
882
+										    if ( $value ) {
883
+											    $output .= $cap;
884
+										    } else {
885
+											    /* translators: %s: Capability name. */
886
+											    $output .= sprintf( __( 'Denied: %s' ), $cap );
887
+										    }
888
+									    }
889
+								    }
890
+								    echo $output;
891
+								    ?>
892 892
 							</td>
893 893
 						</tr>
894 894
 					</table>
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
 			</form>
903 903
 		</div>
904 904
 		<?php
905
-		break;
905
+		    break;
906 906
 }
907 907
 ?>
908 908
 <script type="text/javascript">
Please login to merge, or discard this patch.
brighty/wp-admin/setup-config.php 1 patch
Switch Indentation   +179 added lines, -179 removed lines patch added patch discarded remove patch
@@ -124,40 +124,40 @@  discard block
 block discarded – undo
124 124
 }
125 125
 
126 126
 switch ( $step ) {
127
-	case -1:
128
-		if ( wp_can_install_language_pack() && empty( $language ) ) {
129
-			$languages = wp_get_available_translations();
130
-			if ( $languages ) {
131
-				setup_config_display_header( 'language-chooser' );
132
-				echo '<h1 class="screen-reader-text">Select a default language</h1>';
133
-				echo '<form id="setup" method="post" action="?step=0">';
134
-				wp_install_language_form( $languages );
135
-				echo '</form>';
136
-				break;
137
-			}
138
-		}
139
-
140
-		// Deliberately fall through if we can't reach the translations API.
141
-
142
-	case 0:
143
-		if ( ! empty( $language ) ) {
144
-			$loaded_language = wp_download_language_pack( $language );
145
-			if ( $loaded_language ) {
146
-				load_default_textdomain( $loaded_language );
147
-				$GLOBALS['wp_locale'] = new WP_Locale();
148
-			}
149
-		}
150
-
151
-		setup_config_display_header();
152
-		$step_1 = 'setup-config.php?step=1';
153
-		if ( isset( $_REQUEST['noapi'] ) ) {
154
-			$step_1 .= '&amp;noapi';
155
-		}
156
-		if ( ! empty( $loaded_language ) ) {
157
-			$step_1 .= '&amp;language=' . $loaded_language;
158
-		}
159
-		?>
160
-<h1 class="screen-reader-text"><?php _e( 'Before getting started' ); ?></h1>
127
+	    case -1:
128
+		    if ( wp_can_install_language_pack() && empty( $language ) ) {
129
+			    $languages = wp_get_available_translations();
130
+			    if ( $languages ) {
131
+				    setup_config_display_header( 'language-chooser' );
132
+				    echo '<h1 class="screen-reader-text">Select a default language</h1>';
133
+				    echo '<form id="setup" method="post" action="?step=0">';
134
+				    wp_install_language_form( $languages );
135
+				    echo '</form>';
136
+				    break;
137
+			    }
138
+		    }
139
+
140
+		    // Deliberately fall through if we can't reach the translations API.
141
+
142
+	    case 0:
143
+		    if ( ! empty( $language ) ) {
144
+			    $loaded_language = wp_download_language_pack( $language );
145
+			    if ( $loaded_language ) {
146
+				    load_default_textdomain( $loaded_language );
147
+				    $GLOBALS['wp_locale'] = new WP_Locale();
148
+			    }
149
+		    }
150
+
151
+		    setup_config_display_header();
152
+		    $step_1 = 'setup-config.php?step=1';
153
+		    if ( isset( $_REQUEST['noapi'] ) ) {
154
+			    $step_1 .= '&amp;noapi';
155
+		    }
156
+		    if ( ! empty( $loaded_language ) ) {
157
+			    $step_1 .= '&amp;language=' . $loaded_language;
158
+		    }
159
+		    ?>
160
+    <h1 class="screen-reader-text"><?php _e( 'Before getting started' ); ?></h1>
161 161
 <p><?php _e( 'Welcome to WordPress. Before getting started, you will need to know the following items.' ); ?></p>
162 162
 <ol>
163 163
 	<li><?php _e( 'Database name' ); ?></li>
@@ -168,46 +168,46 @@  discard block
 block discarded – undo
168 168
 </ol>
169 169
 <p>
170 170
 		<?php
171
-		printf(
172
-			/* translators: %s: wp-config.php */
173
-			__( 'This information is being used to create a %s file.' ),
174
-			'<code>wp-config.php</code>'
175
-		);
176
-		?>
177
-	<strong>
171
+		    printf(
172
+			    /* translators: %s: wp-config.php */
173
+			    __( 'This information is being used to create a %s file.' ),
174
+			    '<code>wp-config.php</code>'
175
+		    );
176
+		    ?>
177
+    	<strong>
178 178
 		<?php
179
-		printf(
180
-			/* translators: 1: wp-config-sample.php, 2: wp-config.php */
181
-			__( 'If for any reason this automatic file creation does not work, do not worry. All this does is fill in the database information to a configuration file. You may also simply open %1$s in a text editor, fill in your information, and save it as %2$s.' ),
182
-			'<code>wp-config-sample.php</code>',
183
-			'<code>wp-config.php</code>'
184
-		);
185
-		?>
186
-	</strong>
179
+		    printf(
180
+			    /* translators: 1: wp-config-sample.php, 2: wp-config.php */
181
+			    __( 'If for any reason this automatic file creation does not work, do not worry. All this does is fill in the database information to a configuration file. You may also simply open %1$s in a text editor, fill in your information, and save it as %2$s.' ),
182
+			    '<code>wp-config-sample.php</code>',
183
+			    '<code>wp-config.php</code>'
184
+		    );
185
+		    ?>
186
+    	</strong>
187 187
 		<?php
188
-		printf(
189
-			/* translators: 1: Documentation URL, 2: wp-config.php */
190
-			__( 'Need more help? <a href="%1$s">Read the support article on %2$s</a>.' ),
191
-			__( 'https://wordpress.org/support/article/editing-wp-config-php/' ),
192
-			'<code>wp-config.php</code>'
193
-		);
194
-		?>
188
+		    printf(
189
+			    /* translators: 1: Documentation URL, 2: wp-config.php */
190
+			    __( 'Need more help? <a href="%1$s">Read the support article on %2$s</a>.' ),
191
+			    __( 'https://wordpress.org/support/article/editing-wp-config-php/' ),
192
+			    '<code>wp-config.php</code>'
193
+		    );
194
+		    ?>
195 195
 </p>
196 196
 <p><?php _e( 'In all likelihood, these items were supplied to you by your web host. If you do not have this information, then you will need to contact them before you can continue. If you are ready&hellip;' ); ?></p>
197 197
 
198 198
 <p class="step"><a href="<?php echo $step_1; ?>" class="button button-large"><?php _e( 'Let&#8217;s go!' ); ?></a></p>
199 199
 		<?php
200
-		break;
200
+		    break;
201 201
 
202
-	case 1:
203
-		load_default_textdomain( $language );
204
-		$GLOBALS['wp_locale'] = new WP_Locale();
202
+	    case 1:
203
+		    load_default_textdomain( $language );
204
+		    $GLOBALS['wp_locale'] = new WP_Locale();
205 205
 
206
-		setup_config_display_header();
206
+		    setup_config_display_header();
207 207
 
208
-		$autofocus = wp_is_mobile() ? '' : ' autofocus';
209
-		?>
210
-<h1 class="screen-reader-text"><?php _e( 'Set up your database connection' ); ?></h1>
208
+		    $autofocus = wp_is_mobile() ? '' : ' autofocus';
209
+		    ?>
210
+    <h1 class="screen-reader-text"><?php _e( 'Set up your database connection' ); ?></h1>
211 211
 <form method="post" action="setup-config.php?step=2">
212 212
 	<p><?php _e( 'Below you should enter your database connection details. If you are not sure about these, contact your host.' ); ?></p>
213 213
 	<table class="form-table" role="presentation">
@@ -231,9 +231,9 @@  discard block
 block discarded – undo
231 231
 			<td><input name="dbhost" id="dbhost" type="text" aria-describedby="dbhost-desc" size="25" value="localhost" /></td>
232 232
 			<td id="dbhost-desc">
233 233
 			<?php
234
-				/* translators: %s: localhost */
235
-				printf( __( 'You should be able to get this info from your web host, if %s does not work.' ), '<code>localhost</code>' );
236
-			?>
234
+				    /* translators: %s: localhost */
235
+				    printf( __( 'You should be able to get this info from your web host, if %s does not work.' ), '<code>localhost</code>' );
236
+			    ?>
237 237
 			</td>
238 238
 		</tr>
239 239
 		<tr>
@@ -243,128 +243,128 @@  discard block
 block discarded – undo
243 243
 		</tr>
244 244
 	</table>
245 245
 		<?php
246
-		if ( isset( $_GET['noapi'] ) ) {
247
-			?>
248
-<input name="noapi" type="hidden" value="1" /><?php } ?>
249
-	<input type="hidden" name="language" value="<?php echo esc_attr( $language ); ?>" />
246
+		    if ( isset( $_GET['noapi'] ) ) {
247
+			    ?>
248
+    <input name="noapi" type="hidden" value="1" /><?php } ?>
249
+    	<input type="hidden" name="language" value="<?php echo esc_attr( $language ); ?>" />
250 250
 	<p class="step"><input name="submit" type="submit" value="<?php echo htmlspecialchars( __( 'Submit' ), ENT_QUOTES ); ?>" class="button button-large" /></p>
251 251
 </form>
252 252
 		<?php
253
-		break;
254
-
255
-	case 2:
256
-		load_default_textdomain( $language );
257
-		$GLOBALS['wp_locale'] = new WP_Locale();
258
-
259
-		$dbname = trim( wp_unslash( $_POST['dbname'] ) );
260
-		$uname  = trim( wp_unslash( $_POST['uname'] ) );
261
-		$pwd    = trim( wp_unslash( $_POST['pwd'] ) );
262
-		$dbhost = trim( wp_unslash( $_POST['dbhost'] ) );
263
-		$prefix = trim( wp_unslash( $_POST['prefix'] ) );
264
-
265
-		$step_1  = 'setup-config.php?step=1';
266
-		$install = 'install.php';
267
-		if ( isset( $_REQUEST['noapi'] ) ) {
268
-			$step_1 .= '&amp;noapi';
269
-		}
270
-
271
-		if ( ! empty( $language ) ) {
272
-			$step_1  .= '&amp;language=' . $language;
273
-			$install .= '?language=' . $language;
274
-		} else {
275
-			$install .= '?language=en_US';
276
-		}
277
-
278
-		$tryagain_link = '</p><p class="step"><a href="' . $step_1 . '" onclick="javascript:history.go(-1);return false;" class="button button-large">' . __( 'Try Again' ) . '</a>';
279
-
280
-		if ( empty( $prefix ) ) {
281
-			wp_die( __( '<strong>Error</strong>: "Table Prefix" must not be empty.' ) . $tryagain_link );
282
-		}
283
-
284
-		// Validate $prefix: it can only contain letters, numbers and underscores.
285
-		if ( preg_match( '|[^a-z0-9_]|i', $prefix ) ) {
286
-			wp_die( __( '<strong>Error</strong>: "Table Prefix" can only contain numbers, letters, and underscores.' ) . $tryagain_link );
287
-		}
288
-
289
-		// Test the DB connection.
290
-		/**#@+
253
+		    break;
254
+
255
+	    case 2:
256
+		    load_default_textdomain( $language );
257
+		    $GLOBALS['wp_locale'] = new WP_Locale();
258
+
259
+		    $dbname = trim( wp_unslash( $_POST['dbname'] ) );
260
+		    $uname  = trim( wp_unslash( $_POST['uname'] ) );
261
+		    $pwd    = trim( wp_unslash( $_POST['pwd'] ) );
262
+		    $dbhost = trim( wp_unslash( $_POST['dbhost'] ) );
263
+		    $prefix = trim( wp_unslash( $_POST['prefix'] ) );
264
+
265
+		    $step_1  = 'setup-config.php?step=1';
266
+		    $install = 'install.php';
267
+		    if ( isset( $_REQUEST['noapi'] ) ) {
268
+			    $step_1 .= '&amp;noapi';
269
+		    }
270
+
271
+		    if ( ! empty( $language ) ) {
272
+			    $step_1  .= '&amp;language=' . $language;
273
+			    $install .= '?language=' . $language;
274
+		    } else {
275
+			    $install .= '?language=en_US';
276
+		    }
277
+
278
+		    $tryagain_link = '</p><p class="step"><a href="' . $step_1 . '" onclick="javascript:history.go(-1);return false;" class="button button-large">' . __( 'Try Again' ) . '</a>';
279
+
280
+		    if ( empty( $prefix ) ) {
281
+			    wp_die( __( '<strong>Error</strong>: "Table Prefix" must not be empty.' ) . $tryagain_link );
282
+		    }
283
+
284
+		    // Validate $prefix: it can only contain letters, numbers and underscores.
285
+		    if ( preg_match( '|[^a-z0-9_]|i', $prefix ) ) {
286
+			    wp_die( __( '<strong>Error</strong>: "Table Prefix" can only contain numbers, letters, and underscores.' ) . $tryagain_link );
287
+		    }
288
+
289
+		    // Test the DB connection.
290
+		    /**#@+
291 291
 		 *
292 292
 		 * @ignore
293 293
 		 */
294
-		define( 'DB_NAME', $dbname );
295
-		define( 'DB_USER', $uname );
296
-		define( 'DB_PASSWORD', $pwd );
297
-		define( 'DB_HOST', $dbhost );
298
-		/**#@-*/
294
+		    define( 'DB_NAME', $dbname );
295
+		    define( 'DB_USER', $uname );
296
+		    define( 'DB_PASSWORD', $pwd );
297
+		    define( 'DB_HOST', $dbhost );
298
+		    /**#@-*/
299 299
 
300
-		// Re-construct $wpdb with these new values.
301
-		unset( $wpdb );
302
-		require_wp_db();
300
+		    // Re-construct $wpdb with these new values.
301
+		    unset( $wpdb );
302
+		    require_wp_db();
303 303
 
304
-		/*
304
+		    /*
305 305
 		* The wpdb constructor bails when WP_SETUP_CONFIG is set, so we must
306 306
 		* fire this manually. We'll fail here if the values are no good.
307 307
 		*/
308
-		$wpdb->db_connect();
309
-
310
-		if ( ! empty( $wpdb->error ) ) {
311
-			wp_die( $wpdb->error->get_error_message() . $tryagain_link );
312
-		}
313
-
314
-		$errors = $wpdb->hide_errors();
315
-		$wpdb->query( "SELECT $prefix" );
316
-		$wpdb->show_errors( $errors );
317
-		if ( ! $wpdb->last_error ) {
318
-			// MySQL was able to parse the prefix as a value, which we don't want. Bail.
319
-			wp_die( __( '<strong>Error</strong>: "Table Prefix" is invalid.' ) );
320
-		}
321
-
322
-		// Generate keys and salts using secure CSPRNG; fallback to API if enabled; further fallback to original wp_generate_password().
323
-		try {
324
-			$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_ []{}<>~`+=,.;:/?|';
325
-			$max   = strlen( $chars ) - 1;
326
-			for ( $i = 0; $i < 8; $i++ ) {
327
-				$key = '';
328
-				for ( $j = 0; $j < 64; $j++ ) {
329
-					$key .= substr( $chars, random_int( 0, $max ), 1 );
330
-				}
331
-				$secret_keys[] = $key;
332
-			}
333
-		} catch ( Exception $ex ) {
334
-			$no_api = isset( $_POST['noapi'] );
335
-
336
-			if ( ! $no_api ) {
337
-				$secret_keys = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' );
338
-			}
339
-
340
-			if ( $no_api || is_wp_error( $secret_keys ) ) {
341
-				$secret_keys = array();
342
-				for ( $i = 0; $i < 8; $i++ ) {
343
-					$secret_keys[] = wp_generate_password( 64, true, true );
344
-				}
345
-			} else {
346
-				$secret_keys = explode( "\n", wp_remote_retrieve_body( $secret_keys ) );
347
-				foreach ( $secret_keys as $k => $v ) {
348
-					$secret_keys[ $k ] = substr( $v, 28, 64 );
349
-				}
350
-			}
351
-		}
352
-
353
-		$key = 0;
354
-		foreach ( $config_file as $line_num => $line ) {
355
-			if ( '$table_prefix =' === substr( $line, 0, 15 ) ) {
356
-				$config_file[ $line_num ] = '$table_prefix = \'' . addcslashes( $prefix, "\\'" ) . "';\r\n";
357
-				continue;
358
-			}
359
-
360
-			if ( ! preg_match( '/^define\(\s*\'([A-Z_]+)\',([ ]+)/', $line, $match ) ) {
361
-				continue;
362
-			}
363
-
364
-			$constant = $match[1];
365
-			$padding  = $match[2];
366
-
367
-			switch ( $constant ) {
308
+		    $wpdb->db_connect();
309
+
310
+		    if ( ! empty( $wpdb->error ) ) {
311
+			    wp_die( $wpdb->error->get_error_message() . $tryagain_link );
312
+		    }
313
+
314
+		    $errors = $wpdb->hide_errors();
315
+		    $wpdb->query( "SELECT $prefix" );
316
+		    $wpdb->show_errors( $errors );
317
+		    if ( ! $wpdb->last_error ) {
318
+			    // MySQL was able to parse the prefix as a value, which we don't want. Bail.
319
+			    wp_die( __( '<strong>Error</strong>: "Table Prefix" is invalid.' ) );
320
+		    }
321
+
322
+		    // Generate keys and salts using secure CSPRNG; fallback to API if enabled; further fallback to original wp_generate_password().
323
+		    try {
324
+			    $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_ []{}<>~`+=,.;:/?|';
325
+			    $max   = strlen( $chars ) - 1;
326
+			    for ( $i = 0; $i < 8; $i++ ) {
327
+				    $key = '';
328
+				    for ( $j = 0; $j < 64; $j++ ) {
329
+					    $key .= substr( $chars, random_int( 0, $max ), 1 );
330
+				    }
331
+				    $secret_keys[] = $key;
332
+			    }
333
+		    } catch ( Exception $ex ) {
334
+			    $no_api = isset( $_POST['noapi'] );
335
+
336
+			    if ( ! $no_api ) {
337
+				    $secret_keys = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' );
338
+			    }
339
+
340
+			    if ( $no_api || is_wp_error( $secret_keys ) ) {
341
+				    $secret_keys = array();
342
+				    for ( $i = 0; $i < 8; $i++ ) {
343
+					    $secret_keys[] = wp_generate_password( 64, true, true );
344
+				    }
345
+			    } else {
346
+				    $secret_keys = explode( "\n", wp_remote_retrieve_body( $secret_keys ) );
347
+				    foreach ( $secret_keys as $k => $v ) {
348
+					    $secret_keys[ $k ] = substr( $v, 28, 64 );
349
+				    }
350
+			    }
351
+		    }
352
+
353
+		    $key = 0;
354
+		    foreach ( $config_file as $line_num => $line ) {
355
+			    if ( '$table_prefix =' === substr( $line, 0, 15 ) ) {
356
+				    $config_file[ $line_num ] = '$table_prefix = \'' . addcslashes( $prefix, "\\'" ) . "';\r\n";
357
+				    continue;
358
+			    }
359
+
360
+			    if ( ! preg_match( '/^define\(\s*\'([A-Z_]+)\',([ ]+)/', $line, $match ) ) {
361
+				    continue;
362
+			    }
363
+
364
+			    $constant = $match[1];
365
+			    $padding  = $match[2];
366
+
367
+			    switch ( $constant ) {
368 368
 				case 'DB_NAME':
369 369
 				case 'DB_USER':
370 370
 				case 'DB_PASSWORD':
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 				case 'NONCE_SALT':
387 387
 					$config_file[ $line_num ] = "define( '" . $constant . "'," . $padding . "'" . $secret_keys[ $key++ ] . "' );\r\n";
388 388
 					break;
389
-			}
389
+			    }
390 390
 		}
391 391
 		unset( $line );
392 392
 
Please login to merge, or discard this patch.
brighty/wp-includes/Text/Diff/Engine/shell.php 1 patch
Switch Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -91,29 +91,29 @@
 block discarded – undo
91 91
             }
92 92
 
93 93
             switch ($match[3]) {
94
-            case 'd':
95
-                // deleted lines
96
-                array_push($edits,
97
-                    new Text_Diff_Op_delete(
98
-                        $this->_getLines($from_lines, $from_line_no, $match[2])));
99
-                $to_line_no++;
100
-                break;
101
-
102
-            case 'c':
103
-                // changed lines
104
-                array_push($edits,
105
-                    new Text_Diff_Op_change(
106
-                        $this->_getLines($from_lines, $from_line_no, $match[2]),
107
-                        $this->_getLines($to_lines, $to_line_no, $match[5])));
108
-                break;
109
-
110
-            case 'a':
111
-                // added lines
112
-                array_push($edits,
113
-                    new Text_Diff_Op_add(
114
-                        $this->_getLines($to_lines, $to_line_no, $match[5])));
115
-                $from_line_no++;
116
-                break;
94
+                case 'd':
95
+                    // deleted lines
96
+                    array_push($edits,
97
+                        new Text_Diff_Op_delete(
98
+                            $this->_getLines($from_lines, $from_line_no, $match[2])));
99
+                    $to_line_no++;
100
+                    break;
101
+
102
+                case 'c':
103
+                    // changed lines
104
+                    array_push($edits,
105
+                        new Text_Diff_Op_change(
106
+                            $this->_getLines($from_lines, $from_line_no, $match[2]),
107
+                            $this->_getLines($to_lines, $to_line_no, $match[5])));
108
+                    break;
109
+
110
+                case 'a':
111
+                    // added lines
112
+                    array_push($edits,
113
+                        new Text_Diff_Op_add(
114
+                            $this->_getLines($to_lines, $to_line_no, $match[5])));
115
+                    $from_line_no++;
116
+                    break;
117 117
             }
118 118
         }
119 119
 
Please login to merge, or discard this patch.
brighty/wp-includes/Text/Diff/Engine/string.php 1 patch
Switch Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -95,41 +95,41 @@  discard block
 block discarded – undo
95 95
         for ($i = 0; $i < $end;) {
96 96
             $diff1 = array();
97 97
             switch (substr($diff[$i], 0, 1)) {
98
-            case ' ':
99
-                do {
100
-                    $diff1[] = substr($diff[$i], 1);
101
-                } while (++$i < $end && substr($diff[$i], 0, 1) == ' ');
102
-                $edits[] = new Text_Diff_Op_copy($diff1);
103
-                break;
104
-
105
-            case '+':
106
-                // get all new lines
107
-                do {
108
-                    $diff1[] = substr($diff[$i], 1);
109
-                } while (++$i < $end && substr($diff[$i], 0, 1) == '+');
110
-                $edits[] = new Text_Diff_Op_add($diff1);
111
-                break;
112
-
113
-            case '-':
114
-                // get changed or removed lines
115
-                $diff2 = array();
116
-                do {
117
-                    $diff1[] = substr($diff[$i], 1);
118
-                } while (++$i < $end && substr($diff[$i], 0, 1) == '-');
98
+                case ' ':
99
+                    do {
100
+                        $diff1[] = substr($diff[$i], 1);
101
+                    } while (++$i < $end && substr($diff[$i], 0, 1) == ' ');
102
+                    $edits[] = new Text_Diff_Op_copy($diff1);
103
+                    break;
119 104
 
120
-                while ($i < $end && substr($diff[$i], 0, 1) == '+') {
121
-                    $diff2[] = substr($diff[$i++], 1);
122
-                }
123
-                if (count($diff2) == 0) {
124
-                    $edits[] = new Text_Diff_Op_delete($diff1);
125
-                } else {
126
-                    $edits[] = new Text_Diff_Op_change($diff1, $diff2);
127
-                }
128
-                break;
105
+                case '+':
106
+                    // get all new lines
107
+                    do {
108
+                        $diff1[] = substr($diff[$i], 1);
109
+                    } while (++$i < $end && substr($diff[$i], 0, 1) == '+');
110
+                    $edits[] = new Text_Diff_Op_add($diff1);
111
+                    break;
129 112
 
130
-            default:
131
-                $i++;
132
-                break;
113
+                case '-':
114
+                    // get changed or removed lines
115
+                    $diff2 = array();
116
+                    do {
117
+                        $diff1[] = substr($diff[$i], 1);
118
+                    } while (++$i < $end && substr($diff[$i], 0, 1) == '-');
119
+
120
+                    while ($i < $end && substr($diff[$i], 0, 1) == '+') {
121
+                        $diff2[] = substr($diff[$i++], 1);
122
+                    }
123
+                    if (count($diff2) == 0) {
124
+                        $edits[] = new Text_Diff_Op_delete($diff1);
125
+                    } else {
126
+                        $edits[] = new Text_Diff_Op_change($diff1, $diff2);
127
+                    }
128
+                    break;
129
+
130
+                default:
131
+                    $i++;
132
+                    break;
133 133
             }
134 134
         }
135 135
 
@@ -195,49 +195,49 @@  discard block
 block discarded – undo
195 195
             if ($i < $max_i) {
196 196
                 $diff1 = array();
197 197
                 switch (substr($diff[$i], 0, 1)) {
198
-                case '!':
199
-                    $diff2 = array();
200
-                    do {
201
-                        $diff1[] = substr($diff[$i], 2);
202
-                        if ($j < $max_j && substr($diff[$j], 0, 1) == '!') {
203
-                            $diff2[] = substr($diff[$j++], 2);
204
-                        }
205
-                    } while (++$i < $max_i && substr($diff[$i], 0, 1) == '!');
206
-                    $edits[] = new Text_Diff_Op_change($diff1, $diff2);
207
-                    break;
208
-
209
-                case '+':
210
-                    do {
211
-                        $diff1[] = substr($diff[$i], 2);
212
-                    } while (++$i < $max_i && substr($diff[$i], 0, 1) == '+');
213
-                    $edits[] = new Text_Diff_Op_add($diff1);
214
-                    break;
215
-
216
-                case '-':
217
-                    do {
218
-                        $diff1[] = substr($diff[$i], 2);
219
-                    } while (++$i < $max_i && substr($diff[$i], 0, 1) == '-');
220
-                    $edits[] = new Text_Diff_Op_delete($diff1);
221
-                    break;
198
+                    case '!':
199
+                        $diff2 = array();
200
+                        do {
201
+                            $diff1[] = substr($diff[$i], 2);
202
+                            if ($j < $max_j && substr($diff[$j], 0, 1) == '!') {
203
+                                $diff2[] = substr($diff[$j++], 2);
204
+                            }
205
+                        } while (++$i < $max_i && substr($diff[$i], 0, 1) == '!');
206
+                        $edits[] = new Text_Diff_Op_change($diff1, $diff2);
207
+                        break;
208
+
209
+                    case '+':
210
+                        do {
211
+                            $diff1[] = substr($diff[$i], 2);
212
+                        } while (++$i < $max_i && substr($diff[$i], 0, 1) == '+');
213
+                        $edits[] = new Text_Diff_Op_add($diff1);
214
+                        break;
215
+
216
+                    case '-':
217
+                        do {
218
+                            $diff1[] = substr($diff[$i], 2);
219
+                        } while (++$i < $max_i && substr($diff[$i], 0, 1) == '-');
220
+                        $edits[] = new Text_Diff_Op_delete($diff1);
221
+                        break;
222 222
                 }
223 223
             }
224 224
 
225 225
             if ($j < $max_j) {
226 226
                 $diff2 = array();
227 227
                 switch (substr($diff[$j], 0, 1)) {
228
-                case '+':
229
-                    do {
230
-                        $diff2[] = substr($diff[$j++], 2);
231
-                    } while ($j < $max_j && substr($diff[$j], 0, 1) == '+');
232
-                    $edits[] = new Text_Diff_Op_add($diff2);
233
-                    break;
228
+                    case '+':
229
+                        do {
230
+                            $diff2[] = substr($diff[$j++], 2);
231
+                        } while ($j < $max_j && substr($diff[$j], 0, 1) == '+');
232
+                        $edits[] = new Text_Diff_Op_add($diff2);
233
+                        break;
234 234
 
235
-                case '-':
236
-                    do {
237
-                        $diff2[] = substr($diff[$j++], 2);
238
-                    } while ($j < $max_j && substr($diff[$j], 0, 1) == '-');
239
-                    $edits[] = new Text_Diff_Op_delete($diff2);
240
-                    break;
235
+                    case '-':
236
+                        do {
237
+                            $diff2[] = substr($diff[$j++], 2);
238
+                        } while ($j < $max_j && substr($diff[$j], 0, 1) == '-');
239
+                        $edits[] = new Text_Diff_Op_delete($diff2);
240
+                        break;
241 241
                 }
242 242
             }
243 243
         }
Please login to merge, or discard this patch.
brighty/wp-includes/Text/Diff/Engine/xdiff.php 1 patch
Switch Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -44,17 +44,17 @@
 block discarded – undo
44 44
                 continue;
45 45
             }
46 46
             switch ($line[0]) {
47
-            case ' ':
48
-                $edits[] = new Text_Diff_Op_copy(array(substr($line, 1)));
49
-                break;
47
+                case ' ':
48
+                    $edits[] = new Text_Diff_Op_copy(array(substr($line, 1)));
49
+                    break;
50 50
 
51
-            case '+':
52
-                $edits[] = new Text_Diff_Op_add(array(substr($line, 1)));
53
-                break;
51
+                case '+':
52
+                    $edits[] = new Text_Diff_Op_add(array(substr($line, 1)));
53
+                    break;
54 54
 
55
-            case '-':
56
-                $edits[] = new Text_Diff_Op_delete(array(substr($line, 1)));
57
-                break;
55
+                case '-':
56
+                    $edits[] = new Text_Diff_Op_delete(array(substr($line, 1)));
57
+                    break;
58 58
             }
59 59
         }
60 60
 
Please login to merge, or discard this patch.
brighty/wp-includes/Text/Diff/Renderer.php 1 patch
Switch Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -154,21 +154,21 @@
 block discarded – undo
154 154
 
155 155
         foreach ($edits as $edit) {
156 156
             switch (strtolower(get_class($edit))) {
157
-            case 'text_diff_op_copy':
158
-                $output .= $this->_context($edit->orig);
159
-                break;
157
+                case 'text_diff_op_copy':
158
+                    $output .= $this->_context($edit->orig);
159
+                    break;
160 160
 
161
-            case 'text_diff_op_add':
162
-                $output .= $this->_added($edit->final);
163
-                break;
161
+                case 'text_diff_op_add':
162
+                    $output .= $this->_added($edit->final);
163
+                    break;
164 164
 
165
-            case 'text_diff_op_delete':
166
-                $output .= $this->_deleted($edit->orig);
167
-                break;
165
+                case 'text_diff_op_delete':
166
+                    $output .= $this->_deleted($edit->orig);
167
+                    break;
168 168
 
169
-            case 'text_diff_op_change':
170
-                $output .= $this->_changed($edit->orig, $edit->final);
171
-                break;
169
+                case 'text_diff_op_change':
170
+                    $output .= $this->_changed($edit->orig, $edit->final);
171
+                    break;
172 172
             }
173 173
         }
174 174
 
Please login to merge, or discard this patch.
plugins/awesome-support/includes/gas-framework/inc/scssphp/scss.inc.php 1 patch
Switch Indentation   +336 added lines, -336 removed lines patch added patch discarded remove patch
@@ -353,12 +353,12 @@  discard block
 block discarded – undo
353 353
 		foreach ($piece as &$p) {
354 354
 			if (!is_array($p)) continue;
355 355
 			switch ($p[0]) {
356
-			case "interpolate":
357
-				$p = $this->compileValue($p);
358
-				break;
359
-			case "string":
360
-				$p = $this->compileValue($p);
361
-				break;
356
+			    case "interpolate":
357
+				    $p = $this->compileValue($p);
358
+				    break;
359
+			    case "string":
360
+				    $p = $this->compileValue($p);
361
+				    break;
362 362
 			}
363 363
 		}
364 364
 		return $this->flattenSelectorSingle($piece);
@@ -374,12 +374,12 @@  discard block
 block discarded – undo
374 374
 		foreach ($piece as &$p) {
375 375
 			if (!is_array($p)) continue;
376 376
 			switch ($p[0]) {
377
-			case "self":
378
-				$p = "&";
379
-				break;
380
-			default:
381
-				$p = $this->compileValue($p);
382
-				break;
377
+			    case "self":
378
+				    $p = "&";
379
+				    break;
380
+			    default:
381
+				    $p = $this->compileValue($p);
382
+				    break;
383 383
 			}
384 384
 		}
385 385
 		return implode($piece);
@@ -461,186 +461,186 @@  discard block
 block discarded – undo
461 461
 		$this->sourcePos = isset($child[-1]) ? $child[-1] : -1;
462 462
 		$this->sourceParser = isset($child[-2]) ? $child[-2] : $this->parser;
463 463
 		switch ($child[0]) {
464
-		case "import":
465
-			list(,$rawPath) = $child;
466
-			$rawPath = $this->reduce($rawPath);
467
-			if (!$this->compileImport($rawPath, $out)) {
468
-				$out->lines[] = "@import " . $this->compileValue($rawPath) . ";";
469
-			}
470
-			break;
471
-		case "directive":
472
-			list(, $directive) = $child;
473
-			$s = "@" . $directive->name;
474
-			if (!empty($directive->value)) {
475
-				$s .= " " . $this->compileValue($directive->value);
476
-			}
477
-			$this->compileNestedBlock($directive, array($s));
478
-			break;
479
-		case "media":
480
-			$this->compileMedia($child[1]);
481
-			break;
482
-		case "block":
483
-			$this->compileBlock($child[1]);
484
-			break;
485
-		case "charset":
486
-			$out->lines[] = "@charset ".$this->compileValue($child[1]).";";
487
-			break;
488
-		case "assign":
489
-			list(,$name, $value) = $child;
490
-			if ($name[0] == "var") {
491
-				$isDefault = !empty($child[3]);
492
-				if ($isDefault) {
493
-					$existingValue = $this->get($name[1], true);
494
-					$shouldSet = $existingValue === true || $existingValue == self::$null;
495
-				}
496
-				if (!$isDefault || $shouldSet) {
497
-					$this->set($name[1], $this->reduce($value));
498
-				}
499
-				break;
500
-			}
501
-			// if the value reduces to null from something else then
502
-			// the property should be discarded
503
-			if ($value[0] != "null") {
504
-				$value = $this->reduce($value);
505
-				if ($value[0] == "null") {
506
-					break;
507
-				}
508
-			}
509
-			$compiledValue = $this->compileValue($value);
510
-			$out->lines[] = $this->formatter->property(
511
-				$this->compileValue($name),
512
-				$compiledValue);
513
-			break;
514
-		case "comment":
515
-			$out->lines[] = $child[1];
516
-			break;
517
-		case "mixin":
518
-		case "function":
519
-			list(,$block) = $child;
520
-			$this->set(self::$namespaces[$block->type] . $block->name, $block);
521
-			break;
522
-		case "extend":
523
-			list(, $selectors) = $child;
524
-			foreach ($selectors as $sel) {
525
-				// only use the first one
526
-				$sel = current($this->evalSelector($sel));
527
-				$this->pushExtends($sel, $out->selectors);
528
-			}
529
-			break;
530
-		case "if":
531
-			list(, $if) = $child;
532
-			if ($this->isTruthy($this->reduce($if->cond, true))) {
533
-				return $this->compileChildren($if->children, $out);
534
-			} else {
535
-				foreach ($if->cases as $case) {
536
-					if ($case->type == "else" ||
537
-						$case->type == "elseif" && $this->isTruthy($this->reduce($case->cond)))
538
-					{
539
-						return $this->compileChildren($case->children, $out);
540
-					}
541
-				}
542
-			}
543
-			break;
544
-		case "return":
545
-			return $this->reduce($child[1], true);
546
-		case "each":
547
-			list(,$each) = $child;
548
-			$list = $this->coerceList($this->reduce($each->list));
549
-			foreach ($list[2] as $item) {
550
-				$this->pushEnv();
551
-				$this->set($each->var, $item);
552
-				// TODO: allow return from here
553
-				$this->compileChildren($each->children, $out);
554
-				$this->popEnv();
555
-			}
556
-			break;
557
-		case "while":
558
-			list(,$while) = $child;
559
-			while ($this->isTruthy($this->reduce($while->cond, true))) {
560
-				$ret = $this->compileChildren($while->children, $out);
561
-				if ($ret) return $ret;
562
-			}
563
-			break;
564
-		case "for":
565
-			list(,$for) = $child;
566
-			$start = $this->reduce($for->start, true);
567
-			$start = $start[1];
568
-			$end = $this->reduce($for->end, true);
569
-			$end = $end[1];
570
-			$d = $start < $end ? 1 : -1;
571
-			while (true) {
572
-				if ((!$for->until && $start - $d == $end) ||
573
-					($for->until && $start == $end))
574
-				{
575
-					break;
576
-				}
577
-				$this->set($for->var, array("number", $start, ""));
578
-				$start += $d;
579
-				$ret = $this->compileChildren($for->children, $out);
580
-				if ($ret) return $ret;
581
-			}
582
-			break;
583
-		case "nestedprop":
584
-			list(,$prop) = $child;
585
-			$prefixed = array();
586
-			$prefix = $this->compileValue($prop->prefix) . "-";
587
-			foreach ($prop->children as $child) {
588
-				if ($child[0] == "assign") {
589
-					array_unshift($child[1][2], $prefix);
590
-				}
591
-				if ($child[0] == "nestedprop") {
592
-					array_unshift($child[1]->prefix[2], $prefix);
593
-				}
594
-				$prefixed[] = $child;
595
-			}
596
-			$this->compileChildren($prefixed, $out);
597
-			break;
598
-		case "include": // including a mixin
599
-			list(,$name, $argValues, $content) = $child;
600
-			$mixin = $this->get(self::$namespaces["mixin"] . $name, false);
601
-			if (!$mixin) {
602
-				$this->throwError("Undefined mixin $name");
603
-			}
604
-			$callingScope = $this->env;
605
-			// push scope, apply args
606
-			$this->pushEnv();
607
-			if ($this->env->depth > 0) {
608
-				$this->env->depth--;
609
-			}
610
-			if (!is_null($content)) {
611
-				$content->scope = $callingScope;
612
-				$this->setRaw(self::$namespaces["special"] . "content", $content);
613
-			}
614
-			if (!is_null($mixin->args)) {
615
-				$this->applyArguments($mixin->args, $argValues);
616
-			}
617
-			foreach ($mixin->children as $child) {
618
-				$this->compileChild($child, $out);
619
-			}
620
-			$this->popEnv();
621
-			break;
622
-		case "mixin_content":
623
-			$content = $this->get(self::$namespaces["special"] . "content");
624
-			if (is_null($content)) {
625
-				$this->throwError("Expected @content inside of mixin");
626
-			}
627
-			$strongTypes = array('include', 'block', 'for', 'while');
628
-			foreach ($content->children as $child) {
629
-				$this->storeEnv = (in_array($child[0], $strongTypes))
630
-					? null
631
-					: $content->scope;
632
-				$this->compileChild($child, $out);
633
-			}
634
-			unset($this->storeEnv);
635
-			break;
636
-		case "debug":
637
-			list(,$value, $pos) = $child;
638
-			$line = $this->parser->getLineNo($pos);
639
-			$value = $this->compileValue($this->reduce($value, true));
640
-			fwrite(STDERR, "Line $line DEBUG: $value\n");
641
-			break;
642
-		default:
643
-			$this->throwError("unknown child type: $child[0]");
464
+		    case "import":
465
+			    list(,$rawPath) = $child;
466
+			    $rawPath = $this->reduce($rawPath);
467
+			    if (!$this->compileImport($rawPath, $out)) {
468
+				    $out->lines[] = "@import " . $this->compileValue($rawPath) . ";";
469
+			    }
470
+			    break;
471
+		    case "directive":
472
+			    list(, $directive) = $child;
473
+			    $s = "@" . $directive->name;
474
+			    if (!empty($directive->value)) {
475
+				    $s .= " " . $this->compileValue($directive->value);
476
+			    }
477
+			    $this->compileNestedBlock($directive, array($s));
478
+			    break;
479
+		    case "media":
480
+			    $this->compileMedia($child[1]);
481
+			    break;
482
+		    case "block":
483
+			    $this->compileBlock($child[1]);
484
+			    break;
485
+		    case "charset":
486
+			    $out->lines[] = "@charset ".$this->compileValue($child[1]).";";
487
+			    break;
488
+		    case "assign":
489
+			    list(,$name, $value) = $child;
490
+			    if ($name[0] == "var") {
491
+				    $isDefault = !empty($child[3]);
492
+				    if ($isDefault) {
493
+					    $existingValue = $this->get($name[1], true);
494
+					    $shouldSet = $existingValue === true || $existingValue == self::$null;
495
+				    }
496
+				    if (!$isDefault || $shouldSet) {
497
+					    $this->set($name[1], $this->reduce($value));
498
+				    }
499
+				    break;
500
+			    }
501
+			    // if the value reduces to null from something else then
502
+			    // the property should be discarded
503
+			    if ($value[0] != "null") {
504
+				    $value = $this->reduce($value);
505
+				    if ($value[0] == "null") {
506
+					    break;
507
+				    }
508
+			    }
509
+			    $compiledValue = $this->compileValue($value);
510
+			    $out->lines[] = $this->formatter->property(
511
+				    $this->compileValue($name),
512
+				    $compiledValue);
513
+			    break;
514
+		    case "comment":
515
+			    $out->lines[] = $child[1];
516
+			    break;
517
+		    case "mixin":
518
+		    case "function":
519
+			    list(,$block) = $child;
520
+			    $this->set(self::$namespaces[$block->type] . $block->name, $block);
521
+			    break;
522
+		    case "extend":
523
+			    list(, $selectors) = $child;
524
+			    foreach ($selectors as $sel) {
525
+				    // only use the first one
526
+				    $sel = current($this->evalSelector($sel));
527
+				    $this->pushExtends($sel, $out->selectors);
528
+			    }
529
+			    break;
530
+		    case "if":
531
+			    list(, $if) = $child;
532
+			    if ($this->isTruthy($this->reduce($if->cond, true))) {
533
+				    return $this->compileChildren($if->children, $out);
534
+			    } else {
535
+				    foreach ($if->cases as $case) {
536
+					    if ($case->type == "else" ||
537
+						    $case->type == "elseif" && $this->isTruthy($this->reduce($case->cond)))
538
+					    {
539
+						    return $this->compileChildren($case->children, $out);
540
+					    }
541
+				    }
542
+			    }
543
+			    break;
544
+		    case "return":
545
+			    return $this->reduce($child[1], true);
546
+		    case "each":
547
+			    list(,$each) = $child;
548
+			    $list = $this->coerceList($this->reduce($each->list));
549
+			    foreach ($list[2] as $item) {
550
+				    $this->pushEnv();
551
+				    $this->set($each->var, $item);
552
+				    // TODO: allow return from here
553
+				    $this->compileChildren($each->children, $out);
554
+				    $this->popEnv();
555
+			    }
556
+			    break;
557
+		    case "while":
558
+			    list(,$while) = $child;
559
+			    while ($this->isTruthy($this->reduce($while->cond, true))) {
560
+				    $ret = $this->compileChildren($while->children, $out);
561
+				    if ($ret) return $ret;
562
+			    }
563
+			    break;
564
+		    case "for":
565
+			    list(,$for) = $child;
566
+			    $start = $this->reduce($for->start, true);
567
+			    $start = $start[1];
568
+			    $end = $this->reduce($for->end, true);
569
+			    $end = $end[1];
570
+			    $d = $start < $end ? 1 : -1;
571
+			    while (true) {
572
+				    if ((!$for->until && $start - $d == $end) ||
573
+					    ($for->until && $start == $end))
574
+				    {
575
+					    break;
576
+				    }
577
+				    $this->set($for->var, array("number", $start, ""));
578
+				    $start += $d;
579
+				    $ret = $this->compileChildren($for->children, $out);
580
+				    if ($ret) return $ret;
581
+			    }
582
+			    break;
583
+		    case "nestedprop":
584
+			    list(,$prop) = $child;
585
+			    $prefixed = array();
586
+			    $prefix = $this->compileValue($prop->prefix) . "-";
587
+			    foreach ($prop->children as $child) {
588
+				    if ($child[0] == "assign") {
589
+					    array_unshift($child[1][2], $prefix);
590
+				    }
591
+				    if ($child[0] == "nestedprop") {
592
+					    array_unshift($child[1]->prefix[2], $prefix);
593
+				    }
594
+				    $prefixed[] = $child;
595
+			    }
596
+			    $this->compileChildren($prefixed, $out);
597
+			    break;
598
+		    case "include": // including a mixin
599
+			    list(,$name, $argValues, $content) = $child;
600
+			    $mixin = $this->get(self::$namespaces["mixin"] . $name, false);
601
+			    if (!$mixin) {
602
+				    $this->throwError("Undefined mixin $name");
603
+			    }
604
+			    $callingScope = $this->env;
605
+			    // push scope, apply args
606
+			    $this->pushEnv();
607
+			    if ($this->env->depth > 0) {
608
+				    $this->env->depth--;
609
+			    }
610
+			    if (!is_null($content)) {
611
+				    $content->scope = $callingScope;
612
+				    $this->setRaw(self::$namespaces["special"] . "content", $content);
613
+			    }
614
+			    if (!is_null($mixin->args)) {
615
+				    $this->applyArguments($mixin->args, $argValues);
616
+			    }
617
+			    foreach ($mixin->children as $child) {
618
+				    $this->compileChild($child, $out);
619
+			    }
620
+			    $this->popEnv();
621
+			    break;
622
+		    case "mixin_content":
623
+			    $content = $this->get(self::$namespaces["special"] . "content");
624
+			    if (is_null($content)) {
625
+				    $this->throwError("Expected @content inside of mixin");
626
+			    }
627
+			    $strongTypes = array('include', 'block', 'for', 'while');
628
+			    foreach ($content->children as $child) {
629
+				    $this->storeEnv = (in_array($child[0], $strongTypes))
630
+					    ? null
631
+					    : $content->scope;
632
+				    $this->compileChild($child, $out);
633
+			    }
634
+			    unset($this->storeEnv);
635
+			    break;
636
+		    case "debug":
637
+			    list(,$value, $pos) = $child;
638
+			    $line = $this->parser->getLineNo($pos);
639
+			    $value = $this->compileValue($this->reduce($value, true));
640
+			    fwrite(STDERR, "Line $line DEBUG: $value\n");
641
+			    break;
642
+		    default:
643
+			    $this->throwError("unknown child type: $child[0]");
644 644
 		}
645 645
 	}
646 646
 	protected function expToString($exp) {
@@ -658,13 +658,13 @@  discard block
 block discarded – undo
658 658
 	// should $value cause its operand to eval
659 659
 	protected function shouldEval($value) {
660 660
 		switch ($value[0]) {
661
-		case "exp":
662
-			if ($value[1] == "/") {
663
-				return $this->shouldEval($value[2], $value[3]);
664
-			}
665
-		case "var":
666
-		case "fncall":
667
-			return true;
661
+		    case "exp":
662
+			    if ($value[1] == "/") {
663
+				    return $this->shouldEval($value[2], $value[3]);
664
+			    }
665
+		    case "var":
666
+		    case "fncall":
667
+			    return true;
668 668
 		}
669 669
 		return false;
670 670
 	}
@@ -749,11 +749,11 @@  discard block
 block discarded – undo
749 749
 				$exp = $this->reduce($exp);
750 750
 				if ($exp[0] == "number") {
751 751
 					switch ($op) {
752
-					case "+":
753
-						return $exp;
754
-					case "-":
755
-						$exp[1] *= -1;
756
-						return $exp;
752
+					    case "+":
753
+						    return $exp;
754
+					    case "-":
755
+						    $exp[1] *= -1;
756
+						    return $exp;
757 757
 					}
758 758
 				}
759 759
 				if ($op == "not") {
@@ -825,19 +825,19 @@  discard block
 block discarded – undo
825 825
 		$value = $this->coerceForExpression($this->reduce($value));
826 826
 		list($type) = $value;
827 827
 		switch ($type) {
828
-		case "list":
829
-			$value = $this->extractInterpolation($value);
830
-			if ($value[0] != "list") {
831
-				return array("keyword", $this->compileValue($value));
832
-			}
833
-			foreach ($value[2] as $key => $item) {
834
-				$value[2][$key] = $this->normalizeValue($item);
835
-			}
836
-			return $value;
837
-		case "number":
838
-			return $this->normalizeNumber($value);
839
-		default:
840
-			return $value;
828
+		    case "list":
829
+			    $value = $this->extractInterpolation($value);
830
+			    if ($value[0] != "list") {
831
+				    return array("keyword", $this->compileValue($value));
832
+			    }
833
+			    foreach ($value[2] as $key => $item) {
834
+				    $value[2][$key] = $this->normalizeValue($item);
835
+			    }
836
+			    return $value;
837
+		    case "number":
838
+			    return $this->normalizeNumber($value);
839
+		    default:
840
+			    return $value;
841 841
 		}
842 842
 	}
843 843
 	// just does physical lengths for now
@@ -905,30 +905,30 @@  discard block
 block discarded – undo
905 905
 			$lval = isset($left[$i]) ? $left[$i] : 0;
906 906
 			$rval = isset($right[$i]) ? $right[$i] : 0;
907 907
 			switch ($op) {
908
-			case '+':
909
-				$out[] = $lval + $rval;
910
-				break;
911
-			case '-':
912
-				$out[] = $lval - $rval;
913
-				break;
914
-			case '*':
915
-				$out[] = $lval * $rval;
916
-				break;
917
-			case '%':
918
-				$out[] = $lval % $rval;
919
-				break;
920
-			case '/':
921
-				if ($rval == 0) {
922
-					$this->throwError("color: Can't divide by zero");
923
-				}
924
-				$out[] = $lval / $rval;
925
-				break;
926
-			case "==":
927
-				return $this->op_eq($left, $right);
928
-			case "!=":
929
-				return $this->op_neq($left, $right);
930
-			default:
931
-				$this->throwError("color: unknown op $op");
908
+			    case '+':
909
+				    $out[] = $lval + $rval;
910
+				    break;
911
+			    case '-':
912
+				    $out[] = $lval - $rval;
913
+				    break;
914
+			    case '*':
915
+				    $out[] = $lval * $rval;
916
+				    break;
917
+			    case '%':
918
+				    $out[] = $lval % $rval;
919
+				    break;
920
+			    case '/':
921
+				    if ($rval == 0) {
922
+					    $this->throwError("color: Can't divide by zero");
923
+				    }
924
+				    $out[] = $lval / $rval;
925
+				    break;
926
+			    case "==":
927
+				    return $this->op_eq($left, $right);
928
+			    case "!=":
929
+				    return $this->op_neq($left, $right);
930
+			    default:
931
+				    $this->throwError("color: unknown op $op");
932 932
 			}
933 933
 		}
934 934
 		if (isset($left[4])) $out[4] = $left[4];
@@ -988,68 +988,68 @@  discard block
 block discarded – undo
988 988
 		$value = $this->reduce($value);
989 989
 		list($type) = $value;
990 990
 		switch ($type) {
991
-		case "keyword":
992
-			return $value[1];
993
-		case "color":
994
-			// [1] - red component (either number for a %)
995
-			// [2] - green component
996
-			// [3] - blue component
997
-			// [4] - optional alpha component
998
-			list(, $r, $g, $b) = $value;
999
-			$r = round($r);
1000
-			$g = round($g);
1001
-			$b = round($b);
1002
-			if (count($value) == 5 && $value[4] != 1) { // rgba
1003
-				return 'rgba('.$r.', '.$g.', '.$b.', '.$value[4].')';
1004
-			}
1005
-			$h = sprintf("#%02x%02x%02x", $r, $g, $b);
1006
-			// Converting hex color to short notation (e.g. #003399 to #039)
1007
-			if ($h[1] === $h[2] && $h[3] === $h[4] && $h[5] === $h[6]) {
1008
-				$h = '#' . $h[1] . $h[3] . $h[5];
1009
-			}
1010
-			return $h;
1011
-		case "number":
1012
-			return round($value[1], $this->numberPrecision) . $value[2];
1013
-		case "string":
1014
-			return $value[1] . $this->compileStringContent($value) . $value[1];
1015
-		case "function":
1016
-			$args = !empty($value[2]) ? $this->compileValue($value[2]) : "";
1017
-			return "$value[1]($args)";
1018
-		case "list":
1019
-			$value = $this->extractInterpolation($value);
1020
-			if ($value[0] != "list") return $this->compileValue($value);
1021
-			list(, $delim, $items) = $value;
1022
-			$filtered = array();
1023
-			foreach ($items as $item) {
1024
-				if ($item[0] == "null") continue;
1025
-				$filtered[] = $this->compileValue($item);
1026
-			}
1027
-			return implode("$delim ", $filtered);
1028
-		case "interpolated": # node created by extractInterpolation
1029
-			list(, $interpolate, $left, $right) = $value;
1030
-			list(,, $whiteLeft, $whiteRight) = $interpolate;
1031
-			$left = count($left[2]) > 0 ?
1032
-				$this->compileValue($left).$whiteLeft : "";
1033
-			$right = count($right[2]) > 0 ?
1034
-				$whiteRight.$this->compileValue($right) : "";
1035
-			return $left.$this->compileValue($interpolate).$right;
1036
-		case "interpolate": # raw parse node
1037
-			list(, $exp) = $value;
1038
-			// strip quotes if it's a string
1039
-			$reduced = $this->reduce($exp);
1040
-			switch ($reduced[0]) {
991
+		    case "keyword":
992
+			    return $value[1];
993
+		    case "color":
994
+			    // [1] - red component (either number for a %)
995
+			    // [2] - green component
996
+			    // [3] - blue component
997
+			    // [4] - optional alpha component
998
+			    list(, $r, $g, $b) = $value;
999
+			    $r = round($r);
1000
+			    $g = round($g);
1001
+			    $b = round($b);
1002
+			    if (count($value) == 5 && $value[4] != 1) { // rgba
1003
+				    return 'rgba('.$r.', '.$g.', '.$b.', '.$value[4].')';
1004
+			    }
1005
+			    $h = sprintf("#%02x%02x%02x", $r, $g, $b);
1006
+			    // Converting hex color to short notation (e.g. #003399 to #039)
1007
+			    if ($h[1] === $h[2] && $h[3] === $h[4] && $h[5] === $h[6]) {
1008
+				    $h = '#' . $h[1] . $h[3] . $h[5];
1009
+			    }
1010
+			    return $h;
1011
+		    case "number":
1012
+			    return round($value[1], $this->numberPrecision) . $value[2];
1013
+		    case "string":
1014
+			    return $value[1] . $this->compileStringContent($value) . $value[1];
1015
+		    case "function":
1016
+			    $args = !empty($value[2]) ? $this->compileValue($value[2]) : "";
1017
+			    return "$value[1]($args)";
1018
+		    case "list":
1019
+			    $value = $this->extractInterpolation($value);
1020
+			    if ($value[0] != "list") return $this->compileValue($value);
1021
+			    list(, $delim, $items) = $value;
1022
+			    $filtered = array();
1023
+			    foreach ($items as $item) {
1024
+				    if ($item[0] == "null") continue;
1025
+				    $filtered[] = $this->compileValue($item);
1026
+			    }
1027
+			    return implode("$delim ", $filtered);
1028
+		    case "interpolated": # node created by extractInterpolation
1029
+			    list(, $interpolate, $left, $right) = $value;
1030
+			    list(,, $whiteLeft, $whiteRight) = $interpolate;
1031
+			    $left = count($left[2]) > 0 ?
1032
+				    $this->compileValue($left).$whiteLeft : "";
1033
+			    $right = count($right[2]) > 0 ?
1034
+				    $whiteRight.$this->compileValue($right) : "";
1035
+			    return $left.$this->compileValue($interpolate).$right;
1036
+		    case "interpolate": # raw parse node
1037
+			    list(, $exp) = $value;
1038
+			    // strip quotes if it's a string
1039
+			    $reduced = $this->reduce($exp);
1040
+			    switch ($reduced[0]) {
1041 1041
 				case "string":
1042 1042
 					$reduced = array("keyword",
1043 1043
 						$this->compileStringContent($reduced));
1044 1044
 					break;
1045 1045
 				case "null":
1046 1046
 					$reduced = array("keyword", "");
1047
-			}
1047
+			    }
1048 1048
 			return $this->compileValue($reduced);
1049
-		case "null":
1050
-			return "null";
1051
-		default:
1052
-			$this->throwError("unknown value type: $type");
1049
+		    case "null":
1050
+			    return "null";
1051
+		    default:
1052
+			    $this->throwError("unknown value type: $type");
1053 1053
 		}
1054 1054
 	}
1055 1055
 	protected function compileStringContent($string) {
@@ -1419,25 +1419,25 @@  discard block
 block discarded – undo
1419 1419
 	}
1420 1420
 	protected function coerceColor($value) {
1421 1421
 		switch ($value[0]) {
1422
-		case "color": return $value;
1423
-		case "keyword":
1424
-			$name = $value[1];
1425
-			if (isset(self::$cssColors[$name])) {
1426
-				@list($r, $g, $b, $a) = explode(',', self::$cssColors[$name]);
1427
-				return isset($a)
1428
-					? array('color', (int) $r, (int) $g, (int) $b, (int) $a)
1429
-					: array('color', (int) $r, (int) $g, (int) $b);
1430
-			}
1431
-			return null;
1422
+		    case "color": return $value;
1423
+		    case "keyword":
1424
+			    $name = $value[1];
1425
+			    if (isset(self::$cssColors[$name])) {
1426
+				    @list($r, $g, $b, $a) = explode(',', self::$cssColors[$name]);
1427
+				    return isset($a)
1428
+					    ? array('color', (int) $r, (int) $g, (int) $b, (int) $a)
1429
+					    : array('color', (int) $r, (int) $g, (int) $b);
1430
+			    }
1431
+			    return null;
1432 1432
 		}
1433 1433
 		return null;
1434 1434
 	}
1435 1435
 	protected function coerceString($value) {
1436 1436
 		switch ($value[0]) {
1437
-		case "string":
1438
-			return $value;
1439
-		case "keyword":
1440
-			return array("string", "", array($value[1]));
1437
+		    case "string":
1438
+			    return $value;
1439
+		    case "keyword":
1440
+			    return array("string", "", array($value[1]));
1441 1441
 		}
1442 1442
 		return null;
1443 1443
 	}
@@ -1615,16 +1615,16 @@  discard block
 block discarded – undo
1615 1615
 		// 4, 5, 6 - hsl
1616 1616
 		// 7 - a
1617 1617
 		switch ($i) {
1618
-		case 1:
1619
-		case 2:
1620
-		case 3:
1621
-			$max = 255; break;
1622
-		case 4:
1623
-			$max = 360; break;
1624
-		case 7:
1625
-			$max = 1; break;
1626
-		default:
1627
-			$max = 100;
1618
+		    case 1:
1619
+		    case 2:
1620
+		    case 3:
1621
+			    $max = 255; break;
1622
+		    case 4:
1623
+			    $max = 360; break;
1624
+		    case 7:
1625
+			    $max = 1; break;
1626
+		    default:
1627
+			    $max = 100;
1628 1628
 		}
1629 1629
 		$scale = $scale / 100;
1630 1630
 		if ($scale < 0) {
@@ -1910,12 +1910,12 @@  discard block
 block discarded – undo
1910 1910
 	protected function listSeparatorForJoin($list1, $sep) {
1911 1911
 		if (is_null($sep)) return $list1[1];
1912 1912
 		switch ($this->compileValue($sep)) {
1913
-		case "comma":
1914
-			return ",";
1915
-		case "space":
1916
-			return "";
1917
-		default:
1918
-			return $list1[1];
1913
+		    case "comma":
1914
+			    return ",";
1915
+		    case "space":
1916
+			    return "";
1917
+		    default:
1918
+			    return $list1[1];
1919 1919
 		}
1920 1920
 	}
1921 1921
 	protected static $lib_join = array("list1", "list2", "separator");
@@ -1956,16 +1956,16 @@  discard block
 block discarded – undo
1956 1956
 	protected function lib_type_of($args) {
1957 1957
 		$value = $args[0];
1958 1958
 		switch ($value[0]) {
1959
-		case "keyword":
1960
-			if ($value == self::$true || $value == self::$false) {
1961
-				return "bool";
1962
-			}
1963
-			if ($this->coerceColor($value)) {
1964
-				return "color";
1965
-			}
1966
-			return "string";
1967
-		default:
1968
-			return $value[0];
1959
+		    case "keyword":
1960
+			    if ($value == self::$true || $value == self::$false) {
1961
+				    return "bool";
1962
+			    }
1963
+			    if ($this->coerceColor($value)) {
1964
+				    return "color";
1965
+			    }
1966
+			    return "string";
1967
+		    default:
1968
+			    return $value[0];
1969 1969
 		}
1970 1970
 	}
1971 1971
 	protected static $lib_unit = array("number");
Please login to merge, or discard this patch.