Skip to content

Commit 68cd3bb

Browse files
authored
Improve Attachments class documentation (#2391)
1 parent 1a8c7fa commit 68cd3bb

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

includes/class-attachments.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ public static function delete_ap_posts_directory( $post_id ) {
5757
/**
5858
* Import attachments from an ActivityPub object and attach them to a post.
5959
*
60+
* Creates full WordPress attachment posts in the media library. Each attachment
61+
* becomes a searchable, manageable attachment post that appears in the WordPress
62+
* Media Library and is part of the user's content.
63+
*
64+
* Use this when:
65+
* - Importing content that will be owned and editable by the user.
66+
* - You need WordPress attachment posts with full metadata support.
67+
* - Media should be searchable and manageable in the Media Library.
68+
* - Working with content that will be part of the user's site (e.g., importers).
69+
*
6070
* @param array $attachments Array of ActivityPub attachment objects.
6171
* @param int $post_id The post ID to attach files to.
6272
* @param int $author_id Optional. User ID to set as attachment author. Default 0.
@@ -103,7 +113,17 @@ public static function import( $attachments, $post_id, $author_id = 0 ) {
103113
* Import attachments as direct files for posts.
104114
*
105115
* Saves files directly to uploads/activitypub/ap_posts/{post_id}/ without creating
106-
* WordPress attachment posts. Used for ActivityPub inbox items.
116+
* WordPress attachment posts. This lightweight approach is ideal for federated content
117+
* that doesn't require full WordPress media management.
118+
*
119+
* Files are stored in a dedicated directory structure and automatically cleaned up
120+
* when the parent post is deleted. Media URLs point directly to the stored files
121+
* rather than going through WordPress attachment APIs.
122+
*
123+
* Use this when:
124+
* - Processing ActivityPub Create/Update activities from the inbox.
125+
* - Handling federated content that won't be owned or edited by the user.
126+
* - You want lightweight storage without Media Library overhead.
107127
*
108128
* @param array $attachments Array of ActivityPub attachment objects.
109129
* @param int $post_id The post ID to attach files to.

0 commit comments

Comments
 (0)