From b931f924a774be25c3150933e034317b1368d890 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 10 Feb 2015 02:22:49 +0000 Subject: [PATCH] Update body class when switching between admin color schemes. props valendesigns. fixes #30488. git-svn-id: https://develop.svn.wordpress.org/trunk@31400 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/ajax-actions.php | 7 ++++++- src/wp-admin/js/user-profile.js | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php index 1c84d42009..43e6fbda13 100644 --- a/src/wp-admin/includes/ajax-actions.php +++ b/src/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/src/wp-admin/js/user-profile.js b/src/wp-admin/js/user-profile.js index ae4b97ab89..ba99586c59 100644 --- a/src/wp-admin/js/user-profile.js +++ b/src/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 ); + } }); } });