I’m having problems adding “transport” capabilities for existing settings using the customize API. I can add and delete settings without issue, but adding transport to current ones doesn’t seem to take. The js is loaded without issue, but the “refresh” method is still utilized.
Are you able to add “postMessage Transport” within a plugin? These calls within a theme worked fine.
function __construct() {
add_action( 'customize_register', array( $this, 'base_customize_register' ) );
add_action( 'customize_preview_init', array( $this, 'base_customize_preview_js' ) );
}
function base_customize_register( $wp_customize ) {
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
$wp_customize->remove_section( 'static_front_page');
}
function base_customize_preview_js() {
wp_enqueue_script( 'base_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20131008', true );
}
Looks like it is a timing issue. Unfortunately, the sections don’t yet exist in the chain, so manipulating them does not have the desired effect. I ended up having to keep the logic which handles default settings in the theme.
I also had the same exact problem. I solved this by using priority argument on add_action function.
Hope this helps for someone 🙂