WordPress.org

Make WordPress Core


Ignore:
Timestamp:
05/26/2012 06:44:31 PM (8 years ago)
Author:
koopersmith
Message:

Theme Customizer: Ensure that JS color controls always use real color values, even if the server-side value is a hex value without a hash. fixes #20448, see #19910.

Adds WP_Customize_Setting->sanitize_js_callback and 'customize_sanitize_js_$settingID' filter, to filter values before they're passed to JS using WP_Customize_Setting->js_value().

Adds support for regular hex colors to the color picker.

Changes color methods:

  • sanitize_hex_color() accepts 3 and 6 digit hex colors (with hashes) and the empty string.
  • sanitize_hex_color_no_hash() accepts 3 and 6 digit hex colors (without hashes) and the empty string.
  • maybe_hash_hex_color() ensures that a hex color has a hash, and otherwise leaves the value untouched.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/themes/twentyeleven/inc/theme-options.php

    r20916 r20936  
    484484        'default'           => twentyeleven_get_default_link_color( $options['color_scheme'] ),
    485485        'type'              => 'option',
    486         'sanitize_callback' => 'twentyeleven_sanitize_hexcolor',
     486        'sanitize_callback' => 'sanitize_hex_color',
    487487        'capability'        => 'edit_theme_options',
    488488    ) );
     
    521521
    522522/**
    523  * Sanitize user input hex color value
    524  *
    525  * @uses sanitize_hexcolor()
    526  * @param $color string
    527  * @return string sanitized with prefixed # character
    528  */
    529 function twentyeleven_sanitize_hexcolor( $color ) {
    530     return '#' . sanitize_hexcolor( $color );
    531 }
    532 
    533 /**
    534523 * Bind JS handlers to make Theme Customizer preview reload changes asynchronously.
    535524 * Used with blogname and blogdescription.
Note: See TracChangeset for help on using the changeset viewer.