Skip to content

Instantly share code, notes, and snippets.

@deckerweb
Created September 11, 2019 06:48
Show Gist options
  • Save deckerweb/11878962da6f4e31877520e199254cef to your computer and use it in GitHub Desktop.
Save deckerweb/11878962da6f4e31877520e199254cef to your computer and use it in GitHub Desktop.
For Elementor Page Builder Plugin: Remove the regular WordPress Widgets from the left-hand Panel in the Live Editor. --- CAUTION: Use at your own risk! No support here!!!
<?php
/** Do NOT include the opening php tag */
if ( ! function_exists( 'ddw_tweak_elementor_remove_wp_widgets' ) ) :
add_filter( 'elementor/widgets/black_list', 'ddw_tweak_elementor_remove_wp_widgets' );
/**
* Optionally remove all WordPress widgets from the Elementor Live Editor.
* Note: A native Elementor filter is used.
*
* @link https://gist.github.com/deckerweb/11878962da6f4e31877520e199254cef
* @author David Decker - DECKERWEB
*
* @global array $GLOBALS[ 'wp_widget_factory' ]
*
* @param array $black_list Array holding all blacklisted WordPress widgets.
* @return array Tweaked array of black listed WordPress widgets.
*/
function ddw_tweak_elementor_remove_wp_widgets( $black_list ) {
/** Bail early if Elementor not active or tweak not wanted */
if ( ! defined( 'ELEMENTOR_VERSION' ) ) {
return $black_list;
}
/**
* Get all registered WordPress widgets, but only the classes
* (= the first-level array keys)
*/
$black_list = array_keys( $GLOBALS[ 'wp_widget_factory' ]->widgets );
/** Return black list array for filter */
return (array) $black_list;
} // end function
endif;
@pako69
Copy link

pako69 commented Feb 22, 2020

I did it, sorry:

add_action('elementor/widgets/widgets_registered', function( $widget_manager ){
	// FREE
	$widget_manager->unregister_widget_type('read-more');
	$widget_manager->unregister_widget_type('sidebar');
	$widget_manager->unregister_widget_type('audio');
	
	// PRO
	$widget_manager->unregister_widget_type('form');
	$widget_manager->unregister_widget_type('nav-menu');

}, 15);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment