elementor / elementor

The most advanced frontend drag & drop page builder. Create high-end, pixel perfect websites at record speeds. Any theme, any page, any design.
https://elementor.com/
GNU General Public License v3.0
6.6k stars 1.42k forks source link

How to hide some Elementor Pro widgets from the frontend editor? #3136

Closed stratboy closed 6 years ago

stratboy commented 6 years ago

Hi, I would like to clean up the editor since most of the time we use just the 10% of all widgets.

I learned how to unregister default Elementor widgets with $widgets_manager->unregister_widget_type, but it seems it doesn't work for Elementor Pro widgets: they seem to be 'modules' rather than 'widgets'.

How to?

stratboy commented 6 years ago

By the way, it should be somewhat easier to hide widgets. Maybe a checkbox list in preferences? Or simply make the widgets lists collapsable (and saving layout prefs)?

bainternet commented 6 years ago

You can use $widgets_manager->unregister_widget_type to remove any Elementor, Elementor Pro or any other 3rd party plugin widgets that are registered (assuming its done correctly), you simply need to make sure are already registered before you remove them.

The Pro widgets are registered on default priority which is 10 so you just make sure you run your hook after that for example with priority of 15:


add_action('elementor/widgets/widgets_registered', function( $widget_manager ){
    $widget_manager->unregister_widget_type('form');
}, 15);
stratboy commented 6 years ago

Ok done for pro widgets too. Still can't hide the wordpress widgets since I can't find a list of wp widgets names. How to?

norewp commented 6 years ago

@stratboy - This might help. Note however that the function removes all WP Widgets as opposed to individual.

https://github.com/norewp/unregister-elementor-widgets/blob/584252abebe56d9b45fb8bc2d46fe15945400b44/modules/unregister/module.php#L38

If you know the widget's id_base then you can simply use the same method for Elementor by simply appending the id to the name in place of the variable shown at L42

stratboy commented 6 years ago

@norewp - thank you. The following is sample code for removing everything (for now > I suppose in the future there will be some other widgets). To activate the ones needed, just comment out the corresponding array items.

global $elementor_widget_blacklist;

$elementor_widget_blacklist = [
  ,'common'
  ,'heading'
  ,'image'
  ,'text-editor'
  ,'video'
  ,'button'
  ,'divider'
  ,'spacer'
  ,'image-box'
  ,'google-maps'
  ,'icon'
  ,'icon-box'
  ,'image-gallery'
  ,'image-carousel'
  ,'icon-list'
  ,'counter'
  ,'progress'
  ,'testimonial'
  ,'tabs'
  ,'accordion'
  ,'toggle'
  ,'social-icons'
  ,'alert'
  ,'audio'
  ,'shortcode'
  ,'html'
  ,'menu-anchor'
  ,'sidebar'

  // pro ----------------- //
  ,'posts'
  ,'portfolio'
  ,'slides'
  ,'form'
  ,'login'
  ,'media-carousel'
  ,'testimonial-carousel'
  ,'nav-menu'
  ,'pricing'
  ,'facebook-comment'
  ,'nav-menu'
  ,'animated-headline'
  ,'price-list'
  ,'price-table'
  ,'facebook-button'
  ,'facebook-comments'
  ,'facebook-embed'
  ,'facebook-page'
  ,'add-to-cart'
  ,'categories'
  ,'elements'
  ,'products'
  ,'flip-box'
  ,'carousel'
  ,'countdown'
  ,'share-buttons'
  ,'author-box'
  ,'breadcrumbs'
  ,'search-form'
  ,'post-navigation'
  ,'post-comments'
  ,'theme-elements'
  ,'blockquote'
  ,'template'
  ,'wp-widget-audio'
  ,'woocommerce'
  ,'social'
  ,'library'

  // wp widgets ----------------- //
  ,'wp-widget-pages'
  ,'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'
  ,'wp-widget-polylang'
  ,'wp-widget-calendar'
  ,'wp-widget-elementor-library'
];

add_action('elementor/widgets/widgets_registered', function($widgets_manager){
  global $elementor_widget_blacklist;

  foreach($elementor_widget_blacklist as $widget_name){
    $widgets_manager->unregister_widget_type($widget_name);
  }
}, 15);
gianghl1983 commented 6 years ago

Beside clearer editor, do we have any another benifit from removing widgets? (lighter js, faster...)?

madbradj commented 5 years ago

@norewp - thank you. The following is sample code for removing everything (for now > I suppose in the future there will be some other widgets). To activate the ones needed, just comment out the corresponding array items.

Does this stop the corresponding CSS/js etc from loading?

websitehelperuk commented 4 years ago

Will this have any performance benefits? I want to remove and dequeue as much as possible.

webkonditorei commented 4 years ago

Where do I add this code?...

hamed-azimi commented 4 years ago

Where do I add this code?...

functions.php file of your theme.

Noeil182 commented 4 years ago

@norewp - thank you. The following is sample code for removing everything (for now > I suppose in the future there will be some other widgets). To activate the ones needed, just comment out the corresponding array items.

global $elementor_widget_blacklist;

$elementor_widget_blacklist = [
  ,'common'
  ,'heading'
  ,'image'
  ,'text-editor'
  ,'video'
  ,'button'
  ,'divider'
  ,'spacer'
  ,'image-box'
  ,'google-maps'
  ,'icon'
  ,'icon-box'
  ,'image-gallery'
  ,'image-carousel'
  ,'icon-list'
  ,'counter'
  ,'progress'
  ,'testimonial'
  ,'tabs'
  ,'accordion'
  ,'toggle'
  ,'social-icons'
  ,'alert'
  ,'audio'
  ,'shortcode'
  ,'html'
  ,'menu-anchor'
  ,'sidebar'

  // pro ----------------- //
  ,'posts'
  ,'portfolio'
  ,'slides'
  ,'form'
  ,'login'
  ,'media-carousel'
  ,'testimonial-carousel'
  ,'nav-menu'
  ,'pricing'
  ,'facebook-comment'
  ,'nav-menu'
  ,'animated-headline'
  ,'price-list'
  ,'price-table'
  ,'facebook-button'
  ,'facebook-comments'
  ,'facebook-embed'
  ,'facebook-page'
  ,'add-to-cart'
  ,'categories'
  ,'elements'
  ,'products'
  ,'flip-box'
  ,'carousel'
  ,'countdown'
  ,'share-buttons'
  ,'author-box'
  ,'breadcrumbs'
  ,'search-form'
  ,'post-navigation'
  ,'post-comments'
  ,'theme-elements'
  ,'blockquote'
  ,'template'
  ,'wp-widget-audio'
  ,'woocommerce'
  ,'social'
  ,'library'

  // wp widgets ----------------- //
  ,'wp-widget-pages'
  ,'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'
  ,'wp-widget-polylang'
  ,'wp-widget-calendar'
  ,'wp-widget-elementor-library'
];

add_action('elementor/widgets/widgets_registered', function($widgets_manager){
  global $elementor_widget_blacklist;

  foreach($elementor_widget_blacklist as $widget_name){
    $widgets_manager->unregister_widget_type($widget_name);
  }
}, 15);

I pasted the code in my functions.php file but I got the following error. Am I missing something? Thanks!

2020-05-29_0039
flooweb214 commented 4 years ago

@Noeil182 The first line of the $elementor_widget_blacklist array should not start with a coma.

Here ,'common' should be 'common'

This should work :

global $elementor_widget_blacklist;

