Skip to content

Instantly share code, notes, and snippets.

@justintadlock
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justintadlock/111336946baa29dd4179 to your computer and use it in GitHub Desktop.
Save justintadlock/111336946baa29dd4179 to your computer and use it in GitHub Desktop.
Customize color with empty default
<?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