Add or remove HTML class with selective refresh?

Yes. This can be accomplished by creating a custom selective refresh Partial type, and overriding the refresh method in the JavaScript class. Here’s the relevant JavaScript which should get enqueued in the Customizer preview, with customize-selective-refresh as its script dependency: wp.customize.selectiveRefresh.partialConstructor.body_class = wp.customize.selectiveRefresh.Partial.extend({ /** * Class name choices. * * This is populated in PHP … Read more

Customizer JS API: Defining control settings

Settings must be registered in PHP one way or another. If you don’t register them statically via $wp_customize->add_setting() calls, you will have to register dynamic recognition of them via the customize_dynamic_setting_args filter. Why? In order for a setting to be safely stored it must be sanitized and validated by the server. Relying on client-side sanitization … Read more

How to get control choices from $setting object passed to sanitize_callback

This is correct: $control = $setting->manager->get_control($setting->id); $choices = $control->choices; However, in your example, $setting->id will be theme_oenology_options[name]. So, get_control(‘theme_oenology_options[name]’) will return null because there’s no control with that name. You gave the control the id of oenology_name instead. I always give the same ID to settings and their matching controls for that reason.

Is it possible to conditionally displaying and hiding of customizer controls for each device preview?

I’m not familiar working with Kikri, but I’ve made a standalone example plugin that shows the approach I’d use to get controls to be contextual based on the previewed device. The plugin adds colored outlines around each element in the site, with a different color for elements in desktop, tablet, and mobile (obviously just for … Read more

Customiser `active_callback` not working on control with `postMessage` transport method

Because postMessage uses JavaScript entirely, any PHP active_callback will not get called unless the preview refreshes (e.g. via wp.customize.previewer.refresh()). So what you need to do is implement the active callback in JavaScript instead, like so: wp.customize.bind( ‘ready’, function () { wp.customize.control( ‘archive_show_more_link’, function( control ) { var setting = wp.customize( ‘archive_link_tile_size’ ); control.active.set( ‘large’ === … Read more

How to Save Different Settings Options Using Settings API and/or the Theme Optimizer

I did something similar as an import/export facility. Essentially I created a Theme Options Import/Export page in the dashboard, then just export the theme options (using get_option()) to a file as a JSON encoded string and post it for the user to download. Then give them an upload facility the imports said file (using update_option()). … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)