Skip to content

Commit 550e2f8

Browse files
committed
Respect disabled block allowlists
1 parent 7990cb4 commit 550e2f8

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

includes/classes/Comments/Comments.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,9 +406,9 @@ public function remove_comment_widget() {
406406
/**
407407
* Remove the comment blocks
408408
*
409-
* @param array $allowed_block_types Array of allowed block types.
409+
* @param bool|string[] $allowed_block_types Array of block type slugs, or boolean to enable/disable all.
410410
*
411-
* @return array
411+
* @return bool|string[] Filtered array of block type slugs, or false if all blocks are disabled.
412412
*/
413413
public function remove_comment_blocks( $allowed_block_types ) {
414414
// A list of disallowed comment blocks.
@@ -437,8 +437,13 @@ public function remove_comment_blocks( $allowed_block_types ) {
437437
*/
438438
$disallowed_blocks = apply_filters( 'tenup_experience_disable_comments_disallowed_blocks', $disallowed_blocks );
439439

440-
// Get all registered blocks if $allowed_block_types is not already set.
441-
if ( ! is_array( $allowed_block_types ) || empty( $allowed_block_types ) ) {
440+
// Respect other filters that have disabled all blocks.
441+
if ( false === $allowed_block_types ) {
442+
return false;
443+
}
444+
445+
// Get all registered blocks if all blocks are allowed or no explicit list is set.
446+
if ( true === $allowed_block_types || ! is_array( $allowed_block_types ) || empty( $allowed_block_types ) ) {
442447
$registered_blocks = \WP_Block_Type_Registry::get_instance()->get_all_registered();
443448
$allowed_block_types = array_keys( $registered_blocks );
444449

0 commit comments

Comments
 (0)