user_id !== $user_id && $user_id > 0 ) { return false; } if ( \wp_trash_comment( $comment ) ) { return $comment; } return false; } /** * Try to delete a post by its ActivityPub ID. * * @param string $object_id The ActivityPub object ID (URL). * @param int $user_id The user ID. * * @return \WP_Post|false The deleted post, or false on failure. */ private static function maybe_delete_post( $object_id, $user_id ) { // Try to find a local post by permalink. $post_id = \url_to_postid( $object_id ); $post = $post_id ? \get_post( $post_id ) : null; // Fall back to Posts collection for remote posts (ap_post type). if ( ! $post instanceof \WP_Post ) { $post = Remote_Posts::get_by_guid( $object_id ); } if ( ! $post instanceof \WP_Post ) { return false; } // Verify the user owns this post. if ( (int) $post->post_author !== $user_id && $user_id > 0 ) { return false; } if ( \wp_trash_post( $post->ID ) ) { return $post; } return false; } }