PluginProbe
ActivityPub / 8.0.2
ActivityPub v8.0.2
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/functions-comment.php +26 -17 9.2.08.0.2 View file →
@@ -9,30 +9,39 @@
9 9
10 10 namespace Activitypub;
11 11
12 12 /**
13 - * Get the ActivityPub ID of a Comment by the WordPress Comment ID.
13 + * Detect a comment request.
14 14 *
15 - * @param int|\WP_Comment $id The WordPress Comment ID or object.
15 + * @deprecated 7.1.0
16 16 *
17 - * @return string The ActivityPub ID (a URL) of the Comment.
17 + * @return int|bool Comment ID or false if not found.
18 18 */
19 -function get_comment_id( $id ) {
20 - return Comment::generate_id( $id );
19 +function is_comment() {
20 + \_deprecated_function( __FUNCTION__, '7.1.0' );
21 +
22 + $comment_id = get_query_var( 'c', null );
23 +
24 + if ( ! is_null( $comment_id ) ) {
25 + $comment = \get_comment( $comment_id );
26 +
27 + if ( $comment ) {
28 + return $comment_id;
29 + }
30 + }
31 +
32 + return false;
21 33 }
22 34
23 35 /**
24 36 * Get the comment from an ActivityPub Object ID.
25 37 *
26 - * @since 9.1.0 Added the `$args` parameter.
38 + * @param string $id ActivityPub object ID (usually a URL) to check.
27 39 *
28 - * @param string $id ActivityPub object ID (usually a URL) to check.
29 - * @param array $args Optional. Additional WP_Comment_Query arguments.
30 - *
31 40 * @return \WP_Comment|boolean Comment, or false on failure.
32 41 */
33 -function object_id_to_comment( $id, $args = array() ) {
34 - return Comment::object_id_to_comment( $id, $args );
42 +function object_id_to_comment( $id ) {
43 + return Comment::object_id_to_comment( $id );
35 44 }
36 45
37 46 /**
38 47 * Verify that URL is a local comment or a previously received remote comment.
@@ -134,9 +143,9 @@
134 143
135 144 $parent_id = (int) $ancestor->comment_parent;
136 145
137 146 // Loop detection: If the ancestor has been seen before, break.
138 - if ( empty( $parent_id ) || ( $parent_id === (int) $comment->comment_ID ) || \in_array( $parent_id, $ancestors, true ) ) {
147 + if ( empty( $parent_id ) || ( $parent_id === (int) $comment->comment_ID ) || in_array( $parent_id, $ancestors, true ) ) {
139 148 break;
140 149 }
141 150
142 151 $id = $parent_id;
@@ -156,14 +165,14 @@
156 165 */
157 166 function register_comment_type( $comment_type, $args = array() ) {
158 167 global $activitypub_comment_types;
159 168
160 - if ( ! \is_array( $activitypub_comment_types ) ) {
169 + if ( ! is_array( $activitypub_comment_types ) ) {
161 170 $activitypub_comment_types = array();
162 171 }
163 172
164 173 // Sanitize comment type name.
165 - $comment_type = \sanitize_key( $comment_type );
174 + $comment_type = sanitize_key( $comment_type );
166 175
167 176 $activitypub_comment_types[ $comment_type ] = $args;
168 177
169 178 /**
@@ -171,9 +180,9 @@
171 180 *
172 181 * @param string $comment_type Comment type.
173 182 * @param array $args Arguments used to register the comment type.
174 183 */
175 - \do_action( 'activitypub_registered_comment_type', $comment_type, $args );
184 + do_action( 'activitypub_registered_comment_type', $comment_type, $args );
176 185
177 186 return $args;
178 187 }
179 188
@@ -182,9 +191,9 @@
182 191 *
183 192 * @return string The reply intent URI.
184 193 */
185 194 function get_reply_intent_js() {
186 - return \sprintf(
195 + return sprintf(
187 196 'javascript:(()=>{window.open(\'%s\'+encodeURIComponent(window.location.href));})();',
188 197 get_reply_intent_url()
189 198 );
190 199 }
@@ -213,6 +222,6 @@
213 222 * @param string $url The reply intent URL.
214 223 */
215 224 $url = \apply_filters( 'activitypub_reply_intent_url', $url );
216 225
217 - return \esc_url_raw( $url );
226 + return esc_url_raw( $url );
218 227 }