Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Filters a widget's settings before saving.
- *
- * Returning false will effectively short-circuit the widget's ability
- * to update settings.
- *
- * @since 2.8.0
- *
- * @param array $instance The current widget instance's settings.
- * @param array $new_instance Array of new widget settings.
- * @param array $old_instance Array of old widget settings.
- * @param WP_Widget $this The current widget instance.
- */
- $instance = apply_filters(
- 'widget_update_callback',
- $instance,
- $new_instance,
- $old_instance,
- $this
- );
- add_filter( 'widget_update_callback', function( $instance, $new, $old, $obj )
- {
- if( 'text' === $obj->id_base && ! empty( $instance['text'] ) )
- {
- // Warning this overrides the widget instance text input:
- // $instance['text'] = 'override text';
- }
- return $instance;
- }, 10, 4 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement