Created
September 12, 2019 14:36
-
-
Save mkwebworker/ec7149b53ff72b703d298bd265b69048 to your computer and use it in GitHub Desktop.
disable elementor widgets for editors
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
/* | |
* disable elementor widgets for editors | |
*/ | |
add_filter( 'elementor/editor/localize_settings', function( $settings ) { | |
$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', | |
'star-rating', | |
'read-more', | |
'reviews', | |
'call-to-action', | |
// 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' | |
]; | |
//get current user | |
$user = wp_get_current_user(); | |
if( ! in_array( 'administrator', $user->roles ) ): | |
foreach ($elementor_widget_blacklist as $widget): | |
$settings['widgets'][$widget]['show_in_panel'] = false; | |
endforeach; | |
endif; | |
return $settings; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment