Skip to content

Add API for stylesheet link tags - #14310

Closed
huubl wants to merge 1 commit into
WordPress:trunkfrom
huubl:huubl-stylesheet-link-api
Closed

huubl wants to merge 1 commit into
WordPress:trunkfrom
huubl:huubl-stylesheet-link-api

Conversation

@huubl

@huubl huubl commented Oct 15, 2026

Copy link
Copy Markdown

Adds wp_get_stylesheet_link_tag() and wp_print_stylesheet_link_tag() backed by WP_HTML_Tag_Processor, with the wp_style_attributes filter for applying attributes such as CSP nonces. Core stylesheet links now use the API across WP_Styles (including RTL/alternate output), concatenated admin styles, the wp_admin_css() fallback, locale and media-preview styles, compatibility markup, and Twenty Ten/Twenty Eleven (with older-Core fallbacks).

Raw URLs are passed to the tag processor for escaping and protocol checks. The legacy style_loader_tag and wp_admin_css filters remain in their existing order; style_loader_tag keeps its escaped $href argument. Concatenated output gets the new attribute filter once and does not newly invoke style_loader_tag.

Validation:

  • ./vendor/bin/phpunit tests/phpunit/tests/dependencies/wpStylesheetLinkTag.php - passed (6 tests, 7 assertions).
  • ./vendor/bin/phpunit tests/phpunit/tests/dependencies/styles.php - passed (84 tests, 209 assertions).
  • php -l on both stylesheet test files, targeted PHPCS on both test files, and git diff --check - passed.

Trac ticket: https://core.trac.wordpress.org/ticket/51325 (related context only; this is a separate external stylesheet-link follow-up, not a change to that ticket's inline-style scope).

Use of AI Tools

AI assistance: Yes
Tool(s): GitHub Copilot
Model(s): GPT-6 Luna
Used for: Architecture analysis, API implementation, Core call-site migration, and tests; reviewed and validated in the isolated WordPress Core worktree.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this PR. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Build external stylesheet links with WP_HTML_Tag_Processor and expose wp_style_attributes. Migrate Core stylesheet link emitters while preserving legacy filters and add API and integration coverage.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

huubl commented Oct 19, 2026

Copy link
Copy Markdown
Author

Closing in favor of three PRs, which split this change so that it can be committed in separate changesets, and incorporate feedback from #13250 and Core-51325:

The functions are renamed to wp_get_style_link_tag() and wp_print_style_link_tag(), as suggested on Core-51325. The markup passed to style_loader_tag and wp_admin_css is kept unchanged, a supplied id cannot be changed by the wp_style_attributes filter, and the branch is up to date with trunk.


Generated by Claude Code

@huubl huubl closed this Oct 19, 2026
@huubl
huubl deleted the huubl-stylesheet-link-api branch October 19, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant