You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Deprecate/Remove the wp_theme_json_get_style_nodes filter #45172
Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.json[Type] Code QualityIssues or PRs that relate to code quality
Part of #45171 (an effort to maintain our codebase in a healthy state)
What
Remove the existing wp_theme_json_get_style_nodes filter.
Why
The wp_theme_json_get_style_nodes filter was introduced #41160 (different name back then) and allows consumers to hook into the implementation of the WP_Theme_JSON::get_style_nodes method.
It allows consumers to filter a private method of a private class, converting into public API something that was private.
Unlike the merge algorithm, how we read and process a theme.json is not part of the public API. We should be able to change the implementation if we find a performance bottleneck, for example. That we have at some point in time all the style nodes in one place is a very low-level detail that can change if we modify the parser. By exposing this implementation detail, we are creating the expectation that it won't ever change.
I wish I had had the opportunity to offer this feedback at the time it was created, but I was not. I still find this problematic, and I'd like us to act preemptively rather than reactively.
Could we move the apply_filters to these functions? And do we really need it in the latter function?
I'm more concerned with the fact that how we read a theme.json should be a private implementation detail, and the filter makes it public. Firing the filter from a public function doesn't solve the core issue.
The only place I see the filter being hooked into is in function wp_enqueue_global_styles()
Yeah, true in the realm of WordPress codebase. Though because it is a filter, anyone can potentially use it: plugins, themes, building tools, etc.
It's been almost 4 years since this issue. While the rationale still stands, I'm not sure this is longer a goal for us. I'm going to close, but happy if anyone wants to own/reopen it.
Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.json[Type] Code QualityIssues or PRs that relate to code quality
Activity
oandregal commentedon Oct 20, 2022
cc @scruffian @adamziel @draganescu @ramonjd as the original authors/reviewers of the PR.
I wish I had had the opportunity to offer this feedback at the time it was created, but I was not. I still find this problematic, and I'd like us to act preemptively rather than reactively.
ramonjd commentedon Oct 20, 2022
Looking at where
WP_Theme_JSON::get_style_nodesis called, it appears in two publicly declared functions:public function get_stylesheetpublic static function remove_insecure_propertiesCould we move the
apply_filtersto these functions? And do we really need it in the latter function?I'm not sure if it's in keeping with the intentions behind #41160
The only place I see the filter being hooked into is in
function wp_enqueue_global_styles()oandregal commentedon Oct 21, 2022
I'm more concerned with the fact that how we read a
theme.jsonshould be a private implementation detail, and the filter makes it public. Firing the filter from a public function doesn't solve the core issue.Yeah, true in the realm of WordPress codebase. Though because it is a filter, anyone can potentially use it: plugins, themes, building tools, etc.
jorgefilipecosta commentedon Jul 24, 2026
Hi @oandregal us this issue still valid and we should deprecate wp_theme_json_get_style_nodes ?
oandregal commentedon Jul 24, 2026
It's been almost 4 years since this issue. While the rationale still stands, I'm not sure this is longer a goal for us. I'm going to close, but happy if anyone wants to own/reopen it.