WordPress.org

Make WordPress Core

Opened 22 months ago

Last modified 22 months ago

#24528 new defect (bug)

Customizer checkbox with refresh option gives inconsistent values

Reported by: nathanrowe82 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.5
Component: Customize Keywords:
Focuses: Cc:

Description

When adding a checkbox control to the customizer feature with type = refresh, the value returned is sometimes a string and sometimes a boolean, when the checkbox is changed.

I've tested this in 3.5, and 3.6-beta3-24407.

How to reproduce in 3.5:

Load the "Twenty Twelve" theme. In the functions file add a test checkbox setting & control:

$wp_customize->add_setting('test', array(
    'type' => 'option',
    'default' => true,
    'priority' => 10,
    'transport' => 'refresh'
  ));

  $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'test', array(
    'label' => __( 'Test' ),
    'section' => 'title_tagline',
    'settings' => 'test',
    'type' => 'checkbox'
  )));

Dump the value into the index.php of the theme:

<?php var_dump(get_option('test')); ?>

This is where things get odd:

Load up the customizer,
- Theme should output: bool(true)

Toggle the checkbox, allowing for the iframe to refresh each time:
All results should be boolean values.

Toggle to checkbox to ON, hit save, and refresh the browser window.
- Theme should output: string(1) "1"

Toggle the checkbox to OFF, allowing for the iframe to refresh:
Value does not update

Toggle the checkbox some more, allowing for the iframe to refresh each time:
Results will toggle between string(1) "1" and boolean(true)

ONE LAST TEST:
Toggle to checkbox to OFF, hit save, and refresh the browser window.
- Theme should output: string(0) ""

Toggle the checkbox some more, allowing for the iframe to refresh each time:
Results will toggle between string(0) "" and boolean(true)

Thanks

Change History (1)

comment:1 @SergeyBiryukov22 months ago

  • Component changed from General to Appearance

Might be related to #20712.

Note: See TracTickets for help on using tickets.