Tag Info

Hot answers tagged

15

Yoast's plug-in is actually a very good example if all you want to do is add menus. Basically, the admin bar is just an alternate set of links to the same plug-in admin pages you have in the sidebar. To add the top-level SEO menu, Yoast does the following: $wp_admin_bar->add_menu( array( 'id' => 'wpseo-menu', 'title' => __( 'SEO' ), 'href' => ...


11

small example, i had write this also on wp-hackers list before view days function wp_codex_search_form() { global $wp_admin_bar, $wpdb; if ( !is_super_admin() || !is_admin_bar_showing() ) return; $codex_search = '<form target="_blank" method="get" action="http://wordpress.org/search/do-search.php" style="margin:2px 0 0;"> ...


11

WordPress contains built in functions for quickly returning values. They are intended to be used as a quick built in function that returns a common value to a filter hook such as true, false, or an empty array. __return_false — Returns the Boolean value of false. __return_true — Returns the Boolean value of true. __return_empty_array — Returns an empty ...


8

Try adding this to your CSS file: body.admin-bar #branding-wrap{top: 28px;} body.admin-bar #wrapper{margin-top: 145px;} the body.admin-bardeclaration at the front will make sure that these styles only get applied when the admin bar is visible.


8

You are right on the mark with GET, that would probably be easiest to make use of. Try this: Add_Child_Page::on_load(); class Add_Child_Page { static function on_load() { add_action( 'init', array( __CLASS__, 'init' ) ); add_action( 'admin_init', array( __CLASS__, 'admin_init' ) ); } static function init() { ...


7

I've not worked with the admin-bar before. However, I found your question interesting and decided to take a look. If you add a function to handle the action hook 'admin_bar_menu' and set the priority to be higher than 70, you will have access to the raw admin_bar_menu nodes where you can modify the properties you are trying to access. Below is a detailed set ...


7

There is a remove_menu hook for the admin menu bar. The class you want to hook into $wp_admin_bar , you can see the remove function here and test it out since there is no documentation on it ( line 86), it should work with the submenu ID. http://core.trac.wordpress.org/browser/tags/3.2.1/wp-includes/class-wp-admin-bar.php Since you did not seem to ...


7

Unset Here's an example of how to unset the comments link if the default status is 'closed' (offers 2 different approaches). /** * Disable 'Comments' link if default status is _closed_ */ function remove_comments() { $default_comment_status = get_option( 'default_comment_status' ); if ( $default_comment_status == 'closed' ) { ...


6

Download the nightly build, and check out these two files; wp-includes/admin-bar.php wp-includes/class-wp-admin-bar.php The class WP_Admin_Bar is essentially the 'API', whilst the file admin-bar.php uses it to build the default bar and fire off a load of hooks. function my_admin_bar() { global $wp_admin_bar; $wp_admin_bar->add_menu(array( ...


6

Wordpress SEO If you want to remove the admin menu: you can do that with: function hide_wpseo() { remove_action('admin_menu', 'zeo_options_menu'); } add_action( 'init', 'hide_wpseo'); where it will be removed for all users. WordPress SEO by Yoast To hide the admin menu: and the admin menu bar: one can use: function hide_yoastseo() { ...


5

Add the following to your theme's functions.php file: // Disable Admin Bar for all users add_filter('show_admin_bar', '__return_false'); // Remove Admin Bar Options from all users' Profile page add_action('admin_print_scripts-profile.php', 'hide_admin_bar_prefs'); function hide_admin_bar_prefs() { ?> <style type="text/css"> .show-admin-bar { ...


5

You could use a function inside your theme's functions file to selectively disable it for specific users. function disable_bar_for_user( $ids ) { if( !is_user_logged_in() ) return; global $current_user; if( is_numeric( $ids ) ) $ids = (array) $ids; if( !in_array( $current_user->data->ID, $ids ) ) return; ...


5

You should be able to just add the filter inside of a conditional: <?php if ($_GET['hidetoolbar']) { add_filter('show_admin_bar', '__return_false'); } ?> or, since conditionally adding action handlers and filters is sometimes frowned upon, you could add your own function as a filter and then put your conditional inside that: <?php function ...


4

This menu is added in WP_Admin_Bar::add_menus() with an action: add_action( 'admin_bar_menu', 'wp_admin_bar_wp_menu', 10 ); To remove it take the same action – just one step later. The following code works as a mu plugin or as a regular plugin: <?php # -*- coding: utf-8 -*- /** * Plugin Name: Remove WP Menu From Tool Bar */ if ( ! function_exists( ...


4

I'm solving this getting all nodes from the Admin Bar, iterating through them and removing all that doesn't have a parent. An exception is made to the User Actions menu ("Howdy, user_name"), which needs an extra checking. add_action( 'admin_bar_menu', 'wpse_76491_admin_bar_menu', 200 ); function wpse_76491_admin_bar_menu() { global $wp_admin_bar; ...


4

Didn't work for me, but I found a nice fix. In your header.php use the wordpress function to query if the toolbar is displayed, and then create an empty div below the navbar div: <div class="navbar navbar-inverse navbar-fixed-top"> <?php // Fix menu overlap bug.. if ( is_admin_bar_showing() ) echo '<div style="min-height: ...


4

Found my answer including my full solution: <?php /* Plugin Name: Rename Posts to News Description: Rename built in posts to be called News Version: 1.0 Author: Scott Cariss @ Philosophy Design Author URI: http://www.philosophydesign.com */ // Not a WordPress context? Stop. ! defined( 'ABSPATH' ) and exit; add_action( 'init', array ( ...


4

function mytheme_admin_bar_render() { global $wp_admin_bar; $wp_admin_bar->remove_menu('wp-logo'); } add_action( 'wp_before_admin_bar_render', 'mytheme_admin_bar_render' ); For specific user roles you can wrap the add_action in a conditional, something like if(current_user_can('editor')){ add_action( 'wp_before_admin_bar_render', ...


4

It turns out to be very easy! No need for a special walker, wp_get_nav_menu_items() returns everything you need. This example adds an single root menu item and then the menu, you can do this differently if you want. It maps all extra menu features I could find in the code, I don't know whether you can set them all in the menu UI. add_action( ...


4

Use this small plugin, also available on Gist: https://gist.github.com/1503172 Works fine and is also a part of the plugin free "Adminimize". add_action( 'init', 'fb_remove_admin_bar', 0 ); function fb_remove_admin_bar() { wp_deregister_script( 'admin-bar' ); wp_deregister_style( 'admin-bar' ); remove_action( 'init', '_wp_admin_bar_init' ); ...


4

It's not well documented, but the add_node and add_menu methods of the WP_Admin_Bar class can be used not only to create new menu or nodes, but also to update an existing menu or node. So i went ahead and tracked down the code that WordPress initially uses to create that item in the admin bar, replicated it, then made adjustments to the Howdy text and used ...


3

Just use is_admin_bar_showing() to check if the currently logged in user is logged in has activated the admin bar in his user settings/preferences


3

if (!function_exists('disableAdminBar')) { function disableAdminBar(){ remove_action( 'admin_footer', 'wp_admin_bar_render', 1000 ); function remove_admin_bar_style_backend() { echo '<style>body.admin-bar #wpcontent, body.admin-bar #adminmenu { padding-top: 0px !important; }</style>'; } ...


3

function remove_admin_bar_links() { global $wp_admin_bar; $wp_admin_bar->remove_menu('site-name'); } add_action( 'wp_before_admin_bar_render', 'remove_admin_bar_links' ); function my_admin_bar_menu() { global $wp_admin_bar; if ( !is_super_admin() || !is_admin_bar_showing() ) return; $wp_admin_bar->add_menu( array( 'id' ...


3

You are not declaring an 'id' key. Without one, the id will default to a sanitized version of the 'title' value - hence your overwrite. Declare a unique id element, and you should be golden. That said, add_node is now the preferred method of achieving this.


3

In the WP_Admin_Bar::add_menus() class method you will find the actions: add_action( 'admin_bar_menu', 'wp_admin_bar_my_account_menu', 0 ); add_action( 'admin_bar_menu', 'wp_admin_bar_my_account_item', 7 ); and the two corresponding callbacks are using get_avatar(). To prevent the avatar changes in the admin bar, we can remove the foo_change_avatar ...


3

Might be one of 3 things (since you verified a wp_footer) you set it to not show in your user profile a plugin you installed has a Confliction with it you created a php / js code which produces errors in your wp_footer Course of action: 1. Check you personal user profile backend to see you haven't turned it off 1. turn off all plugin (rename ...


3

Here is a simple solution I figured out by reverse engineering this plugin: http://wordpress.org/extend/plugins/dashboard-tweaks/ function custom_logout_link() { global $wp_admin_bar; $wp_admin_bar->add_menu( array( 'id' => 'wp-custom-logout', 'title' => 'Logout', 'parent'=> 'top-secondary', 'href' ...


3

See the Admin Bar remove_node function: add_action( 'admin_bar_menu', 'remove_wp_nodes', 999 ); function remove_wp_nodes() { global $wp_admin_bar; $wp_admin_bar->remove_node( 'new-post' ); $wp_admin_bar->remove_node( 'new-link' ); $wp_admin_bar->remove_node( 'new-media' ); }



Only top voted, non community-wiki answers of a minimum length are eligible