From c0d09bd0b49f0d2c6277a93b6395b238f05c4ff5 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Fri, 27 Sep 2024 15:40:13 +0200 Subject: [PATCH 1/2] Allow "Approve & Always Allow" only for Webmentions This fails on other comment types like for example ActivityPub: https://github.com/Automattic/wordpress-activitypub/issues/865 --- includes/class-admin.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/includes/class-admin.php b/includes/class-admin.php index d356152..e7865b6 100644 --- a/includes/class-admin.php +++ b/includes/class-admin.php @@ -195,11 +195,17 @@ public static function comment_row_actions( $actions, $comment ) { $approve_url = admin_url( 'comment.php' ); $approve_url = add_query_arg( $query, $approve_url ); + $status = wp_get_comment_status( $comment ); + $protocol = get_comment_meta( $comment->comment_ID, 'protocol' ); + + if ( ! $protocol || ! in_array( 'webmention', $protocol, true ) ) { + return $actions; + } - $status = wp_get_comment_status( $comment ); if ( 'unapproved' === $status ) { $actions['domainapprovelist'] = sprintf( '%2$s', esc_url( $approve_url ), esc_attr__( 'Approve & Always Allow', 'webmention' ) ); } + return $actions; } From 9dfda72173824c6a9b255a888c01afb3abbd174e Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Fri, 27 Sep 2024 15:43:02 +0200 Subject: [PATCH 2/2] reformatting --- includes/class-admin.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/class-admin.php b/includes/class-admin.php index e7865b6..e38cbad 100644 --- a/includes/class-admin.php +++ b/includes/class-admin.php @@ -203,7 +203,11 @@ public static function comment_row_actions( $actions, $comment ) { } if ( 'unapproved' === $status ) { - $actions['domainapprovelist'] = sprintf( '%2$s', esc_url( $approve_url ), esc_attr__( 'Approve & Always Allow', 'webmention' ) ); + $actions['domainapprovelist'] = sprintf( + '%2$s', + esc_url( $approve_url ), + esc_attr__( 'Approve & Always Allow', 'webmention' ) + ); } return $actions;