PluginProbe
ActivityPub / 7.7.0
ActivityPub v7.7.0
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/collection/class-replies.php +12 -12 9.2.0 → 7.7.0 View file →
@@ -13,9 +13,9 @@
13 13 use Activitypub\Transformer\Post as Post_Transformer;
14 14
15 15 use function Activitypub\get_rest_url_by_path;
16 16 use function Activitypub\is_local_comment;
17 -use function Activitypub\is_post_publicly_queryable;
17 +use function Activitypub\is_post_disabled;
18 18 use function Activitypub\is_user_type_disabled;
19 19
20 20 /**
21 21 * Class containing code for getting replies Collections and CollectionPages of posts and comments.
@@ -54,11 +54,11 @@
54 54 * @return string|\WP_Error The rest URL of the replies collection or WP_Error if the object is not a post or comment.
55 55 */
56 56 private static function get_id( $wp_object ) {
57 57 if ( $wp_object instanceof \WP_Post ) {
58 - return get_rest_url_by_path( \sprintf( 'posts/%d/replies', $wp_object->ID ) );
58 + return get_rest_url_by_path( sprintf( 'posts/%d/replies', $wp_object->ID ) );
59 59 } elseif ( $wp_object instanceof \WP_Comment ) {
60 - return get_rest_url_by_path( \sprintf( 'comments/%d/replies', $wp_object->comment_ID ) );
60 + return get_rest_url_by_path( sprintf( 'comments/%d/replies', $wp_object->comment_ID ) );
61 61 } else {
62 62 return new \WP_Error( 'unsupported_object', 'The object is not a post or comment.' );
63 63 }
64 64 }
@@ -72,9 +72,9 @@
72 72 */
73 73 public static function get_collection( $wp_object ) {
74 74 $id = self::get_id( $wp_object );
75 75
76 - if ( \is_wp_error( $id ) ) {
76 + if ( is_wp_error( $id ) ) {
77 77 return \wp_is_serving_rest_request() ? $id : null;
78 78 }
79 79
80 80 $replies = array(
@@ -100,9 +100,9 @@
100 100 */
101 101 public static function get_collection_page( $wp_object, $page, $part_of = null ) {
102 102 // Build initial arguments for fetching approved comments.
103 103 $args = self::build_args( $wp_object );
104 - if ( \is_wp_error( $args ) ) {
104 + if ( is_wp_error( $args ) ) {
105 105 return \wp_is_serving_rest_request() ? $args : null;
106 106 }
107 107
108 108 // Retrieve the partOf if not already given.
@@ -108,18 +108,18 @@
108 108 // Retrieve the partOf if not already given.
109 109 $part_of = $part_of ?? self::get_id( $wp_object );
110 110
111 111 // If the collection page does not exist.
112 - if ( \is_wp_error( $part_of ) ) {
112 + if ( is_wp_error( $part_of ) ) {
113 113 return \wp_is_serving_rest_request() ? $part_of : null;
114 114 }
115 115
116 116 // Get to total replies count.
117 - $total_replies = \get_comments( \array_merge( $args, array( 'count' => true ) ) );
117 + $total_replies = \get_comments( array_merge( $args, array( 'count' => true ) ) );
118 118
119 119 // If set to zero, we get errors below. You need at least one comment per page, here.
120 - $args['number'] = \max( (int) \get_option( 'comments_per_page' ), 1 );
121 - $args['offset'] = \intval( $page - 1 ) * $args['number'];
120 + $args['number'] = max( (int) \get_option( 'comments_per_page' ), 1 );
121 + $args['offset'] = intval( $page - 1 ) * $args['number'];
122 122
123 123 // Get the ActivityPub ID's of the comments, without local-only comments.
124 124 $comment_ids = self::get_reply_ids( \get_comments( $args ) );
125 125
@@ -151,9 +151,9 @@
151 151 */
152 152 public static function get_context_collection( $post_id ) {
153 153 $post = \get_post( $post_id );
154 154
155 - if ( ! is_post_publicly_queryable( $post_id ) ) {
155 + if ( ! $post || is_post_disabled( $post_id ) ) {
156 156 return false;
157 157 }
158 158
159 159 $comments = \get_comments(
@@ -169,9 +169,9 @@
169 169 $post_uri = ( new Post_Transformer( $post ) )->to_id();
170 170 \array_unshift( $ids, $post_uri );
171 171
172 172 $author = Actors::get_by_id( $post->post_author );
173 - if ( \is_wp_error( $author ) ) {
173 + if ( is_wp_error( $author ) ) {
174 174 if ( is_user_type_disabled( 'blog' ) ) {
175 175 return false;
176 176 }
177 177
@@ -181,9 +181,9 @@
181 181 return array(
182 182 'type' => 'OrderedCollection',
183 183 'url' => \get_permalink( $post_id ),
184 184 'attributedTo' => $author->get_id(),
185 - 'totalItems' => \count( $ids ),
185 + 'totalItems' => count( $ids ),
186 186 'items' => $ids,
187 187 );
188 188 }
189 189