[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Edit user administration panel. 4 * 5 * @package WordPress 6 * @subpackage Administration 7 */ 8 9 /** WordPress Administration Bootstrap */ 10 require_once __DIR__ . '/admin.php'; 11 12 /** WordPress Translation Installation API */ 13 require_once ABSPATH . 'wp-admin/includes/translation-install.php'; 14 15 $action = ! empty( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : ''; 16 $user_id = ! empty( $_REQUEST['user_id'] ) ? absint( $_REQUEST['user_id'] ) : 0; 17 $wp_http_referer = ! empty( $_REQUEST['wp_http_referer'] ) ? sanitize_text_field( $_REQUEST['wp_http_referer'] ) : ''; 18 19 $current_user = wp_get_current_user(); 20 21 if ( ! defined( 'IS_PROFILE_PAGE' ) ) { 22 define( 'IS_PROFILE_PAGE', ( $user_id === $current_user->ID ) ); 23 } 24 25 if ( ! $user_id && IS_PROFILE_PAGE ) { 26 $user_id = $current_user->ID; 27 } elseif ( ! $user_id && ! IS_PROFILE_PAGE ) { 28 wp_die( __( 'Invalid user ID.' ) ); 29 } elseif ( ! get_userdata( $user_id ) ) { 30 wp_die( __( 'Invalid user ID.' ) ); 31 } 32 33 wp_enqueue_script( 'user-profile' ); 34 35 if ( wp_is_application_passwords_available_for_user( $user_id ) ) { 36 wp_enqueue_script( 'application-passwords' ); 37 } 38 39 if ( IS_PROFILE_PAGE ) { 40 // Used in the HTML title tag. 41 $title = __( 'Profile' ); 42 } else { 43 // Used in the HTML title tag. 44 /* translators: %s: User's display name. */ 45 $title = __( 'Edit User %s' ); 46 } 47 48 if ( current_user_can( 'edit_users' ) && ! IS_PROFILE_PAGE ) { 49 $submenu_file = 'users.php'; 50 } else { 51 $submenu_file = 'profile.php'; 52 } 53 54 if ( current_user_can( 'edit_users' ) && ! is_user_admin() ) { 55 $parent_file = 'users.php'; 56 } else { 57 $parent_file = 'profile.php'; 58 } 59 60 $profile_help = '<p>' . __( 'Your profile contains information about you (your “account”) as well as some personal options related to using WordPress.' ) . '</p>' . 61 '<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>' . 62 '<p>' . __( 'You can select the language you wish to use while using the WordPress administration screen without affecting the language site visitors see.' ) . '</p>' . 63 '<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>' . 64 '<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>' . 65 '<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>' . 66 '<p>' . __( 'Remember to click the Update Profile button when you are finished.' ) . '</p>'; 67 68 get_current_screen()->add_help_tab( 69 array( 70 'id' => 'overview', 71 'title' => __( 'Overview' ), 72 'content' => $profile_help, 73 ) 74 ); 75 76 get_current_screen()->set_help_sidebar( 77 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . 78 '<p>' . __( '<a href="https://wordpress.org/documentation/article/users-your-profile-screen/">Documentation on User Profiles</a>' ) . '</p>' . 79 '<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>' 80 ); 81 82 $wp_http_referer = remove_query_arg( array( 'update', 'delete_count', 'user_id' ), $wp_http_referer ); 83 84 $user_can_edit = current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ); 85 86 /** 87 * Filters whether to allow administrators on Multisite to edit every user. 88 * 89 * Enabling the user editing form via this filter also hinges on the user holding 90 * the 'manage_network_users' cap, and the logged-in user not matching the user 91 * profile open for editing. 92 * 93 * The filter was introduced to replace the EDIT_ANY_USER constant. 94 * 95 * @since 3.0.0 96 * 97 * @param bool $allow Whether to allow editing of any user. Default true. 98 */ 99 if ( is_multisite() 100 && ! current_user_can( 'manage_network_users' ) 101 && $user_id !== $current_user->ID 102 && ! apply_filters( 'enable_edit_any_user_configuration', true ) 103 ) { 104 wp_die( __( 'Sorry, you are not allowed to edit this user.' ) ); 105 } 106 107 // Execute confirmed email change. See send_confirmation_on_profile_email(). 108 if ( IS_PROFILE_PAGE && isset( $_GET['newuseremail'] ) && $current_user->ID ) { 109 $new_email = get_user_meta( $current_user->ID, '_new_email', true ); 110 if ( $new_email && hash_equals( $new_email['hash'], $_GET['newuseremail'] ) ) { 111 $user = new stdClass(); 112 $user->ID = $current_user->ID; 113 $user->user_email = esc_html( trim( $new_email['newemail'] ) ); 114 if ( is_multisite() && $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $current_user->user_login ) ) ) { 115 $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $user->user_email, $current_user->user_login ) ); 116 } 117 wp_update_user( $user ); 118 delete_user_meta( $current_user->ID, '_new_email' ); 119 wp_redirect( add_query_arg( array( 'updated' => 'true' ), self_admin_url( 'profile.php' ) ) ); 120 die(); 121 } else { 122 wp_redirect( add_query_arg( array( 'error' => 'new-email' ), self_admin_url( 'profile.php' ) ) ); 123 } 124 } elseif ( IS_PROFILE_PAGE && ! empty( $_GET['dismiss'] ) && $current_user->ID . '_new_email' === $_GET['dismiss'] ) { 125 check_admin_referer( 'dismiss-' . $current_user->ID . '_new_email' ); 126 delete_user_meta( $current_user->ID, '_new_email' ); 127 wp_redirect( add_query_arg( array( 'updated' => 'true' ), self_admin_url( 'profile.php' ) ) ); 128 die(); 129 } 130 131 switch ( $action ) { 132 case 'update': 133 check_admin_referer( 'update-user_' . $user_id ); 134 135 if ( ! current_user_can( 'edit_user', $user_id ) ) { 136 wp_die( __( 'Sorry, you are not allowed to edit this user.' ) ); 137 } 138 139 if ( IS_PROFILE_PAGE ) { 140 /** 141 * Fires before the page loads on the 'Profile' editing screen. 142 * 143 * The action only fires if the current user is editing their own profile. 144 * 145 * @since 2.0.0 146 * 147 * @param int $user_id The user ID. 148 */ 149 do_action( 'personal_options_update', $user_id ); 150 } else { 151 /** 152 * Fires before the page loads on the 'Edit User' screen. 153 * 154 * @since 2.7.0 155 * 156 * @param int $user_id The user ID. 157 */ 158 do_action( 'edit_user_profile_update', $user_id ); 159 } 160 161 // Update the email address in signups, if present. 162 if ( is_multisite() ) { 163 $user = get_userdata( $user_id ); 164 165 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 ) ) ) { 166 $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $_POST['email'], $user_login ) ); 167 } 168 } 169 170 // Update the user. 171 $errors = edit_user( $user_id ); 172 173 // Grant or revoke super admin status if requested. 174 if ( is_multisite() && is_network_admin() 175 && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) 176 && ! isset( $super_admins ) && empty( $_POST['super_admin'] ) === is_super_admin( $user_id ) 177 ) { 178 empty( $_POST['super_admin'] ) ? revoke_super_admin( $user_id ) : grant_super_admin( $user_id ); 179 } 180 181 if ( ! is_wp_error( $errors ) ) { 182 $redirect = add_query_arg( 'updated', true, get_edit_user_link( $user_id ) ); 183 if ( $wp_http_referer ) { 184 $redirect = add_query_arg( 'wp_http_referer', urlencode( $wp_http_referer ), $redirect ); 185 } 186 wp_redirect( $redirect ); 187 exit; 188 } 189 190 // Intentional fall-through to display $errors. 191 default: 192 $profile_user = get_user_to_edit( $user_id ); 193 194 if ( ! current_user_can( 'edit_user', $user_id ) ) { 195 wp_die( __( 'Sorry, you are not allowed to edit this user.' ) ); 196 } 197 198 $title = sprintf( $title, $profile_user->display_name ); 199 $sessions = WP_Session_Tokens::get_instance( $profile_user->ID ); 200 201 require_once ABSPATH . 'wp-admin/admin-header.php'; 202 ?> 203 204 <?php 205 if ( ! IS_PROFILE_PAGE && is_super_admin( $profile_user->ID ) && current_user_can( 'manage_network_options' ) ) : 206 $message = '<strong>' . __( 'Important:' ) . '</strong> ' . __( 'This user has super admin privileges.' ); 207 wp_admin_notice( 208 $message, 209 array( 210 'type' => 'info', 211 ) 212 ); 213 endif; 214 215 if ( isset( $_GET['updated'] ) ) : 216 if ( IS_PROFILE_PAGE ) : 217 $message = '<p><strong>' . __( 'Profile updated.' ) . '</strong></p>'; 218 else : 219 $message = '<p><strong>' . __( 'User updated.' ) . '</strong></p>'; 220 endif; 221 if ( $wp_http_referer && ! str_contains( $wp_http_referer, 'user-new.php' ) && ! IS_PROFILE_PAGE ) : 222 $message .= sprintf( 223 '<p><a href="%1$s">%2$s</a></p>', 224 esc_url( wp_validate_redirect( sanitize_url( $wp_http_referer ), self_admin_url( 'users.php' ) ) ), 225 __( '← Go to Users' ) 226 ); 227 endif; 228 wp_admin_notice( 229 $message, 230 array( 231 'id' => 'message', 232 'dismissible' => true, 233 'additional_classes' => array( 'updated' ), 234 'paragraph_wrap' => false, 235 ) 236 ); 237 endif; 238 239 if ( isset( $_GET['error'] ) ) : 240 $message = ''; 241 if ( 'new-email' === $_GET['error'] ) : 242 $message = __( 'Error while saving the new email address. Please try again.' ); 243 endif; 244 wp_admin_notice( 245 $message, 246 array( 247 'type' => 'error', 248 ) 249 ); 250 endif; 251 252 if ( isset( $errors ) && is_wp_error( $errors ) ) { 253 wp_admin_notice( 254 implode( "</p>\n<p>", $errors->get_error_messages() ), 255 array( 256 'additional_classes' => array( 'error' ), 257 ) 258 ); 259 } 260 ?> 261 262 <div class="wrap" id="profile-page"> 263 <h1 class="wp-heading-inline"> 264 <?php echo esc_html( $title ); ?> 265 </h1> 266 267 <?php if ( ! IS_PROFILE_PAGE ) : ?> 268 <?php if ( current_user_can( 'create_users' ) ) : ?> 269 <a href="user-new.php" class="page-title-action"><?php echo esc_html__( 'Add New User' ); ?></a> 270 <?php elseif ( is_multisite() && current_user_can( 'promote_users' ) ) : ?> 271 <a href="user-new.php" class="page-title-action"><?php echo esc_html__( 'Add Existing User' ); ?></a> 272 <?php endif; ?> 273 <?php endif; ?> 274 275 <hr class="wp-header-end"> 276 277 <form id="your-profile" action="<?php echo esc_url( self_admin_url( IS_PROFILE_PAGE ? 'profile.php' : 'user-edit.php' ) ); ?>" method="post" novalidate="novalidate" 278 <?php 279 /** 280 * Fires inside the your-profile form tag on the user editing screen. 281 * 282 * @since 3.0.0 283 */ 284 do_action( 'user_edit_form_tag' ); 285 ?> 286 > 287 <?php wp_nonce_field( 'update-user_' . $user_id ); ?> 288 <?php if ( $wp_http_referer ) : ?> 289 <input type="hidden" name="wp_http_referer" value="<?php echo esc_url( $wp_http_referer ); ?>" /> 290 <?php endif; ?> 291 <p> 292 <input type="hidden" name="from" value="profile" /> 293 <input type="hidden" name="checkuser_id" value="<?php echo get_current_user_id(); ?>" /> 294 </p> 295 296 <h2><?php _e( 'Personal Options' ); ?></h2> 297 298 <table class="form-table" role="presentation"> 299 <?php if ( ! ( IS_PROFILE_PAGE && ! $user_can_edit ) ) : ?> 300 <tr class="user-rich-editing-wrap"> 301 <th scope="row"><?php _e( 'Visual Editor' ); ?></th> 302 <td> 303 <label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="false" <?php checked( 'false', $profile_user->rich_editing ); ?> /> 304 <?php _e( 'Disable the visual editor when writing' ); ?> 305 </label> 306 </td> 307 </tr> 308 <?php endif; ?> 309 310 <?php 311 $show_syntax_highlighting_preference = ( 312 // For Custom HTML widget and Additional CSS in Customizer. 313 user_can( $profile_user, 'edit_theme_options' ) 314 || 315 // Edit plugins. 316 user_can( $profile_user, 'edit_plugins' ) 317 || 318 // Edit themes. 319 user_can( $profile_user, 'edit_themes' ) 320 ); 321 ?> 322 323 <?php if ( $show_syntax_highlighting_preference ) : ?> 324 <tr class="user-syntax-highlighting-wrap"> 325 <th scope="row"><?php _e( 'Syntax Highlighting' ); ?></th> 326 <td> 327 <label for="syntax_highlighting"><input name="syntax_highlighting" type="checkbox" id="syntax_highlighting" value="false" <?php checked( 'false', $profile_user->syntax_highlighting ); ?> /> 328 <?php _e( 'Disable syntax highlighting when editing code' ); ?> 329 </label> 330 </td> 331 </tr> 332 <?php endif; ?> 333 334 <?php if ( count( $_wp_admin_css_colors ) > 1 && has_action( 'admin_color_scheme_picker' ) ) : ?> 335 <tr class="user-admin-color-wrap"> 336 <th scope="row"><?php _e( 'Admin Color Scheme' ); ?></th> 337 <td> 338 <?php 339 /** 340 * Fires in the 'Admin Color Scheme' section of the user editing screen. 341 * 342 * The section is only enabled if a callback is hooked to the action, 343 * and if there is more than one defined color scheme for the admin. 344 * 345 * @since 3.0.0 346 * @since 3.8.1 Added `$user_id` parameter. 347 * 348 * @param int $user_id The user ID. 349 */ 350 do_action( 'admin_color_scheme_picker', $user_id ); 351 ?> 352 </td> 353 </tr> 354 <?php endif; // End if count ( $_wp_admin_css_colors ) > 1 ?> 355 356 <?php if ( ! ( IS_PROFILE_PAGE && ! $user_can_edit ) ) : ?> 357 <tr class="user-comment-shortcuts-wrap"> 358 <th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th> 359 <td> 360 <label for="comment_shortcuts"> 361 <input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php checked( 'true', $profile_user->comment_shortcuts ); ?> /> 362 <?php _e( 'Enable keyboard shortcuts for comment moderation.' ); ?> 363 </label> 364 <?php _e( '<a href="https://wordpress.org/documentation/article/keyboard-shortcuts-classic-editor/#keyboard-shortcuts-for-comments">Documentation on Keyboard Shortcuts</a>' ); ?> 365 </td> 366 </tr> 367 <?php endif; ?> 368 369 <tr class="show-admin-bar user-admin-bar-front-wrap"> 370 <th scope="row"><?php _e( 'Toolbar' ); ?></th> 371 <td> 372 <label for="admin_bar_front"> 373 <input name="admin_bar_front" type="checkbox" id="admin_bar_front" value="1"<?php checked( _get_admin_bar_pref( 'front', $profile_user->ID ) ); ?> /> 374 <?php _e( 'Show Toolbar when viewing site' ); ?> 375 </label><br /> 376 </td> 377 </tr> 378 379 <?php 380 $languages = get_available_languages(); 381 $can_install_translations = current_user_can( 'install_languages' ) && wp_can_install_language_pack(); 382 ?> 383 <?php if ( $languages || $can_install_translations ) : ?> 384 <tr class="user-language-wrap"> 385 <th scope="row"> 386 <?php /* translators: The user language selection field label. */ ?> 387 <label for="locale"><?php _e( 'Language' ); ?><span class="dashicons dashicons-translation" aria-hidden="true"></span></label> 388 </th> 389 <td> 390 <?php 391 $user_locale = $profile_user->locale; 392 393 if ( 'en_US' === $user_locale ) { 394 $user_locale = ''; 395 } elseif ( '' === $user_locale || ! in_array( $user_locale, $languages, true ) ) { 396 $user_locale = 'site-default'; 397 } 398 399 wp_dropdown_languages( 400 array( 401 'name' => 'locale', 402 'id' => 'locale', 403 'selected' => $user_locale, 404 'languages' => $languages, 405 'show_available_translations' => $can_install_translations, 406 'show_option_site_default' => true, 407 ) 408 ); 409 ?> 410 </td> 411 </tr> 412 <?php endif; ?> 413 414 <?php 415 /** 416 * Fires at the end of the 'Personal Options' settings table on the user editing screen. 417 * 418 * @since 2.7.0 419 * 420 * @param WP_User $profile_user The current WP_User object. 421 */ 422 do_action( 'personal_options', $profile_user ); 423 ?> 424 425 </table> 426 <?php 427 if ( IS_PROFILE_PAGE ) { 428 /** 429 * Fires after the 'Personal Options' settings table on the 'Profile' editing screen. 430 * 431 * The action only fires if the current user is editing their own profile. 432 * 433 * @since 2.0.0 434 * 435 * @param WP_User $profile_user The current WP_User object. 436 */ 437 do_action( 'profile_personal_options', $profile_user ); 438 } 439 ?> 440 441 <h2><?php _e( 'Name' ); ?></h2> 442 443 <table class="form-table" role="presentation"> 444 <tr class="user-user-login-wrap"> 445 <th><label for="user_login"><?php _e( 'Username' ); ?></label></th> 446 <td><input type="text" name="user_login" id="user_login" value="<?php echo esc_attr( $profile_user->user_login ); ?>" readonly="readonly" class="regular-text" /> <span class="description"><?php _e( 'Usernames cannot be changed.' ); ?></span></td> 447 </tr> 448 449 <?php if ( ! IS_PROFILE_PAGE && ! is_network_admin() && current_user_can( 'promote_user', $profile_user->ID ) ) : ?> 450 <tr class="user-role-wrap"> 451 <th><label for="role"><?php _e( 'Role' ); ?></label></th> 452 <td> 453 <select name="role" id="role"> 454 <?php 455 // Compare user role against currently editable roles. 456 $user_roles = array_intersect( array_values( $profile_user->roles ), array_keys( get_editable_roles() ) ); 457 $user_role = reset( $user_roles ); 458 459 // Print the full list of roles with the primary one selected. 460 wp_dropdown_roles( $user_role ); 461 462 // Print the 'no role' option. Make it selected if the user has no role yet. 463 if ( $user_role ) { 464 echo '<option value="">' . __( '— No role for this site —' ) . '</option>'; 465 } else { 466 echo '<option value="" selected="selected">' . __( '— No role for this site —' ) . '</option>'; 467 } 468 ?> 469 </select> 470 </td> 471 </tr> 472 <?php endif; // End if ! IS_PROFILE_PAGE. ?> 473 474 <?php if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && ! isset( $super_admins ) ) : ?> 475 <tr class="user-super-admin-wrap"> 476 <th><?php _e( 'Super Admin' ); ?></th> 477 <td> 478 <?php if ( 0 !== strcasecmp( $profile_user->user_email, get_site_option( 'admin_email' ) ) || ! is_super_admin( $profile_user->ID ) ) : ?> 479 <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> 480 <?php else : ?> 481 <p><?php _e( 'Super admin privileges cannot be removed because this user has the network admin email.' ); ?></p> 482 <?php endif; ?> 483 </td> 484 </tr> 485 <?php endif; ?> 486 487 <tr class="user-first-name-wrap"> 488 <th><label for="first_name"><?php _e( 'First Name' ); ?></label></th> 489 <td><input type="text" name="first_name" id="first_name" value="<?php echo esc_attr( $profile_user->first_name ); ?>" class="regular-text" /></td> 490 </tr> 491 492 <tr class="user-last-name-wrap"> 493 <th><label for="last_name"><?php _e( 'Last Name' ); ?></label></th> 494 <td><input type="text" name="last_name" id="last_name" value="<?php echo esc_attr( $profile_user->last_name ); ?>" class="regular-text" /></td> 495 </tr> 496 497 <tr class="user-nickname-wrap"> 498 <th><label for="nickname"><?php _e( 'Nickname' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th> 499 <td><input type="text" name="nickname" id="nickname" value="<?php echo esc_attr( $profile_user->nickname ); ?>" class="regular-text" /></td> 500 </tr> 501 502 <tr class="user-display-name-wrap"> 503 <th> 504 <label for="display_name"><?php _e( 'Display name publicly as' ); ?></label> 505 </th> 506 <td> 507 <select name="display_name" id="display_name"> 508 <?php 509 $public_display = array(); 510 $public_display['display_nickname'] = $profile_user->nickname; 511 $public_display['display_username'] = $profile_user->user_login; 512 513 if ( ! empty( $profile_user->first_name ) ) { 514 $public_display['display_firstname'] = $profile_user->first_name; 515 } 516 517 if ( ! empty( $profile_user->last_name ) ) { 518 $public_display['display_lastname'] = $profile_user->last_name; 519 } 520 521 if ( ! empty( $profile_user->first_name ) && ! empty( $profile_user->last_name ) ) { 522 $public_display['display_firstlast'] = $profile_user->first_name . ' ' . $profile_user->last_name; 523 $public_display['display_lastfirst'] = $profile_user->last_name . ' ' . $profile_user->first_name; 524 } 525 526 if ( ! in_array( $profile_user->display_name, $public_display, true ) ) { // Only add this if it isn't duplicated elsewhere. 527 $public_display = array( 'display_displayname' => $profile_user->display_name ) + $public_display; 528 } 529 530 $public_display = array_map( 'trim', $public_display ); 531 $public_display = array_unique( $public_display ); 532 533 ?> 534 <?php foreach ( $public_display as $id => $item ) : ?> 535 <option <?php selected( $profile_user->display_name, $item ); ?>><?php echo $item; ?></option> 536 <?php endforeach; ?> 537 </select> 538 </td> 539 </tr> 540 </table> 541 542 <h2><?php _e( 'Contact Info' ); ?></h2> 543 544 <table class="form-table" role="presentation"> 545 <tr class="user-email-wrap"> 546 <th><label for="email"><?php _e( 'Email' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th> 547 <td> 548 <input type="email" name="email" id="email" aria-describedby="email-description" value="<?php echo esc_attr( $profile_user->user_email ); ?>" class="regular-text ltr" /> 549 <?php if ( $profile_user->ID === $current_user->ID ) : ?> 550 <p class="description" id="email-description"> 551 <?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>' ); ?> 552 </p> 553 <?php endif; ?> 554 555 <?php 556 $new_email = get_user_meta( $current_user->ID, '_new_email', true ); 557 if ( $new_email && $new_email['newemail'] !== $current_user->user_email && $profile_user->ID === $current_user->ID ) : 558 559 $pending_change_message = sprintf( 560 /* translators: %s: New email. */ 561 __( 'There is a pending change of your email to %s.' ), 562 '<code>' . esc_html( $new_email['newemail'] ) . '</code>' 563 ); 564 $pending_change_message .= sprintf( 565 ' <a href="%1$s">%2$s</a>', 566 esc_url( wp_nonce_url( self_admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ), 'dismiss-' . $current_user->ID . '_new_email' ) ), 567 __( 'Cancel' ) 568 ); 569 wp_admin_notice( 570 $pending_change_message, 571 array( 572 'additional_classes' => array( 'updated', 'inline' ), 573 ) 574 ); 575 endif; 576 ?> 577 </td> 578 </tr> 579 580 <tr class="user-url-wrap"> 581 <th><label for="url"><?php _e( 'Website' ); ?></label></th> 582 <td><input type="url" name="url" id="url" value="<?php echo esc_attr( $profile_user->user_url ); ?>" class="regular-text code" /></td> 583 </tr> 584 585 <?php foreach ( wp_get_user_contact_methods( $profile_user ) as $name => $desc ) : ?> 586 <tr class="user-<?php echo $name; ?>-wrap"> 587 <th> 588 <label for="<?php echo $name; ?>"> 589 <?php 590 /** 591 * Filters a user contactmethod label. 592 * 593 * The dynamic portion of the hook name, `$name`, refers to 594 * each of the keys in the contact methods array. 595 * 596 * @since 2.9.0 597 * 598 * @param string $desc The translatable label for the contact method. 599 */ 600 echo apply_filters( "user_{$name}_label", $desc ); 601 ?> 602 </label> 603 </th> 604 <td> 605 <input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr( $profile_user->$name ); ?>" class="regular-text" /> 606 </td> 607 </tr> 608 <?php endforeach; ?> 609 </table> 610 611 <h2><?php IS_PROFILE_PAGE ? _e( 'About Yourself' ) : _e( 'About the user' ); ?></h2> 612 613 <table class="form-table" role="presentation"> 614 <tr class="user-description-wrap"> 615 <th><label for="description"><?php _e( 'Biographical Info' ); ?></label></th> 616 <td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profile_user->description; // textarea_escaped ?></textarea> 617 <p class="description"><?php _e( 'Share a little biographical information to fill out your profile. This may be shown publicly.' ); ?></p></td> 618 </tr> 619 620 <?php if ( get_option( 'show_avatars' ) ) : ?> 621 <tr class="user-profile-picture"> 622 <th><?php _e( 'Profile Picture' ); ?></th> 623 <td> 624 <?php echo get_avatar( $user_id ); ?> 625 <p class="description"> 626 <?php 627 if ( IS_PROFILE_PAGE ) { 628 $description = sprintf( 629 /* translators: %s: Gravatar URL. */ 630 __( '<a href="%s">You can change your profile picture on Gravatar</a>.' ), 631 /* translators: The localized Gravatar URL. */ 632 __( 'https://gravatar.com/' ) 633 ); 634 } else { 635 $description = ''; 636 } 637 638 /** 639 * Filters the user profile picture description displayed under the Gravatar. 640 * 641 * @since 4.4.0 642 * @since 4.7.0 Added the `$profile_user` parameter. 643 * 644 * @param string $description The description that will be printed. 645 * @param WP_User $profile_user The current WP_User object. 646 */ 647 echo apply_filters( 'user_profile_picture_description', $description, $profile_user ); 648 ?> 649 </p> 650 </td> 651 </tr> 652 <?php endif; ?> 653 <?php 654 /** 655 * Filters the display of the password fields. 656 * 657 * @since 1.5.1 658 * @since 2.8.0 Added the `$profile_user` parameter. 659 * @since 4.4.0 Now evaluated only in user-edit.php. 660 * 661 * @param bool $show Whether to show the password fields. Default true. 662 * @param WP_User $profile_user User object for the current user to edit. 663 */ 664 $show_password_fields = apply_filters( 'show_password_fields', true, $profile_user ); 665 ?> 666 <?php if ( $show_password_fields ) : ?> 667 </table> 668 669 <h2><?php _e( 'Account Management' ); ?></h2> 670 671 <table class="form-table" role="presentation"> 672 <tr id="password" class="user-pass1-wrap"> 673 <th><label for="pass1"><?php _e( 'New Password' ); ?></label></th> 674 <td> 675 <input type="hidden" value=" " /><!-- #24364 workaround --> 676 <button type="button" class="button wp-generate-pw hide-if-no-js" aria-expanded="false"><?php _e( 'Set New Password' ); ?></button> 677 <div class="wp-pwd hide-if-js"> 678 <div class="password-input-wrapper"> 679 <input type="password" name="pass1" id="pass1" class="regular-text" value="" autocomplete="new-password" spellcheck="false" data-pw="<?php echo esc_attr( wp_generate_password( 24 ) ); ?>" aria-describedby="pass-strength-result" /> 680 <div style="display:none" id="pass-strength-result" aria-live="polite"></div> 681 </div> 682 <button type="button" class="button wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>"> 683 <span class="dashicons dashicons-hidden" aria-hidden="true"></span> 684 <span class="text"><?php _e( 'Hide' ); ?></span> 685 </button> 686 <button type="button" class="button wp-cancel-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Cancel password change' ); ?>"> 687 <span class="dashicons dashicons-no" aria-hidden="true"></span> 688 <span class="text"><?php _e( 'Cancel' ); ?></span> 689 </button> 690 </div> 691 </td> 692 </tr> 693 <tr class="user-pass2-wrap hide-if-js"> 694 <th scope="row"><label for="pass2"><?php _e( 'Repeat New Password' ); ?></label></th> 695 <td> 696 <input type="password" name="pass2" id="pass2" class="regular-text" value="" autocomplete="new-password" spellcheck="false" aria-describedby="pass2-desc" /> 697 <?php if ( IS_PROFILE_PAGE ) : ?> 698 <p class="description" id="pass2-desc"><?php _e( 'Type your new password again.' ); ?></p> 699 <?php else : ?> 700 <p class="description" id="pass2-desc"><?php _e( 'Type the new password again.' ); ?></p> 701 <?php endif; ?> 702 </td> 703 </tr> 704 <tr class="pw-weak"> 705 <th><?php _e( 'Confirm Password' ); ?></th> 706 <td> 707 <label> 708 <input type="checkbox" name="pw_weak" class="pw-checkbox" /> 709 <span id="pw-weak-text-label"><?php _e( 'Confirm use of weak password' ); ?></span> 710 </label> 711 </td> 712 </tr> 713 <?php endif; // End Show Password Fields. ?> 714 715 <?php // Allow admins to send reset password link. ?> 716 <?php if ( ! IS_PROFILE_PAGE && true === wp_is_password_reset_allowed_for_user( $profile_user ) ) : ?> 717 <tr class="user-generate-reset-link-wrap hide-if-no-js"> 718 <th><?php _e( 'Password Reset' ); ?></th> 719 <td> 720 <div class="generate-reset-link"> 721 <button type="button" class="button button-secondary" id="generate-reset-link"> 722 <?php _e( 'Send Reset Link' ); ?> 723 </button> 724 </div> 725 <p class="description"> 726 <?php 727 printf( 728 /* translators: %s: User's display name. */ 729 __( 'Send %s a link to reset their password. This will not change their password, nor will it force a change.' ), 730 esc_html( $profile_user->display_name ) 731 ); 732 ?> 733 </p> 734 </td> 735 </tr> 736 <?php endif; ?> 737 738 <?php if ( IS_PROFILE_PAGE && count( $sessions->get_all() ) === 1 ) : ?> 739 <tr class="user-sessions-wrap hide-if-no-js"> 740 <th><?php _e( 'Sessions' ); ?></th> 741 <td aria-live="assertive"> 742 <div class="destroy-sessions"><button type="button" disabled class="button"><?php _e( 'Log Out Everywhere Else' ); ?></button></div> 743 <p class="description"> 744 <?php _e( 'You are only logged in at this location.' ); ?> 745 </p> 746 </td> 747 </tr> 748 <?php elseif ( IS_PROFILE_PAGE && count( $sessions->get_all() ) > 1 ) : ?> 749 <tr class="user-sessions-wrap hide-if-no-js"> 750 <th><?php _e( 'Sessions' ); ?></th> 751 <td aria-live="assertive"> 752 <div class="destroy-sessions"><button type="button" class="button" id="destroy-sessions"><?php _e( 'Log Out Everywhere Else' ); ?></button></div> 753 <p class="description"> 754 <?php _e( 'Did you lose your phone or leave your account logged in at a public computer? You can log out everywhere else, and stay logged in here.' ); ?> 755 </p> 756 </td> 757 </tr> 758 <?php elseif ( ! IS_PROFILE_PAGE && $sessions->get_all() ) : ?> 759 <tr class="user-sessions-wrap hide-if-no-js"> 760 <th><?php _e( 'Sessions' ); ?></th> 761 <td> 762 <p><button type="button" class="button" id="destroy-sessions"><?php _e( 'Log Out Everywhere' ); ?></button></p> 763 <p class="description"> 764 <?php 765 /* translators: %s: User's display name. */ 766 printf( __( 'Log %s out of all locations.' ), $profile_user->display_name ); 767 ?> 768 </p> 769 </td> 770 </tr> 771 <?php endif; ?> 772 </table> 773 774 <?php if ( wp_is_application_passwords_available_for_user( $user_id ) || ! wp_is_application_passwords_supported() ) : ?> 775 <div class="application-passwords hide-if-no-js" id="application-passwords-section"> 776 <h2><?php _e( 'Application Passwords' ); ?></h2> 777 <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> 778 <?php if ( wp_is_application_passwords_available_for_user( $user_id ) ) : ?> 779 <?php 780 if ( is_multisite() ) : 781 $blogs = get_blogs_of_user( $user_id, true ); 782 $blogs_count = count( $blogs ); 783 784 if ( $blogs_count > 1 ) : 785 ?> 786 <p> 787 <?php 788 /* translators: 1: URL to my-sites.php, 2: Number of sites the user has. */ 789 $message = _n( 790 'Application passwords grant access to <a href="%1$s">the %2$s site in this installation that you have permissions on</a>.', 791 'Application passwords grant access to <a href="%1$s">all %2$s sites in this installation that you have permissions on</a>.', 792 $blogs_count 793 ); 794 795 if ( is_super_admin( $user_id ) ) { 796 /* translators: 1: URL to my-sites.php, 2: Number of sites the user has. */ 797 $message = _n( 798 'Application passwords grant access to <a href="%1$s">the %2$s site on the network as you have Super Admin rights</a>.', 799 'Application passwords grant access to <a href="%1$s">all %2$s sites on the network as you have Super Admin rights</a>.', 800 $blogs_count 801 ); 802 } 803 804 printf( 805 $message, 806 admin_url( 'my-sites.php' ), 807 number_format_i18n( $blogs_count ) 808 ); 809 ?> 810 </p> 811 <?php 812 endif; 813 endif; 814 ?> 815 816 <?php if ( ! wp_is_site_protected_by_basic_auth( 'front' ) ) : ?> 817 <div class="create-application-password form-wrap"> 818 <div class="form-field"> 819 <label for="new_application_password_name"><?php _e( 'New Application Password Name' ); ?></label> 820 <input type="text" size="30" id="new_application_password_name" name="new_application_password_name" class="input" aria-required="true" aria-describedby="new_application_password_name_desc" spellcheck="false" /> 821 <p class="description" id="new_application_password_name_desc"><?php _e( 'Required to create an Application Password, but not to update the user.' ); ?></p> 822 </div> 823 824 <?php 825 /** 826 * Fires in the create Application Passwords form. 827 * 828 * @since 5.6.0 829 * 830 * @param WP_User $profile_user The current WP_User object. 831 */ 832 do_action( 'wp_create_application_password_form', $profile_user ); 833 ?> 834 835 <button type="button" name="do_new_application_password" id="do_new_application_password" class="button button-secondary"><?php _e( 'Add New Application Password' ); ?></button> 836 </div> 837 <?php 838 else : 839 wp_admin_notice( 840 __( 'Your website appears to use Basic Authentication, which is not currently compatible with Application Passwords.' ), 841 array( 842 'type' => 'error', 843 'additional_classes' => array( 'inline' ), 844 ) 845 ); 846 endif; 847 ?> 848 849 <div class="application-passwords-list-table-wrapper"> 850 <?php 851 $application_passwords_list_table = _get_list_table( 'WP_Application_Passwords_List_Table', array( 'screen' => 'application-passwords-user' ) ); 852 $application_passwords_list_table->prepare_items(); 853 $application_passwords_list_table->display(); 854 ?> 855 </div> 856 <?php elseif ( ! wp_is_application_passwords_supported() ) : ?> 857 <p><?php _e( 'The application password feature requires HTTPS, which is not enabled on this site.' ); ?></p> 858 <p> 859 <?php 860 printf( 861 /* translators: %s: Documentation URL. */ 862 __( 'If this is a development website, you can <a href="%s">set the environment type accordingly</a> to enable application passwords.' ), 863 __( 'https://developer.wordpress.org/apis/wp-config-php/#wp-environment-type' ) 864 ); 865 ?> 866 </p> 867 <?php endif; ?> 868 </div> 869 <?php endif; // End Application Passwords. ?> 870 871 <?php 872 if ( IS_PROFILE_PAGE ) { 873 /** 874 * Fires after the 'About Yourself' settings table on the 'Profile' editing screen. 875 * 876 * The action only fires if the current user is editing their own profile. 877 * 878 * @since 2.0.0 879 * 880 * @param WP_User $profile_user The current WP_User object. 881 */ 882 do_action( 'show_user_profile', $profile_user ); 883 } else { 884 /** 885 * Fires after the 'About the User' settings table on the 'Edit User' screen. 886 * 887 * @since 2.0.0 888 * 889 * @param WP_User $profile_user The current WP_User object. 890 */ 891 do_action( 'edit_user_profile', $profile_user ); 892 } 893 ?> 894 895 <?php 896 /** 897 * Filters whether to display additional capabilities for the user. 898 * 899 * The 'Additional Capabilities' section will only be enabled if 900 * the number of the user's capabilities exceeds their number of 901 * roles. 902 * 903 * @since 2.8.0 904 * 905 * @param bool $enable Whether to display the capabilities. Default true. 906 * @param WP_User $profile_user The current WP_User object. 907 */ 908 $display_additional_caps = apply_filters( 'additional_capabilities_display', true, $profile_user ); 909 ?> 910 911 <?php if ( count( $profile_user->caps ) > count( $profile_user->roles ) && ( true === $display_additional_caps ) ) : ?> 912 <h2><?php _e( 'Additional Capabilities' ); ?></h2> 913 914 <table class="form-table" role="presentation"> 915 <tr class="user-capabilities-wrap"> 916 <th scope="row"><?php _e( 'Capabilities' ); ?></th> 917 <td> 918 <?php 919 $output = ''; 920 foreach ( $profile_user->caps as $cap => $value ) { 921 if ( ! $wp_roles->is_role( $cap ) ) { 922 if ( '' !== $output ) { 923 $output .= ', '; 924 } 925 926 if ( $value ) { 927 $output .= $cap; 928 } else { 929 /* translators: %s: Capability name. */ 930 $output .= sprintf( __( 'Denied: %s' ), $cap ); 931 } 932 } 933 } 934 echo $output; 935 ?> 936 </td> 937 </tr> 938 </table> 939 <?php endif; // End Display Additional Capabilities. ?> 940 941 <input type="hidden" name="action" value="update" /> 942 <input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr( $user_id ); ?>" /> 943 944 <?php submit_button( IS_PROFILE_PAGE ? __( 'Update Profile' ) : __( 'Update User' ) ); ?> 945 946 </form> 947 </div> 948 <?php 949 break; 950 } 951 ?> 952 <script type="text/javascript"> 953 if (window.location.hash == '#password') { 954 document.getElementById('pass1').focus(); 955 } 956 </script> 957 958 <script type="text/javascript"> 959 jQuery( function( $ ) { 960 var languageSelect = $( '#locale' ); 961 $( 'form' ).on( 'submit', function() { 962 /* 963 * Don't show a spinner for English and installed languages, 964 * as there is nothing to download. 965 */ 966 if ( ! languageSelect.find( 'option:selected' ).data( 'installed' ) ) { 967 $( '#submit', this ).after( '<span class="spinner language-install-spinner is-active" />' ); 968 } 969 }); 970 } ); 971 </script> 972 973 <?php if ( isset( $application_passwords_list_table ) ) : ?> 974 <script type="text/html" id="tmpl-new-application-password"> 975 <div class="notice notice-success is-dismissible new-application-password-notice" role="alert"> 976 <p class="application-password-display"> 977 <label for="new-application-password-value"> 978 <?php 979 printf( 980 /* translators: %s: Application name. */ 981 __( 'Your new password for %s is:' ), 982 '<strong>{{ data.name }}</strong>' 983 ); 984 ?> 985 </label> 986 <input id="new-application-password-value" type="text" class="code" readonly="readonly" value="{{ data.password }}" /> 987 <button type="button" class="button copy-button" data-clipboard-text="{{ data.password }}"><?php _e( 'Copy' ); ?></button> 988 <span class="success hidden" aria-hidden="true"><?php _e( 'Copied!' ); ?></span> 989 </p> 990 <p><?php _e( 'Be sure to save this in a safe location. You will not be able to retrieve it.' ); ?></p> 991 <button type="button" class="notice-dismiss"> 992 <span class="screen-reader-text"> 993 <?php 994 /* translators: Hidden accessibility text. */ 995 _e( 'Dismiss this notice.' ); 996 ?> 997 </span> 998 </button> 999 </div> 1000 </script> 1001 1002 <script type="text/html" id="tmpl-application-password-row"> 1003 <?php $application_passwords_list_table->print_js_template_row(); ?> 1004 </script> 1005 <?php endif; ?> 1006 <?php 1007 require_once ABSPATH . 'wp-admin/admin-footer.php';
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Sat Oct 5 08:20:01 2024 | Cross-referenced by PHPXref |