How do I completely remove widget support from a theme/plugin ?
Like removing the appearance -> widgets page, and prevent WP from loading widget classes and all widget-related stuff.
4 Answers
One option would be to simply flush the widget code out of the sidebar.php file, as well as the header/footer/post pages if they are using widgets.
However, take a peek at this code snippet (courtesy of this site), which you can add to your functions.php file and will disable the widgets. I think this would be a cleaner approach if you’re looking to change themes and sill have widgets disabled.
<?php
add_filter( ‘sidebars_widgets’, ‘disable_all_widgets’ );
function disable_all_widgets( $sidebars_widgets )
{
if ( is_home() ) $sidebars_widgets = array( false );
return $sidebars_widgets;
}
?>
Note that this will only disable the widgets on your home page, so you’ll need to find the additional conditionals for individual pages/posts/etc.