From a2e5fc2021949b3ab1df64e3b34ddf1b42a51dca Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Tue, 12 Dec 2023 14:01:43 +0100 Subject: [PATCH] Add CSS class for AP comments to allow custom designs (#602) * Add CSS class for AP comments to allow custom designs fix #600 * updated changelog --- README.md | 1 + includes/class-activitypub.php | 20 ++++++++++++++++++++ readme.txt | 1 + 3 files changed, 22 insertions(+) diff --git a/README.md b/README.md index 2f7a22d..e83f274 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,7 @@ Project maintained on GitHub at [automattic/wordpress-activitypub](https://githu * Fixed: Normalize attributes that can have mixed value types * Added: URL support for WebFinger * Added: Make Post-Template filterable +* Addes: CSS class for ActivityPub comments to allow custom designs ### 1.3.0 ### diff --git a/includes/class-activitypub.php b/includes/class-activitypub.php index 8fbdbbf..0ae3c36 100644 --- a/includes/class-activitypub.php +++ b/includes/class-activitypub.php @@ -39,6 +39,8 @@ class Activitypub { \add_action( 'in_plugin_update_message-' . ACTIVITYPUB_PLUGIN_BASENAME, array( self::class, 'plugin_update_message' ) ); + \add_filter( 'comment_class', array( self::class, 'comment_class' ), 10, 3 ); + // register several post_types self::register_post_types(); } @@ -410,4 +412,22 @@ class Activitypub { do_action( 'activitypub_after_register_post_type' ); } + + /** + * Filters the CSS classes to add an ActivityPub class. + * + * @param string[] $classes An array of comment classes. + * @param string[] $css_class An array of additional classes added to the list. + * @param string $comment_id The comment ID as a numeric string. + * + * @return string[] An array of classes. + */ + public static function comment_class( $classes, $css_class, $comment_id ) { + // check if ActivityPub comment + if ( 'activitypub' === get_comment_meta( $comment_id, 'protocol', true ) ) { + $classes[] = 'activitypub-comment'; + } + + return $classes; + } } diff --git a/readme.txt b/readme.txt index 51235c1..40f210a 100644 --- a/readme.txt +++ b/readme.txt @@ -111,6 +111,7 @@ Project maintained on GitHub at [automattic/wordpress-activitypub](https://githu * Fixed: Normalize attributes that can have mixed value types * Added: URL support for WebFinger * Added: Make Post-Template filterable +* Addes: CSS class for ActivityPub comments to allow custom designs = 1.3.0 =