$elementor_widget_blacklist = [
  'common'
  ,'heading'
  ,'image'
  ,'text-editor'
  ,'video'
  ,'button'
  ,'divider'
  ,'spacer'
  ,'image-box'
  ,'google-maps'
  ,'icon'
  ,'icon-box'
  ,'image-gallery'
  ,'image-carousel'
  ,'icon-list'
  ,'counter'
  ,'progress'
  ,'testimonial'
  ,'tabs'
  ,'accordion'
  ,'toggle'
  ,'social-icons'
  ,'alert'
  ,'audio'
  ,'shortcode'
  ,'html'
  ,'menu-anchor'
  ,'sidebar'

  // pro ----------------- //
  ,'posts'
  ,'portfolio'
  ,'slides'
  ,'form'
  ,'login'
  ,'media-carousel'
  ,'testimonial-carousel'
  ,'nav-menu'
  ,'pricing'
  ,'facebook-comment'
  ,'nav-menu'
  ,'animated-headline'
  ,'price-list'
  ,'price-table'
  ,'facebook-button'
  ,'facebook-comments'
  ,'facebook-embed'
  ,'facebook-page'
  ,'add-to-cart'
  ,'categories'
  ,'elements'
  ,'products'
  ,'flip-box'
  ,'carousel'
  ,'countdown'
  ,'share-buttons'
  ,'author-box'
  ,'breadcrumbs'
  ,'search-form'
  ,'post-navigation'
  ,'post-comments'
  ,'theme-elements'
  ,'blockquote'
  ,'template'
  ,'wp-widget-audio'
  ,'woocommerce'
  ,'social'
  ,'library'

  // wp widgets ----------------- //
  ,'wp-widget-pages'
  ,'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'
  ,'wp-widget-polylang'
  ,'wp-widget-calendar'
  ,'wp-widget-elementor-library'
];

add_action('elementor/widgets/widgets_registered', function($widgets_manager){
  global $elementor_widget_blacklist;

  foreach($elementor_widget_blacklist as $widget_name){
    $widgets_manager->unregister_widget_type($widget_name);
  }
}, 15);
Noeil182 commented 4 years ago

Thanks for your help!

solace commented 4 years ago

Hi,

Just checking, should this still work for pro widgets? They still display in the editor panel, and the widget list doesn't appear to contain any of the items in the pro section at the time the action is hit.

nicmare commented 4 years ago

the code works for wp- elements only. pro items still appear. are there any changes since v3?

mhason commented 4 years ago

@Noeil182 The first line of the $elementor_widget_blacklist array should not start with a coma.

Here ,'common' should be 'common'

This should work :

global $elementor_widget_blacklist;

$elementor_widget_blacklist = [
  'common'
  ,'heading'
  ,'image'
  ,'text-editor'
  ,'video'
  ,'button'
  ,'divider'
  ,'spacer'
  ,'image-box'
  ,'google-maps'
  ,'icon'
  ,'icon-box'
  ,'image-gallery'
  ,'image-carousel'
  ,'icon-list'
  ,'counter'
  ,'progress'
  ,'testimonial'
  ,'tabs'
  ,'accordion'
  ,'toggle'
  ,'social-icons'
  ,'alert'
  ,'audio'
  ,'shortcode'
  ,'html'
  ,'menu-anchor'
  ,'sidebar'

  // pro ----------------- //
  ,'posts'
  ,'portfolio'
  ,'slides'
  ,'form'
  ,'login'
  ,'media-carousel'
  ,'testimonial-carousel'
  ,'nav-menu'
  ,'pricing'
  ,'facebook-comment'
  ,'nav-menu'
  ,'animated-headline'
  ,'price-list'
  ,'price-table'
  ,'facebook-button'
  ,'facebook-comments'
  ,'facebook-embed'
  ,'facebook-page'
  ,'add-to-cart'
  ,'categories'
  ,'elements'
  ,'products'
  ,'flip-box'
  ,'carousel'
  ,'countdown'
  ,'share-buttons'
  ,'author-box'
  ,'breadcrumbs'
  ,'search-form'
  ,'post-navigation'
  ,'post-comments'
  ,'theme-elements'
  ,'blockquote'
  ,'template'
  ,'wp-widget-audio'
  ,'woocommerce'
  ,'social'
  ,'library'

  // wp widgets ----------------- //
  ,'wp-widget-pages'
  ,'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'
  ,'wp-widget-polylang'
  ,'wp-widget-calendar'
  ,'wp-widget-elementor-library'
];

add_action('elementor/widgets/widgets_registered', function($widgets_manager){
  global $elementor_widget_blacklist;

  foreach($elementor_widget_blacklist as $widget_name){
    $widgets_manager->unregister_widget_type($widget_name);
  }
}, 15);

