Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#22177 closed defect (bug) (invalid)

Adding theme customizer checkbox

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

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
12 years ago

  • Component changed from Themes to Appearance

#2 @dgwyer
12 years ago

  • Cc d.v.gwyer@… added

#3 @TobiasBg
12 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
12 years ago

  • Keywords close added; reporter-feedback removed
  • Resolution set to invalid
  • Status changed from new to closed

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

#5 @SergeyBiryukov
12 years ago

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