Hello fellow Stackoverflowers, I’m having a problem with WordPress.
I have added a custom section to an existing theme so that it shows up in the theme customization page (customize.php). The problem I am having is that I don’t know how to notify wordpress when changes are made in my custom control, In other words when I change the order of the items in my sortable list I want the save button to be enabled (as for now it stays disabled). I guess I am missing something in my code because it should do it in automatic? I read the official documentation but still I don’t understand how to ‘link’ my custom control (which has some javascript behind but in the end just a list)
Here is some sample code:
$wp_customize->add_section('my_section',
array(
'title' => 'My title',
'description' => 'My description',
'priority' => 201
)
);
$wp_customize->add_setting(
'my_setting',
array(
'default' => '',
'type' => 'option',
'transport' => 'postMessage'
)
);
$wp_customize->add_control(
new My_Control(
$wp_customize,
'my_control',
array(
'label' => 'My label',
'settings' => 'my_setting',
'section' => 'my_section'
)
)
);
Note that My_Control
is a class which enqueues additional JS/CSS files and renders my sortable list (extends from WP_Customize_Control
). I am storing my model in an array rather than using multiple settings; I add my model to the page using the wp_localize_script
function.
Did you try this?