gatherpress: prevent gatherpress blocks from being rendered in activitystreams
Some checks failed
PHP Code Checker / PHP Code Checker (pull_request) Successful in 40s
PHPUnit / PHPUnit – PHP 8.1 (pull_request) Failing after 1m5s
PHPUnit / PHPUnit – PHP 8.2 (pull_request) Failing after 1m4s
PHPUnit / PHPUnit – PHP 8.3 (pull_request) Failing after 1m7s

This commit is contained in:
André Menrath 2024-10-02 18:46:57 +02:00
parent 676bb20751
commit 2301900baa

View file

@ -117,6 +117,33 @@ final class GatherPress extends Event {
return $attachments; return $attachments;
} }
/**
* Prevents gatherpress blocks from being rendered for the content.
*
* @param mixed $block_content The blocks content.
* @param mixed $block The block.
*/
public static function filter_gatherpress_blocks( $block_content, $block ) {
// Check if the block name starts with 'gatherpress'.
if ( strpos( $block['blockName'], 'gatherpress/' ) === 0 ) {
return ''; // Skip rendering this block.
}
return $block_content; // Return the content for other blocks.
}
/**
* Apply the filter for preventing the rendering off gatherpress blocks just in time.
*
* @return Event_Object
*/
public function to_object(): Event_Object {
add_filter( 'render_block', array( self::class, 'filter_gatherpress_blocks' ), 10, 2 );
$activitypub_object = parent::to_object();
remove_filter( 'render_block', array( self::class, 'filter_gatherpress_blocks' ) );
return $activitypub_object;
}
/** /**
* Determine whether the event is online. * Determine whether the event is online.
* *