I was using widget and found that it has hook widget_init.
Like below and works well.
add_action('widgets_init', create_function('', 'return register_widget("example_widget");'));
But the hook is “wp_widgets_init”, so what’s the difference here? Which is better?
Looking at the source of wp_widgets_init it looks like the wp_widgets_init initializes internal widgets first and then calls generic widgets_init. As such you’ll want to use the second one as you can relay on WP environment to be already setup.