Tribe__Customizer::maybe_selective_refresh()
Using the Previously created CSS element, we not just re-create it every setting change
Return
(void)
Source
File: src/Tribe/Customizer.php
public function maybe_selective_refresh() {
// Only try to apply selective refresh if it's active
if ( ! isset( $this->manager->selective_refresh ) ) {
return;
}
foreach ( $this->settings as $name ) {
$setting = $this->manager->get_setting( $name );
// Skip if we don't have that setting then skip it
if ( is_null( $setting ) ) {
continue;
}
// Skip if we already have that
if ( ! is_null( $this->manager->selective_refresh->get_partial( $name ) ) ) {
continue;
}
// Remove the Setting
// We need this because settings are protected on the WP_Customize_Manager
$this->manager->remove_setting( $name );
// Change the Transport
$setting->transport = 'postMessage';
// Re-add the setting
// We need this because settings are protected on the WP_Customize_Manager
$this->manager->add_setting( $setting );
// Add the Partial
$this->manager->selective_refresh->add_partial(
$name,
array(
'selector' => '#' . esc_attr( $this->ID . '_css' ),
'render_callback' => array( $this, 'print_css_template' ),
)
);
}
}
Changelog
| Version | Description |
|---|---|
| 4.2 | Introduced. |