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

git-svn-id: https://develop.svn.wordpress.org/trunk@26535 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin
2013-12-02 19:44:50 +00:00
parent 5e14491a2e
commit 16b6b6b8e4
2 changed files with 10 additions and 14 deletions
+6 -9
View File
@@ -2249,18 +2249,15 @@ function wp_ajax_get_revision_diffs() {
function wp_ajax_save_user_color_scheme() {
global $_wp_admin_css_colors;
$user_id = intval( $_POST['user_id'] );
$user_id = get_current_user_id();
check_ajax_referer( 'update-user_' . $user_id, 'nonce' );
$color_scheme = sanitize_key( $_POST['color_scheme'] );
if ( get_current_user_id() !== $user_id )
if ( ! isset( $_wp_admin_css_colors[ $color_scheme ] ) ) {
wp_send_json_error();
}
if ( ! get_user_by( 'id', $user_id ) )
wp_send_json_error();
if ( ! isset( $_wp_admin_css_colors[ $color_scheme ] ) )
wp_send_json_error();
update_user_option( $user_id, 'admin_color', $color_scheme, true );
update_user_meta( $user_id, 'admin_color', $color_scheme );
wp_send_json_success();
}
+4 -5
View File
@@ -83,8 +83,7 @@
current_user_id = $( 'input[name="checkuser_id"]' ).val();
$colorpicker.on( 'click.colorpicker', '.color-option', function() {
var $this = $(this),
color_scheme = $this.children( 'input[name="admin_color"]' ).val();
var $this = $(this);
if ( $this.hasClass( 'selected' ) ) {
return;
@@ -106,9 +105,9 @@
// update user option
$.post( ajaxurl, {
action: 'save-user-color-scheme',
color_scheme: color_scheme,
user_id: user_id
action: 'save-user-color-scheme',
color_scheme: $this.children( 'input[name="admin_color"]' ).val(),
nonce: $('#_wpnonce').val()
});
}
});