Skip to content

Commit d5ca2a6

Browse files
committed
Block Support: Change block visibility support key
1 parent 4198141 commit d5ca2a6

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/wp-includes/block-supports/block-visibility.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
function wp_render_block_visibility_support( $block_content, $block ) {
2020
$block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] );
2121

22-
if ( ! $block_type || ! block_has_support( $block_type, 'blockVisibility', true ) ) {
22+
if ( ! $block_type || ! block_has_support( $block_type, 'visibility', true ) ) {
2323
return $block_content;
2424
}
2525

26-
if ( isset( $block['attrs']['metadata']['blockVisibility'] ) && false === $block['attrs']['metadata']['blockVisibility'] ) {
26+
if ( isset( $block['attrs']['metadata']['visibility'] ) && false === $block['attrs']['metadata']['visibility'] ) {
2727
return '';
2828
}
2929

tests/phpunit/tests/block-supports/block-visibility.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,55 +56,55 @@ private function register_visibility_block_with_support( $block_name, $supports
5656

5757
/**
5858
* Tests that block visibility support renders empty string when block is hidden
59-
* and blockVisibility support is opted in.
59+
* and visibility support is opted in.
6060
*
6161
* @ticket 64061
6262
*/
6363
public function test_block_visibility_support_hides_block_when_visibility_false() {
6464
$block_type = $this->register_visibility_block_with_support(
6565
'test/visibility-block',
66-
array( 'blockVisibility' => true )
66+
array( 'visibility' => true )
6767
);
6868

6969
$block_content = '<p>This is a test block.</p>';
7070
$block = array(
7171
'blockName' => 'test/visibility-block',
7272
'attrs' => array(
7373
'metadata' => array(
74-
'blockVisibility' => false,
74+
'visibility' => false,
7575
),
7676
),
7777
);
7878

7979
$result = wp_render_block_visibility_support( $block_content, $block );
8080

81-
$this->assertSame( '', $result, 'Block content should be empty when blockVisibility is false and support is opted in.' );
81+
$this->assertSame( '', $result, 'Block content should be empty when visibility is false and support is opted in.' );
8282
}
8383

8484
/**
8585
* Tests that block visibility support renders block normally when visibility is false
86-
* but blockVisibility support is not opted in.
86+
* but visibility support is not opted in.
8787
*
8888
* @ticket 64061
8989
*/
9090
public function test_block_visibility_support_shows_block_when_support_not_opted_in() {
9191
$block_type = $this->register_visibility_block_with_support(
9292
'test/visibility-block',
93-
array( 'blockVisibility' => false )
93+
array( 'visibility' => false )
9494
);
9595

9696
$block_content = '<p>This is a test block.</p>';
9797
$block = array(
9898
'blockName' => 'test/visibility-block',
9999
'attrs' => array(
100100
'metadata' => array(
101-
'blockVisibility' => false,
101+
'visibility' => false,
102102
),
103103
),
104104
);
105105

106106
$result = wp_render_block_visibility_support( $block_content, $block );
107107

108-
$this->assertSame( $block_content, $result, 'Block content should remain unchanged when blockVisibility support is not opted in.' );
108+
$this->assertSame( $block_content, $result, 'Block content should remain unchanged when visibility support is not opted in.' );
109109
}
110110
}

0 commit comments

Comments
 (0)