[wp-trac] [WordPress Trac] #28790: Apply widget_update_callback filter, before update() is called on a widget instance.
WordPress Trac
noreply at wordpress.org
Tue Jul 8 10:07:45 UTC 2014
#28790: Apply widget_update_callback filter, before update() is called on a widget
instance.
--------------------------+-----------------------------
Reporter: jayarjo | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Widgets | Version: 3.9.1
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
form_callback() in WP_Widget applies filter before it invokes form()
method. Among other things this gives developer an opportunity to do some
manipulations on the output:
{{{
$instance = apply_filters( 'widget_form_callback', $instance,
$this );
$return = null;
if ( false !== $instance ) {
$return = $this->form($instance);
}}}
display_callback() has it right as well. But for the update_callback() the
same is not true:
{{{
$instance = $this->update( $new_instance, $old_instance );
if ( $this->is_preview() ) {
wp_suspend_cache_addition( $was_cache_addition_suspended
);
}
$instance = apply_filters( 'widget_update_callback', $instance,
$new_instance, $old_instance, $this );
}}}
So basically there's no way to manipulate the instance, before it gets
itself into the update() method. Could we do it opposite instead?
{{{
$instance = apply_filters( 'widget_update_callback', $instance,
$new_instance, $old_instance, $this );
$instance = $this->update( $new_instance, $old_instance );
if ( $this->is_preview() ) {
wp_suspend_cache_addition( $was_cache_addition_suspended
);
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/28790>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list