[wp-trac] [WordPress Trac] #38074: comments_template needs a filter for $top_level_args
WordPress Trac
noreply at wordpress.org
Fri Oct 2 16:32:25 UTC 2020
#38074: comments_template needs a filter for $top_level_args
-------------------------------------------------+-------------------------
Reporter: thomaslhotta | Owner:
| SergeyBiryukov
Type: enhancement | Status: reviewing
Priority: normal | Milestone: 5.6
Component: Comments | Version: 4.5
Severity: normal | Resolution:
Keywords: has-patch needs-testing needs-dev- | Focuses:
note needs-unit-tests |
-------------------------------------------------+-------------------------
Comment (by davidbaumwald):
Replying to [comment:9 Howdy_McGee]:
> Thanks @dream-encode for the latest patch!
>
> Via Test Scrub today:
> It sounds like the latest patch via Github looks good. We just want to
test the new filter against some basic dev and logical test cases.
Questions that need answers:
>
> - Are the reported use-case(s) for this filter valid?
I think so. When comments are paged, filtering
`comments_template_query_args` alone leads to a potential mismatch in the
`offset` parameter because there's a pre-query run to set the "top level"
comments arguments. This new filter allows for the `offset` to also take
into account any customizations to the main query the developer has in
mind.
As mentioned by the reporter, `WP_Comment_Query` can be filtered as a last
resort, and this new filter is a quality of life enhancement. I'd welcome
a discussion of an alternate approach.
> - Does this filter pass all the necessary variables to make it useful
for developers?
Yes. The `$top_level_args` parameter is an array of multiple variables,
including the post ID of the current post.
To test this in general, comments should be paged. Filter the
`comments_template_query_args` args with something other than the default,
filter the same arg in `comments_template_top_level_query_args`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/38074#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list