From 4a0067aab42bc3847011c5078ee139f17db4a7a9 Mon Sep 17 00:00:00 2001 From: Alex Kirk Date: Tue, 17 Oct 2023 10:22:16 +0200 Subject: [PATCH] Use a Custom Web Protocol for following --- feed-parsers/class-feed-parser-activitypub.php | 13 +++++++++++++ includes/class-feed.php | 7 +++++-- includes/class-frontend.php | 1 + templates/frontend/header.php | 5 +++++ templates/frontend/parts/header-status.php | 5 +++++ 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/feed-parsers/class-feed-parser-activitypub.php b/feed-parsers/class-feed-parser-activitypub.php index 86a5664d..0595a41f 100644 --- a/feed-parsers/class-feed-parser-activitypub.php +++ b/feed-parsers/class-feed-parser-activitypub.php @@ -81,6 +81,7 @@ public function __construct( Feed $friends_feed ) { \add_filter( 'friends_reblog', array( $this, 'reblog' ), 20, 2 ); \add_filter( 'friends_unreblog', array( $this, 'unreblog' ), 20, 2 ); \add_filter( 'friends_reblog', array( $this, 'maybe_unqueue_friends_reblog_post' ), 9, 2 ); + \add_filter( 'friends_reblogged_author', array( $this, 'reblogged_author' ), 10, 2 ); \add_filter( 'pre_get_remote_metadata_by_actor', array( $this, 'disable_webfinger_for_example_domains' ), 9, 2 ); @@ -1580,6 +1581,18 @@ public function maybe_unqueue_friends_reblog_post( $ret, $post ) { return $ret; } + public function reblogged_author( $url, $post_id ) { + if ( User_Feed::get_parser_for_post_id( $post_id ) !== 'activitypub' ) { + return $url; + } + + $meta = get_post_meta( $post_id, self::SLUG, true ); + if ( isset( $meta['attributedTo']['id'] ) ) { + return $meta['attributedTo']['id']; + } + return $url; + } + public function reblog( $ret, $post ) { $post = get_post( $post ); if ( ! $post ) { diff --git a/includes/class-feed.php b/includes/class-feed.php index 2f781abb..b94b3d9c 100644 --- a/includes/class-feed.php +++ b/includes/class-feed.php @@ -755,8 +755,11 @@ public function friends_add_friend_redirect() { if ( ! isset( $_GET['add-friend'] ) || isset( $_GET['page'] ) ) { return; } - - wp_safe_redirect( add_query_arg( 'url', $_GET['add-friend'], self_admin_url( 'admin.php?page=add-friend' ) ) ); + $add_friend = $_GET['add-friend']; + if ( 'web+follow' === substr( $add_friend, 0, 10 ) ) { + $add_friend = substr( $add_friend, 13 ); + } + wp_safe_redirect( add_query_arg( 'url', $add_friend, self_admin_url( 'admin.php?page=add-friend' ) ) ); exit; } diff --git a/includes/class-frontend.php b/includes/class-frontend.php index 0e8a1fcc..3e072bbe 100644 --- a/includes/class-frontend.php +++ b/includes/class-frontend.php @@ -95,6 +95,7 @@ private function register_hooks() { add_filter( 'body_class', array( $this, 'add_body_class' ) ); add_filter( 'friends_override_author_name', array( $this, 'override_author_name' ), 10, 3 ); + add_filter( 'friends_boosted_author', array( $this, 'boosted_author' ), 10, 2 ); } /** diff --git a/templates/frontend/header.php b/templates/frontend/header.php index 4208557b..0c899678 100644 --- a/templates/frontend/header.php +++ b/templates/frontend/header.php @@ -17,6 +17,11 @@ + > diff --git a/templates/frontend/parts/header-status.php b/templates/frontend/parts/header-status.php index 19ea3faa..bc972a65 100644 --- a/templates/frontend/parts/header-status.php +++ b/templates/frontend/parts/header-status.php @@ -28,6 +28,7 @@ * ``` */ $override_author_name = apply_filters( 'friends_override_author_name', '', $author_name, get_the_id() ); +$reblogged_author = apply_filters( 'friends_reblogged_author', false, get_the_id() ); ?>
@@ -49,6 +50,10 @@ – + + [] + +