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

git-svn-id: http://svn.automattic.com/wordpress/trunk@14382 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2010-05-03 19:01:43 +00:00
parent b63ee5748a
commit 18513489e2

View File

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