Adding autosave for color schemes and removing RTL handling. See #26387, props ryelle.

git-svn-id: https://develop.svn.wordpress.org/trunk@26746 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Matt Thomas 2013-12-06 21:25:31 +00:00
parent a05083f3a4
commit b9893b491c
2 changed files with 11 additions and 9 deletions

View File

@ -81,15 +81,17 @@ include( ABSPATH . 'wp-admin/admin-header.php' );
<div>
<h3><?php echo ( 'Pick a color' ); ?></h3>
<p><?php echo ( 'We&#8217;ve included four color schemes so that you can choose your favorite. Don&#8217;t like this striking new admin? Choose from any of the schemes below to change it in an instant.' ); ?></p>
<?php $user_id = get_current_user_id(); ?>
<?php if ( count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker') ) :?>
<?php
wp_nonce_field('update-user_' . $user_id);
/** This action is documented in wp-admin/user-edit.php */
do_action( 'admin_color_scheme_picker' );
?>
<?php else : ?>
<img src="<?php echo admin_url( 'images/about-color-schemes.png' ); ?>" />
<?php endif; ?>
<p><?php printf( ( 'To change your color scheme later, just <a href="%1$s">visit your profile settings</a>.' ), get_edit_profile_url( get_current_user_id() ) ); ?></p>
<p><?php printf( ( 'To change your color scheme later, just <a href="%1$s">visit your profile settings</a>.' ), get_edit_profile_url( $user_id ) ); ?></p>
</div>
</div>
</div>

View File

@ -1,4 +1,4 @@
/* global isRtl */
/* global ajaxurl */
(function($){
$(document).ready( function() {
@ -10,9 +10,6 @@
$colorpicker = $( '#color-picker' );
$stylesheet = $( '#colors-css' );
if ( isRtl ){
$stylesheet = $( '#colors-rtl-css' );
}
$colorpicker.on( 'click.colorpicker', '.color-option', function() {
var colors, css_url,
@ -28,10 +25,6 @@
// Set color scheme
// Load the colors stylesheet
css_url = $this.children( '.css_url' ).val();
if ( isRtl ){
css_url = css_url.replace('.min', '-rtl.min');
}
$stylesheet.attr( 'href', css_url );
// repaint icons
@ -45,6 +38,13 @@
wp.svgPainter.paint();
}
}
// update user option
$.post( ajaxurl, {
action: 'save-user-color-scheme',
color_scheme: $this.children( 'input[name="admin_color"]' ).val(),
nonce: $('#_wpnonce').val()
});
});
});