Make WordPress Core

Ticket #31588: 31588.diff

File 31588.diff, 6.5 KB (added by rachelbaker, 9 years ago)

Retains the verbose pre_user_ filter information and updates the exceptions. Also corrects string typo.

  • src/wp-includes/user.php

     
    18061806 * Insert a user into the database.
    18071807 *
    18081808 * Most of the $userdata array fields have filters associated with the values.
    1809  * The exceptions are 'rich_editing', 'role', 'jabber', 'aim', 'yim',
    1810  * 'user_registered', and 'ID'. The filters have the prefix 'pre_user_' followed
    1811  * by the field name. An example using 'description' would have the filter
    1812  * called, 'pre_user_description' that can be hooked into.
     1809 * The exceptions are 'ID', 'rich_editing', 'comment_shortcuts', 'admin_color', 'use_ssl',
     1810 * 'user_registered', and 'role'. The filters have the prefix 'pre_user_' followed by the field
     1811 * name. An example using 'description' would have the filter called, 'pre_user_description' that
     1812 * can be hooked into.
    18131813 *
    18141814 * @since 2.0.0
     1815 * @since 3.6.0 The `aim`, `jabber`, and `yim` fields were removed as default user contact
     1816 *              methods for new installs. See {@see wp_get_user_contact_methods()}.
    18151817 *
    18161818 * @global wpdb $wpdb WordPress database object for queries.
    18171819 *
     
    18181820 * @param array $userdata {
    18191821 *     An array, object, or WP_User object of user data arguments.
    18201822 *
    1821  *     @type int         $ID              User ID. If supplied, the user will be updated.
    1822  *     @type string      $user_pass       The plain-text user password.
    1823  *     @type string      $user_login      The user's login username.
    1824  *     @type string      $user_nicename   The URL-friendly user name.
    1825  *     @type string      $user_url        The user URL.
    1826  *     @type string      $user_email      The user email address.
    1827  *     @type string      $display_name    The user's display name.
    1828  *                                        Default is the the user's username.
    1829  *     @type string      $nickname        The user's nickname. Default
    1830  *                                        Default is the the user's username.
    1831  *     @type string      $first_name      The user's first name. For new users, will be used
    1832  *                                        to build $display_name if unspecified.
    1833  *     @type stirng      $last_name       The user's last name. For new users, will be used
    1834  *                                        to build $display_name if unspecified.
    1835  *     @type string|bool $rich_editing    Whether to enable the rich-editor for the user. False
    1836  *                                        if not empty.
    1837  *     @type string      $user_registered Date the user registered. Format is 'Y-m-d H:i:s'.
    1838  *     @type string      $role            User's role.
    1839  *     @type string      $jabber          User's Jabber account username.
    1840  *     @type string      $aim             User's AIM account username.
    1841  *     @type string      $yim             User's Yahoo! messenger username.
     1823 *     @type int         $ID                   User ID. If supplied, the user will be updated.
     1824 *     @type string      $user_pass            The plain-text user password.
     1825 *     @type string      $user_login           The user's login username.
     1826 *     @type string      $user_nicename        The URL-friendly user name.
     1827 *     @type string      $user_url             The user URL.
     1828 *     @type string      $user_email           The user email address.
     1829 *     @type string      $display_name         The user's display name.
     1830 *                                             Default is the the user's username.
     1831 *     @type string      $nickname             The user's nickname.
     1832 *                                             Default is the the user's username.
     1833 *     @type string      $first_name           The user's first name. For new users, will be used
     1834 *                                             to build the user's display name if `$display_name`
     1835 *                                             is not specified.
     1836 *     @type string      $last_name            The user's last name. For new users, will be used
     1837 *                                             to build the user's display name if `$display_name`
     1838 *                                             is not specified.
     1839 *     @type string      $description          The user's description.
     1840 *     @type string|bool $rich_editing         Whether to enable the rich-editor for the user.
     1841 *                                             False if not empty.
     1842 *     @type string|bool $comment_shortcuts    Whether to enable comment moderation keyboard
     1843 *                                             shortcuts for the user. Default false.
     1844 *     @type string      $admin_color          Admin color scheme for the user. Default 'fresh'.
     1845 *     @type bool        $use_ssl              Whether the user should always access the admin over
     1846 *                                             https. Default false.
     1847 *     @type string      $user_registered      Date the user registered. Format is 'Y-m-d H:i:s'.
     1848 *     @type string|bool $show_admin_bar_front Whether to display the Admin Bar for the user on the
     1849 *                                             site's frontend. Default true.
     1850 *     @type string      $role                 User's role.
    18421851 * }
    18431852 * @return int|WP_Error The newly created user's ID or a WP_Error object if the user could not
    18441853 *                      be created.
     
    20142023
    20152024        $meta['rich_editing'] = empty( $userdata['rich_editing'] ) ? 'true' : $userdata['rich_editing'];
    20162025
    2017         $meta['comment_shortcuts'] = empty( $userdata['comment_shortcuts'] ) ? 'false' : $userdata['comment_shortcuts'];
     2026        $meta['comment_shortcuts'] = empty( $userdata['comment_shortcuts'] ) || 'false' === $userdata['comment_shortcuts'] ? 'false' : 'true';
    20182027
    20192028        $admin_color = empty( $userdata['admin_color'] ) ? 'fresh' : $userdata['admin_color'];
    20202029        $meta['admin_color'] = preg_replace( '|[^a-z0-9 _.\-@]|i', '', $admin_color );
  • tests/phpunit/tests/user.php

     
    308308                // Test update of fields in _get_additional_user_keys()
    309309                $user_data = array( 'ID' => $user_id, 'use_ssl' => 1, 'show_admin_bar_front' => 1,
    310310                                                   'rich_editing' => 1, 'first_name' => 'first', 'last_name' => 'last',
    311                                                    'nickname' => 'nick', 'comment_shortcuts' => 1, 'admin_color' => 'classic',
     311                                                   'nickname' => 'nick', 'comment_shortcuts' => 'true', 'admin_color' => 'classic',
    312312                                                   'description' => 'describe' );
    313313                wp_update_user( $user_data );
    314314