Last active
August 29, 2015 14:21
-
-
Save justintadlock/111336946baa29dd4179 to your computer and use it in GitHub Desktop.
Customize color with empty default
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'customize_register', 'my_customize_register' ); | |
function my_customize_register( $wp_customize ) { | |
$wp_customize->add_setting( | |
'color_xyz', | |
array( | |
'default' => '', | |
'sanitize_callback' => 'sanitize_hex_color_no_hash', | |
'sanitize_js_callback' => 'maybe_hash_hex_color', | |
'transport' => 'postMessage', | |
) | |
); | |
$wp_customize->add_control( | |
new WP_Customize_Color_Control( | |
$wp_customize, | |
'color_xyz', | |
array( | |
'label' => esc_html__( 'XYZ Color', 'textdomain' ), | |
'section' => 'colors', | |
) | |
) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment