[wp-trac] [WordPress Trac] #30988: Setting's default value doesn't apply on preview window
WordPress Trac
noreply at wordpress.org
Mon Feb 2 22:33:20 UTC 2015
#30988: Setting's default value doesn't apply on preview window
--------------------------+-----------------------------
Reporter: Aniruddh | Owner: ocean90
Type: defect (bug) | Status: reviewing
Priority: normal | Milestone: 4.1.1
Component: Customize | Version: 4.1
Severity: normal | Resolution:
Keywords: has-patch | Focuses: administration
--------------------------+-----------------------------
Comment (by ocean90):
Replying to [comment:8 Aniruddh]:
> So, I was under impression that customizer will save default values to
empty table row but instead it saved values of those settings whose
default values were changed.
I could reproduce this issue or at least a regression from 4.0.
My code:
{{{
add_action( 'customize_register', function() {
global $wp_customize;
$wp_customize->add_panel( 'foo', array(
'title' => 'Foo',
'capability' => 'edit_theme_options',
) );
$wp_customize->add_section( 'bar', array(
'title' => 'Bar',
'capability' => 'edit_theme_options',
'panel' => 'foo'
) );
$wp_customize->add_setting( 'foo_text', array(
'default' => 'Lorem',
'capability' => 'edit_posts',
'type' => 'option',
) );
$wp_customize->add_control( 'foo_text', array(
'label' => 'Foo & bar',
'section' => 'bar',
'type' => 'textarea',
) );
$wp_customize->add_setting( 'foo_color', array(
'default' => '#f00',
'capability' => 'edit_theme_options',
'type' => 'option',
) );
$wp_customize->add_control( new WP_Customize_Color_Control(
$wp_customize, 'foo_color', array(
'label' => 'Color',
'section' => 'bar',
) ) );
});
add_action( 'wp_head', function() {
var_dump( get_option( 'foo_color' ) );
var_dump( get_option( 'foo_text' ) );
});
}}}
'''4.0:'''
Front page without Customizer:
{{{
bool(false)
bool(false)
}}}
Front page in Customizer:
{{{
string(4) "#f00"
string(5) "Lorem"
}}}
Front page in Customizer, color changed:
{{{
string(7) "#6900db"
string(5) "Lorem"
}}}
Changes saved, and front page without Customizer:
{{{
string(7) "#6900db"
string(5) "Lorem" ) // Default value is stored
}}}
'''Trunk with patch applied:'''
Front page without Customizer:
{{{
bool(false)
bool(false)
}}}
Front page in Customizer:
{{{
string(4) "#f00"
string(5) "Lorem"
}}}
Front page in Customizer, color changed:
{{{
string(7) "#6900db"
string(5) "Lorem"
}}}
Changes saved, and front page without Customizer:
{{{
string(7) "#6900db"
bool(false) // Default value isn't stored
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/30988#comment:19>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list