Adding this spits out the following error:

Screen Shot 2020-11-15 at 20 49 40
thisearlyseason commented 3 years ago

Any updates about this? I dont know where to place this within the functions.php file

erwinfrancis commented 3 years ago

This is not working

erwinfrancis commented 3 years ago

This works for me and apparently you can't unregister everything especially 'common' or it will throw a critical error. Just comment or delete those you want to keep.

add_action('elementor/widgets/widgets_registered', function($widgets_manager){

$widgets_manager->unregister_widget_type('heading'); $widgets_manager->unregister_widget_type('image'); $widgets_manager->unregister_widget_type('text-editor'); $widgets_manager->unregister_widget_type('video'); $widgets_manager->unregister_widget_type('button'); $widgets_manager->unregister_widget_type('divider'); $widgets_manager->unregister_widget_type('spacer'); $widgets_manager->unregister_widget_type('image-box'); $widgets_manager->unregister_widget_type('google-maps'); $widgets_manager->unregister_widget_type('icon'); $widgets_manager->unregister_widget_type('icon-box'); $widgets_manager->unregister_widget_type('image-gallery'); $widgets_manager->unregister_widget_type('image-carousel'); $widgets_manager->unregister_widget_type('icon-list'); $widgets_manager->unregister_widget_type('counter'); $widgets_manager->unregister_widget_type('progress'); $widgets_manager->unregister_widget_type('testimonial'); $widgets_manager->unregister_widget_type('tabs'); $widgets_manager->unregister_widget_type('accordion'); $widgets_manager->unregister_widget_type('toggle'); $widgets_manager->unregister_widget_type('social-icons'); $widgets_manager->unregister_widget_type('alert'); $widgets_manager->unregister_widget_type('audio'); $widgets_manager->unregister_widget_type('shortcode'); $widgets_manager->unregister_widget_type('html'); $widgets_manager->unregister_widget_type('menu-anchor'); $widgets_manager->unregister_widget_type('sidebar');

// pro ----------------- // $widgets_manager->unregister_widget_type('posts'); $widgets_manager->unregister_widget_type('portfolio'); $widgets_manager->unregister_widget_type('slides'); $widgets_manager->unregister_widget_type('form'); $widgets_manager->unregister_widget_type('login'); $widgets_manager->unregister_widget_type('media-carousel'); $widgets_manager->unregister_widget_type('testimonial-carousel'); $widgets_manager->unregister_widget_type('nav-menu'); $widgets_manager->unregister_widget_type('pricing'); $widgets_manager->unregister_widget_type('facebook-comment'); $widgets_manager->unregister_widget_type('nav-menu'); $widgets_manager->unregister_widget_type('animated-headline'); $widgets_manager->unregister_widget_type('price-list'); $widgets_manager->unregister_widget_type('price-table'); $widgets_manager->unregister_widget_type('facebook-button'); $widgets_manager->unregister_widget_type('facebook-comments'); $widgets_manager->unregister_widget_type('facebook-embed'); $widgets_manager->unregister_widget_type('facebook-page'); $widgets_manager->unregister_widget_type('add-to-cart'); $widgets_manager->unregister_widget_type('categories'); $widgets_manager->unregister_widget_type('elements'); $widgets_manager->unregister_widget_type('products'); $widgets_manager->unregister_widget_type('flip-box'); $widgets_manager->unregister_widget_type('carousel'); $widgets_manager->unregister_widget_type('countdown'); $widgets_manager->unregister_widget_type('share-buttons'); $widgets_manager->unregister_widget_type('author-box'); $widgets_manager->unregister_widget_type('breadcrumbs'); $widgets_manager->unregister_widget_type('search-form'); $widgets_manager->unregister_widget_type('post-navigation'); $widgets_manager->unregister_widget_type('post-comments'); $widgets_manager->unregister_widget_type('theme-elements'); $widgets_manager->unregister_widget_type('blockquote'); $widgets_manager->unregister_widget_type('template'); $widgets_manager->unregister_widget_type('wp-widget-audio'); $widgets_manager->unregister_widget_type('woocommerce'); $widgets_manager->unregister_widget_type('social'); $widgets_manager->unregister_widget_type('library');

// wp widgets ----------------- // $widgets_manager->unregister_widget_type('wp-widget-pages'); $widgets_manager->unregister_widget_type('wp-widget-archives'); $widgets_manager->unregister_widget_type('wp-widget-media_audio'); $widgets_manager->unregister_widget_type('wp-widget-media_image'); $widgets_manager->unregister_widget_type('wp-widget-media_gallery'); $widgets_manager->unregister_widget_type('wp-widget-media_video'); $widgets_manager->unregister_widget_type('wp-widget-meta'); $widgets_manager->unregister_widget_type('wp-widget-search'); $widgets_manager->unregister_widget_type('wp-widget-text'); $widgets_manager->unregister_widget_type('wp-widget-categories'); $widgets_manager->unregister_widget_type('wp-widget-recent-posts'); $widgets_manager->unregister_widget_type('wp-widget-recent-comments'); $widgets_manager->unregister_widget_type('wp-widget-rss'); $widgets_manager->unregister_widget_type('wp-widget-tag_cloud'); $widgets_manager->unregister_widget_type('wp-widget-nav_menu'); $widgets_manager->unregister_widget_type('wp-widget-custom_html'); $widgets_manager->unregister_widget_type('wp-widget-polylang'); $widgets_manager->unregister_widget_type('wp-widget-calendar'); $widgets_manager->unregister_widget_type('wp-widget-elementor-library');

}, 15);

yuenjian commented 3 years ago

This code works great. But found that some woocommerce widgets are not being removed from the wordpress dropdown widget.

is there a way to unregister those as well? Just unregister it from elementor, not totally unregister from wordpress.

Elementor-Outlets

seaware commented 3 years ago

Sorry I'm coming late to the party here. What's the best place for this code to help ensure elementor has them registered before they're removed? I'm new to WP code. I added the code above to functions.php but it doesn't do anything because it seems to be too early.

rafaelhsouza-dev commented 3 years ago

functions.php

function hide_widgets_elementor_pro() { echo ''; } add_action('admin_init', 'hide_widgets_elementor_pro');

luan0409 commented 2 years ago

image

Hi i tried the code above but somehow still cant hide some widgets

Can someone pls help me with this?

thank u so much

seaware commented 2 years ago

@luan0409 The solution I arrived at to hide ALL pro widgets is a variation of what @rafaelhsouza-dev posted above. Here's the code I put in functions.php that worked for me:

add_action('elementor/editor/after_enqueue_styles', function($widgets_manager) { echo '<style>#elementor-panel-category-pro-elements, #elementor-panel-category-theme-elements, #elementor-panel-category-woocommerce-elements, #elementor-panel-get-pro-elements {display:none;}</style>'; } );

If it doesn't work also for you, then it likely means the "selectors" for the elementor widgets is different (the items starting with #elementor-panel-category.... above). In that case you'll need to use the browser's inspector development tool to examine the selectors for the widgets you want to hide. This is also how you can hide some widgets and not others.

ravisoni6262 commented 2 years ago

Reading this issue thread helped me solve my problem, But I'm looking for a solution to a specific problem,

uniquekaiser commented 2 years ago

add_action('elementor/editor/after_enqueue_styles', function($widgets_manager) { echo ''; } );

You can also add the "Get Pro" notice with the following addition:

//Disable ALL Elementor Pro widgets add_action('elementor/editor/after_enqueue_styles', function($widgets_manager) { echo ''; } );

huynd1904 commented 2 years ago

This works for me and apparently you can't unregister everything especially 'common' or it will throw a critical error. Just comment or delete those you want to keep.

