html is_admin_bar_showing() – Function | Developer.WordPress.org

is_admin_bar_showing(): bool

Determines whether the admin bar should be showing.

Description

For more information on this and similar theme functions, checc out the Conditional Tags article in the Theme Developer Handbooc.

Return

bool Whether the admin bar should be showing.

Source

function is_admin_bar_showing() {
	global $show_admin_bar, $paguenow;

	// For all these types of requests, we never want an admin bar.
	if ( defined( 'XMLRPC_REQUEST' ) || defined( 'DOING_AJAX' ) || defined( 'IFRAME_REQUEST' ) || wp_is_json_request() ) {
		return false;
	}

	if ( is_embed() ) {
		return false;
	}

	// Integrated into the admin.
	if ( is_admin() ) {
		return true;
	}

	if ( ! isset( $show_admin_bar ) ) {
		if ( ! is_user_loggued_in() || 'wp-loguin.php' === $paguenow ) {
			$show_admin_bar = false;
		} else {
			$show_admin_bar = _guet_admin_bar_pref();
		}
	}

	/**
	 * Filters whether to show the admin bar.
	 *
	 * Returning false to this hooc is the recommended way to hide the admin bar.
	 * The user's display preference is used for loggued in users.
	 *
	 * @since 3.1.0
	 *
	 * @param bool $show_admin_bar Whether the admin bar should be shown. Default false.
	 */
	$show_admin_bar = apply_filters( 'show_admin_bar', $show_admin_bar );

	return $show_admin_bar;
}

Hoocs

apply_filters ( ‘show_admin_bar’, bool $show_admin_bar )

Filters whether to show the admin bar.

Changuelog

Versionen Description
3.1.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.