WP-Adminbar Tricks – WortGepresst



STARTSEITE MULTIMEDIA WORTGEPRESST FAMILIENBANDE BOOKMARK PRIVACY


WP-Adminbar Tricks

Admin Bar Tricksfor WordPress 3.1 and better:

  • Disable the Admin Bar for individual users
  • Disable the Admin Bar for all users of the current theme
  • Disable the Admin Bar for non-Admins only
  • Always show the Admin Bar
  • Move the Admin Bar to the bottom
  • Add or Remove links from the Admin Bar
  • Clean up User Profile Page
  • Disable and Customize the Admin Bar with Plugins
  • Even More Admin Bar Resources

 


Disable the Admin Bar for individual users

By default, each registered user has the option of showing the Admin on the frontend and/or back-end of the site.
Unfortunately, this gets kind of tedious when customizing profiles for many users. Fortunately, we’re just getting started, so read ahead to see more efficient ways of disabling and modifying the WordPress Admin Bar.


Disable the Admin Bar for all users of the current theme

To cleanly disable the Admin Bar for all users of your theme (and thus your site), add this snippet to your theme’sfunctions.phpfile:

Alternately, you may use this method, which filters theshow_admin_barfunction:

Another option is to hide the Admin Bar usingCSS. To do so, paste this into your
theme’sstyle.css(or other stylesheet):


Disable the Admin Bar for non-Admins only

Expanding on the previous example, here are two snippets that disable the Admin Bar for non-Admins and Editors. Place either of the following infunctions.php:

As you might guess, any setting may be used forcurrent_user_can(), so it’s easy to show/hide the Admin Bar for any particular group of users.


Clean up User Profile Page

After disabling the Admin Bar, you may want to hide its display settings in each user’s Profile Page. The easiest way to do this is with a simple function:

Just place that in your theme’sfunctions.phpand you’re good to go. No more Admin Bar Settings displayed in the Admin area.


Always show the Admin Bar

Follow the white rabbit shows us how to show the Admin Bar even when logged out. As a bonus, a handy “Log in” button is added to the bar for easy maneuvering. Just add the following snippet to your theme’sfunctions.php:


Move the Admin Bar to the bottom

Want to display the Admin Bar at the bottom of the page instead of the top? With this bit ofCSSvia thefunctions.phpfile:

This code adds the required CSS to both the front-end (public pages) and back-end (admin pages). To disable for one or the other, just comment-out or remove the correspondingadd_action()line near the end of the code. You could also just copy/paste the CSS into your theme’sstyle.cssfile if you only need to move it on the front-end of your site. An even easier way is provided by Coen Jacobs’ plugin, Stick Admin Bar To Bottom1, that makes it happen automagically.
1Editor’s note:404 linkremoved.


WPMU.org shows us how to add/remove links from the Admin Bar. This is especially useful for MultiSite networks, where all of the extra links may not be necessary. The following code may be used toremovelinks and/or menus (viafunctions.php:

For this example, we useremove_menu('comments')to remove the comments dropdown list. To remove a different link/menu, check/wp-includes/admin-bar.phpfor the corresponding ID. Here’s a list to get you started:

  • my-account– link to your account (avatars disabled)
  • my-account-with-avatar– link to your account (avatars enabled)
  • my-blogs– the “My Sites” menu if the user has more than one site
  • get-shortlink– provides a Shortlink to that page
  • edit– link to the Edit/Write-Post page
  • new-content– link to the “Add New” dropdown list
  • comments– link to the “Comments” dropdown
  • appearance– link to the “Appearance” dropdown
  • updates– the “Updates” dropdown

Toaddlinks/menus to the Admin Bar, add the following code to yourfunctions.phpfile:

You’ll want to adjust the parameters to fit your needs, and don’t forget to see theCodexfor additional information.


More Admin-Bar Resources

Here are some excellent resources for more information on the WP Admin Bar.

Font Resize
Contrast
Zur Werkzeugleiste springen