add_action('elementor/widgets/widgets_registered', function($widgets_manager){

$widgets_manager->unregister_widget_type('heading'); $widgets_manager->unregister_widget_type('image'); $widgets_manager->unregister_widget_type('text-editor'); $widgets_manager->unregister_widget_type('video'); $widgets_manager->unregister_widget_type('button'); $widgets_manager->unregister_widget_type('divider'); $widgets_manager->unregister_widget_type('spacer'); $widgets_manager->unregister_widget_type('image-box'); $widgets_manager->unregister_widget_type('google-maps'); $widgets_manager->unregister_widget_type('icon'); $widgets_manager->unregister_widget_type('icon-box'); $widgets_manager->unregister_widget_type('image-gallery'); $widgets_manager->unregister_widget_type('image-carousel'); $widgets_manager->unregister_widget_type('icon-list'); $widgets_manager->unregister_widget_type('counter'); $widgets_manager->unregister_widget_type('progress'); $widgets_manager->unregister_widget_type('testimonial'); $widgets_manager->unregister_widget_type('tabs'); $widgets_manager->unregister_widget_type('accordion'); $widgets_manager->unregister_widget_type('toggle'); $widgets_manager->unregister_widget_type('social-icons'); $widgets_manager->unregister_widget_type('alert'); $widgets_manager->unregister_widget_type('audio'); $widgets_manager->unregister_widget_type('shortcode'); $widgets_manager->unregister_widget_type('html'); $widgets_manager->unregister_widget_type('menu-anchor'); $widgets_manager->unregister_widget_type('sidebar');

// pro ----------------- // $widgets_manager->unregister_widget_type('posts'); $widgets_manager->unregister_widget_type('portfolio'); $widgets_manager->unregister_widget_type('slides'); $widgets_manager->unregister_widget_type('form'); $widgets_manager->unregister_widget_type('login'); $widgets_manager->unregister_widget_type('media-carousel'); $widgets_manager->unregister_widget_type('testimonial-carousel'); $widgets_manager->unregister_widget_type('nav-menu'); $widgets_manager->unregister_widget_type('pricing'); $widgets_manager->unregister_widget_type('facebook-comment'); $widgets_manager->unregister_widget_type('nav-menu'); $widgets_manager->unregister_widget_type('animated-headline'); $widgets_manager->unregister_widget_type('price-list'); $widgets_manager->unregister_widget_type('price-table'); $widgets_manager->unregister_widget_type('facebook-button'); $widgets_manager->unregister_widget_type('facebook-comments'); $widgets_manager->unregister_widget_type('facebook-embed'); $widgets_manager->unregister_widget_type('facebook-page'); $widgets_manager->unregister_widget_type('add-to-cart'); $widgets_manager->unregister_widget_type('categories'); $widgets_manager->unregister_widget_type('elements'); $widgets_manager->unregister_widget_type('products'); $widgets_manager->unregister_widget_type('flip-box'); $widgets_manager->unregister_widget_type('carousel'); $widgets_manager->unregister_widget_type('countdown'); $widgets_manager->unregister_widget_type('share-buttons'); $widgets_manager->unregister_widget_type('author-box'); $widgets_manager->unregister_widget_type('breadcrumbs'); $widgets_manager->unregister_widget_type('search-form'); $widgets_manager->unregister_widget_type('post-navigation'); $widgets_manager->unregister_widget_type('post-comments'); $widgets_manager->unregister_widget_type('theme-elements'); $widgets_manager->unregister_widget_type('blockquote'); $widgets_manager->unregister_widget_type('template'); $widgets_manager->unregister_widget_type('wp-widget-audio'); $widgets_manager->unregister_widget_type('woocommerce'); $widgets_manager->unregister_widget_type('social'); $widgets_manager->unregister_widget_type('library');

// wp widgets ----------------- // $widgets_manager->unregister_widget_type('wp-widget-pages'); $widgets_manager->unregister_widget_type('wp-widget-archives'); $widgets_manager->unregister_widget_type('wp-widget-media_audio'); $widgets_manager->unregister_widget_type('wp-widget-media_image'); $widgets_manager->unregister_widget_type('wp-widget-media_gallery'); $widgets_manager->unregister_widget_type('wp-widget-media_video'); $widgets_manager->unregister_widget_type('wp-widget-meta'); $widgets_manager->unregister_widget_type('wp-widget-search'); $widgets_manager->unregister_widget_type('wp-widget-text'); $widgets_manager->unregister_widget_type('wp-widget-categories'); $widgets_manager->unregister_widget_type('wp-widget-recent-posts'); $widgets_manager->unregister_widget_type('wp-widget-recent-comments'); $widgets_manager->unregister_widget_type('wp-widget-rss'); $widgets_manager->unregister_widget_type('wp-widget-tag_cloud'); $widgets_manager->unregister_widget_type('wp-widget-nav_menu'); $widgets_manager->unregister_widget_type('wp-widget-custom_html'); $widgets_manager->unregister_widget_type('wp-widget-polylang'); $widgets_manager->unregister_widget_type('wp-widget-calendar'); $widgets_manager->unregister_widget_type('wp-widget-elementor-library');

}, 15);

