--- a/wp/wp-admin/user-new.php Tue Oct 22 16:11:46 2019 +0200
+++ b/wp/wp-admin/user-new.php Tue Dec 15 13:49:49 2020 +0100
@@ -7,7 +7,7 @@
*/
/** WordPress Administration Bootstrap */
-require_once( dirname( __FILE__ ) . '/admin.php' );
+require_once __DIR__ . '/admin.php';
if ( is_multisite() ) {
if ( ! current_user_can( 'create_users' ) && ! current_user_can( 'promote_users' ) ) {
@@ -29,7 +29,7 @@
add_filter( 'wpmu_signup_user_notification_email', 'admin_created_user_email' );
}
-if ( isset( $_REQUEST['action'] ) && 'adduser' == $_REQUEST['action'] ) {
+if ( isset( $_REQUEST['action'] ) && 'adduser' === $_REQUEST['action'] ) {
check_admin_referer( 'add-user', '_wpnonce_add-user' );
$user_details = null;
@@ -58,12 +58,12 @@
);
}
- // Adding an existing user to this blog
+ // Adding an existing user to this blog.
$new_user_email = $user_details->user_email;
$redirect = 'user-new.php';
$username = $user_details->user_login;
$user_id = $user_details->ID;
- if ( $username != null && array_key_exists( $blog_id, get_blogs_of_user( $user_id ) ) ) {
+ if ( null != $username && array_key_exists( $blog_id, get_blogs_of_user( $user_id ) ) ) {
$redirect = add_query_arg( array( 'update' => 'addexisting' ), 'user-new.php' );
} else {
if ( isset( $_POST['noconfirmation'] ) && current_user_can( 'manage_network_users' ) ) {
@@ -105,14 +105,14 @@
* @since 4.4.0
*
* @param int $user_id The invited user's ID.
- * @param array $role The role of invited user.
+ * @param array $role Array containing role information for the invited user.
* @param string $newuser_key The key of the invitation.
*/
do_action( 'invite_user', $user_id, $role, $newuser_key );
$switched_locale = switch_to_locale( get_user_locale( $user_details ) );
- /* translators: 1: Site name, 2: site URL, 3: role, 4: activation URL */
+ /* translators: 1: Site title, 2: Site URL, 3: User role, 4: Activation URL. */
$message = __(
'Hi,
@@ -123,8 +123,21 @@
%4$s'
);
- /* translators: Joining confirmation notification email subject. %s: Site title */
- wp_mail( $new_user_email, sprintf( __( '[%s] Joining Confirmation' ), wp_specialchars_decode( get_option( 'blogname' ) ) ), sprintf( $message, get_option( 'blogname' ), home_url(), wp_specialchars_decode( translate_user_role( $role['name'] ) ), home_url( "/newbloguser/$newuser_key/" ) ) );
+ wp_mail(
+ $new_user_email,
+ sprintf(
+ /* translators: Joining confirmation notification email subject. %s: Site title. */
+ __( '[%s] Joining Confirmation' ),
+ wp_specialchars_decode( get_option( 'blogname' ) )
+ ),
+ sprintf(
+ $message,
+ get_option( 'blogname' ),
+ home_url(),
+ wp_specialchars_decode( translate_user_role( $role['name'] ) ),
+ home_url( "/newbloguser/$newuser_key/" )
+ )
+ );
if ( $switched_locale ) {
restore_previous_locale();
@@ -135,7 +148,7 @@
}
wp_redirect( $redirect );
die();
-} elseif ( isset( $_REQUEST['action'] ) && 'createuser' == $_REQUEST['action'] ) {
+} elseif ( isset( $_REQUEST['action'] ) && 'createuser' === $_REQUEST['action'] ) {
check_admin_referer( 'create-user', '_wpnonce_create-user' );
if ( ! current_user_can( 'create_users' ) ) {
@@ -161,7 +174,7 @@
die();
}
} else {
- // Adding a new user to this site
+ // Adding a new user to this site.
$new_user_email = wp_unslash( $_REQUEST['email'] );
$user_details = wpmu_validate_user_signup( $_REQUEST['user_login'], $new_user_email );
if ( is_wp_error( $user_details['errors'] ) && $user_details['errors']->has_errors() ) {
@@ -170,8 +183,8 @@
/** This filter is documented in wp-includes/user.php */
$new_user_login = apply_filters( 'pre_user_login', sanitize_user( wp_unslash( $_REQUEST['user_login'] ), true ) );
if ( isset( $_POST['noconfirmation'] ) && current_user_can( 'manage_network_users' ) ) {
- add_filter( 'wpmu_signup_user_notification', '__return_false' ); // Disable confirmation email
- add_filter( 'wpmu_welcome_user_notification', '__return_false' ); // Disable welcome email
+ add_filter( 'wpmu_signup_user_notification', '__return_false' ); // Disable confirmation email.
+ add_filter( 'wpmu_welcome_user_notification', '__return_false' ); // Disable welcome email.
}
wpmu_signup_user(
$new_user_login,
@@ -240,19 +253,19 @@
'id' => 'user-roles',
'title' => __( 'User Roles' ),
'content' => '<p>' . __( 'Here is a basic overview of the different user roles and the permissions associated with each one:' ) . '</p>' .
- '<ul>' .
- '<li>' . __( 'Subscribers can read comments/comment/receive newsletters, etc. but cannot create regular site content.' ) . '</li>' .
- '<li>' . __( 'Contributors can write and manage their posts but not publish posts or upload media files.' ) . '</li>' .
- '<li>' . __( 'Authors can publish and manage their own posts, and are able to upload files.' ) . '</li>' .
- '<li>' . __( 'Editors can publish posts, manage posts as well as manage other people’s posts, etc.' ) . '</li>' .
- '<li>' . __( 'Administrators have access to all the administration features.' ) . '</li>' .
- '</ul>',
+ '<ul>' .
+ '<li>' . __( 'Subscribers can read comments/comment/receive newsletters, etc. but cannot create regular site content.' ) . '</li>' .
+ '<li>' . __( 'Contributors can write and manage their posts but not publish posts or upload media files.' ) . '</li>' .
+ '<li>' . __( 'Authors can publish and manage their own posts, and are able to upload files.' ) . '</li>' .
+ '<li>' . __( 'Editors can publish posts, manage posts as well as manage other people’s posts, etc.' ) . '</li>' .
+ '<li>' . __( 'Administrators have access to all the administration features.' ) . '</li>' .
+ '</ul>',
)
);
get_current_screen()->set_help_sidebar(
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
- '<p>' . __( '<a href="https://codex.wordpress.org/Users_Add_New_Screen">Documentation on Adding New Users</a>' ) . '</p>' .
+ '<p>' . __( '<a href="https://wordpress.org/support/article/users-add-new-screen/">Documentation on Adding New Users</a>' ) . '</p>' .
'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
);
@@ -272,7 +285,7 @@
wp_enqueue_script( 'user-suggest' );
}
-require_once( ABSPATH . 'wp-admin/admin-header.php' );
+require_once ABSPATH . 'wp-admin/admin-header.php';
if ( isset( $_GET['update'] ) ) {
$messages = array();
@@ -293,12 +306,13 @@
$messages[] = __( 'Invitation email sent to user. A confirmation link must be clicked for them to be added to your site.' );
break;
case 'addnoconfirmation':
- if ( empty( $edit_link ) ) {
- $messages[] = __( 'User has been added to your site.' );
- } else {
- /* translators: %s: edit page url */
- $messages[] = sprintf( __( 'User has been added to your site. <a href="%s">Edit user</a>' ), $edit_link );
+ $message = __( 'User has been added to your site.' );
+
+ if ( $edit_link ) {
+ $message .= sprintf( ' <a href="%s">%s</a>', $edit_link, __( 'Edit user' ) );
}
+
+ $messages[] = $message;
break;
case 'addexisting':
$messages[] = __( 'That user is already a member of this site.' );
@@ -317,7 +331,7 @@
break;
}
} else {
- if ( 'add' == $_GET['update'] ) {
+ if ( 'add' === $_GET['update'] ) {
$messages[] = __( 'User added.' );
}
}
@@ -413,7 +427,7 @@
<label for="adduser-noconfirmation"><?php _e( 'Add the user without sending an email that requires their confirmation.' ); ?></label>
</td>
</tr>
-<?php } ?>
+ <?php } ?>
</table>
<?php
/**
@@ -432,7 +446,7 @@
<?php submit_button( __( 'Add Existing User' ), 'primary', 'adduser', true, array( 'id' => 'addusersub' ) ); ?>
</form>
<?php
-} // is_multisite()
+} // End if is_multisite().
if ( current_user_can( 'create_users' ) ) {
if ( $do_both ) {
@@ -484,6 +498,33 @@
<th scope="row"><label for="url"><?php _e( 'Website' ); ?></label></th>
<td><input name="url" type="url" id="url" class="code" value="<?php echo esc_attr( $new_user_uri ); ?>" /></td>
</tr>
+ <?php
+ $languages = get_available_languages();
+ if ( $languages ) :
+ ?>
+ <tr class="form-field user-language-wrap">
+ <th scope="row">
+ <label for="locale">
+ <?php /* translators: The user language selection field label. */ ?>
+ <?php _e( 'Language' ); ?><span class="dashicons dashicons-translation" aria-hidden="true"></span>
+ </label>
+ </th>
+ <td>
+ <?php
+ wp_dropdown_languages(
+ array(
+ 'name' => 'locale',
+ 'id' => 'locale',
+ 'selected' => 'site-default',
+ 'languages' => $languages,
+ 'show_available_translations' => false,
+ 'show_option_site_default' => true,
+ )
+ );
+ ?>
+ </td>
+ </tr>
+ <?php endif; ?>
<tr class="form-field form-required user-pass1-wrap">
<th scope="row">
<label for="pass1">
@@ -533,7 +574,8 @@
<label for="send_user_notification"><?php _e( 'Send the new user an email about their account.' ); ?></label>
</td>
</tr>
-<?php } // !is_multisite ?>
+ <?php } // End if ! is_multisite(). ?>
+ <?php if ( current_user_can( 'promote_users' ) ) { ?>
<tr class="form-field">
<th scope="row"><label for="role"><?php _e( 'Role' ); ?></label></th>
<td><select name="role" id="role">
@@ -546,6 +588,7 @@
</select>
</td>
</tr>
+ <?php } ?>
<?php if ( is_multisite() && current_user_can( 'manage_network_users' ) ) { ?>
<tr>
<th scope="row"><?php _e( 'Skip Confirmation Email' ); ?></th>
@@ -565,7 +608,7 @@
<?php submit_button( __( 'Add New User' ), 'primary', 'createuser', true, array( 'id' => 'createusersub' ) ); ?>
</form>
-<?php } // current_user_can('create_users') ?>
+<?php } // End if current_user_can( 'create_users' ). ?>
</div>
<?php
-include( ABSPATH . 'wp-admin/admin-footer.php' );
+require_once ABSPATH . 'wp-admin/admin-footer.php';