<?php
/**
* Edit user administration panel.
*
* @package WordPress
* @subpackage Administration
*/
/** WordPress Administration Bootstrap */
require_once __DIR__ . '/admin.php';
/** WordPress Translation Installation API */
require_once ABSPATH . 'wp-admin/includes/translation-install.php';
$action = ! empty( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : '';
$user_id = ! empty( $_REQUEST['user_id'] ) ? absint( $_REQUEST['user_id'] ) : 0;
$wp_http_referer = ! empty( $_REQUEST['wp_http_referer'] ) ? sanitize_text_field( $_REQUEST['wp_http_referer'] ) : '';
$current_user = wp_get_current_user();
if ( ! defined( 'IS_PROFILE_PAGE' ) ) {
define( 'IS_PROFILE_PAGE', ( $user_id === $current_user->ID ) );
}
if ( ! $user_id && IS_PROFILE_PAGE ) {
$user_id = $current_user->ID;
} elseif ( ! $user_id && ! IS_PROFILE_PAGE ) {
wp_die( __( 'Invalid user ID.' ) );
} elseif ( ! get_userdata( $user_id ) ) {
wp_die( __( 'Invalid user ID.' ) );
}
wp_enqueue_script( 'user-profile' );
if ( wp_is_application_passwords_available_for_user( $user_id ) ) {
wp_enqueue_script( 'application-passwords' );
}
if ( IS_PROFILE_PAGE ) {
// Used in the HTML title tag.
$title = __( 'Profile' );
} else {
// Used in the HTML title tag.
/* translators: %s: User's display name. */
$title = __( 'Edit User %s' );
}
if ( current_user_can( 'edit_users' ) && ! IS_PROFILE_PAGE ) {
$submenu_file = 'users.php';
} else {
$submenu_file = 'profile.php';
}
if ( current_user_can( 'edit_users' ) && ! is_user_admin() ) {
$parent_file = 'users.php';
} else {
$parent_file = 'profile.php';
}
$profile_help = '<p>' . __( 'Your profile contains information about you (your “account”) as well as some personal options related to using WordPress.' ) . '</p>' .
'<p>' . __( 'You can change your password, turn on keyboard shortcuts, change the color scheme of your WordPress administration screens, and turn off the WYSIWYG (Visual) editor, among other things. You can hide the Toolbar (formerly called the Admin Bar) from the front end of your site, however it cannot be disabled on the admin screens.' ) . '</p>' .
'<p>' . __( 'You can select the language you wish to use while using the WordPress administration screen without affecting the language site visitors see.' ) . '</p>' .
'<p>' . __( 'Your username cannot be changed, but you can use other fields to enter your real name or a nickname, and change which name to display on your posts.' ) . '</p>' .
'<p>' . __( 'You can log out of other devices, such as your phone or a public computer, by clicking the Log Out Everywhere Else button.' ) . '</p>' .
'<p>' . __( 'Required fields are indicated; the rest are optional. Profile information will only be displayed if your theme is set up to do so.' ) . '</p>' .
'<p>' . __( 'Remember to click the Update Profile button when you are finished.' ) . '</p>';
get_current_screen()->add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' => $profile_help,
)
);
get_current_screen()->set_help_sidebar(
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
'<p>' . __( '<a href="https://wordpress.org/documentation/article/users-your-profile-screen/">Documentation on User Profiles</a>' ) . '</p>' .
'<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>'
);
$wp_http_referer = remove_query_arg( array( 'update', 'delete_count', 'user_id' ), $wp_http_referer );
$user_can_edit = current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' );
/**
* Filters whether to allow administrators on Multisite to edit every user.
*
* Enabling the user editing form via this filter also hinges on the user holding
* the 'manage_network_users' cap, and the logged-in user not matching the user
* profile open for editing.
*
* The filter was introduced to replace the EDIT_ANY_USER constant.
*
* @since 3.0.0
*
* @param bool $allow Whether to allow editing of any user. Default true.
*/
if ( is_multisite()
&& ! current_user_can( 'manage_netwo