_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
if ( !function_exists( '_register_widget_update_callback' ) ) { require_once ABSPATH . WPINC . '/widgets.php'; } // The base ID of a widget created by extending WP_Widget. $id_base = ''; // Update callback method for the widget. $update_callback = null; // Optional. Widget control options. See wp_register_widget_control(). // Default empty array. $options = array(); // NOTICE! Understand what this does before running. $result = _register_widget_update_callback($id_base, $update_callback, $options);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/widgets.php
- function _register_widget_update_callback( $id_base, $update_callback, $options = array() ) {
- global $wp_registered_widget_updates;
- if ( isset($wp_registered_widget_updates[$id_base]) ) {
- if ( empty($update_callback) )
- unset($wp_registered_widget_updates[$id_base]);
- return;
- }
- $widget = array(
- 'callback' => $update_callback,
- 'params' => array_slice(func_get_args(), 3)
- );
- $widget = array_merge($widget, $options);
- $wp_registered_widget_updates[$id_base] = $widget;
- }