Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. /**
  2. * Filters a widget's settings before saving.
  3. *
  4. * Returning false will effectively short-circuit the widget's ability
  5. * to update settings.
  6. *
  7. * @since 2.8.0
  8. *
  9. * @param array $instance The current widget instance's settings.
  10. * @param array $new_instance Array of new widget settings.
  11. * @param array $old_instance Array of old widget settings.
  12. * @param WP_Widget $this The current widget instance.
  13. */
  14. $instance = apply_filters(
  15. 'widget_update_callback',
  16. $instance,
  17. $new_instance,
  18. $old_instance,
  19. $this
  20. );
  21.  
  22. add_filter( 'widget_update_callback', function( $instance, $new, $old, $obj )
  23. {
  24. if( 'text' === $obj->id_base && ! empty( $instance['text'] ) )
  25. {
  26. // Warning this overrides the widget instance text input:
  27. // $instance['text'] = 'override text';
  28. }
  29.  
  30. return $instance;
  31. }, 10, 4 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement