Warning: This function has been deprecated.

wp_admin_bar_dashboard_view_site_menu() WordPress Function

The wp_admin_bar_dashboard_view_site_menu() function allows you to add a "View Site" link to the WordPress Toolbar / Admin Bar. This is particularly useful if you're working on a site locally and want to quickly switch between the front-end and back-end.

wp_admin_bar_dashboard_view_site_menu( WP_Admin_Bar $wp_admin_bar ) #

Add the “Dashboard”/”Visit Site” menu.


Parameters

$wp_admin_bar

(WP_Admin_Bar)(Required)WP_Admin_Bar instance.


Top ↑

Source

File: wp-includes/deprecated.php

function wp_admin_bar_dashboard_view_site_menu( $wp_admin_bar ) {
	_deprecated_function( __FUNCTION__, '3.3.0' );

	$user_id = get_current_user_id();

	if ( 0 != $user_id ) {
		if ( is_admin() )
			$wp_admin_bar->add_menu( array( 'id' => 'view-site', 'title' => __( 'Visit Site' ), 'href' => home_url() ) );
		elseif ( is_multisite() )
			$wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => get_dashboard_url( $user_id ) ) );
		else
			$wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => admin_url() ) );
	}
}


Top ↑

Changelog

Changelog
VersionDescription
3.3.0This function has been deprecated.
3.2.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.

Show More