Skip to content

Commit 905aaab

Browse files
authored
Enhance Jetpack integration for comment meta sync (#2233)
1 parent 80e1d26 commit 905aaab

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: minor
2+
Type: changed
3+
4+
Updated sync allowlist to add support for Jetpack notifications of likes and reposts.

integration/class-jetpack.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class Jetpack {
2121
*/
2222
public static function init() {
2323
\add_filter( 'jetpack_sync_post_meta_whitelist', array( self::class, 'add_sync_meta' ) );
24+
\add_filter( 'jetpack_sync_comment_meta_whitelist', array( self::class, 'add_sync_comment_meta' ) );
25+
\add_filter( 'jetpack_sync_whitelisted_comment_types', array( self::class, 'add_comment_types' ) );
2426
\add_filter( 'jetpack_json_api_comment_types', array( self::class, 'add_comment_types' ) );
2527
\add_filter( 'jetpack_api_include_comment_types_count', array( self::class, 'add_comment_types' ) );
2628
}
@@ -39,13 +41,31 @@ public static function add_sync_meta( $allow_list ) {
3941
return $allow_list;
4042
}
4143

44+
/**
45+
* Add ActivityPub comment meta keys to the Jetpack sync allow list.
46+
*
47+
* @param array $allow_list The Jetpack sync allow list.
48+
*
49+
* @return array The Jetpack sync allow list with ActivityPub comment meta keys.
50+
*/
51+
public static function add_sync_comment_meta( $allow_list ) {
52+
$allow_list[] = 'avatar_url';
53+
54+
return $allow_list;
55+
}
56+
4257
/**
4358
* Add custom comment types to the list of comment types.
4459
*
4560
* @param array $comment_types Default comment types.
4661
* @return array
4762
*/
4863
public static function add_comment_types( $comment_types ) {
64+
// jetpack_sync_whitelisted_comment_types runs on plugins_loaded, before comment types are registered.
65+
if ( 'jetpack_sync_whitelisted_comment_types' === current_filter() ) {
66+
Comment::register_comment_types();
67+
}
68+
4969
return array_unique( \array_merge( $comment_types, Comment::get_comment_type_slugs() ) );
5070
}
5171
}

0 commit comments

Comments
 (0)