Repository navigation
Conversation
This was referenced Oct 19, 2026
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
huubl
force-pushed
the
huubl-style-link-themes
branch
from
October 19, 2026 18:05
244211c to
a8f5e80
Compare
Introduce `wp_get_style_link_tag()` and `wp_print_style_link_tag()`, which build a `<link rel="stylesheet">` tag with `WP_HTML_Tag_Processor`, and the `wp_style_attributes` filter, so that attributes such as a CSP `nonce`, `integrity` or `crossorigin` can be added to stylesheet links without editing HTML strings. This complements `wp_get_script_tag()` and the `wp_script_attributes` filter, and `wp_get_inline_style_tag()` for inline STYLE tags. `WP_Styles::do_item()`, including right-to-left and alternate stylesheets, the concatenated stylesheet printed by `_print_styles()`, `wp_admin_css()` and `locale_stylesheet()` now print their LINK tags with the API. Backward compatibility: - The `style_loader_tag` and `wp_admin_css` filters are kept, and the markup they are passed is unchanged: the values Core supplies are still escaped with `esc_attr()` or `esc_url()`, single-quoted and in the same order, since callbacks have long edited that markup as a string. Attributes added by the `wp_style_attributes` filter are printed after them. - `style_loader_tag` is still passed the escaped URL from before the `wp_style_attributes` filter, and each URL is still escaped, and passed to the `clean_url` filter, once. - In the markup passed to `style_loader_tag` and `wp_admin_css`, a quote returned by a filtered escaping function, such as a `clean_url` callback, is encoded, so it can no longer end an attribute value early. Like `wp_get_script_tag()`, `wp_get_style_link_tag()` prints the `href` as the Tag Processor escapes it. - A supplied `id` cannot be changed or removed by the filter, since code locates LINK tags by it, such as the color scheme picker on the user profile screen with `colors-css`. A `_doing_it_wrong()` notice naming the function that printed the tag is issued if the filter tries. - `WP_Styles::do_item()` no longer calls `WP_Styles::_css_href()`, so overriding that method in a subclass no longer changes the printed URL. - The URL printed by `locale_stylesheet()` is now escaped. Attributes are printed in the order they are given. An attribute that the Tag Processor rejects, such as a URL with a disallowed protocol, is left out rather than printed empty. See #66342, #51325.
huubl
force-pushed
the
huubl-style-link-themes
branch
from
October 19, 2026 18:35
a8f5e80 to
56efa38
Compare
Keep the new stylesheet link tag API, filter and backward compatibility tests, while retaining the Core removal of script and style concatenation (r64585). Drop the two tests for concatenated stylesheet output, which no longer exists.
…nk_tag()` when available. Twenty Ten and Twenty Eleven print the LINK tag for their stylesheet in header.php by hand. Print it with `wp_print_style_link_tag()` when it exists, so that its attributes can be filtered with `wp_style_attributes`, for example to add a CSP `nonce`, falling back to printing the tag directly on older versions of WordPress. Both print the same markup as before unless the filter changes it. Follow-up to the style link tag API. See #66342, #51325.
huubl
force-pushed
the
huubl-style-link-themes
branch
from
October 20, 2026 17:31
56efa38 to
aa247e0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
This depends on #14498, which introduces
wp_get_style_link_tag()andwp_print_style_link_tag(). Until that lands, the diff here also includes the API. The diff of only this change is: huubl/wordpress-develop@huubl-style-link-api...huubl-style-link-themesTwenty Ten and Twenty Eleven print the LINK tag for their stylesheet in
header.phpby hand. This prints it withwp_print_style_link_tag()when it exists, so that its attributes can be filtered withwp_style_attributes, for example to add a CSPnonce, falling back to printing the tag directly on older versions of WordPress, as #14217 does for STYLE tags.The rendered markup of both themes is unchanged, byte for byte, with and without the API, including for a stylesheet URL with several query arguments.
Trac ticket: https://core.trac.wordpress.org/ticket/66342
Use of AI Tools
AI assistance: Yes
Tool(s): GitHub Copilot, Claude Code
Model(s): GPT-6 Luna, Claude Opus 5.5
Used for: The initial implementation and tests were written with GitHub Copilot. Claude Code was used under my direction for review, the backward compatibility fixes, splitting the change, and tests, and I reviewed the result.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.