Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#33922 closed defect (bug) (duplicate)

login_enqueue_scripts and head placement

Reported by: tifosi's profile tifosi Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Script Loader Keywords: needs-testing has-patch
Focuses: Cc:

Description

According to the codex for the correct method is to enqueue the style with wp_enqueue_style linked to the login_enqueue_script action: https://codex.wordpress.org/Plugin_API/Action_Reference/login_enqueue_scripts

However this places the style in the body of the page just above the body tag. This is fine if you're queuing up a block of inline style, but not for a link element. Any styles won't be parsed until the page is loaded and any overriding css elements will cause jerky refresh issues.

If you're recommending this hook for login page scripts it needs a way to either differentiate the enqueued style i.e. link attr, or an argument such as for wp_enquque_scripts where in this case placement in the header is forced with a TRUE parameter.

There is a workaround as this stack exchange query details: http://wordpress.stackexchange.com/questions/127835/enqueue-a-stylesheet-for-login-page-and-make-it-appear-in-head-element

Thanks.

Attachments (1)

33922.diff (608 bytes) - added by diddledani 9 years ago.
Add filter on login_head to call wp_print_styles

Download all attachments as: .zip

Change History (5)

#1 @tifosi
9 years ago

  • Component changed from General to Login and Registration

#2 @johnbillion
9 years ago

  • Component changed from Login and Registration to Script Loader
  • Keywords needs-patch needs-testing added
  • Milestone changed from Awaiting Review to Future Release
  • Type changed from enhancement to defect (bug)
  • Version trunk deleted

Confirmed. Enqueuing scripts on this hook works as expected, but enqueuing styles results in the <link> tag being output in the footer.

@diddledani
9 years ago

Add filter on login_head to call wp_print_styles

#3 @diddledani
9 years ago

  • Keywords has-patch added; needs-patch removed

Explanation:

The print_late_styles() function was the only way styles were being printed to the login page. This meant that the queued items for the header were still in the queue as the queue hadn't been flushed yet. Adding a call to wp_print_styles() at login_head allows the head-specific styles to be flushed at the correct time.

#4 @SergeyBiryukov
9 years ago

  • Milestone Future Release deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #17916.

Note: See TracTickets for help on using tickets.