This is not an alteration to the Plugin itself, it's just a way to revert what is already done. So, to Activate a plugin there's a WordPress function:
register_widget('Class_of_the_Widget');
As we can unregister the default plugins using the unregister_widget()
function, we can use the same function for JetPack plugin's widgets too.
Get into the /wp-content/plugins/jetpack/modules/widgets
, you will get most of the Jetpack plugins are registered from there, and fortunately they are sorted with their name (as of Version 2.9.3). Suppose, facebook-likebox.php
file contains the widget information of the 'Jetpack Facebook Like Box' widget.
So, the rest is the same as the default widget-hiding, call the same thing:
// unregister jetpack widgets
function wpse140512_unregister_jetpack_widgets() {
//hide from the 'Editor' only
if ( is_admin() && current_user_can('editor') ) {
unregister_widget('WPCOM_Widget_Facebook_LikeBox'); //Facebook Likebox
unregister_widget('Jetpack_Gravatar_Profile_Widget'); //Gravatar Profile
}
}
add_action('widgets_init', 'wpse140512_unregister_jetpack_widgets', 11);
...and so on. But how could I get those 'Widget Classes'?
Open all those widget files and get the name from the register_widget()
function. As the widget is registered with a Class, you can unregister them with the same Class.
The better way to find them all in an instance is to use a Smart Text Editor's Find in Folder/Files feature. Suppose:
- In Sublime Text: Use the Menu bar's Find » Find in Files... (Ctrl+Shift+F), then find
register_widget
and browse the jetpack
folder under /plugins
in your /wp-content
, and then find them all at once.
But...
This process is worthy for almost all the cases, but some widgets are not registered using the register_widget()
function, in that case, such widgets are registered using the wp_register_sidebar_widget()
function. For those, you have to unregister them using the wp_unregister_sidebar_widget()
function, but this time you have pass the Widget ID inside the function rather than the Widget Class.
So, let's travel! :)