This hook is called once for each widget that is registered. A widget is generally registered using the register_widget() function, defined in wp-includes/widget.php.
<?php add_action( 'wp_register_sidebar_widget', 'my_function' ); function my_function( $widget ){ // do something with $widget } ?>
[name] => Pages [id] => pages-1 [callback] => Array ( [0] => WP_Widget_Pages Object ( [id_base] => pages [name] => Pages [widget_options] => Array ( [classname] => widget_pages [description] => Your site’s WordPress Pages ) [control_options] => Array ( [id_base] => pages ) [number] => 1 [id] => pages-1 [updated] => [option_name] => widget_pages ) [1] => display_callback ) [params] => Array ( [0] => Array ( [number] => -1 ) ) [classname] => widget_pages [description] => Your site’s WordPress Pages
<?php add_action( 'wp_register_sidebar_widget', 'my_function' ); function my_function( $widget ){ // In this case we only want to do something with the default 'Pages' widget if ( 'Pages' === $widget['name'] ){ // Found the widget we wanted... do something really cool here. } } ?>
wp_register_sidebar_widget is located in wp-includes/widgets.php
.