Skip to content

Scripts and styles enqueued before wp_enqueue_scripts fail to get sources identified #4133

@westonruter

Description

@westonruter

Bug Description

Scripts and stylesheets enqueued at init do not get sourcing information. The same goes for assets registered at wp_default_styles and wp_scripts.

See demo plugin which demonstrates the issue.

(Additionally, inline styles added via wp_add_inline_style() do not get their source attributed.)

The wp-includes source is erroneous for 2 scripts and 3 stylesheets shown on the page.

Related: #4134

Expected Behaviour

The source column should indicate the theme/plugin that is actually responsible for the style or script being added to the page.

The case of the inline stylesheet is a tricky one, since it is one stylesheet with multiple sources. At the very least it should have the same source information as the stylesheet it is being added inline for. Best case is for it to include all themes/plugins that added inline styles to it.

Steps to reproduce

  1. Enable Standard or Transitional mode in the AMP plugin.
  2. Activate the above plugin
  3. Validate a page.
  4. Notice the wp-includes mentioned unexpectedly.

Screenshots

When active (and #4026 checked out) the validated URL screen looks like the following, with the red entries erroneously saying they are from wp-includes when they should actually be from “Add Assets before wp_enqueue_scripts”.

72671921-d66e7780-3a06-11ea-8135-d2f12e3dc6b5

Additional context

  • WordPress version:
  • Plugin version:
  • Gutenberg plugin version (if applicable):
  • AMP plugin template mode:
  • PHP version:
  • OS:
  • Browser: [e.g. chrome, safari]
  • Device: [e.g. iPhone6]

Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

Implementation brief

  • This may be resolved simply by adding the validation hooks earlier. Origination is also a solution, perhaps long-term.

QA testing instructions

Demo

Changelog entry

Metadata

Metadata

Labels

BugSomething isn't workingCSS

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions