Translate and empty header text color into the default text color. Honor blank. Props kovshenin. fixes #20600

git-svn-id: http://core.svn.wordpress.org/trunk@20851 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2012-05-23 15:36:27 +00:00
parent f550bc01e5
commit 5a53ce6d28
1 changed files with 12 additions and 2 deletions

View File

@ -564,8 +564,7 @@ final class WP_Customize {
) ); ) );
$this->add_setting( 'header_textcolor', array( $this->add_setting( 'header_textcolor', array(
// @todo: replace with a new accept() setting method 'sanitize_callback' => 'sanitize_header_textcolor',
// 'sanitize_callback' => 'sanitize_hexcolor',
'theme_supports' => array( 'custom-header', 'header-text' ), 'theme_supports' => array( 'custom-header', 'header-text' ),
'default' => get_theme_support( 'custom-header', 'default-text-color' ), 'default' => get_theme_support( 'custom-header', 'default-text-color' ),
) ); ) );
@ -793,6 +792,17 @@ final class WP_Customize {
} }
}; };
// Callback function for sanitizing the header textcolor setting.
function sanitize_header_textcolor( $color ) {
if ( empty( $color ) )
return get_theme_support( 'custom-header', 'default-text-color' );
elseif ( $color == 'blank' )
return 'blank';
return sanitize_hexcolor( $color );
}
// Callback function for sanitizing a hex color // Callback function for sanitizing a hex color
function sanitize_hexcolor( $color ) { function sanitize_hexcolor( $color ) {
$color = preg_replace( '/[^0-9a-fA-F]/', '', $color ); $color = preg_replace( '/[^0-9a-fA-F]/', '', $color );