comment_parent ) || (int) $comment->comment_parent === (int) $comment->comment_ID ) { return array(); } $ancestors = array(); $id = (int) $comment->comment_parent; $ancestors[] = $id; while ( $id > 0 ) { $ancestor = \get_comment( $id ); if ( ! $ancestor ) { break; } $parent_id = (int) $ancestor->comment_parent; // Loop detection: If the ancestor has been seen before, break. if ( empty( $parent_id ) || ( $parent_id === (int) $comment->comment_ID ) || in_array( $parent_id, $ancestors, true ) ) { break; } $id = $parent_id; $ancestors[] = $id; } return $ancestors; } /** * Registers a ActivityPub comment type. * * @param string $comment_type Key for comment type. * @param array $args Optional. Array of arguments for registering a comment type. Default empty array. * * @return array The registered Activitypub comment type. */ function register_comment_type( $comment_type, $args = array() ) { global $activitypub_comment_types; if ( ! is_array( $activitypub_comment_types ) ) { $activitypub_comment_types = array(); } // Sanitize comment type name. $comment_type = sanitize_key( $comment_type ); $activitypub_comment_types[ $comment_type ] = $args; /** * Fires after a ActivityPub comment type is registered. * * @param string $comment_type Comment type. * @param array $args Arguments used to register the comment type. */ do_action( 'activitypub_registered_comment_type', $comment_type, $args ); return $args; } /** * Get the reply intent URI as a JavaScript URI. * * @return string The reply intent URI. */ function get_reply_intent_js() { return sprintf( 'javascript:(()=>{window.open(\'%s\'+encodeURIComponent(window.location.href));})();', get_reply_intent_url() ); } /** * Get the reply intent URI. * * @return string The reply intent URI. */ function get_reply_intent_url() { /** * Filters the reply intent parameters. * * @param array $params The reply intent parameters. */ $params = \apply_filters( 'activitypub_reply_intent_params', array() ); $params += array( 'in_reply_to' => '' ); $query = \http_build_query( $params ); $path = 'post-new.php?' . $query; $url = \admin_url( $path ); /** * Filters the reply intent URL. * * @param string $url The reply intent URL. */ $url = \apply_filters( 'activitypub_reply_intent_url', $url ); return esc_url_raw( $url ); }