mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 17:18:32 +01:00
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:
parent
b63ee5748a
commit
18513489e2
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user