The latest Roots doesn’t have any such php file in lib and when I tried to copy the code into sidebar.php evidently that crashed the whole Wordpress theme because roots_widgets_init isn’t being used by anything.
Any tips on how to fix this mess? I checked this issue but the instructions were too vague for me to work with. I tried making a new file called widgets.php and add the following 'lib/widgets.php', to functions.php but that also crashed the theme. Help?
I don’t think that’s what’s going on. In the code you pasted, roots_widgets_initis being used with widgets_init.
What specific errors did you see? “crashed the whole Wordpress theme” doesn’t give us enough details.
In the code you pasted you’re registering a widget called Roots_Vcard_Widget. Does that exist in your code?
Adding custom widgets with Roots is no different than adding custom widgets with any other theme, or plugin, in WordPress. You don’t need to include older Roots code into a newer Roots version in order to add a custom widget. There’s lots of resources out there that show you how to create custom widgets.
The wordpress install becomes blank - as if php include() was hanging forever - and wp-admin is blank too - the only way to fix it is to ssh into the install and delete the broken wordpress theme from the command line and then the wordpress install displays: “the current theme is broken, reverting to default theme”
This isn’t related to anything in a default Roots installation. Look at error logs and double check the code that you’re trying to add.
Also, use http://codex.wordpress.org/Widgets_API and other resources for information on adding a custom widget. Like I said in my previous post, adding custom widgets with Roots is no different than adding custom widgets with any other theme, or plugin, in WordPress.
@gersande, make sure you set define('WP_DEBUG', true); in your wp-config.php file to output PHP errors instead of a white screen.
My guess is that you aren’t namespacing correctly, try using add_action('widgets_init', __NAMESPACE__ . '\\roots_widgets_init'); as your widget add_action in init.php.