PluginProbe
ActivityPub / 3.2.4
ActivityPub v3.2.4
9.3.1 9.3.0 9.2.2 9.2.1 9.2.0 9.1.0 9.0.2 9.0.1 9.0.0 8.3.0 8.2.1 8.2.0 8.1.1 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.2.0 1.3.0 2.0.0 2.0.1 2.1.0 2.1.1 All 160 releases
← All changes | includes/transformer/class-attachment.php +9 -20 9.2.2 → 3.2.4 View file →
@@ -1,15 +1,11 @@
1 1 <?php
2 -/**
3 - * Attachment Transformer Class file.
4 - *
5 - * @package Activitypub
6 - */
2 +namespace Activitypub\Transformer;
7 3
8 -namespace Activitypub\Transformer;
4 +use Activitypub\Transformer\Post;
9 5
10 6 /**
11 - * WordPress Attachment Transformer.
7 + * WordPress Attachment Transformer
12 8 *
13 9 * The Attachment Transformer is responsible for transforming a WP_Post object into different other
14 10 * Object-Types.
15 11 *
@@ -15,12 +11,8 @@
15 11 *
16 12 * Currently supported are:
17 13 *
18 14 * - Activitypub\Activity\Base_Object
19 - *
20 - * Redaction is inherited from {@see Post::is_redacted()}: `is_post_publicly_queryable()`
21 - * already resolves an attachment's own visibility, password, post-type support, and — for
22 - * attached media — its parent's visibility, so no attachment-specific override is needed.
23 15 */
24 16 class Attachment extends Post {
25 17 /**
26 18 * Generates all Media Attachments for a Post.
@@ -27,18 +19,15 @@
27 19 *
28 20 * @return array The Attachments.
29 21 */
30 22 protected function get_attachment() {
31 - $mime_type = \get_post_mime_type( $this->item->ID );
32 - $mime_type_parts = \explode( '/', $mime_type );
33 - $type = '';
23 + $mime_type = get_post_mime_type( $this->wp_object->ID );
24 + $media_type = preg_replace( '/(\/[a-zA-Z]+)/i', '', $mime_type );
34 25
35 - switch ( $mime_type_parts[0] ) {
26 + switch ( $media_type ) {
36 27 case 'audio':
37 - $type = 'Audio';
38 - break;
39 28 case 'video':
40 - $type = 'Video';
29 + $type = 'Document';
41 30 break;
42 31 case 'image':
43 32 $type = 'Image';
44 33 break;
@@ -45,13 +34,13 @@
45 34 }
46 35
47 36 $attachment = array(
48 37 'type' => $type,
49 - 'url' => \wp_get_attachment_url( $this->item->ID ),
38 + 'url' => wp_get_attachment_url( $this->wp_object->ID ),
50 39 'mediaType' => $mime_type,
51 40 );
52 41
53 - $alt = \get_post_meta( $this->item->ID, '_wp_attachment_image_alt', true );
42 + $alt = \get_post_meta( $this->wp_object->ID, '_wp_attachment_image_alt', true );
54 43 if ( $alt ) {
55 44 $attachment['name'] = $alt;
56 45 }
57 46