WordPress.org

Make WordPress Core

Changeset 26535


Ignore:
Timestamp:
12/02/2013 07:44:50 PM (8 years ago)
Author:
nacin
Message:

Simplify the color scheme profile saving JS. see #25858.

Location:
trunk/src/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/ajax-actions.php

    r26220 r26535  
    22502250    global $_wp_admin_css_colors;
    22512251
    2252     $user_id = intval( $_POST['user_id'] );
     2252    $user_id = get_current_user_id();
     2253    check_ajax_referer( 'update-user_' . $user_id, 'nonce' );
     2254
    22532255    $color_scheme = sanitize_key( $_POST['color_scheme'] );
    22542256
    2255     if ( get_current_user_id() !== $user_id )
    2256         wp_send_json_error();
    2257 
    2258     if ( ! get_user_by( 'id', $user_id ) )
    2259         wp_send_json_error();
    2260 
    2261     if ( ! isset( $_wp_admin_css_colors[ $color_scheme ] ) )
    2262         wp_send_json_error();
    2263 
    2264     update_user_option( $user_id, 'admin_color', $color_scheme, true );
     2257    if ( ! isset( $_wp_admin_css_colors[ $color_scheme ] ) ) {
     2258        wp_send_json_error();
     2259    }
     2260
     2261    update_user_meta( $user_id, 'admin_color', $color_scheme );
    22652262    wp_send_json_success();
    22662263}
  • trunk/src/wp-admin/js/user-profile.js

    r26506 r26535  
    8484
    8585        $colorpicker.on( 'click.colorpicker', '.color-option', function() {
    86             var $this = $(this),
    87                 color_scheme = $this.children( 'input[name="admin_color"]' ).val();
     86            var $this = $(this);
    8887
    8988            if ( $this.hasClass( 'selected' ) ) {
     
    107106                // update user option
    108107                $.post( ajaxurl, {
    109                     action: 'save-user-color-scheme',
    110                     color_scheme: color_scheme,
    111                     user_id: user_id
     108                    action:       'save-user-color-scheme',
     109                    color_scheme: $this.children( 'input[name="admin_color"]' ).val(),
     110                    nonce:        $('#_wpnonce').val()
    112111                });
    113112            }
Note: See TracChangeset for help on using the changeset viewer.