Created
September 11, 2019 06:48
-
-
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!!!
This file contains 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 | |
/** 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; |
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
Hi and thanks for this :)
Do you have any idea to remove chosen widgets that comes from the Pro version as well?
They are listed in this file (comming from the pro version):