Default Customizer settings

Why does the customizer.js and the admin.php both listen for changes in .brand?

I’m not sure if this is some kind of best practice, example code or does this serves some kind of other purpose.

wp.customize('blogname', (value) => {
    value.bind(to => $('.brand').text(to));


add_action('customize_register', function (\WP_Customize_Manager $wp_customize) {
    // Add postMessage support
    $wp_customize->get_setting('blogname')->transport = 'postMessage';
    $wp_customize->selective_refresh->add_partial('blogname', [
        'selector' => '.brand',
        'render_callback' => function () {


On a less related note, why doesn’t this code use @if?

if (post_password_required()) {

It’s an example. Open up the customizer and change the name of your site — then watch how it’s updated immediately without a refresh.

It was probably missed. Easy PR if anyone wants to make a contribution :smiley:

1 Like

Thanks, I was beginning to wonder if I should make JS redundancies for my PHP code :wink:

1 Like

This topic was automatically closed after 42 days. New replies are no longer allowed.