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
This commit is contained in:
Matthias Pfefferle 2023-12-12 14:01:43 +01:00 committed by GitHub
parent 9f8bad3e8d
commit a2e5fc2021
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 0 deletions

View file

@ -111,6 +111,7 @@ Project maintained on GitHub at [automattic/wordpress-activitypub](https://githu
* Fixed: Normalize attributes that can have mixed value types * Fixed: Normalize attributes that can have mixed value types
* Added: URL support for WebFinger * Added: URL support for WebFinger
* Added: Make Post-Template filterable * Added: Make Post-Template filterable
* Addes: CSS class for ActivityPub comments to allow custom designs
### 1.3.0 ### ### 1.3.0 ###

View file

@ -39,6 +39,8 @@ class Activitypub {
\add_action( 'in_plugin_update_message-' . ACTIVITYPUB_PLUGIN_BASENAME, array( self::class, 'plugin_update_message' ) ); \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 // register several post_types
self::register_post_types(); self::register_post_types();
} }
@ -410,4 +412,22 @@ class Activitypub {
do_action( 'activitypub_after_register_post_type' ); 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;
}
} }

View file

@ -111,6 +111,7 @@ Project maintained on GitHub at [automattic/wordpress-activitypub](https://githu
* Fixed: Normalize attributes that can have mixed value types * Fixed: Normalize attributes that can have mixed value types
* Added: URL support for WebFinger * Added: URL support for WebFinger
* Added: Make Post-Template filterable * Added: Make Post-Template filterable
* Addes: CSS class for ActivityPub comments to allow custom designs
= 1.3.0 = = 1.3.0 =