Forked from obiPlabon/elementor-disable-all-wp-widgets.php
Created
December 12, 2020 18:24
-
-
Save hasinhayder/ce57b1404b82c0fa42203a28de2ed17f to your computer and use it in GitHub Desktop.
Disable or remove elementor widget from editor panel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Disable elementor registered widget. | |
* | |
* This will disable all WordPress native widgets | |
* | |
* @param \Elementor\Widgets_Manager $widgets_manager Instance of elementor widgets manager | |
* | |
* @author obiPlabon <https://obiPlabon.im> | |
* | |
* @return void | |
*/ | |
add_action( 'elementor/widgets/widgets_registered', function ( $widgets_manager ) { | |
$wp_widgets = [ | |
'wp-widget-pages', | |
'wp-widget-calendar', | |
'wp-widget-archives', | |
'wp-widget-media_audio', | |
'wp-widget-media_image', | |
'wp-widget-media_gallery', | |
'wp-widget-media_video', | |
'wp-widget-meta', | |
'wp-widget-search', | |
'wp-widget-text', | |
'wp-widget-categories', | |
'wp-widget-recent-posts', | |
'wp-widget-recent-comments', | |
'wp-widget-rss', | |
'wp-widget-tag_cloud', | |
'wp-widget-nav_menu', | |
'wp-widget-custom_html', | |
]; | |
foreach ( $wp_widgets as $widget ) { | |
$widgets_manager->unregister_widget_type( $widget ); | |
} | |
} ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Disable elementor registered widget. | |
* | |
* This will remove elemtor widget from the editor panel | |
* as well as the the widget instance will get removed. | |
* And following this method you can disable any elementor widget | |
* including elementor and elementor pro widgets. | |
* | |
* @param \Elementor\Widgets_Manager $widgets_manager Instance of elementor widgets manager | |
* | |
* @author obiPlabon <https://obiPlabon.im> | |
* | |
* @return void | |
*/ | |
add_action( 'elementor/widgets/widgets_registered', function ( $widgets_manager ) { | |
// $widget_name_goes_here could be 'heading', 'text-widget', 'wp-widget-pages' | |
$widgets_manager->unregister_widget_type( $widget_name_goes_here ); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment