[*]
The problem with the code sample is that the setting is using widget_
as the prefix. This is a reserved prefix for widgets, per the customizer handbook:
Important: Do not use a setting ID that looks like
widget_*
,sidebars_widgets[*]
,nav_menu[*]
, ornav_menu_item[*]
. These setting ID patterns are reserved for widget instances, sidebars, nav menus, and nav menu items respectively. If you need to use “widget” in your setting ID, use it as a suffix instead of a prefix, for example “homepage_widget
”.
Here is the modified code which works as expected:
<?php
namespace Roots\Sage\Customizer;
use Roots\Sage\Assets;
/**
* Add customization settings for the theme
*/
function customize_register($wp_customize) {
//////////////////////////
// WIDGET STYLE OPTIONS //
//////////////////////////
$wp_customize->add_section( 'style_section_widget', array(
'title' => __('Widget Styling', __NAMESPACE__),
'priority' => 115,
));
$wp_customize->add_setting( 'list_style_widget', array(
'default' => 'hide',
'transport' => 'postMessage',
));
$wp_customize->add_control( 'widget_list_style_control', array(
'label' => __( 'Display List Style?', __NAMESPACE__),
'Description' => __('Removes the symbols next to bulleted and unbulleted lists in Widgets', __NAMESPACE__),
'section' => 'style_section_widget',
'settings' => 'list_style_widget',
'type' => 'radio',
'choices' => array(
'hide' => __('Hide'),
'show' => __('Show'),
),
));
// Add postMessage support
$wp_customize->get_setting('blogname')->transport="postMessage";
$wp_customize->get_setting('blogdescription')->transport="postMessage";
}
add_action('customize_register', __NAMESPACE__ . '\\customize_register', 11);
Note also that I changed the priority for customize_register
from 10 (the default) to 11 since the blogname
and blogdescription
settings may not be registered at that point.
[*]