WordPress 4.5 includes a new Customizer framework called selective refresh. To recap, selective refresh is a hybrid preview mechanism that has the performance benefit of not having to refresh the entire preview window. This was previously available with JS-applied postMessage previews, but selective refresh also improves the accuracy of the previewed change while reducing the amount of code you have to write; it also just makes possible to do performant previews that would previously been practically impossible. For example, themes often include some variation of the following PHP and JavaScript to enable performant previewing of changes to the site title: function mytheme_customize_register( WP_Customize_Manager $wp_customize ) { $wp_customize->get_option( 'blogname' )->transport = 'postMessage'; } add_action( 'customize_register', 'mytheme_customize_register' ); function mytheme_customize_preview_js() { $handle = 'mytheme-customize-preview'; $src = get_template_directory_uri() . '/js/customize-preview.js'; $deps = array( 'customize-preview' ); $ver = '0.1'; $in_footer = true; wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ); } add_action( 'customize_preview_init',
Share This