Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#24074 closed enhancement (worksforme)

Admin bar can provide redirect hook and home button

Reported by: godhulii_1985's profile godhulii_1985 Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.5.1
Component: Toolbar Keywords: ux-feedback ui-feedback
Focuses: Cc:

Description

If a wordpress theme uses wp_footer() then visiting the site will provide an admin bar at the top. I think the user experience for this bar can be extended considering these points:


Enable/Disable

# Despite lots of potential information in this bar, a theme owner may not want to see this in his site. So there should be an option in Dashboard > Settings to show/hide this.


Act as Home button

# Leftmost anchor element of this bar is site-name that redirects the user to http://example.com/wpurl/wp-admin. However there is another link just below it (Dashboard) that redirect to the same link.

This admin bar is always visible no matter how deep we scroll in a site. So lets assume, an user (say Bob) has scrolled down for 1000 lines. Then Bob wish to return to homepage. Facebook or other sites in this situation provide their site-logo on top-left to return to Home and allow pressing Home button in keyboard to go to top of the page. So the admin bar in this case can provide a link to return to: http://example.com/siteurl.

This way we will skip information duplication (the top-left and Dashboard both point to same location now), increase information efficiency and provide a consistent user experience with current trend.


Redirection on Logout

# The logout button works as follows: From http://example.com?p=111 page if Bob click on logout then Bob will be taken to http://example.com/wpurl/wp-login.php?action=logout. From here Bob have to click to back to Site-name link to return to homepage or type http://example.com?p=111 in address bar to return to this page. This is distracting for the user IMO.

This can be improved as if logout link append an extra parameter where to redirect the user (in this case window.location.href). This way the user will not be distracted from his interaction with the site.

So long story short: there should be a hook for the logout link in admin bar, taking input on where to redirect once Bob logout.


Right now I have implemented these in my site with this way:

if( is_user_logged_in() )
{
 var $logoutURL= $('#wp-admin-bar-logout a');
 $logoutURL.attr('href',$logoutURL.attr('href')+'&redirect_to='+window.location);

 $('#wp-admin-bar-site-name a').attr('href', get_bloginfo('siteurl') );
}

Thanks,
-S.

Change History (3)

#1 @SergeyBiryukov
12 years ago

  • Component changed from General to Toolbar

Despite lots of potential information in this bar, a theme owner may not want to see this in his site. So there should be an option in Dashboard > Settings to show/hide this.

There's an option in user profile:
http://core.trac.wordpress.org/browser/tags/3.5.1/wp-admin/user-edit.php#L224

There's also a function and a filter for theme and plugin developers:
http://codex.wordpress.org/Function_Reference/show_admin_bar
http://codex.wordpress.org/Plugin_API/Filter_Reference/show_admin_bar

Leftmost anchor element of this bar is site-name that redirects the user to ​http://example.com/wpurl/wp-admin. However there is another link just below it (Dashboard) that redirect to the same link.

This is intentional, see #19184.

This admin bar is always visible no matter how deep we scroll in a site. So lets assume, an user (say Bob) has scrolled down for 1000 lines. Then Bob wish to return to homepage.

This is partially implemented in #18758. A click on an empty area in Toolbar would take you to the top of the page.

The logout button works as follows: From ​http://example.com?p=111 page if Bob click on logout then Bob will be taken to ​http://example.com/wpurl/wp-login.php?action=logout. From here Bob have to click to back to Site-name link to return to homepage or type ​http://example.com?p=111 in address bar to return to this page. This is distracting for the user IMO.

The user needs a way to make sure the operation was successful, and the redirect to wp-login.php makes that explicit.

So long story short: there should be a hook for the logout link in admin bar, taking input on where to redirect once Bob logout.

The Toolbar uses wp_logout_url() function, which has logout_url filter:
http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/general-template.php#L199

You can use it this way to redirect back to the current page:

function redirect_on_logout_24074( $logout_url, $redirect ) {
	if ( empty( $redirect ) )
		$logout_url = add_query_arg( 'redirect_to', urlencode( $_SERVER['REQUEST_URI'] ), $logout_url );
	return $logout_url;
}
add_filter( 'logout_url', 'redirect_on_logout_24074', 10, 2 );

#2 @godhulii_1985
12 years ago

  • Resolution set to worksforme
  • Status changed from new to closed

Hello Sergey,

Thanks for making these points clear. I am changing the status to 'WorksForMe' :-)

Thanks,
-S.

#3 @SergeyBiryukov
12 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.