improvements-2.x-dev/modules/improvements_toolbar/improvements_toolbar.module
modules/improvements_toolbar/improvements_toolbar.module
<?php /** * Implements hook_element_info_alter(). */ function improvements_toolbar_element_info_alter(array &$elements): void { if (isset($elements['toolbar'])) { $elements['toolbar']['#attached']['library'][] = 'improvements_toolbar/toolbar'; } } /** * Implements hook_toolbar_alter(). */ function improvements_toolbar_toolbar_alter(array &$items): void { if (isset($items['administration']['#attached']['library'])) { $items['administration']['#attached']['library'] = array_diff($items['administration']['#attached']['library'], [ 'admin_toolbar/toolbar.tree', 'admin_toolbar_tools/toolbar.icon', ]); } foreach (['home', 'user', 'contextual', 'devel', 'admin_toolbar_tools', 'administration_search'] as $item) { if (isset($items[$item])) { unset($items[$item]); } } } /** * Implements hook_theme_registry_alter(). */ function improvements_toolbar_theme_registry_alter(array &$theme_registry): void { $theme_registry['html']['preprocess functions'] = array_diff($theme_registry['html']['preprocess functions'], ['toolbar_preprocess_html']); } /** * Preprocess function for html.html.twig. */ function improvements_toolbar_preprocess_html(array &$vars): void { if (\Drupal::currentUser()->hasPermission('access toolbar')) { $vars['attributes']['class'][] = 'page--with-toolbar'; } } /** * Preprocess function for menu--toolbar.html.twig. */ function improvements_toolbar_preprocess_menu__toolbar(array &$vars): void { // Remove description from admin menu links improvements_unset_menu_items_description($vars['items']); }