Missing part of the admin bar rework. See #14772 props filosofo.
git-svn-id: https://develop.svn.wordpress.org/trunk@16043 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
c3a0a1919b
commit
c0c3167621
|
@ -4404,37 +4404,17 @@ function wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override = ar
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve or set the admin bar display state.
|
* Set the display status of the admin bar
|
||||||
*
|
*
|
||||||
* This can be called immediately upon plugin load. It does not need to be called from a function hooked to the init action.
|
* This can be called immediately upon plugin load. It does not need to be called from a function hooked to the init action.
|
||||||
*
|
*
|
||||||
* @param bool $show Optional. True to show the admin bar, false to hide it. If not provided the current display state is returned.
|
|
||||||
* @return bool The current display state if $show is not provided, the previous disply state if $show is provided.
|
|
||||||
*
|
|
||||||
* @since 3.1.0
|
* @since 3.1.0
|
||||||
|
*
|
||||||
|
* @param bool $show Whether to allow the admin bar to show.
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
function show_admin_bar( $show = null ) {
|
function show_admin_bar( $show ) {
|
||||||
static $show_admin_bar = null;
|
global $show_admin_bar;
|
||||||
|
$show_admin_bar = (bool) $show;
|
||||||
if ( !isset($show_admin_bar) ) {
|
|
||||||
if ( null !== $show )
|
|
||||||
$show_admin_bar = $show;
|
|
||||||
elseif ( defined('WP_SHOW_ADMIN_BAR') )
|
|
||||||
$show_admin_bar = WP_SHOW_ADMIN_BAR;
|
|
||||||
else
|
|
||||||
$show_admin_bar = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( null === $show ) {
|
|
||||||
return $show_admin_bar;
|
|
||||||
} else {
|
|
||||||
$old_value = $show_admin_bar;
|
|
||||||
$show_admin_bar = $show;
|
|
||||||
|
|
||||||
// Prevent rendering if already initiated.
|
|
||||||
if ( ! $show_admin_bar && isset( $GLOBALS['wp_admin_bar'] ) )
|
|
||||||
$GLOBALS['wp_admin_bar'] = null;
|
|
||||||
|
|
||||||
return $old_value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue