Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
stratboy opened this issue Jan 10, 2018 · 7 comments
Labels

Comments

@stratboy
Copy link
Contributor

@stratboy stratboy commented Jan 10, 2018

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

This comment has been minimized.

Copy link
Contributor Author

@stratboy stratboy commented Jan 10, 2018

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

This comment has been minimized.

Copy link
Collaborator

@bainternet bainternet commented Jan 11, 2018

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

This comment has been minimized.

Copy link
Contributor Author

@stratboy stratboy commented Jan 11, 2018

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

This comment has been minimized.

Copy link

@norewp norewp commented Jan 19, 2018

@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

This comment has been minimized.

Copy link
Contributor Author

@stratboy stratboy commented Jan 30, 2018

@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

This comment has been minimized.

Copy link

@gianghl1983 gianghl1983 commented Sep 23, 2018

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

@madbradj

This comment has been minimized.

Copy link

@madbradj madbradj commented Aug 21, 2019

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.