I'm trying to figure out how to remove wordpress widgets added by plugins. I know there are a couple of plugins that do this, like https://wordpress.org/plugins/wp-remove-widgets/ and https://wordpress.org/plugins/post-lists-view-custom/, however I'd rather not use a seperate plugin for something that seems like such a small task.
Specifically, I'm trying to unregister the wordpress engine powered by widget that http://wpengine.com/ loads on the widgets page. I searched the source code and found the id of the widget is wpe_widget_powered_by
However, this does not work...
function my_widgets_init() {
unregister_widget( 'wpe_widget_powered_by' );
}
add_action('widgets_init', 'my_widgets_init');
So far the only thing I've been able to do effectively is use a combination of css/js to hide then remove the widget. I use css to hide it on page load and then remove it with jquery so there's not a blank gap where the widget is suppose to go.
function remove_wpe_powered_by_widget() {
?>
<style type="text/css">
[id*="wpe_widget_powered_by"] {
display: none;
}
</style>
<script type="text/javascript">
jQuery(document).ready(function($) {
$("div[id$='wpe_widget_powered_by']").remove();
});
</script>
<?php
}
add_action( 'admin_head', 'remove_wpe_powered_by_widget' );
While the above works, I know it's not the correct way to do things and I'm wondering why the first function doesn't work. The codex says to do the following.
<?php unregister_widget( $widget_class ) ?>
Maybe I'm not understanding what exactly $widget_class is. Is there a way to find the widget class without searching through the plugins code? Or do I already have the correct class and it's not working for another reason (perhaps a late hook or something).
I looked all through stackexchange and the internet and could only find ways to remove default widgets, but no one tells you how to remove widgets added by plugins. Sorry if I'm missing something and this is an obvious question.