Tag Info

Hot answers tagged

17

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 ...


16

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;"> ...


10

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.


9

http://vudu.me/88 Has an article about it. But basically /* Disable the Admin Bar. */ add_filter( 'show_admin_bar', '__return_false' ); or also //REMOVE ADMIN BAR remove_action('init', 'wp_admin_bar_init'); I believe in your functions.php will disable it. Probably a better way than just hiding it thriough css THe reason you still get the gap with ...


9

function hide_admin_bar_from_front_end(){ if (is_blog_admin()) { return true; } return false; } add_filter( 'show_admin_bar', 'hide_admin_bar_from_front_end' );


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() { ...


8

Go to Dashboard > Your Profile > Show Admin Bar and uncheck "when viewing site"


8

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' ) { ...


8

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

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( ...


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 ...


6

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: ...


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

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 ...


5

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( ...


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 ...


5

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', ...


5

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' ); }


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; ...


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

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

in your css you could try something like: body.logged-in{margin-top:20px;} or if this doesnt work some other code using the .logged-in class


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

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

I just ran into this issue as well, the cause of this is that at 600 pixels wide the admin bar goes from being position:fixed to position:absolute; When fixed, it is locked to the top of the screen (top:0) When absolute it is locked to the top of the closest container that contains it. This is the html element by default, but if a parent is defined to have ...


4

Full example A quick (mu-)plugin as example: <?php /** Plugin Name: Add Admin Bar Icon */ add_action( 'admin_bar_menu', function( \WP_Admin_Bar $bar ) { $bar->add_menu( array( 'id' => 'wpse', 'parent' => null, 'group' => null, 'title' => __( 'Example', 'some-textdomain' ), 'href' => ...


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



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