_register_widget_update_callback

Registers the update callback for a widget.

Description

_register_widget_update_callback( (string) $id_base, (callable) $update_callback, (array) $options = array() ); 

Parameters (3)

0. $id_base (string)
The base ID of a widget created by extending WP_Widget.
1. $update_callback (callable)
Update callback method for the widget.
2. $options — Optional. (array) => array()
Widget control options. See wp_register_widget_control(). Default empty array.

Usage

  1. if ( !function_exists( '_register_widget_update_callback' ) ) { 
  2. require_once ABSPATH . WPINC . '/widgets.php'; 
  3.  
  4. // The base ID of a widget created by extending WP_Widget. 
  5. $id_base = ''; 
  6.  
  7. // Update callback method for the widget. 
  8. $update_callback = null; 
  9.  
  10. // Optional. Widget control options. See wp_register_widget_control(). 
  11. // Default empty array. 
  12. $options = array(); 
  13.  
  14. // NOTICE! Understand what this does before running. 
  15. $result = _register_widget_update_callback($id_base, $update_callback, $options); 
  16.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/widgets.php  
  1. function _register_widget_update_callback( $id_base, $update_callback, $options = array() ) { 
  2. global $wp_registered_widget_updates; 
  3.  
  4. if ( isset($wp_registered_widget_updates[$id_base]) ) { 
  5. if ( empty($update_callback) ) 
  6. unset($wp_registered_widget_updates[$id_base]); 
  7. return; 
  8.  
  9. $widget = array( 
  10. 'callback' => $update_callback,  
  11. 'params' => array_slice(func_get_args(), 3) 
  12. ); 
  13.  
  14. $widget = array_merge($widget, $options); 
  15. $wp_registered_widget_updates[$id_base] = $widget;