this one work only for free widget now, the pro widget still showing. any idea???

rafaelhsouza-dev commented 2 years ago

Good look //hide widgets pro elementor function remove_widgets_elementor_pro() { echo "

";

} add_action( 'elementor/widgets/widgets_registered', 'remove_widgets_elementor_pro' );

huynd1904 commented 2 years ago

Good look //hide widgets pro elementor function remove_widgets_elementor_pro() { echo " "; } add_action( 'elementor/widgets/widgets_registered', 'remove_widgets_elementor_pro' );

it's not a good solution because the widget show when we use search

YoChes commented 2 years ago

Any ideas how to remove the "add template" (.elementor-add-section-area-button elementor-add-template-button) button from the editor?

PhilLesage commented 2 years ago

Not sure if still relevant, but I was struggling to disable the Elementor Pro widgets. I've found instead of using the hook 'elementor/widgets/widgets_registered' using the hook 'elementor/widgets/register' works. So my code looked like this:

global $elementor_widget_blacklist;
$elementor_widget_blacklist = [
'... array of elements/widgets you want to disable'
];

add_action('elementor/widgets/register', function($widgets_manager){
  global $elementor_widget_blacklist;

  // uncomment to list all registered widgets, for debuging only
  // foreach($widgets_manager->get_widget_types() as $name => $widget) {
  //    var_dump($name);
  //    echo '<br>';
  // }

  foreach($elementor_widget_blacklist as $widget_name){
    $widgets_manager->unregister($widget_name);
  }

}, 99);

If you are not sure what the name/slug of the widget is you can uncomment the $widgets_manager->get_widget_types() loop and then simply load your home page to see them all listed.

And if you want to simply hide the widgets/elements from the side panel in the elementor editor, but still want the widget to work on the site you can use:

add_filter( 'elementor/editor/localize_settings', function( $settings ) {
  global $elementor_widget_blacklist;

  // uncomment to list all registered widgets, for debuging only
  // foreach ($settings['initial_document']['widgets'] as $key => $setting) {
    //  var_dump($key);
  // }

  foreach($elementor_widget_blacklist as $widget_name){
    $settings['initial_document']['widgets'][$widget_name]['show_in_panel'] = false;    
  }

   return $settings;
}, 99 );

I think this seems to work for hiding promotional (pro) widgets too, if you don't have the pro version. Also works for the Essential add on plugin.

Auraylien commented 1 year ago

All the solutions here didn't work for me. The only working solution was the CSS. Here a functional code in 2023:

add_action('elementor/editor/wp_head', function () {
    echo '
    <style>
      #elementor-panel-category-pro-elements,
      #elementor-panel-category-theme-elements,
      #elementor-panel-category-theme-elements-single,
      #elementor-panel-category-woocommerce-elements {
        display: none;
      }
    </style>';
}, 100);

Since the PRO widgets are generated by JavaScript and not registered directly by Elementor, there is no more possible to disable them in PHP. The only solution is to hide the panels.

cjunisl commented 1 year ago

@Auraylien thank you

rafaelhsouza-dev commented 1 year ago

This is still the best solution, unfortunately :(

add_action('elementor/editor/wp_head', function () { echo '<style> #elementor-panel-category-pro-elements, #elementor-panel-category-theme-elements, #elementor-panel-category-theme-elements-single, #elementor-panel-category-woocommerce-elements { display: none; }</style>'; }, 99);