mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-31 13:37:51 +01:00
Allow turning off the admin bar via WP_SHOW_ADMIN_BAR constant, no_admin_bar() function, or show_admin_bar filter. see #14772
git-svn-id: http://svn.automattic.com/wordpress/trunk@15834 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
54ae23aa08
commit
580bf5eead
@ -9,6 +9,8 @@
|
||||
* @subpackage Administration
|
||||
*/
|
||||
|
||||
define('WP_SHOW_ADMIN_BAR' , false);
|
||||
|
||||
/** Load WordPress Administration Bootstrap */
|
||||
require_once('./admin.php');
|
||||
|
||||
|
@ -6,8 +6,11 @@
|
||||
* @subpackage Press_This
|
||||
*/
|
||||
|
||||
define('WP_SHOW_ADMIN_BAR' , false);
|
||||
|
||||
/** WordPress Administration Bootstrap */
|
||||
require_once('./admin.php');
|
||||
|
||||
header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
|
||||
|
||||
if ( ! current_user_can('edit_posts') )
|
||||
|
@ -6,6 +6,8 @@
|
||||
* @subpackage Administration
|
||||
*/
|
||||
|
||||
define('WP_SHOW_ADMIN_BAR' , false);
|
||||
|
||||
/** WordPress Administration Bootstrap */
|
||||
require_once('./admin.php');
|
||||
|
||||
|
@ -11,12 +11,20 @@
|
||||
function wp_admin_bar_init() {
|
||||
global $current_user, $pagenow, $wp_admin_bar;
|
||||
|
||||
if ( defined('WP_SHOW_ADMIN_BAR') )
|
||||
$show_it = (bool) WP_SHOW_ADMIN_BAR;
|
||||
else
|
||||
$show_it = true;
|
||||
|
||||
if ( ! apply_filters('show_admin_bar', $show_it, get_current_screen() ) )
|
||||
return false;
|
||||
|
||||
/* Set the protocol constant used throughout this code */
|
||||
if ( !defined( 'PROTO' ) )
|
||||
if ( is_ssl() ) define( 'PROTO', 'https://' ); else define( 'PROTO', 'http://' );
|
||||
|
||||
/* Don't load the admin bar if the user is not logged in, or we are using press this */
|
||||
if ( !is_user_logged_in() || 'press-this.php' == $pagenow || 'update.php' == $pagenow )
|
||||
/* Don't load the admin bar if the user is not logged in */
|
||||
if ( !is_user_logged_in() )
|
||||
return false;
|
||||
|
||||
/* Set up the settings we need to render menu items */
|
||||
@ -26,7 +34,7 @@ function wp_admin_bar_init() {
|
||||
/* Enqueue the JS files for the admin bar. */
|
||||
if ( is_user_logged_in() )
|
||||
wp_enqueue_script( 'jquery', false, false, false, true );
|
||||
|
||||
|
||||
/* Load the admin bar class code ready for instantiation */
|
||||
require( ABSPATH . WPINC . '/admin-bar/admin-bar-class.php' );
|
||||
|
||||
@ -38,6 +46,9 @@ function wp_admin_bar_init() {
|
||||
|
||||
/* Initialize the admin bar */
|
||||
$wp_admin_bar = new wp_admin_bar();
|
||||
|
||||
add_action( 'wp_head', 'wp_admin_bar_css' );
|
||||
add_action( 'admin_head', 'wp_admin_bar_css' );
|
||||
}
|
||||
add_action( 'init', 'wp_admin_bar_init' );
|
||||
|
||||
@ -221,7 +232,7 @@ add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_edit_menu', 100 );
|
||||
function wp_admin_bar_css() {
|
||||
global $pagenow, $wp_locale;
|
||||
|
||||
if ( !is_user_logged_in() || 'press-this.php' == $pagenow || 'update.php' == $pagenow || 'media-upload.php' == $pagenow )
|
||||
if ( !is_user_logged_in() )
|
||||
return;
|
||||
|
||||
$nobump = false;
|
||||
@ -232,8 +243,6 @@ function wp_admin_bar_css() {
|
||||
<!--[if IE 6]><style type="text/css">#wpadminbar, #wpadminbar .menupop a span, #wpadminbar .menupop ul li a:hover, #wpadminbar .myaccount a, .quicklinks a:hover,#wpadminbar .menupop:hover { background-image: none !important; } #wpadminbar .myaccount a { margin-left:0 !important; padding-left:12px !important;}</style><![endif]-->
|
||||
<style type="text/css" media="print">#wpadminbar { display:none; }</style><?php
|
||||
}
|
||||
add_action( 'wp_head', 'wp_admin_bar_css' );
|
||||
add_action( 'admin_head', 'wp_admin_bar_css' );
|
||||
|
||||
/**
|
||||
* Load up the JS needed to allow the admin bar to function correctly.
|
||||
|
@ -4408,3 +4408,14 @@ function wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override = ar
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevents the admin bar from being shown for the current screen.
|
||||
*
|
||||
* This can be called immediately upon plugin load. It does not need to be called from a function hooked to the init action.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
function no_admin_bar() {
|
||||
define('WP_SHOW_ADMIN_BAR', false);
|
||||
}
|
Loading…
Reference in New Issue
Block a user