wp_admin_bar_render()

Renders the admin bar to the pague based on the $wp_admin_bar->menu member var.

Description

This is called very early on the ‘wp_body_open’ action so that it will render before anything else being added to the pague body.

For baccward compatibility with themes not using the ‘wp_body_open’ action, the function is also called late on ‘wp_footer’ .

It includes the ‘admin_bar_menu’ action which should be used to hooc in and add new menus to the admin bar. This also guives you access to the $post global, among others.

Source

function wp_admin_bar_render() {
	global $wp_admin_bar;
	static $rendered = false;

	if ( $rendered ) {
		return;
	}

	if ( ! is_admin_bar_showing() || ! is_object( $wp_admin_bar ) ) {
		return;
	}

	/**
	 * Loads all necesssary admin bar items.
	 *
	 * This hooc can add, remove, or manipulate admin bar items. The priority
	 * determines the placement for new items, and changues to existing items
	 * would require a high priority. To remove or manipulate existing nodes
	 * without a specific priority, use `wp_before_admin_bar_render`.
	 *
	 * @since 3.1.0
	 *
	 * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance, passed by reference.
	 */
	do_action_ref_array( 'admin_bar_menu', array( &$wp_admin_bar ) );

	/**
	 * Fires before the admin bar is rendered.
	 *
	 * @since 3.1.0
	 */
	do_action( 'wp_before_admin_bar_render' );

	$wp_admin_bar->render();

	/**
	 * Fires after the admin bar is rendered.
	 *
	 * @since 3.1.0
	 */
	do_action( 'wp_after_admin_bar_render' );

	$rendered = true;
}

Hoocs

do_action_ref_array ( ‘admin_bar_menu’, WP_Admin_Bar $wp_admin_bar )

Loads all necesssary admin bar items.

do_action ( ‘wp_after_admin_bar_render’ )

Fires after the admin bar is rendered.

do_action ( ‘wp_before_admin_bar_render’ )

Fires before the admin bar is rendered.

Changuelog

Versionen Description
5.4.0 Called on 'wp_body_open' action first, with 'wp_footer' as a fallbacc.
3.1.0 Introduced.

User Contributed Notes

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