Make WordPress Core

Changeset 20910


Ignore:
Timestamp:
05/25/2012 06:54:57 PM (12 years ago)
Author:
koopersmith
Message:

Theme Customizer: Improve hex color sanitization functions. fixes #20600, see #19910.

Instead of fetching default header_textcolor manually, return null to do so automatically.
Improve hex regex.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class-wp-customize-manager.php

    r20908 r20910  
    847847// Callback function for sanitizing the header textcolor setting.
    848848function sanitize_header_textcolor( $color ) {
    849     if ( empty( $color ) )
    850         return get_theme_support( 'custom-header', 'default-text-color' );
    851 
    852     elseif ( $color == 'blank' )
     849    if ( $color == 'blank' )
    853850        return 'blank';
    854851
     
    860857    $color = preg_replace( '/[^0-9a-fA-F]/', '', $color );
    861858
    862     if ( preg_match('|[A-Fa-f0-9]{3,6}|', $color ) )
     859    // 3 or 6 hex digits.
     860    if ( preg_match('|^([A-Fa-f0-9]{3}){1,2}$|', $color ) )
    863861        return $color;
    864862
    865     return $color;
     863    return null;
    866864}
Note: See TracChangeset for help on using the changeset viewer.