| 1 |
<?php |
| 2 |
/** |
| 3 |
* Jetpack integration file. |
| 4 |
* |
| 5 |
* @package Activitypub |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace Activitypub\Integration; |
| 9 |
|
| 10 |
use Activitypub\Comment; |
| 11 |
|
| 12 |
/** |
| 13 |
* Jetpack integration class. |
| 14 |
*/ |
| 15 |
class Jetpack { |
| 16 |
|
| 17 |
/** |
| 18 |
* Initialize the class, registering WordPress hooks. |
| 19 |
*/ |
| 20 |
public static function init() { |
| 21 |
\add_filter( 'jetpack_sync_post_meta_whitelist', array( self::class, 'add_sync_meta' ) ); |
| 22 |
\add_filter( 'jetpack_json_api_comment_types', array( self::class, 'add_comment_types' ) ); |
| 23 |
\add_filter( 'jetpack_api_include_comment_types_count', array( self::class, 'add_comment_types' ) ); |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Add ActivityPub meta keys to the Jetpack sync allow list. |
| 28 |
* |
| 29 |
* @param array $allow_list The Jetpack sync allow list. |
| 30 |
* |
| 31 |
* @return array The Jetpack sync allow list with ActivityPub meta keys. |
| 32 |
*/ |
| 33 |
public static function add_sync_meta( $allow_list ) { |
| 34 |
if ( ! is_array( $allow_list ) ) { |
| 35 |
return $allow_list; |
| 36 |
} |
| 37 |
$activitypub_meta_keys = array( |
| 38 |
'_activitypub_user_id', |
| 39 |
'_activitypub_inbox', |
| 40 |
'_activitypub_actor_json', |
| 41 |
); |
| 42 |
return \array_merge( $allow_list, $activitypub_meta_keys ); |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* Add custom comment types to the list of comment types. |
| 47 |
* |
| 48 |
* @param array $comment_types Default comment types. |
| 49 |
* @return array |
| 50 |
*/ |
| 51 |
public static function add_comment_types( $comment_types ) { |
| 52 |
return array_unique( \array_merge( $comment_types, Comment::get_comment_type_slugs() ) ); |
| 53 |
} |
| 54 |
} |
| 55 |
|