Make WordPress Core

Ticket #22310: patch.diff

File patch.diff, 5.3 KB (added by saimonh, 6 years ago)

make rich_editing, syntax_highlighting and show_admin_bar_front user meta more logical in wp_insert_user function

  • wp-admin/includes/user.php

    diff --git a/wp-admin/includes/user.php b/wp-admin/includes/user.php
    index 79286f1014..cb4bc4017e 100644
    a b function edit_user( $user_id = 0 ) { 
    112112        }
    113113
    114114        if ( $update ) {
    115                 $user->rich_editing         = isset( $_POST['rich_editing'] ) && 'false' === $_POST['rich_editing'] ? 'false' : 'true';
    116                 $user->syntax_highlighting  = isset( $_POST['syntax_highlighting'] ) && 'false' === $_POST['syntax_highlighting'] ? 'false' : 'true';
     115                $user->rich_editing         = isset( $_POST['rich_editing'] ) && $_POST['rich_editing'] === 'false' ? false : true;
     116                $user->syntax_highlighting  = isset( $_POST['syntax_highlighting'] ) && $_POST['syntax_highlighting'] === 'false' ? false : true;
    117117                $user->admin_color          = isset( $_POST['admin_color'] ) ? sanitize_text_field( $_POST['admin_color'] ) : 'fresh';
    118                 $user->show_admin_bar_front = isset( $_POST['admin_bar_front'] ) ? 'true' : 'false';
     118                $user->show_admin_bar_front = isset( $_POST['admin_bar_front'] ) && $_POST['admin_bar_front'] === 'false' ? true : false;
    119119                $user->locale               = '';
    120120
    121121                if ( isset( $_POST['locale'] ) ) {
  • wp-admin/user-edit.php

    diff --git a/wp-admin/user-edit.php b/wp-admin/user-edit.php
    index b1547886d5..d4b306f100 100644
    a b if ( ! ( IS_PROFILE_PAGE && ! $user_can_edit ) ) : 
    314314<th scope="row"><?php _e( 'Toolbar' ); ?></th>
    315315<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Toolbar' ); ?></span></legend>
    316316<label for="admin_bar_front">
    317 <input name="admin_bar_front" type="checkbox" id="admin_bar_front" value="1"<?php checked( _get_admin_bar_pref( 'front', $profileuser->ID ) ); ?> />
     317<input name="admin_bar_front" type="checkbox" id="admin_bar_front" value="false" <?php checked( _get_admin_bar_pref( 'front', $profileuser->ID ) ); ?> />
    318318<?php _e( 'Show Toolbar when viewing site' ); ?></label><br />
    319319</fieldset>
    320320</td>
  • wp-includes/user.php

    diff --git a/wp-includes/user.php b/wp-includes/user.php
    index 1bf62632ad..d73d89e9fe 100644
    a b function validate_username( $username ) { 
    14781478 *                                             if `$display_name` is not specified.
    14791479 *     @type string      $description          The user's biographical description.
    14801480 *     @type string|bool $rich_editing         Whether to enable the rich-editor for the user.
    1481  *                                             False if not empty.
     1481 *                                             Default true.
    14821482 *     @type string|bool $syntax_highlighting  Whether to enable the rich code editor for the user.
    1483  *                                             False if not empty.
     1483 *                                             Default true.
    14841484 *     @type string|bool $comment_shortcuts    Whether to enable comment moderation keyboard
    14851485 *                                             shortcuts for the user. Default false.
    14861486 *     @type string      $admin_color          Admin color scheme for the user. Default 'fresh'.
    function wp_insert_user( $userdata ) { 
    16921692         */
    16931693        $meta['description'] = apply_filters( 'pre_user_description', $description );
    16941694
    1695         $meta['rich_editing'] = empty( $userdata['rich_editing'] ) ? 'true' : $userdata['rich_editing'];
     1695        $meta['rich_editing'] = isset( $userdata['rich_editing'] ) && empty( $userdata['rich_editing'] ) ? 'false' : 'true';
    16961696
    1697         $meta['syntax_highlighting'] = empty( $userdata['syntax_highlighting'] ) ? 'true' : $userdata['syntax_highlighting'];
     1697        $meta['syntax_highlighting'] = isset( $userdata['syntax_highlighting'] ) && empty( $userdata['syntax_highlighting'] ) ? 'false' : 'true';
    16981698
    16991699        $meta['comment_shortcuts'] = empty( $userdata['comment_shortcuts'] ) || 'false' === $userdata['comment_shortcuts'] ? 'false' : 'true';
    17001700
    function wp_insert_user( $userdata ) { 
    17051705
    17061706        $user_registered = empty( $userdata['user_registered'] ) ? gmdate( 'Y-m-d H:i:s' ) : $userdata['user_registered'];
    17071707
    1708         $meta['show_admin_bar_front'] = empty( $userdata['show_admin_bar_front'] ) ? 'true' : $userdata['show_admin_bar_front'];
     1708        $meta['show_admin_bar_front'] = isset( $userdata['show_admin_bar_front'] ) && empty( $userdata['show_admin_bar_front'] ) ? 'false' : 'true';
    17091709
    17101710        $meta['locale'] = isset( $userdata['locale'] ) ? $userdata['locale'] : '';
    17111711
    function wp_insert_user( $userdata ) { 
    17821782         *     @type string   $first_name           The user's first name.
    17831783         *     @type string   $last_name            The user's last name.
    17841784         *     @type string   $description          The user's description.
    1785          *     @type bool     $rich_editing         Whether to enable the rich-editor for the user. False if not empty.
    1786          *     @type bool     $syntax_highlighting  Whether to enable the rich code editor for the user. False if not empty.
     1785         *     @type bool     $rich_editing         Whether to enable the rich-editor for the user. Default true
     1786         *     @type bool     $syntax_highlighting  Whether to enable the rich code editor for the user. Default true
    17871787         *     @type bool     $comment_shortcuts    Whether to enable keyboard shortcuts for the user. Default false.
    17881788         *     @type string   $admin_color          The color scheme for a user's admin screen. Default 'fresh'.
    17891789         *     @type int|bool $use_ssl              Whether to force SSL on the user's admin area. 0|false if SSL is