Ticket #14772: show_admin_bar.diff
File show_admin_bar.diff, 1.5 KB (added by , 13 years ago) |
---|
-
wp-includes/functions.php
4404 4404 } 4405 4405 4406 4406 /** 4407 * Retrieve or set the admin bar display state.4407 * Set the display status of the admin bar 4408 4408 * 4409 4409 * This can be called immediately upon plugin load. It does not need to be called from a function hooked to the init action. 4410 4410 * 4411 * @param bool $show Optional. True to show the admin bar, false to hide it. If not provided the current display state is returned.4412 * @return bool The current display state if $show is not provided, the previous disply state if $show is provided.4413 *4414 4411 * @since 3.1.0 4412 * 4413 * @param bool $show Whether to allow the admin bar to show. 4414 * @return void 4415 4415 */ 4416 function show_admin_bar( $show = null ) { 4417 static $show_admin_bar = null; 4418 4419 if ( !isset($show_admin_bar) ) { 4420 if ( null !== $show ) 4421 $show_admin_bar = $show; 4422 elseif ( defined('WP_SHOW_ADMIN_BAR') ) 4423 $show_admin_bar = WP_SHOW_ADMIN_BAR; 4424 else 4425 $show_admin_bar = true; 4426 } 4427 4428 if ( null === $show ) { 4429 return $show_admin_bar; 4430 } else { 4431 $old_value = $show_admin_bar; 4432 $show_admin_bar = $show; 4433 4434 // Prevent rendering if already initiated. 4435 if ( ! $show_admin_bar && isset( $GLOBALS['wp_admin_bar'] ) ) 4436 $GLOBALS['wp_admin_bar'] = null; 4437 4438 return $old_value; 4439 } 4416 function show_admin_bar( $show ) { 4417 global $show_admin_bar; 4418 $show_admin_bar = (bool) $show; 4440 4419 } 4420