Make WordPress Core

Opened 4 years ago

Last modified 2 years ago

#48831 new enhancement

WP Admin Bar doesn't display on wp-login.php page

Reported by: henrywright's profile henry.wright Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Toolbar Keywords: has-patch
Focuses: Cc:

Description (last modified by sabernhardt)

I like to display the WP Admin Bar on all pages even if a user isn't authenticated because we get the WordPress logo and menu and a search button. To always show the WP Admin Bar we can do this:

add_filter( 'show_admin_bar', '__return_true' );

This will display it everywhere except wp-login.php. I think it _should_ display on this page if we return true in the filter

Attachments (3)

48831.diff (1.5 KB) - added by donmhico 4 years ago.
48831.2.diff (2.2 KB) - added by donmhico 4 years ago.
With CSS fix.
48831.3.diff (2.0 KB) - added by sabernhardt 2 years ago.
check that filter returns true and that the page is not an interim login

Download all attachments as: .zip

Change History (13)

#1 @henry.wright
4 years ago

I think it _should_ display on this page if we return true in show_admin_bar()

I can't edit the ticket description but I should have said:

I think it _should_ display on this page if we return true in the filter.

#2 @henry.wright
4 years ago

  • Component changed from General to Toolbar

#3 @henry.wright
4 years ago

This is because wp-login.php uses a different set of hooks. login_header and login_footer are used instead of wp_head and wp_footer

@donmhico
4 years ago

#4 @donmhico
4 years ago

  • Type changed from defect (bug) to enhancement

@donmhico
4 years ago

With CSS fix.

#5 @donmhico
4 years ago

Hello @henrywright,

I attached a patch, https://core.trac.wordpress.org/attachment/ticket/48831/48831.2.diff, that should address this ticket.

P.S. - I changed this ticket from bug to enhancement as I feel that this is more of an enhancement.

#6 @donmhico
4 years ago

  • Keywords has-patch added

#7 @SergeyBiryukov
4 years ago

I like to display the WP Admin Bar on all pages even if a user isn't authenticated because we get the WordPress logo and menu and a search button.

Just noting there's a Logged Out Admin Bar plugin used on WordPress.org for that purpose, though it doesn't display the toolbar on the login page either.

#8 @henry.wright
4 years ago

@donmhico I think you are right to set this to an enhancement. It isn't really a bug

Thanks @SergeyBiryukov

#9 @sabernhardt
2 years ago

  • Description modified (diff)

@sabernhardt
2 years ago

check that filter returns true and that the page is not an interim login

#10 @sabernhardt
2 years ago

Latest iteration: 48831.3.diff

I moved the actions into wp-login.php so it checks whether the filter returns true (not every case of showing toolbar). The toolbar also does not fit in an interim login.

For the CSS, I prefer resetting form element styles along with the links, and the search input min-height matches the height. The html element includes an admin-bar class so the full height layout can subtract the toolbar height from 100% (using the new custom property).

Note: See TracTickets for help on using tickets.