Add support for Mastodon FeaturedCollection import#3168
Merged
Conversation
Add FeaturedItem handling to object_to_uri() so the Starter Kit importer can process both the Pixelfed starter-kit format and the Mastodon FEP FeaturedCollection format transparently. Also validates collection type on import, resolves images via object_to_uri() for format-agnostic URL extraction, and shows actor display names when available in the import UI.
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds support for importing Starter Packs in both Pixelfed “starter-kit” and Mastodon FEP “FeaturedCollection” formats, including FeaturedItem handling and improved UI output.
Changes:
- Extend
object_to_uri()to resolve MastodonFeaturedItemobjects. - Validate imported JSON
typeas a Collection-like type (supports multi-type arrays). - Make image URL extraction format-agnostic and show actor display names in the selection UI.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/phpunit/tests/includes/class-test-functions-activity.php | Adds test cases for FeaturedItem URI extraction. |
| includes/wp-admin/import/class-starter-kit.php | Updates importer UI (image + actor display name) and validates starter kit collection types. |
| includes/functions-activity.php | Adds FeaturedItem handling in object_to_uri(). |
| .github/changelog/3168-from-description | Adds changelog entry for the new import support. |
Fall back to url, then href, then null when an object has no id property. This prevents PHP notices when processing objects like images that may only have a url or href.
The test expected a PHP notice when actor has no id field. Now that object_to_uri() returns null gracefully instead of triggering a notice, the test asserts the correct behavior: not blocked.
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.
Proposed changes:
FeaturedItemtype handling toobject_to_uri()so the Starter Kit importer transparently supports both the Pixelfed starter-kit format and the Mastodon FEP FeaturedCollection format.typeon import (acceptsCollection,OrderedCollection, andFeaturedCollection, including multi-type arrays).object_to_uri()for format-agnostic URL extraction (handles both{ "url": "..." }and{ "url": { "type": "Link", "href": "..." } }).Other information:
Testing instructions:
type: CollectionandPersonitems) — should work as before.type: FeaturedCollectionandFeaturedItementries containingfeaturedObject) — actors should be correctly extracted and listed.type(e.g.Note) — should show an error message.Changelog entry
Changelog Entry Details
Significance
Type
Message
Add support for importing Starter Packs in both the Pixelfed and Mastodon formats.