Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#34418 closed defect (bug) (fixed)

The Toolbar isn't displayed on wp-signup.php when you're logged-in.

Reported by: drewapicture's profile DrewAPicture Owned by: drewapicture's profile DrewAPicture
Milestone: 4.4 Priority: normal
Severity: normal Version:
Component: Login and Registration Keywords: has-screenshots has-patch commit
Focuses: Cc:

Description

The Toolbar doesn't get initialized and therefore doesn't get rendered on wp-signup.php when you're logged in.

This was actually a pretty cool bug to track down.

Turns out, the bug was introduced three years ago in [23512] when the _wp_admin_bar_init() callback was switched from the init hook to template_redirect and admin_init, respectively, to allow access to conditional tags for the show_admin_bar hook.

The template_redirect hook isn't fired on wp-signup.php because WP_USE_THEMES isn't defined.

Solution: We can't force template_redirect to fire on wp-signup.php because it'll actually try to load a template instead, so the best option is to hook to signup_header.

Attachments (2)

34418.diff (568 bytes) - added by DrewAPicture 8 years ago.
34418.2.diff (575 bytes) - added by DrewAPicture 8 years ago.

Download all attachments as: .zip

Change History (10)

@DrewAPicture
8 years ago

#1 @DrewAPicture
8 years ago

  • Keywords needs-testing added

#2 @adamsilverstein
8 years ago

  • Keywords dev-feedback has-screenshots added; needs-testing removed

I tested this patch and it works as promised.

Here are some screenshots visiting wp-signup.php as a logged in user:

Before patch:
http://cl.ly/image/1M3F1d0V1r1i/Test_Site__Just_another_WordPress_site_2015-10-23_15-41-03.jpg

After patch:
http://cl.ly/image/1o2x2x3n3M1i/Test_Site__Just_another_WordPress_site_2015-10-23_15-40-03.jpg

#3 @iamtakashi
8 years ago

As I see in the screenshot above, the admin bar is overlapping the page. To make the admin bar displayed correctly, the sign up page needs to have the top margin added by _admin_bar_bump_cb() as other pages.

https://core.trac.wordpress.org/browser/trunk/src/wp-includes/admin-bar.php#L864

Last edited 8 years ago by iamtakashi (previous) (diff)

#4 @johnbillion
8 years ago

  • Keywords needs-patch added; has-patch dev-feedback removed

@DrewAPicture
8 years ago

#5 @DrewAPicture
8 years ago

  • Keywords has-patch commit added; needs-patch removed
  • Owner set to DrewAPicture
  • Status changed from new to accepted

34418.2.diff instead uses the before_signup_header hook. This enables the _wp_admin_bar_init() function to run before wp_head fires like it does elsewhere on the front-end on template_redirect or in the admin on admin_init. This has the effect that _admin_bar_bump_cb() can then fire on wp_head in the expected order.

This ticket was mentioned in Slack in #core by drew. View the logs.


8 years ago

#7 @DrewAPicture
8 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 35423:

Multisite: Restore displaying the Toolbar on wp-signup.php while logged-in.

Prior to [23512], the Toolbar was still displayed on wp-signup.php while logged-in because it was hooked to the init action. When _wp_admin_bar_init() was moved to instead fire on template_redirect for the front-end and admin_init on the back-end, the visibility was lost because template_redirect isn't fired on wp-signup.php due to WP_USE_THEMES not being defined.

In order to maintain expected display results, a default filter has been added to hook _wp_admin_bar_init() to the before_signup_header action. This approach has the added benefit of allowing _wp_admin_bar_init() to be fired prior to the wp_head action where _admin_bar_bump_cb() is called (or the callback defined when 'admin-bar' theme support is added).

Fixes #34418.

#8 @DrewAPicture
8 years ago

In 35449:

Multisite: Restore display of the Toolbar on wp-activate.php while logged-in.

Just as with wp-signup.php, display of the Toolbar on wp-activate.php was broken in [23512] due to a hook change for the _wp_admin_bar_init() callback. wp-signup.php was fixed in [35423] for #34418.

See [35423] for more in-depth background and reasoning behind restoring display of the Toolbar on wp-activate.php and wp-signup.php.

Fixes #34496. See #34418.

Note: See TracTickets for help on using tickets.