This addresses a backward compatibility break where `posts_join_request` and other filters were applied, but their results were subsequently discarded and earlier values were used instead.
Follow-up to [52974], [53175].
Props 5um17, johnbillion, SergeyBiryukov.
Fixes#55699.
git-svn-id: https://develop.svn.wordpress.org/trunk@53370 602fd350-edb4-49c9-b593-d223f7449a82
While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names.
This commit:
* Renames the `$array` parameter to `$query_vars` in `WP_Query::fill_query_vars()`.
* Renames the `$default` parameter to `$default_value` in `WP_Query::get()`.
Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203], [53207], [53215], [53216], [53220], [53230], [53232], [53236], [53239], [53240], [53242], [53243], [53245], [53246], [53257], [53269], [53270], [53271], [53272], [53273], [53274], [53275], [53276].
Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #55327.
git-svn-id: https://develop.svn.wordpress.org/trunk@53277 602fd350-edb4-49c9-b593-d223f7449a82
This addresses a backward compatibility break where `posts_groupby` and other filters were applied, but their results were subsequently discarded and earlier values were used instead.
Follow-up to [52974].
Props nextend_ramona.
See #54728, #meta6273.
git-svn-id: https://develop.svn.wordpress.org/trunk@53175 602fd350-edb4-49c9-b593-d223f7449a82
Cache queries to the comments table in `WP_Query` for various comments feeds. Only comment IDs are stored for each feeds cache to avoid doubling up caching with each individual comment's cache.
Props spacedmonkey, boonebgorges, pbearne.
Fixes#36904.
git-svn-id: https://develop.svn.wordpress.org/trunk@53065 602fd350-edb4-49c9-b593-d223f7449a82
Ensure that the `posts_per_page` parameter submit to sticky post query matches the number of sticky posts requested.
Follow-up to [52982]
Props Spacedmonkey, peterwilsoncc.
See #36907.
git-svn-id: https://develop.svn.wordpress.org/trunk@52990 602fd350-edb4-49c9-b593-d223f7449a82
Reorder the parameters of the `get_posts()` call for consistency with similar calls elsewhere.
Follow-up to [52982].
See #36907.
git-svn-id: https://develop.svn.wordpress.org/trunk@52985 602fd350-edb4-49c9-b593-d223f7449a82
Ensure that the parameters `update_post_meta_cache`, `update_post_term_cache`, `cache_results`, `suppress_filters` and
`lazy_load_term_meta` that are passed to WP_Query, are also passed down to the secondary query used to get sticky
posts.
Props Spacedmonkey, peterwilsoncc, rehanali, uday17035.
Fixes#36907.
git-svn-id: https://develop.svn.wordpress.org/trunk@52982 602fd350-edb4-49c9-b593-d223f7449a82
This further improves the readability by replacing `implode()` calls with string interpolation.
Follow-up to [52973].
Props jrf.
See #54728.
git-svn-id: https://develop.svn.wordpress.org/trunk@52977 602fd350-edb4-49c9-b593-d223f7449a82
This aims to improve readability by fitting the values on a single screen to avoid horizontal scrolling.
See #54728.
git-svn-id: https://develop.svn.wordpress.org/trunk@52973 602fd350-edb4-49c9-b593-d223f7449a82
Previously, the queried object with author data was not available before the posts loop when `author_name` is used in the query instead of `author`. With block themes, this use case appears to be more common to display the author name in the header.
This commit adjusts the logic in `WP_Query::get_queried_object()` to fall back to the `author_name` field if `author` is not present, similar to how taxonomy slugs are handled.
Follow-up to [1728], [3290], [10992].
Props dd32, swissspidy, SergeyBiryukov.
Fixes#55100.
git-svn-id: https://develop.svn.wordpress.org/trunk@52822 602fd350-edb4-49c9-b593-d223f7449a82
* Document the post statuses global as an array of `stdClass` objects
* Document the taxonomies global as an array of `WP_Taxonomy` objects
* Document the return value of the post count functions as `stdClass` objects
* Fix some typos
See #53399
git-svn-id: https://develop.svn.wordpress.org/trunk@51885 602fd350-edb4-49c9-b593-d223f7449a82
This brings some consistency with other instances of using `get_post_stati()` in core.
`get_post_stati()` always returns an array, so the type casting is not needed.
Follow-up to [13172].
See #53359.
git-svn-id: https://develop.svn.wordpress.org/trunk@51285 602fd350-edb4-49c9-b593-d223f7449a82
When querying multiple post types, check the `read_private_posts` capability for each post type when determining which post statuses to return. This ensures private posts appear in search results and archives for users permitted to read them.
Props leogermani, hellofromTonya, jeffpaul, peterwilsoncc.
Fixes#48556.
git-svn-id: https://develop.svn.wordpress.org/trunk@51276 602fd350-edb4-49c9-b593-d223f7449a82
This avoids a "Trying to access array offset on value of type bool" PHP warning in `get_term_link()` if the `$rewrite` parameter of `register_taxonomy()` is set as `false`.
Props Tkama, SergeyBiryukov.
Fixes#52882.
git-svn-id: https://develop.svn.wordpress.org/trunk@50565 602fd350-edb4-49c9-b593-d223f7449a82
The modified checks of the `read_private_posts` capability could result in unexpected SQL queries when calling `WP_Query` with invalid parameters.
Reverts [49830], [49832] and [49833].
See #48556.
git-svn-id: https://develop.svn.wordpress.org/trunk@49899 602fd350-edb4-49c9-b593-d223f7449a82
After this change, the relevant `read_private_posts` capability is checked for
each queried post type. This ensures that private posts appear in search and
archive queries for users who have the ability to view those posts.
Props leogermani.
Fixes#13509, #48968, #48556.
git-svn-id: https://develop.svn.wordpress.org/trunk@49830 602fd350-edb4-49c9-b593-d223f7449a82
While many of these parameters also technically accept an array of numerical strings, they are all ultimately cast to an array of integers. Documenting them as such assists developers in understanding the expected types.
See #51800, #41756
git-svn-id: https://develop.svn.wordpress.org/trunk@49672 602fd350-edb4-49c9-b593-d223f7449a82
Using the canonical function name for PHP functions is strongly recommended, as aliases may be deprecated or removed without (much) warning.
This replaces all uses of the following:
* `join()` with `implode()`
* `sizeof()` with `count()`
* `is_writeable()` with `is_writable()`
* `doubleval()` with a `(float)` cast
In part, this is a follow-up to #47746.
Props jrf.
See #50767.
git-svn-id: https://develop.svn.wordpress.org/trunk@49193 602fd350-edb4-49c9-b593-d223f7449a82
PHP 8 changes the way string to number comparisons are performed: https://wiki.php.net/rfc/string_to_number_comparison
In particular, checking if an empty string is less than zero in PHP 8 evaluates to `true`, not `false`.
For `WP_Query`, this resulted in unintentionally returning a 404 error for most of front-end requests, instead of the relevant content.
By explicitly casting the value to `int`, we make sure to compare both values as numbers, rather than a string and a number.
Follow-up to [38288].
Props trepmal.
See #50913.
git-svn-id: https://develop.svn.wordpress.org/trunk@48960 602fd350-edb4-49c9-b593-d223f7449a82