diff --git a/projects/plugins/social/changelog/add-reply-to-support-social-notes b/projects/plugins/social/changelog/add-reply-to-support-social-notes new file mode 100644 index 0000000000000..9e7a0738be21b --- /dev/null +++ b/projects/plugins/social/changelog/add-reply-to-support-social-notes @@ -0,0 +1,4 @@ +Significance: minor +Type: added + +Social Notes: add support for the ActivityPub Reply-To block. diff --git a/projects/plugins/social/src/class-note.php b/projects/plugins/social/src/class-note.php index 2f47673513ffb..c1326f7f66683 100644 --- a/projects/plugins/social/src/class-note.php +++ b/projects/plugins/social/src/class-note.php @@ -7,6 +7,8 @@ namespace Automattic\Jetpack\Social; +use Automattic\Jetpack\Constants; + /** * Register the Jetpack Social Note custom post type. */ @@ -31,6 +33,19 @@ public function init() { } add_filter( 'allowed_block_types', array( $this, 'restrict_blocks_for_social_note' ), 10, 2 ); + /* + * The ActivityPub plugin has a block to set a Fediverse post that a new post is in reply to. This is perfect for Social Notes. + */ + if ( Constants::get_constant( 'ACTIVITYPUB_PLUGIN_VERSION' ) ) { + add_filter( + 'jetpack_social_allowed_blocks', + function ( $allowed_blocks ) { + $allowed_blocks[] = 'activitypub/reply'; + return $allowed_blocks; + } + ); + } + self::register_cpt(); add_action( 'wp_insert_post_data', array( $this, 'set_empty_title' ), 10, 2 ); add_action( 'admin_init', array( $this, 'admin_init_actions' ) ); @@ -148,7 +163,16 @@ public function restrict_blocks_for_social_note( $allowed_blocks, $post ) { ); } - return $allowed_blocks; + /** + * Filters the blocks available to the Social Notes CPT. + * + * Default is ['core/paragraph', 'core/post-featured-image'] + * + * @since $$next-version$$ + * + * @param array $allowed_blocks A linear array of blocks allowed by the CPT. + */ + return apply_filters( 'jetpack_social_allowed_blocks', $allowed_blocks ); } /**