Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save raazon/09224035b950c0a0b8cf2433b9ceb74b to your computer and use it in GitHub Desktop.
Save raazon/09224035b950c0a0b8cf2433b9ceb74b to your computer and use it in GitHub Desktop.
Disable or remove elementor widget from editor panel
<?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 );
}
} );
<?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