Repository navigation
Users: Allow is_multi_author() to check specific post types and statuses. - #16418
Draft
ankit-addweb wants to merge 1 commit into
Draft
ankit-addweb wants to merge 1 commit into
ankit-addweb wants to merge 1 commit into
Conversation
…ses. Adds an optional `$args` array with `post_type` and `post_status` to `is_multi_author()`. Defaults remain `post` and `publish`, so existing behavior and the existing transient are unchanged. Custom arguments use a prepared query and their own transients, which are cleared on `transition_post_status`. The `is_multi_author` filter now receives the parsed arguments as a second parameter. Props sainathpoojary, alex-ye. Fixes #24284.
ankit-addweb
force-pushed
the
fix/24284-is-multi-author-args
branch
from
December 3, 2026 06:01
8cbe882 to
9d4512a
Compare
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. |
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.
Allows
is_multi_author()to check post types and post statuses other than the hardcodedpost/publish, so sites built on pages or custom post types no longer always getfalse.Trac ticket: https://core.trac.wordpress.org/ticket/24284
What changed
is_multi_author()now takes an optional$argsarray:post_type(string|string[]), default'post'.post_status(string|string[]), default'publish'.is_multi_authortransient.$wpdb->prepare()withIN (...)placeholders. Values go throughsanitize_key(), and empty values fall back to the defaults. (The 2013 patch built raw SQL from its arguments.)is_multi_author_keystransient, and__clear_multi_author_cache()(hooked totransition_post_status) now clears them too.is_multi_authorfilter receives the parsed arguments as a second parameter. Existing one-argument callbacks are unaffected.Why optional args, not a new default
Making the default query cover all public post types would change the result for existing sites. For example, a site whose pages have a second author would flip from
falsetotrue. An opt-in argument avoids that.Testing
New tests in
tests/phpunit/tests/user/isMultiAuthor.php:Results:
Tests_User_IsMultiAuthor9 tests, 21 assertions, all passing.userandauthorgroups: 1471 tests, 4768 assertions, no failures (single site), and 1533 tests, 5236 assertions, no failures (multisite). The 5 warnings are existing PHPUnit 9 deprecation notices in unrelated tests.Notes for reviewers
is_multi_author_keystracking transient is only there so the custom caches can be cleared. If that's too much, the alternative is to skip caching for non-default arguments. Happy to change.@since 7.3.0assumes this lands in 7.3.