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.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement core template loader overrides to rely on wp_template posts #17626
Implement core template loader overrides to rely on wp_template posts #17626
Changes from all commits
c1e61ec
fc183d4
91df716
afb6604
ee46ef5
b9864ea
27eb0f2
7bdcd6d
8f1529a
960b555
d3ddc40
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When will this ever run more than once and require this merging?
And what guarantees subsequent runs pass
$templates
where the first item is of lesser priority than the last item of the current$_wp_current_template_hierarchy
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on how core's template loader works, this may be run multiple times (e.g.
get_index_template()
being called after anotherget_*_template()
function). As well based on core, the functions are called in the correct hierarchy order (more specific come first), so it will always be correct regarding priority.Note that this is only a layer to make it work in the plugin anyway. Most likely, if/when this gets merged into core, it would be more directly integrated with the existing template loader code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why only
wptexturize()
? Should there rather be a new filter applied likewp_template_content
which then can have filters as core applies:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be very useful for theme devs.
cc @youknowriad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is worth a discussion, actually about two things:
Regarding 1., I would prefer to start without one and only introduce it based on requests that are reasonable. The
the_content
filter is mostly misused to append/prepend additional content, which in a block-based world becomes unnecessary - having awp_template_content
being misused in the same way would most likely introduce broader issues (since it covers the entire page markup).Regarding 2., I think some of the filter functions definitely don't make sense for
wp_template
content (e.g.prepend_attachment
). Others we need to discuss further (like do we want to deal with shortcodes at all in this?).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with your points for
1
.I am not familiar enough with these filters to comment about
2
. Maybe we should ping more people who worked on them?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the WP.com implementation of Full Site Editing templates we noticed that we had to run several filters on the template content.
We basically started adding them manually whenever we caught an issue, but then basically added all of them (see for example the useless
prepend_attachment
that I added—thanks for pointing it out @felixarntz! 😅) to save us headaches.For example, I vividly recall how
wp_make_content_images_responsive
almost single-handedly fixed all image related issue we were having.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Copons, I just found that code as well and wanted to comment here, but you beat me to it. :)
Based on that and your comment, I think what we should add to this PR for now are the following:
$wp_embed->run_shortcode( $content )
$wp_embed->autoembed( $content )
wp_make_content_images_responsive( $content )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is in
the_content()
but why is it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's because
wptexturize
doesn't handle that specific case?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary? Couldn't the
body
be used instead of.wp-site-blocks
? Alternatively, thewp-site-blocks
class could be added to thebody_classes
when a block-based template is being served as opposed to a PHP-based template.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
body
will also stylewp_footer
content.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, in a way I agree it'd be nicer to not have this extra div, but the way many themes handle design rules for block content is to use a selector like
.{blocks-wrap-class} > *
, which would indeed stylewp_footer
content that it shouldn't apply to.I'd say let's be conservative for now and start with this div. We should definitely continue to look for an alternative solution though that satisfies the styling needs.