WordPress.org

Make WordPress Core

Changeset 15863


Ignore:
Timestamp:
10/20/2010 01:23:39 PM (8 years ago)
Author:
ryan
Message:

show_admin_bar(). see #14772

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/admin-bar.php

    r15862 r15863  
    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 ) )
     14    if ( ! show_admin_bar() )
    2015        return false;
    2116
  • trunk/wp-includes/functions.php

    r15846 r15863  
    44064406
    44074407/**
    4408  * Prevents the admin bar from being shown for the current screen.
     4408 * Retrieve or set the admin bar display state.
    44094409 *
    44104410 * This can be called immediately upon plugin load.  It does not need to be called from a function hooked to the init action.
    44114411 *
     4412 * @param bool $show Optional. True to show the admin bar, false to hide it. If not provided the current display state is returned.
     4413 * @return bool The current display state if $show is not provided, the previous disply state if $show is provided.
     4414 *
    44124415 * @since 3.1.0
    44134416 */
    4414 function no_admin_bar() {
    4415     define('WP_SHOW_ADMIN_BAR', false);
    4416 }
     4417function show_admin_bar( $show = null ) {
     4418    static $show_admin_bar = null;
     4419
     4420    if ( !isset($show_admin_var) ) {
     4421        if ( null !== $show )
     4422            $show_admin_bar = $show;
     4423        elseif ( defined('WP_SHOW_ADMIN_BAR') )
     4424            $show_admin_bar = WP_SHOW_ADMIN_BAR;
     4425        else
     4426            $show_admin_bar = true;
     4427    }
     4428
     4429    if ( null == $show ) {
     4430        return $show_admin_bar;
     4431    } else {
     4432        $old_value = $show_admin_bar;
     4433        $show_admin_bar = $show;
     4434        return $old_value;
     4435    }
     4436}
Note: See TracChangeset for help on using the changeset viewer.