Make WordPress Core

Opened 8 months ago

Last modified 8 months ago

#38093 new enhancement

WP_Customize_Color_Control - there is no option for transparent color

Reported by: mukesh27 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.5
Component: Customize Keywords: 2nd-opinion
Focuses: ui, javascript Cc:


In wordpress customizer there is no option for transparent color if user don't want to add color. also opacity option is not there is it possible to add this in feature?

php code :


/* Navigation Background Color */

$wp_customize->add_setting( 'add_navigation_bg_color_header', array(
        'default'                       => '#ffffff',
        'sanitize_callback' => 'sanitize_hex_color',
        'transport'         => 'postMessage'
) );

$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'add_navigation_bg_color_header', array(
        'label'                 => esc_attr__( 'Navigation Background Color', 'paperio' ),
        'section'               => 'add_navigation_section',
        'settings'                      => 'add_navigation_bg_color_header',
) ) );

/* End Navigation Background Color */


if we add transparent color in color picker and add new control for rgba() so it's easy to customize any developer and make more functional theme.

Attachments (1)

customizer-color-box.png (18.2 KB) - added by mukesh27 8 months ago.
transparent checkbox option

Download all attachments as: .zip

Change History (3)

8 months ago

transparent checkbox option

This ticket was mentioned in Slack in #core-customize by celloexpressions. View the logs.

8 months ago

#2 @celloexpressions
8 months ago

  • Focuses ui added; administration performance removed
  • Keywords 2nd-opinion added
  • Type changed from feature request to enhancement
  • Version changed from 4.6.1 to 3.5

This was discussed at some length when the color picker was introduced in #21206. I generally still agree with the reasoning there that allowing transparency generally results in a bad experience for end users. A transparent checkbox has been agreed as not a great solution in particular.

RGBA might be an interesting option, and could be a parameter on the color control class so that it's only enabled when a particular feature calls for it. However, it introduces challenges for saving the associated setting and would require new sanitization functions, etc. A similar effect can be achieved by adding a color control followed by a generic control with 'type' => 'range' and building the CSS back out of the two settings on the output side. I don't think core should add the complexity of rgba support to the core control, but does anyone else have opinions here?

Note: See TracTickets for help on using tickets.