Make WordPress Core

Opened 8 weeks ago

Closed 8 weeks ago

Last modified 8 weeks ago

#62629 closed enhancement (fixed)

Begin HTML markup before Customizer script hooks

Reported by: sabernhardt's profile sabernhardt Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 6.8 Priority: normal
Severity: normal Version:
Component: Customize Keywords: has-patch
Focuses: Cc:

Description

Related: #62491

Styles and scripts that plugins might output in the admin_enqueue_scripts hook is added before the <!DOCTYPE> in the Customizer. The resulting potential for invalid HTML has existed at least as early as 5.0 (and likely back to [27907]).

Steps:

  1. Activate a classic theme, such as Twenty Twenty.
  2. Output a style or script tag in the admin_enqueue_scripts hook (sample code snippet) inside a (custom) plugin.
  3. Go to the Customizer.
  4. If your browser lets you view the full page source, check it to find your special tag before <!DOCTYPE>. If you can only use the inspect element tool, you will likely find your tag in the <head> (before the http-equiv meta).

Change History (4)

This ticket was mentioned in PR #7930 on WordPress/wordpress-develop by @sabernhardt.


8 weeks ago
#1

  • Keywords has-patch added

Prevents printing styles and scripts before the <!DOCTYPE>.

The _wp_admin_html_begin() function could precede Customizer script hooks, in case a plugin prints markup inside a hook such as admin_enqueue_scripts.

Trac 62629

#2 @SergeyBiryukov
8 weeks ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 59480:

Customize: Begin HTML markup before Customizer script hooks.

This prevents printing styles and scripts before the <!DOCTYPE>.

The _wp_admin_html_begin() function should precede Customizer script hooks, in case a plugin prints markup inside a hook such as admin_enqueue_scripts.

Follow-up to [19995], [27907].

Props sabernhardt.
Fixes #62629.

#3 @SergeyBiryukov
8 weeks ago

  • Milestone changed from Awaiting Review to 6.8

@SergeyBiryukov commented on PR #7930:


8 weeks ago
#4

Thanks for the PR! Merged in r59480.

Note: See TracTickets for help on using tickets.