WordPress.org

Make WordPress Core

Ticket #25726: 25726.3.diff

File 25726.3.diff, 10.3 KB (added by DrewAPicture, 6 years ago)

Final pass

  • src/wp-admin/user-edit.php

     
    7474<?php
    7575}
    7676
    77 // Only allow super admins on multisite to edit every user.
    78 if ( is_multisite() && ! current_user_can( 'manage_network_users' ) && $user_id != $current_user->ID && ! apply_filters( 'enable_edit_any_user_configuration', true ) )
     77/**
     78 * Filter whether to allow administrators on Multisite to edit every user.
     79 *
     80 * Enabling the user editing form via this filter also hinges on the user holding
     81 * the 'manage_network_users' cap, and the logged-in user not matching the user
     82 * profile open for editing.
     83 *
     84 * The filter was introduced to replace the EDIT_ANY_USER constant.
     85 *
     86 * @since 3.0.0
     87 *
     88 * @param bool $allow Whether to allow editing of any user. Default true.
     89 */
     90if ( is_multisite()
     91        && ! current_user_can( 'manage_network_users' )
     92        && $user_id != $current_user->ID
     93        && ! apply_filters( 'enable_edit_any_user_configuration', true )
     94) {
    7995        wp_die( __( 'You do not have permission to edit this user.' ) );
     96}
    8097
    8198// Execute confirmed email change. See send_confirmation_on_profile_email().
    8299if ( is_multisite() && IS_PROFILE_PAGE && isset( $_GET[ 'newuseremail' ] ) && $current_user->ID ) {
     
    106123if ( !current_user_can('edit_user', $user_id) )
    107124        wp_die(__('You do not have permission to edit this user.'));
    108125
    109 if ( IS_PROFILE_PAGE )
    110         do_action('personal_options_update', $user_id);
    111 else
    112         do_action('edit_user_profile_update', $user_id);
     126if ( IS_PROFILE_PAGE ) {
     127        /**
     128         * Fires before the page loads on the 'Your Profile' editing screen.
     129         *
     130         * The action only fires if the current user is editing their own profile.
     131         *
     132         * @since 2.0.0
     133         *
     134         * @param int $user_id The user ID.
     135         */
     136        do_action( 'personal_options_update', $user_id );
     137} else {
     138        /**
     139         * Fires before the page loads on the 'Edit User' screen.
     140         *
     141         * @since 2.7.0
     142         *
     143         * @param int $user_id The user ID.
     144         */
     145        do_action( 'edit_user_profile_update', $user_id );
     146}
    113147
    114148if ( !is_multisite() ) {
    115149        $errors = edit_user($user_id);
     
    188222        <?php }
    189223} ?>
    190224</h2>
    191 
    192 <form id="your-profile" action="<?php echo esc_url( self_admin_url( IS_PROFILE_PAGE ? 'profile.php' : 'user-edit.php' ) ); ?>" method="post"<?php do_action('user_edit_form_tag'); ?>>
     225<?php
     226/**
     227 * Fires inside the your-profile form tag on the user editing screen.
     228 *
     229 * @since 3.0.0
     230 */
     231?>
     232<form id="your-profile" action="<?php echo esc_url( self_admin_url( IS_PROFILE_PAGE ? 'profile.php' : 'user-edit.php' ) ); ?>" method="post"<?php do_action( 'user_edit_form_tag' ); ?>>
    193233<?php wp_nonce_field('update-user_' . $user_id) ?>
    194234<?php if ( $wp_http_referer ) : ?>
    195235        <input type="hidden" name="wp_http_referer" value="<?php echo esc_url($wp_http_referer); ?>" />
     
    211251<?php if ( count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker') ) : ?>
    212252<tr>
    213253<th scope="row"><?php _e('Admin Color Scheme')?></th>
     254<?php
     255/**
     256 * Fires in the 'Admin Color Scheme' section of the user editing screen.
     257 *
     258 * The section is only enabled if a callback is hooked to the action,
     259 * and if there is more than one defined color scheme for the admin.
     260 *
     261 * @since 3.0.0
     262 */
     263?>
    214264<td><?php do_action( 'admin_color_scheme_picker' ); ?></td>
    215265</tr>
    216266<?php
     
    230280</fieldset>
    231281</td>
    232282</tr>
    233 <?php do_action('personal_options', $profileuser); ?>
     283<?php
     284/**
     285 * Fires at the end of the 'Personal Options' settings table on the user editing screen.
     286 *
     287 * @since 2.7.0
     288 *
     289 * @param WP_User $profileuser The current WP_User object.
     290 */
     291do_action( 'personal_options', $profileuser );
     292?>
    234293</table>
    235294<?php
    236         if ( IS_PROFILE_PAGE )
    237                 do_action('profile_personal_options', $profileuser);
     295        if ( IS_PROFILE_PAGE ) {
     296                /**
     297                 * Fires after the 'Personal Options' settings table on the 'Your Profile' editing screen.
     298                 *
     299                 * The action only fires if the current user is editing their own profile.
     300                 *
     301                 * @since 2.0.0
     302                 *
     303                 * @param WP_User $profileuser The current WP_User object.
     304                 */
     305                do_action( 'profile_personal_options', $profileuser );
     306        }
    238307?>
    239308
    240309<h3><?php _e('Name') ?></h3>
     
    353422        foreach ( wp_get_user_contact_methods( $profileuser ) as $name => $desc ) {
    354423?>
    355424<tr>
    356         <th><label for="<?php echo $name; ?>"><?php echo apply_filters('user_'.$name.'_label', $desc); ?></label></th>
     425        <?php
     426        /**
     427         * Filter a user contactmethod label.
     428         *
     429         * The dynamic portion of the filter hook, $name, refers to
     430         * each of the keys in the contactmethods array.
     431         *
     432         * @since 2.9.0
     433         *
     434         * @param string $desc The translatable label for the contactmethod.
     435         */
     436        ?>
     437        <th><label for="<?php echo $name; ?>"><?php echo apply_filters( "user_{$name}_label", $desc ); ?></label></th>
    357438        <td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr($profileuser->$name) ?>" class="regular-text" /></td>
    358439</tr>
    359440<?php
     
    371452</tr>
    372453
    373454<?php
    374 $show_password_fields = apply_filters('show_password_fields', true, $profileuser);
     455/** This filter is documented in wp-admin/user-new.php */
     456$show_password_fields = apply_filters( 'show_password_fields', true, $profileuser );
    375457if ( $show_password_fields ) :
    376458?>
    377459<tr id="password">
     
    396478</table>
    397479
    398480<?php
    399         if ( IS_PROFILE_PAGE )
     481        if ( IS_PROFILE_PAGE ) {
     482                /**
     483                 * Fires after the 'About the User' settings table on the 'Your Profile' editing screen.
     484                 *
     485                 * The action only fires if the current user is editing their own profile.
     486                 *
     487                 * @since 2.0.0
     488                 *
     489                 * @param WP_User $profileuser The current WP_User object.
     490                 */
    400491                do_action( 'show_user_profile', $profileuser );
    401         else
     492        } else {
     493                /**
     494                 * Fires after the 'About the User' settings table on the 'Edit User' screen.
     495                 *
     496                 * @since 2.0.0
     497                 *
     498                 * @param WP_User $profileuser The current WP_User object.
     499                 */
    402500                do_action( 'edit_user_profile', $profileuser );
     501        }
    403502?>
    404503
    405 <?php if ( count( $profileuser->caps ) > count( $profileuser->roles ) && apply_filters( 'additional_capabilities_display', true, $profileuser ) ) : ?>
     504<?php
     505/**
     506 * Filter whether to display additional capabilities for the user.
     507 *
     508 * The 'Additional Capabilities' section will only be enabled if
     509 * the number of the user's capabilities exceeds their number of
     510 * of roles.
     511 *
     512 * @since 2.8.0
     513 *
     514 * @param bool    $enable      Whether to display the capabilities. Default true.
     515 * @param WP_User $profileuser The current WP_User object.
     516 */
     517if ( count( $profileuser->caps ) > count( $profileuser->roles )
     518        && apply_filters( 'additional_capabilities_display', true, $profileuser )
     519) : ?>
    406520<h3><?php _e( 'Additional Capabilities' ); ?></h3>
    407521<table class="form-table">
    408522<tr>
  • src/wp-admin/user-new.php

     
    117117                        $add_user_errors = $user_details[ 'errors' ];
    118118                } else {
    119119                        /**
    120                          * Filter the user_login, aka the username, before it is added to the site.
     120                         * Filter the user_login, also known as the username, before it is added to the site.
    121121                         *
    122                          * @since 3.0.0
     122                         * @since 2.0.3
    123123                         *
    124                          * @param string $_REQUEST['user_login'] The sanitized username.
     124                         * @param string $user_login The sanitized username.
    125125                         */
    126126                        $new_user_login = apply_filters( 'pre_user_login', sanitize_user( wp_unslash( $_REQUEST['user_login'] ), true ) );
    127127                        if ( isset( $_POST[ 'noconfirmation' ] ) && is_super_admin() ) {
     
    189189wp_enqueue_script('user-profile');
    190190
    191191/**
    192  * Allows you to enable user auto-complete for non-super admins in multisite.
     192 * Filter whether to enable user auto-complete for non-super admins in Multisite.
    193193 *
    194194 * @since 3.4.0
    195195 *
    196  * @param bool True or false, based on if you enable auto-complete for non-super admins. Default is false.
     196 * @param bool $enable Whether to enable auto-complete for non-super admins. Default false.
    197197 */
    198198if ( is_multisite() && current_user_can( 'promote_users' ) && ! wp_is_large_network( 'users' )
    199199        && ( is_super_admin() || apply_filters( 'autocomplete_users_for_site_admins', false ) )
     
    287287 * @since 3.0.0
    288288 */
    289289?>
    290 <form action="" method="post" name="adduser" id="adduser" class="validate"<?php do_action('user_new_form_tag');?>>
     290<form action="" method="post" name="adduser" id="adduser" class="validate"<?php do_action( 'user_new_form_tag' );?>>
    291291<input name="action" type="hidden" value="adduser" />
    292292<?php wp_nonce_field( 'add-user', '_wpnonce_add-user' ) ?>
    293293
     
    320320 *
    321321 * @since 3.7.0
    322322 *
    323  * @param string A contextual string specifying which type of new user form the hook follows.
     323 * @param string $type A contextual string specifying which type of new user form the hook follows.
    324324 */
    325325do_action( 'user_new_form', 'add-existing-user' );
    326326?>
     
    334334                echo '<h3 id="create-new-user">' . __( 'Add New User' ) . '</h3>';
    335335?>
    336336<p><?php _e('Create a brand new user and add them to this site.'); ?></p>
    337 <?php
    338 /** This action is documented in wp-admin/user-new.php */
    339 ?>
    340 <form action="" method="post" name="createuser" id="createuser" class="validate"<?php do_action('user_new_form_tag');?>>
     337<?php /** This action is documented in wp-admin/user-new.php */ ?>
     338<form action="" method="post" name="createuser" id="createuser" class="validate"<?php do_action( 'user_new_form_tag' );?>>
    341339<input name="action" type="hidden" value="createuser" />
    342340<?php wp_nonce_field( 'create-user', '_wpnonce_create-user' ); ?>
    343341<?php
     
    382380 *
    383381 * @since 1.5.1
    384382 *
    385  * @param bool True or false, based on if you want to show the password fields. Default is true.
     383 * @param bool $show Whether to show the password fields. Default true.
    386384 */
    387385if ( apply_filters( 'show_password_fields', true ) ) : ?>
    388386        <tr class="form-field form-required">
  • src/wp-includes/user.php

     
    15641564         * @since 2.9.0
    15651565         *
    15661566         * @param array   $methods Array of contact methods and their labels.
    1567          * @param WP_User $user    Optional. WP_User object.
     1567         * @param WP_User $user    WP_User object.
    15681568         */
    15691569        return apply_filters( 'user_contactmethods', $methods, $user );
    15701570}