WordPress.org

Make WordPress Core

Ticket #6148: 6148.3.patch

File 6148.3.patch, 21.6 KB (added by arealnobrainer, 2 years ago)
  • src/wp-admin/includes/class-wp-ms-users-list-table.php

    diff --git a/src/wp-admin/includes/class-wp-ms-users-list-table.php b/src/wp-admin/includes/class-wp-ms-users-list-table.php
    index d50038a898..1ff0ad71ed 100644
    a b class WP_MS_Users_List_Table extends WP_List_Table { 
    258258         * @param WP_User $user The current WP_User object.
    259259         */
    260260        public function column_name( $user ) {
    261                 echo "$user->first_name $user->last_name";
     261                echo "$user->first_name $user->other_name $user->last_name";
    262262        }
    263263
    264264        /**
  • src/wp-admin/includes/class-wp-users-list-table.php

    diff --git a/src/wp-admin/includes/class-wp-users-list-table.php b/src/wp-admin/includes/class-wp-users-list-table.php
    index 4ba5eef8be..5991c6e6e7 100644
    a b class WP_Users_List_Table extends WP_List_Table { 
    471471                                                $r .= "$avatar $edit";
    472472                                                break;
    473473                                        case 'name':
    474                                                 $r .= "$user_object->first_name $user_object->last_name";
     474                                                $r .= "$user_object->first_name $user_object->other_name $user_object->last_name";
    475475                                                break;
    476476                                        case 'email':
    477477                                                $r .= "<a href='" . esc_url( "mailto:$email" ) . "'>$email</a>";
  • src/wp-admin/includes/export.php

    diff --git a/src/wp-admin/includes/export.php b/src/wp-admin/includes/export.php
    index f321a56eec..711a28019f 100644
    a b function export_wp( $args = array() ) { 
    347347                        echo '<wp:author_email>' . wxr_cdata( $author->user_email ) . '</wp:author_email>';
    348348                        echo '<wp:author_display_name>' . wxr_cdata( $author->display_name ) . '</wp:author_display_name>';
    349349                        echo '<wp:author_first_name>' . wxr_cdata( $author->first_name ) . '</wp:author_first_name>';
     350                        echo '<wp:author_other_name>' . wxr_cdata( $author->other_name ) . '</wp:author_other_name>';
    350351                        echo '<wp:author_last_name>' . wxr_cdata( $author->last_name ) . '</wp:author_last_name>';
    351352                        echo "</wp:author>\n";
    352353                }
  • src/wp-admin/includes/upgrade.php

    diff --git a/src/wp-admin/includes/upgrade.php b/src/wp-admin/includes/upgrade.php
    index 94ad771761..ead5ca18b6 100644
    a b Commenter avatars come from <a href="https://gravatar.com">Gravatar</a>.' ); 
    222222                $first_page = get_site_option( 'first_page' );
    223223
    224224        $first_page = ! empty( $first_page ) ? $first_page : sprintf( __( "This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:
    225                
     225
    226226                <blockquote>Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my website. I live in Los Angeles, have a great dog named Jack, and I like pi&#241;a coladas. (And gettin' caught in the rain.)</blockquote>
    227                
     227
    228228                ...or something like this:
    229                
     229
    230230                <blockquote>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</blockquote>
    231                
     231
    232232                As a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to delete this page and create new pages for your content. Have fun!" ), admin_url() );
    233233
    234234        $first_post_guid = get_option('home') . '/?page_id=2';
    function upgrade_160() { 
    821821        foreach ( $users as $user ) :
    822822                if ( !empty( $user->user_firstname ) )
    823823                        update_user_meta( $user->ID, 'first_name', wp_slash($user->user_firstname) );
     824                if ( !empty( $user->user_othername ) )
     825                        update_user_meta( $user->ID, 'other_name', wp_slash($user->user_othername) );
    824826                if ( !empty( $user->user_lastname ) )
    825827                        update_user_meta( $user->ID, 'last_name', wp_slash($user->user_lastname) );
    826828                if ( !empty( $user->user_nickname ) )
  • src/wp-admin/includes/user.php

    diff --git a/src/wp-admin/includes/user.php b/src/wp-admin/includes/user.php
    index 479745fe10..5170912b5a 100644
    a b function edit_user( $user_id = 0 ) { 
    7575        }
    7676        if ( isset( $_POST['first_name'] ) )
    7777                $user->first_name = sanitize_text_field( $_POST['first_name'] );
     78        if ( isset( $_POST['other_name'] ) )
     79                $user->other_name = sanitize_text_field( $_POST['other_name'] );
    7880        if ( isset( $_POST['last_name'] ) )
    7981                $user->last_name = sanitize_text_field( $_POST['last_name'] );
    8082        if ( isset( $_POST['nickname'] ) )
  • src/wp-admin/js/password-strength-meter.js

    diff --git a/src/wp-admin/js/password-strength-meter.js b/src/wp-admin/js/password-strength-meter.js
    index efd26bbc5a..d5299b1efc 100644
    a b var passwordStrength; 
    3636                        var i, userInputFieldsLength, rawValuesLength, currentField,
    3737                                rawValues       = [],
    3838                                blacklist       = [],
    39                                 userInputFields = [ 'user_login', 'first_name', 'last_name', 'nickname', 'display_name', 'email', 'url', 'description', 'weblog_title', 'admin_email' ];
     39                                userInputFields = [ 'user_login', 'first_name', 'other_name', 'last_name', 'nickname', 'display_name', 'email', 'url', 'description', 'weblog_title', 'admin_email' ];
    4040
    4141                        // Collect all the strings we want to blacklist
    4242                        rawValues.push( document.title );
  • src/wp-admin/js/user-profile.js

    diff --git a/src/wp-admin/js/user-profile.js b/src/wp-admin/js/user-profile.js
    index ca99584215..1bd8e3dd6d 100644
    a b  
    339339                });
    340340
    341341                if ( select.length ) {
    342                         $('#first_name, #last_name, #nickname').bind( 'blur.user_profile', function() {
     342                        $('#first_name, #other_name, #last_name, #nickname').bind( 'blur.user_profile', function() {
    343343                                var dub = [],
    344344                                        inputs = {
    345345                                                display_nickname  : $('#nickname').val() || '',
    346346                                                display_username  : $('#user_login').val() || '',
    347347                                                display_firstname : $('#first_name').val() || '',
     348                                                display_othername : $('#other_name').val() || '',
    348349                                                display_lastname  : $('#last_name').val() || ''
    349350                                        };
    350351
  • src/wp-admin/user-edit.php

    diff --git a/src/wp-admin/user-edit.php b/src/wp-admin/user-edit.php
    index 80cef618e5..721cd98c16 100644
    a b if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_c 
    387387        <td><input type="text" name="first_name" id="first_name" value="<?php echo esc_attr($profileuser->first_name) ?>" class="regular-text" /></td>
    388388</tr>
    389389
     390<tr class="user-other-name-wrap">
     391        <th><label for="other_name"><?php _e('Additional Names') ?></label></th>
     392        <td><input type="text" name="other_name" id="other_name" value="<?php echo esc_attr($profileuser->other_name) ?>" class="regular-text" /></td>
     393</tr>
     394
     395
    390396<tr class="user-last-name-wrap">
    391397        <th><label for="last_name"><?php _e('Last Name') ?></label></th>
    392398        <td><input type="text" name="last_name" id="last_name" value="<?php echo esc_attr($profileuser->last_name) ?>" class="regular-text" /></td>
    if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_c 
    409415                        if ( !empty($profileuser->first_name) )
    410416                                $public_display['display_firstname'] = $profileuser->first_name;
    411417
     418                        if ( !empty($profileuser->other_name) )
     419                                $public_display['display_othername'] = $profileuser->other_name;
     420
    412421                        if ( !empty($profileuser->last_name) )
    413422                                $public_display['display_lastname'] = $profileuser->last_name;
    414423
    415424                        if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) {
    416425                                $public_display['display_firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
    417426                                $public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
     427                                $public_display['display_lastfirstother'] = $profileuser->last_name . ' ' . $profileuser->first_name . ' ' . $profileuser->other_name;
     428                                $public_display['display_firstotherlast'] = $profileuser->first_name . ' ' . $profileuser->other_name . ' ' . $profileuser->last_name;
    418429                        }
    419430
    420431                        if ( !in_array( $profileuser->display_name, $public_display ) ) // Only add this if it isn't duplicated elsewhere
  • src/wp-admin/user-new.php

    diff --git a/src/wp-admin/user-new.php b/src/wp-admin/user-new.php
    index 1ea39ba950..269df53fa5 100644
    a b $creating = isset( $_POST['createuser'] ); 
    392392
    393393$new_user_login = $creating && isset( $_POST['user_login'] ) ? wp_unslash( $_POST['user_login'] ) : '';
    394394$new_user_firstname = $creating && isset( $_POST['first_name'] ) ? wp_unslash( $_POST['first_name'] ) : '';
     395$new_user_othername = $creating && isset( $_POST['other_name'] ) ? wp_unslash( $_POST['other_name'] ) : '';
    395396$new_user_lastname = $creating && isset( $_POST['last_name'] ) ? wp_unslash( $_POST['last_name'] ) : '';
    396397$new_user_email = $creating && isset( $_POST['email'] ) ? wp_unslash( $_POST['email'] ) : '';
    397398$new_user_uri = $creating && isset( $_POST['url'] ) ? wp_unslash( $_POST['url'] ) : '';
    $new_user_ignore_pass = $creating && isset( $_POST['noconfirmation'] ) ? wp_unsl 
    414415                <th scope="row"><label for="first_name"><?php _e('First Name') ?> </label></th>
    415416                <td><input name="first_name" type="text" id="first_name" value="<?php echo esc_attr($new_user_firstname); ?>" /></td>
    416417        </tr>
     418    <tr class="form-field">
     419        <th scope="row"><label for="other_name"><?php _e('Additional Names') ?> </label></th>
     420        <td><input name="other_name" type="text" id="other_name" value="<?php echo esc_attr($new_user_othername); ?>" /></td>
     421    </tr>
    417422        <tr class="form-field">
    418423                <th scope="row"><label for="last_name"><?php _e('Last Name') ?> </label></th>
    419424                <td><input name="last_name" type="text" id="last_name" value="<?php echo esc_attr($new_user_lastname); ?>" /></td>
  • src/wp-includes/author-template.php

    diff --git a/src/wp-includes/author-template.php b/src/wp-includes/author-template.php
    index eb050d89d8..2df1d4b8bb 100644
    a b function wp_list_authors( $args = '' ) { 
    403403                        continue;
    404404                }
    405405
    406                 if ( $args['show_fullname'] && $author->first_name && $author->last_name ) {
    407                         $name = "$author->first_name $author->last_name";
     406                if ( $args['show_fullname'] && $author->first_name && $author->other_name && $author->last_name ) {
     407                        $name = "$author->first_name $author->other_name $author->last_name";
    408408                } else {
    409409                        $name = $author->display_name;
    410410                }
  • src/wp-includes/class-wp-user.php

    diff --git a/src/wp-includes/class-wp-user.php b/src/wp-includes/class-wp-user.php
    index 0b0bb1023a..d5adefb713 100644
    a b  
    1717 * @property string $user_description
    1818 * @property string $first_name
    1919 * @property string $user_firstname
     20 * @property string $other_name
     21 * @property string $user_othername
    2022 * @property string $last_name
    2123 * @property string $user_lastname
    2224 * @property string $user_login
    class WP_User { 
    123125                        $prefix = $GLOBALS['wpdb']->prefix;
    124126                        self::$back_compat_keys = array(
    125127                                'user_firstname' => 'first_name',
     128                                'user_othername' => 'other_name',
    126129                                'user_lastname' => 'last_name',
    127130                                'user_description' => 'description',
    128131                                'user_level' => $prefix . 'user_level',
  • src/wp-includes/class-wp-xmlrpc-server.php

    diff --git a/src/wp-includes/class-wp-xmlrpc-server.php b/src/wp-includes/class-wp-xmlrpc-server.php
    index 9b80f0dfe1..9bf7aae918 100644
    a b class wp_xmlrpc_server extends IXR_Server { 
    11211121                $user_fields = array(
    11221122                        'username'          => $user->user_login,
    11231123                        'first_name'        => $user->user_firstname,
     1124                        'other_name'        => $user->user_othername,
    11241125                        'last_name'         => $user->user_lastname,
    11251126                        'registered'        => $this->_convert_date( $user->user_registered ),
    11261127                        'bio'               => $user->user_description,
    class wp_xmlrpc_server extends IXR_Server { 
    24002401         *  - 'user_id'
    24012402         *  - 'username'
    24022403         *  - 'first_name'
     2404         *  - 'other_name'
    24032405         *  - 'last_name'
    24042406         *  - 'registered'
    24052407         *  - 'bio'
    class wp_xmlrpc_server extends IXR_Server { 
    25922594         *     @type string $password
    25932595         *     @type array  $content_struct It can optionally contain:
    25942596         *      - 'first_name'
     2597         *      - 'other_name'
    25952598         *      - 'last_name'
    25962599         *      - 'website'
    25972600         *      - 'display_name'
    class wp_xmlrpc_server extends IXR_Server { 
    26282631                if ( isset( $content_struct['first_name'] ) )
    26292632                        $user_data['first_name'] = $content_struct['first_name'];
    26302633
     2634                if ( isset( $content_struct['other_name'] ) )
     2635                        $user_data['other_name'] = $content_struct['other_name'];
     2636
    26312637                if ( isset( $content_struct['last_name'] ) )
    26322638                        $user_data['last_name'] = $content_struct['last_name'];
    26332639
    class wp_xmlrpc_server extends IXR_Server { 
    44644470                        'userid'    => $user->ID,
    44654471                        'url'       => $user->user_url,
    44664472                        'lastname'  => $user->last_name,
    4467                         'firstname' => $user->first_name
     4473                        'firstname' => $user->first_name,
     4474                        'othername' => $user->other_name
    44684475                );
    44694476
    44704477                return $struct;
  • src/wp-includes/default-filters.php

    diff --git a/src/wp-includes/default-filters.php b/src/wp-includes/default-filters.php
    index 8f0237028d..97f4046619 100644
    a b  
    1313 */
    1414
    1515// Strip, trim, kses, special chars for string saves
    16 foreach ( array( 'pre_term_name', 'pre_comment_author_name', 'pre_link_name', 'pre_link_target', 'pre_link_rel', 'pre_user_display_name', 'pre_user_first_name', 'pre_user_last_name', 'pre_user_nickname' ) as $filter ) {
     16foreach ( array( 'pre_term_name', 'pre_comment_author_name', 'pre_link_name', 'pre_link_target', 'pre_link_rel', 'pre_user_display_name', 'pre_user_first_name', 'pre_user_other_name', 'pre_user_last_name', 'pre_user_nickname' ) as $filter ) {
    1717        add_filter( $filter, 'sanitize_text_field'  );
    1818        add_filter( $filter, 'wp_filter_kses'       );
    1919        add_filter( $filter, '_wp_specialchars', 30 );
    2020}
    2121
    2222// Strip, kses, special chars for string display
    23 foreach ( array( 'term_name', 'comment_author_name', 'link_name', 'link_target', 'link_rel', 'user_display_name', 'user_first_name', 'user_last_name', 'user_nickname' ) as $filter ) {
     23foreach ( array( 'term_name', 'comment_author_name', 'link_name', 'link_target', 'link_rel', 'user_display_name', 'user_first_name', 'user_other_name', 'user_last_name', 'user_nickname' ) as $filter ) {
    2424        if ( is_admin() ) {
    2525                // These are expensive. Run only on admin pages for defense in depth.
    2626                add_filter( $filter, 'sanitize_text_field'  );
  • src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php

    diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
    index 63fb4e9e99..3092cd170e 100644
    a b class WP_REST_Users_Controller extends WP_REST_Controller { 
    844844                        $data['first_name'] = $user->first_name;
    845845                }
    846846
     847                if ( ! empty( $schema['properties']['other_name'] ) ) {
     848                        $data['other_name'] = $user->other_name;
     849                }
     850
    847851                if ( ! empty( $schema['properties']['last_name'] ) ) {
    848852                        $data['last_name'] = $user->last_name;
    849853                }
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    985989                        $prepared_user->first_name = $request['first_name'];
    986990                }
    987991
     992                if ( isset( $request['other_name'] ) && ! empty( $schema['properties']['other_name'] ) ) {
     993                        $prepared_user->other_name = $request['other_name'];
     994                }
     995
    988996                if ( isset( $request['last_name'] ) && ! empty( $schema['properties']['last_name'] ) ) {
    989997                        $prepared_user->last_name = $request['last_name'];
    990998                }
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    11761184                                                'sanitize_callback' => 'sanitize_text_field',
    11771185                                        ),
    11781186                                ),
     1187                                'other_name' => array(
     1188                                        'description' => __( 'Additional names fot the user.' ),
     1189                                        'type'        => 'string',
     1190                                        'context'     => array( 'edit' ),
     1191                                        'arg_options' => array(
     1192                                                'sanitize_callback' => 'sanitize_text_field',
     1193                                        ),
     1194                                ),
    11791195                                'last_name'   => array(
    11801196                                        'description' => __( 'Last name for the user.' ),
    11811197                                        'type'        => 'string',
  • src/wp-includes/user.php

    diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php
    index 2bb4e0543e..8d06d5c314 100644
    a b function validate_username( $username ) { 
    13881388 *     @type string      $first_name           The user's first name. For new users, will be used
    13891389 *                                             to build the first part of the user's display name
    13901390 *                                             if `$display_name` is not specified.
     1391 *     @type string      $other_name           The user's additional names. For new users, will be used
     1392 *                                             to build the middle part of the user's display name
     1393 *                                             if `$display_name` is not specified.
    13911394 *     @type string      $last_name            The user's last name. For new users, will be used
    13921395 *                                             to build the second part of the user's display name
    13931396 *                                             if `$display_name` is not specified.
    function wp_insert_user( $userdata ) { 
    15571560         */
    15581561        $meta['first_name'] = apply_filters( 'pre_user_first_name', $first_name );
    15591562
     1563        $other_name = empty( $userdata['other_name'] ) ? '' : $userdata['other_name'];
     1564
     1565        /**
     1566         * Filters a user's additional names before the user is created or updated.
     1567         *
     1568         * @since 4.x.x
     1569         *
     1570         * @param string $other_name The user's additional name.
     1571         */
     1572        $meta['other_name'] = apply_filters( 'pre_user_other_name', $other_name );
     1573
    15601574        $last_name = empty( $userdata['last_name'] ) ? '' : $userdata['last_name'];
    15611575
    15621576        /**
    function wp_insert_user( $userdata ) { 
    15741588                } elseif ( $meta['first_name'] && $meta['last_name'] ) {
    15751589                        /* translators: 1: first name, 2: last name */
    15761590                        $display_name = sprintf( _x( '%1$s %2$s', 'Display name based on first name and last name' ), $meta['first_name'], $meta['last_name'] );
     1591                } elseif ( $meta['first_name'] && $meta['other_name'] && $meta['last_name'] ) {
     1592                        /* translators: 1: first name, 2: last name, 3: additional names */
     1593                        $display_name = sprintf( _x( '%1$s %3$s %2$s', 'Display name based on first name and last name' ), $meta['first_name'], $meta['last_name'], $meta['other_name'] );
    15771594                } elseif ( $meta['first_name'] ) {
    15781595                        $display_name = $meta['first_name'];
     1596                } elseif ( $meta['other_name'] ) {
     1597                        $display_name = $meta['other_name'];
    15791598                } elseif ( $meta['last_name'] ) {
    15801599                        $display_name = $meta['last_name'];
    15811600                } else {
    function wp_insert_user( $userdata ) { 
    16621681         *
    16631682         *     @type string   $nickname             The user's nickname. Default is the user's username.
    16641683         *     @type string   $first_name           The user's first name.
     1684         *     @type string   $other_name           The user's additional names.
    16651685         *     @type string   $last_name            The user's last name.
    16661686         *     @type string   $description          The user's description.
    16671687         *     @type bool     $rich_editing         Whether to enable the rich-editor for the user. False if not empty.
    function wp_create_user($username, $password, $email = '') { 
    19892009 * @return array List of user keys to be populated in wp_update_user().
    19902010 */
    19912011function _get_additional_user_keys( $user ) {
    1992         $keys = array( 'first_name', 'last_name', 'nickname', 'description', 'rich_editing', 'comment_shortcuts', 'admin_color', 'use_ssl', 'show_admin_bar_front', 'locale' );
     2012        $keys = array( 'first_name', 'other_name', 'last_name', 'nickname', 'description', 'rich_editing', 'comment_shortcuts', 'admin_color', 'use_ssl', 'show_admin_bar_front', 'locale' );
    19932013        return array_merge( $keys, array_keys( wp_get_user_contact_methods( $user ) ) );
    19942014}
    19952015
  • tests/qunit/fixtures/wp-api-generated.js

    diff --git a/tests/qunit/fixtures/wp-api-generated.js b/tests/qunit/fixtures/wp-api-generated.js
    index 69e2375563..7cfafc6551 100644
    a b mockedApiResponse.Schema = { 
    25392539                            "description": "First name for the user.",
    25402540                            "type": "string"
    25412541                        },
     2542                        "other_name": {
     2543                            "required": false,
     2544                            "description": "Additional names for the user.",
     2545                            "type": "string"
     2546                        },
    25422547                        "last_name": {
    25432548                            "required": false,
    25442549                            "description": "Last name for the user.",
    mockedApiResponse.Schema = { 
    26662671                            "description": "First name for the user.",
    26672672                            "type": "string"
    26682673                        },
     2674                        "other_name": {
     2675                            "required": false,
     2676                            "description": "Additional names for the user.",
     2677                            "type": "string"
     2678                        },
    26692679                        "last_name": {
    26702680                            "required": false,
    26712681                            "description": "Last name for the user.",
    mockedApiResponse.Schema = { 
    28032813                            "description": "First name for the user.",
    28042814                            "type": "string"
    28052815                        },
     2816                        "other_name": {
     2817                            "required": false,
     2818                            "description": "Additional names for the user.",
     2819                            "type": "string"
     2820                        },
    28062821                        "last_name": {
    28072822                            "required": false,
    28082823                            "description": "Last name for the user.",