WordPress.org

Make WordPress Core

Changeset 15834


Ignore:
Timestamp:
10/18/2010 05:58:36 PM (9 years ago)
Author:
ryan
Message:

Allow turning off the admin bar via WP_SHOW_ADMIN_BAR constant, no_admin_bar() function, or show_admin_bar filter. see #14772

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/media-upload.php

    r15171 r15834  
    99 * @subpackage Administration
    1010 */
     11
     12define('WP_SHOW_ADMIN_BAR' , false);
    1113
    1214/** Load WordPress Administration Bootstrap */
  • trunk/wp-admin/press-this.php

    r15365 r15834  
    77 */
    88
     9define('WP_SHOW_ADMIN_BAR' , false);
     10
    911/** WordPress Administration Bootstrap */
    1012require_once('./admin.php');
     13
    1114header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
    1215
  • trunk/wp-admin/update.php

    r14985 r15834  
    66 * @subpackage Administration
    77 */
     8
     9define('WP_SHOW_ADMIN_BAR' , false);
    810
    911/** WordPress Administration Bootstrap */
  • trunk/wp-includes/admin-bar.php

    r15769 r15834  
    1212    global $current_user, $pagenow, $wp_admin_bar;
    1313
     14    if ( defined('WP_SHOW_ADMIN_BAR') )
     15        $show_it = (bool) WP_SHOW_ADMIN_BAR;
     16    else
     17        $show_it = true;
     18
     19    if ( ! apply_filters('show_admin_bar', $show_it, get_current_screen() ) )
     20        return false;
     21
    1422    /* Set the protocol constant used throughout this code */
    1523    if ( !defined( 'PROTO' ) )
    1624        if ( is_ssl() ) define( 'PROTO', 'https://' ); else define( 'PROTO', 'http://' );
    1725
    18     /* Don't load the admin bar if the user is not logged in, or we are using press this */
    19     if ( !is_user_logged_in() || 'press-this.php' == $pagenow || 'update.php' == $pagenow )
     26    /* Don't load the admin bar if the user is not logged in */
     27    if ( !is_user_logged_in() )
    2028        return false;
    2129
     
    2735    if ( is_user_logged_in() )
    2836        wp_enqueue_script( 'jquery', false, false, false, true );
    29    
     37
    3038    /* Load the admin bar class code ready for instantiation */
    3139    require( ABSPATH . WPINC . '/admin-bar/admin-bar-class.php' );
     
    3947    /* Initialize the admin bar */
    4048    $wp_admin_bar = new wp_admin_bar();
     49
     50    add_action( 'wp_head', 'wp_admin_bar_css' );
     51    add_action( 'admin_head', 'wp_admin_bar_css' );
    4152}
    4253add_action( 'init', 'wp_admin_bar_init' );
     
    222233    global $pagenow, $wp_locale;
    223234
    224     if ( !is_user_logged_in() || 'press-this.php' == $pagenow || 'update.php' == $pagenow || 'media-upload.php' == $pagenow )
     235    if ( !is_user_logged_in() )
    225236        return;
    226237
     
    233244    <style type="text/css" media="print">#wpadminbar { display:none; }</style><?php
    234245}
    235 add_action( 'wp_head', 'wp_admin_bar_css' );
    236 add_action( 'admin_head', 'wp_admin_bar_css' );
    237246
    238247/**
  • trunk/wp-includes/functions.php

    r15813 r15834  
    44094409    return false;
    44104410}
     4411
     4412/**
     4413 * Prevents the admin bar from being shown for the current screen.
     4414 *
     4415 * This can be called immediately upon plugin load.  It does not need to be called from a function hooked to the init action.
     4416 *
     4417 * @since 3.1.0
     4418 */
     4419function no_admin_bar() {
     4420    define('WP_SHOW_ADMIN_BAR', false);
     4421}
Note: See TracChangeset for help on using the changeset viewer.