Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#22177 closed defect (bug) (invalid)

Adding theme customizer checkbox

Reported by: dgwyer Owned by:
Priority: normal Milestone:
Component: Customize Version: 3.4.2
Severity: major Keywords:
Cc: Focuses:

Description

I have an issue when adding a simple checkbox to the theme customizer from one of my themes. I then tried to do the same in Twenty Eleven but had the same result.

I think there 'may' be a conflict with the 'Display Header Text' checkbox which is added to the customizer from WordPress core. Reason is because this checkbox disappears when I try adding a checkbox of my own.

Code I added to Twenty Eleven is as follows:

function theme_customizer_register_tagline_checkbox($wp_customize) {

	$wp_customize->add_section( 'my_tagline_section', array(
		'title'          => 'My Tagline Section',
	) );

	$wp_customize->add_setting( 'test_checkbox_setting_1624', array(
		'default'        => null,
		'type'           => 'option',
		'capability'     => 'edit_theme_options' )
	);

	$wp_customize->add_control( 'display_header_text', array(
		'settings' => 'test_checkbox_setting_1624',
		'label'    => 'Customizer checkbox',
		'section'  => 'my_tagline_section',
		'type'     => 'checkbox',
	) );
}
add_action( 'customize_register', 'theme_customizer_register_tagline_checkbox' );

Change History (5)

#1 @SergeyBiryukov
14 years ago

  • Component Themes → Appearance

#2 @dgwyer
14 years ago

  • Cc d.v.gwyer@… added

#3 @TobiasBg
14 years ago

  • Keywords reporter-feedback added

In the line

$wp_customize->add_control( 'display_header_text', array(

you seem to be using an existing ID. You should probably use someting unique and new here, that identifies your checkbox.
What happens when you change that parameter to something else?

#4 @dgwyer
14 years ago

  • Keywords close added; reporter-feedback removed
  • Resolution → invalid
  • Status new → closed

That fixed it. Duplicate ID causes the conflict. Thanks.

#5 @SergeyBiryukov
14 years ago

  • Keywords close removed
  • Milestone Awaiting Review
Note: See TracTickets for help on using tickets.