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: https://develop.svn.wordpress.org/trunk@15834 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
cdafd5fe89
commit
8b610e7c83
|
@ -9,6 +9,8 @@
|
||||||
* @subpackage Administration
|
* @subpackage Administration
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
define('WP_SHOW_ADMIN_BAR' , false);
|
||||||
|
|
||||||
/** Load WordPress Administration Bootstrap */
|
/** Load WordPress Administration Bootstrap */
|
||||||
require_once('./admin.php');
|
require_once('./admin.php');
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,11 @@
|
||||||
* @subpackage Press_This
|
* @subpackage Press_This
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
define('WP_SHOW_ADMIN_BAR' , false);
|
||||||
|
|
||||||
/** WordPress Administration Bootstrap */
|
/** WordPress Administration Bootstrap */
|
||||||
require_once('./admin.php');
|
require_once('./admin.php');
|
||||||
|
|
||||||
header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
|
header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
|
||||||
|
|
||||||
if ( ! current_user_can('edit_posts') )
|
if ( ! current_user_can('edit_posts') )
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
* @subpackage Administration
|
* @subpackage Administration
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
define('WP_SHOW_ADMIN_BAR' , false);
|
||||||
|
|
||||||
/** WordPress Administration Bootstrap */
|
/** WordPress Administration Bootstrap */
|
||||||
require_once('./admin.php');
|
require_once('./admin.php');
|
||||||
|
|
||||||
|
|
|
@ -11,12 +11,20 @@
|
||||||
function wp_admin_bar_init() {
|
function wp_admin_bar_init() {
|
||||||
global $current_user, $pagenow, $wp_admin_bar;
|
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 */
|
/* Set the protocol constant used throughout this code */
|
||||||
if ( !defined( 'PROTO' ) )
|
if ( !defined( 'PROTO' ) )
|
||||||
if ( is_ssl() ) define( 'PROTO', 'https://' ); else define( 'PROTO', 'http://' );
|
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 */
|
/* Don't load the admin bar if the user is not logged in */
|
||||||
if ( !is_user_logged_in() || 'press-this.php' == $pagenow || 'update.php' == $pagenow )
|
if ( !is_user_logged_in() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Set up the settings we need to render menu items */
|
/* 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. */
|
/* Enqueue the JS files for the admin bar. */
|
||||||
if ( is_user_logged_in() )
|
if ( is_user_logged_in() )
|
||||||
wp_enqueue_script( 'jquery', false, false, false, true );
|
wp_enqueue_script( 'jquery', false, false, false, true );
|
||||||
|
|
||||||
/* Load the admin bar class code ready for instantiation */
|
/* Load the admin bar class code ready for instantiation */
|
||||||
require( ABSPATH . WPINC . '/admin-bar/admin-bar-class.php' );
|
require( ABSPATH . WPINC . '/admin-bar/admin-bar-class.php' );
|
||||||
|
|
||||||
|
@ -38,6 +46,9 @@ function wp_admin_bar_init() {
|
||||||
|
|
||||||
/* Initialize the admin bar */
|
/* Initialize the admin bar */
|
||||||
$wp_admin_bar = new wp_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' );
|
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() {
|
function wp_admin_bar_css() {
|
||||||
global $pagenow, $wp_locale;
|
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;
|
return;
|
||||||
|
|
||||||
$nobump = false;
|
$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]-->
|
<!--[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
|
<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.
|
* 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;
|
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