Meta: Add support for site meta in get_object_subtype()#12612
Meta: Add support for site meta in get_object_subtype()#12612SainathPoojary wants to merge 4 commits into
Conversation
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. |
There was a problem hiding this comment.
Pull request overview
This PR extends the metadata API’s get_object_subtype() to recognize multisite “site meta” objects (meta type 'blog'), enabling subtype-aware behavior for site meta and adding PHPUnit coverage for the new behavior.
Changes:
- Add a
'blog'branch toget_object_subtype()that returns'blog'for valid sites on multisite installs. - Update meta registration tests to create/delete a site in multisite and add new multisite-only assertions for blog/site subtype handling.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/wp-includes/meta.php |
Adds 'blog' handling to get_object_subtype() by checking multisite and validating the site via get_site(). |
tests/phpunit/tests/meta/registerMeta.php |
Adds multisite setup/teardown for a created site and new tests targeting subtype behavior for 'blog' meta. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| case 'blog': | ||
| if ( ! is_multisite() ) { | ||
| break; | ||
| } | ||
|
|
||
| $site = get_site( $object_id ); | ||
| if ( ! $site ) { | ||
| break; | ||
| } |
| public function test_get_object_subtype_for_blog_returns_empty_string_for_invalid_site() { | ||
| $this->assertSame( '', get_object_subtype( 'blog', 999999 ) ); | ||
| } |
| * Returns the object subtype for a given object ID of a specific type. | ||
| * | ||
| * @since 4.9.8 | ||
| * @since 6.X.0 Added support for 'blog' object type in multisite. | ||
| * |
Trac ticket: #44387