Simplify the color scheme profile saving JS. see #25858.
Built from https://develop.svn.wordpress.org/trunk@26535 git-svn-id: http://core.svn.wordpress.org/trunk@26427 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
56a97bdc01
commit
710803793b
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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 a("#pass-strength-result").html(pwsL10n.empty),void 0;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("<option />",{text:f}).appendTo(g))}})}),c=a("#color-picker"),d=a("#colors-css"),e=a("input#user_id").val(),f=a('input[name="checkuser_id"]').val(),c.on("click.colorpicker",".color-option",function(){var b=a(this),c=b.children('input[name="admin_color"]').val();b.hasClass("selected")||(b.siblings(".selected").removeClass("selected"),b.addClass("selected").find('input[type="radio"]').prop("checked",!0),e===f&&(d.attr("href",b.children(".css_url").val()),"undefined"!=typeof window.svgPainter&&(svgPainter.setColors(a.parseJSON(b.children(".icon_colors").val())),svgPainter.paint()),a.post(ajaxurl,{action:"save-user-color-scheme",color_scheme:c,user_id:e})))})})}(jQuery);
|
||||
!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 a("#pass-strength-result").html(pwsL10n.empty),void 0;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("<option />",{text:f}).appendTo(g))}})}),c=a("#color-picker"),d=a("#colors-css"),e=a("input#user_id").val(),f=a('input[name="checkuser_id"]').val(),c.on("click.colorpicker",".color-option",function(){var b=a(this);b.hasClass("selected")||(b.siblings(".selected").removeClass("selected"),b.addClass("selected").find('input[type="radio"]').prop("checked",!0),e===f&&(d.attr("href",b.children(".css_url").val()),"undefined"!=typeof window.svgPainter&&(svgPainter.setColors(a.parseJSON(b.children(".icon_colors").val())),svgPainter.paint()),a.post(ajaxurl,{action:"save-user-color-scheme",color_scheme:b.children('input[name="admin_color"]').val(),nonce:a("#_wpnonce").val()})))})})}(jQuery);
|
Loading…
Reference in New Issue