From 34a00ae277ab073b86c7f49f13aac298cffaa4cf Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Thu, 28 Feb 2013 16:56:35 +0000 Subject: [PATCH] Move admin bar initialization from init to template_redirect, so conditional tags may be used in the show_admin_bar filter. props scribu. fixes #20101. git-svn-id: https://develop.svn.wordpress.org/trunk@23512 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/admin-bar.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/wp-includes/admin-bar.php b/wp-includes/admin-bar.php index 4b5a9bce2c..7f5cdf4c27 100644 --- a/wp-includes/admin-bar.php +++ b/wp-includes/admin-bar.php @@ -8,8 +8,8 @@ /** * Instantiate the admin bar object and set it up as a global for access elsewhere. * - * To hide the admin bar, you're looking in the wrong place. Unhooking this function will not - * properly remove the admin bar. For that, use show_admin_bar(false) or the show_admin_bar filter. + * UNHOOKING THIS FUNCTION WILL NOT PROPERLY REMOVE THE ADMIN BAR. + * For that, use show_admin_bar(false) or the 'show_admin_bar' filter. * * @since 3.1.0 * @access private @@ -36,7 +36,9 @@ function _wp_admin_bar_init() { return true; } -add_action( 'init', '_wp_admin_bar_init' ); // Don't remove. Wrong way to disable. +// Don't remove. Wrong way to disable. +add_action( 'template_redirect', '_wp_admin_bar_init', 0 ); +add_action( 'admin_init', '_wp_admin_bar_init' ); /** * Render the admin bar to the page based on the $wp_admin_bar->menu member var.