From f166a5180973c5157adf793a4c2a3105cc53db22 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 10 Feb 2015 02:23:28 +0000 Subject: [PATCH] Update body class when switching between admin color schemes. props valendesigns. fixes #30488. Built from https://develop.svn.wordpress.org/trunk@31400 git-svn-id: http://core.svn.wordpress.org/trunk@31381 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/ajax-actions.php | 7 ++++++- wp-admin/js/user-profile.js | 4 ++++ wp-admin/js/user-profile.min.js | 2 +- wp-includes/version.php | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php index 1c84d42009..43e6fbda13 100644 --- a/wp-admin/includes/ajax-actions.php +++ b/wp-admin/includes/ajax-actions.php @@ -2600,8 +2600,13 @@ function wp_ajax_save_user_color_scheme() { wp_send_json_error(); } + $previous_color_scheme = get_user_meta( get_current_user_id(), 'admin_color', true ); update_user_meta( get_current_user_id(), 'admin_color', $color_scheme ); - wp_send_json_success(); + + wp_send_json_success( array( + 'previousScheme' => 'admin-color-' . $previous_color_scheme, + 'currentScheme' => 'admin-color-' . $color_scheme + ) ); } /** diff --git a/wp-admin/js/user-profile.js b/wp-admin/js/user-profile.js index ae4b97ab89..ba99586c59 100644 --- a/wp-admin/js/user-profile.js +++ b/wp-admin/js/user-profile.js @@ -119,6 +119,10 @@ action: 'save-user-color-scheme', color_scheme: $this.children( 'input[name="admin_color"]' ).val(), nonce: $('#color-nonce').val() + }).done( function( response ) { + if ( response.success ) { + $( 'body' ).removeClass( response.data.previousScheme ).addClass( response.data.currentScheme ); + } }); } }); diff --git a/wp-admin/js/user-profile.min.js b/wp-admin/js/user-profile.min.js index 1472b22e9d..bcab6c0f24 100644 --- a/wp-admin/js/user-profile.min.js +++ b/wp-admin/js/user-profile.min.js @@ -1 +1 @@ -!function(a){function b(){var b,c=a("#pass1").val(),d=a("#pass2").val();if(a("#pass-strength-result").removeClass("short bad good strong"),!c)return void a("#pass-strength-result").html(pwsL10n.empty);switch(b=wp.passwordStrength.meter(c,wp.passwordStrength.userInputBlacklist(),d)){case 2:a("#pass-strength-result").addClass("bad").html(pwsL10n.bad);break;case 3:a("#pass-strength-result").addClass("good").html(pwsL10n.good);break;case 4:a("#pass-strength-result").addClass("strong").html(pwsL10n.strong);break;case 5:a("#pass-strength-result").addClass("short").html(pwsL10n.mismatch);break;default:a("#pass-strength-result").addClass("short").html(pwsL10n["short"])}}a(document).ready(function(){var c,d,e,f,g=a("#display_name");a("#pass1").val("").keyup(b),a("#pass2").val("").keyup(b),a("#pass-strength-result").show(),a(".color-palette").click(function(){a(this).siblings('input[name="admin_color"]').prop("checked",!0)}),g.length&&a("#first_name, #last_name, #nickname").bind("blur.user_profile",function(){var b=[],c={display_nickname:a("#nickname").val()||"",display_username:a("#user_login").val()||"",display_firstname:a("#first_name").val()||"",display_lastname:a("#last_name").val()||""};c.display_firstname&&c.display_lastname&&(c.display_firstlast=c.display_firstname+" "+c.display_lastname,c.display_lastfirst=c.display_lastname+" "+c.display_firstname),a.each(a("option",g),function(a,c){b.push(c.value)}),a.each(c,function(d,e){if(e){var f=e.replace(/<\/?[a-z][^>]*>/gi,"");c[d].length&&-1===a.inArray(f,b)&&(b.push(f),a("