wp/wp-admin/options.php
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
--- a/wp/wp-admin/options.php	Wed Sep 21 18:19:35 2022 +0200
+++ b/wp/wp-admin/options.php	Tue Sep 27 16:37:53 2022 +0200
@@ -18,6 +18,7 @@
 /** WordPress Administration Bootstrap */
 require_once __DIR__ . '/admin.php';
 
+// Used in the HTML title tag.
 $title       = __( 'Settings' );
 $this_file   = 'options.php';
 $parent_file = 'options-general.php';
@@ -56,12 +57,17 @@
 if ( ! empty( $_GET['adminhash'] ) ) {
 	$new_admin_details = get_option( 'adminhash' );
 	$redirect          = 'options-general.php?updated=false';
-	if ( is_array( $new_admin_details ) && hash_equals( $new_admin_details['hash'], $_GET['adminhash'] ) && ! empty( $new_admin_details['newemail'] ) ) {
+
+	if ( is_array( $new_admin_details )
+		&& hash_equals( $new_admin_details['hash'], $_GET['adminhash'] )
+		&& ! empty( $new_admin_details['newemail'] )
+	) {
 		update_option( 'admin_email', $new_admin_details['newemail'] );
 		delete_option( 'adminhash' );
 		delete_option( 'new_admin_email' );
 		$redirect = 'options-general.php?updated=true';
 	}
+
 	wp_redirect( admin_url( $redirect ) );
 	exit;
 } elseif ( ! empty( $_GET['dismiss'] ) && 'new_admin_email' === $_GET['dismiss'] ) {
@@ -72,7 +78,7 @@
 	exit;
 }
 
-if ( is_multisite() && ! current_user_can( 'manage_network_options' ) && 'update' != $action ) {
+if ( is_multisite() && ! current_user_can( 'manage_network_options' ) && 'update' !== $action ) {
 	wp_die(
 		'<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
 		'<p>' . __( 'Sorry, you are not allowed to delete these items.' ) . '</p>',
@@ -182,7 +188,9 @@
 	 * or upload_path is not the default ('wp-content/uploads' or empty),
 	 * they can be edited, otherwise they're locked.
 	 */
-	if ( get_option( 'upload_url_path' ) || ( get_option( 'upload_path' ) != 'wp-content/uploads' && get_option( 'upload_path' ) ) ) {
+	if ( get_option( 'upload_url_path' )
+		|| get_option( 'upload_path' ) && 'wp-content/uploads' !== get_option( 'upload_path' )
+	) {
 		$allowed_options['media'][] = 'upload_path';
 		$allowed_options['media'][] = 'upload_url_path';
 	}
@@ -247,7 +255,7 @@
 		if ( is_multisite() && ! current_user_can( 'manage_network_options' ) ) {
 			wp_die( __( 'Sorry, you are not allowed to modify unregistered settings for this site.' ) );
 		}
-		$options = explode( ',', wp_unslash( $_POST['page_options'] ) );
+		$options = isset( $_POST['page_options'] ) ? explode( ',', wp_unslash( $_POST['page_options'] ) ) : null;
 	} else {
 		$options = $allowed_options[ $option_page ];
 	}
@@ -324,6 +332,8 @@
 		if ( $user_language_old !== $user_language_new ) {
 			load_default_textdomain( $user_language_new );
 		}
+	} else {
+		add_settings_error( 'general', 'settings_updated', __( 'Settings save failed.' ), 'error' );
 	}
 
 	/*