[wp-trac] [WordPress Trac] #35855: Let selective refresh component be required but be opt-in for sidebars/widgets (for now)
WordPress Trac
noreply at wordpress.org
Thu Feb 25 20:27:28 UTC 2016
#35855: Let selective refresh component be required but be opt-in for
sidebars/widgets (for now)
----------------------------+--------------------------
Reporter: DrewAPicture | Owner: westonruter
Type: task (blessed) | Status: accepted
Priority: normal | Milestone: 4.5
Component: Customize | Version: trunk
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
----------------------------+--------------------------
Changes (by westonruter):
* keywords: needs-patch => has-patch
Comment:
@DrewAPicture take a look at [attachment:35855.0.diff] to see what I have
in mind.
Themes add support for selective refresh of sidebars via:
{{{#!php
<?php
add_theme_support( 'customize-selective-refresh-widgets' );
}}}
Then individual widgets opt-in for selective refresh via a new
`customize_selective_refresh` widget option:
{{{#!php
<?php
class Foo_Widget extends WP_Widget {
/* ... */
public function __construct() {
$widget_ops = array(
'classname' => 'widget_foo',
'description' => __( 'So much foo[d].' ),
'customize_selective_refresh' => true,
);
parent::__construct( 'calendar', __( 'Foo[d]' ),
$widget_ops );
}
}}}
Alternatively, a plugin can opt-in a theme and widget for selective
refresh via:
{{{#!php
<?php
add_theme_support( 'customize-selective-refresh-widgets', 'foo' );
}}}
The second argument is the widget `id_base` that support is being added
for.
Thoughts?
Twenty Sixteen support via PR:
https://github.com/WordPress/twentysixteen/pull/430
I didn't yet add support for `Twenty_Eleven_Ephemera_Widget` or
`Twenty_Fourteen_Ephemera_Widget`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35855#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list