[wp-trac] [WordPress Trac] #39487: Default to 'transport'=>'postMessage' for a setting associated with a selective refresh partial
WordPress Trac
noreply at wordpress.org
Fri Nov 13 05:32:14 UTC 2020
#39487: Default to 'transport'=>'postMessage' for a setting associated with a
selective refresh partial
--------------------------------------+-----------------------------
Reporter: danielbachhuber | Owner: noisysocks
Type: defect (bug) | Status: reviewing
Priority: normal | Milestone: Future Release
Component: Customize | Version: 4.5
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests | Focuses:
--------------------------------------+-----------------------------
Changes (by noisysocks):
* keywords: has-patch needs-testing has-unit-tests => has-patch has-unit-
tests
* owner: (none) => noisysocks
* status: new => reviewing
Comment:
I tested [attachment:"39487.2.diff"] locally and it works great! 👍
There are two lint errors in `class-wp-customize-selective-refresh.php`.
We need to use `array()` instead of `[]`.
Not a blocking comment at all, but I'm a little worried that changing
`$setting->transport` in `customize_preview_init` creates a weird
situation where the `WP_Customize_Setting` objects that a plugin or theme
sets up in `customize_register` isn't representative of what ends up being
"executed".
For example, the `var_dump()` here still outputs `"refresh"`:
{{{
function foo_theme_customize_register( WP_Customize_Manager $wp_customize
) {
$wp_customize->add_setting(
'mydate',
array(
'type' => 'theme_mod',
'transport' => 'refresh',
)
);
$wp_customize->add_control(
'mydate',
array(
'type' => 'date',
'section' => 'colors',
'label' => __( 'Date' ),
'description' => __( 'This is a date control with
a red border.' ),
'input_attrs' => array(
'placeholder' => __( 'mm/dd/yyyy' ),
),
)
);
$wp_customize->selective_refresh->add_partial(
'mydate',
array(
'selector' => '.my-date',
'container_inclusive' => false,
'render_callback' => function() {
echo 'Date: ' . get_theme_mod( 'mydate' );
},
)
);
var_dump( $wp_customize->get_setting( 'mydate' )->transport );
}
add_action( 'customize_register', 'foo_theme_customize_register' );
}}}
What do you think about overwriting `$setting->transport` in
`WP_Customize_Selective_Refresh::add_partial()` instead? This way
developers might immediately see that their setting is changed with normal
debugging techniques.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39487#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list