Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

_wp_admin_bar_init() WordPress Function

The wp_admin_bar_init() function is used to initialize the WordPress admin bar. This function is called by the admin_init action hook.

_wp_admin_bar_init() #

Instantiates the admin bar object and set it up as a global for access elsewhere.


Description

UNHOOKING THIS FUNCTION WILL NOT PROPERLY REMOVE THE ADMIN BAR. For that, use show_admin_bar(false) or the ‘show_admin_bar’ filter.


Top ↑

Return

(bool) Whether the admin bar was successfully initialized.


Top ↑

Source

File: wp-includes/admin-bar.php

function _wp_admin_bar_init() {
	global $wp_admin_bar;

	if ( ! is_admin_bar_showing() ) {
		return false;
	}

	/* Load the admin bar class code ready for instantiation */
	require_once ABSPATH . WPINC . '/class-wp-admin-bar.php';

	/* Instantiate the admin bar */

	/**
	 * Filters the admin bar class to instantiate.
	 *
	 * @since 3.1.0
	 *
	 * @param string $wp_admin_bar_class Admin bar class to use. Default 'WP_Admin_Bar'.
	 */
	$admin_bar_class = apply_filters( 'wp_admin_bar_class', 'WP_Admin_Bar' );
	if ( class_exists( $admin_bar_class ) ) {
		$wp_admin_bar = new $admin_bar_class;
	} else {
		return false;
	}

	$wp_admin_bar->initialize();
	$wp_admin_bar->add_menus();

	return true;
}


Top ↑

Changelog

Changelog
VersionDescription
3.1.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.