Hooks for the widgets api. Props ptahdunbar. fixes #12546

git-svn-id: https://develop.svn.wordpress.org/trunk@14382 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2010-05-03 19:01:43 +00:00
parent 9eabb51000
commit 1796f678ff

View File

@ -558,7 +558,9 @@ function register_sidebar($args = array()) {
$wp_registered_sidebars[$sidebar['id']] = $sidebar;
add_theme_support('widgets');
do_action( 'register_sidebar', $sidebar );
return $sidebar['id'];
}
@ -629,8 +631,10 @@ function wp_register_sidebar_widget($id, $name, $output_callback, $options = arr
);
$widget = array_merge($widget, $options);
if ( is_callable($output_callback) && ( !isset($wp_registered_widgets[$id]) || did_action( 'widgets_init' ) ) )
if ( is_callable($output_callback) && ( !isset($wp_registered_widgets[$id]) || did_action( 'widgets_init' ) ) ) {
do_action( 'wp_register_sidebar_widget', $widget );
$wp_registered_widgets[$id] = $widget;
}
}
/**
@ -685,6 +689,8 @@ function wp_sidebar_description( $id ) {
* @param int|string $id Widget ID.
*/
function wp_unregister_sidebar_widget($id) {
do_action( 'wp_unregister_sidebar_widget', $id );
wp_register_sidebar_widget($id, '', '');
wp_unregister_widget_control($id);
}
@ -878,6 +884,8 @@ function dynamic_sidebar($index = 1) {
$params = apply_filters( 'dynamic_sidebar_params', $params );
$callback = $wp_registered_widgets[$id]['callback'];
do_action( 'dynamic_sidebar', $wp_registered_widgets[$id] );
if ( is_callable($callback) ) {
call_user_func_array($callback, $params);
@ -1193,6 +1201,8 @@ function the_widget($widget, $instance = array(), $args = array()) {
$args = wp_parse_args($args, $default_args);
$instance = wp_parse_args($instance);
do_action( 'the_widget', $widget, $instance, $args );
$widget_obj->_set(-1);
$widget_obj->widget($args, $instance);
}