Make WordPress Core

Opened 3 weeks ago

Last modified 3 hours ago

#64061 new enhancement

Backport: Add block visibility support

Reported by: wildworks's profile wildworks Owned by:
Milestone: 6.9 Priority: normal
Severity: normal Version:
Component: Editor Keywords: has-patch has-unit-tests gutenberg-merge
Focuses: Cc:

Description

Backport for https://github.com/WordPress/gutenberg/pull/71203

We're adding block support to control block visibility. This support will prevent blocks from being rendered on the frontend, i.e., server-side.

To achieve this, we need to add the render_block filter to core.

Change History (8)

#1 @wildworks
3 weeks ago

  • Milestone changed from Awaiting Review to 6.9
  • Type changed from defect (bug) to enhancement

#2 @wildworks
3 weeks ago

  • Component changed from General to Editor

This ticket was mentioned in PR #10110 on WordPress/wordpress-develop by @wildworks.


3 weeks ago
#3

  • Keywords has-patch has-unit-tests added

#4 @rollybueno
3 weeks ago

Test Report

Description

This report validates whether the indicated patch works as expected.

Patch tested: https://github.com/WordPress/wordpress-develop/pull/10110

Environment

  • WordPress: 6.9-alpha-60093-src
  • PHP: 8.2.29
  • Server: nginx/1.29.1
  • Database: mysqli (Server: 8.4.6 / Client: mysqlnd 8.2.29)
  • Browser: Chrome 140.0.0.0
  • OS: Linux
  • Theme: Twenty Twenty-Five 1.3
  • MU Plugins: None activated
  • Plugins:
    • Gutenberg 21.7.0
    • Test Reports 1.2.0

Actual Results

  1. ✅ Issue resolved with patch.

Additional Notes

  • The following test code was used with 3 paragraphs, a gallery, a paragraph and a gallery
  • The first paragraph should not be visible on the front end since it used the "blockVisibility" set to false
  • The second paragraph should be visible on the front end with the "blockVisibility" set to true
  • The third paragraph should be visible on the front end since it has no "blockVisibility" metadata set
  • The gallery should visible on the front end with the "blockVisibility" set to true.
  • The last gallery should not visible on the front end with the "blockVisibility" set to false.
<!-- wp:paragraph {"metadata":{"blockVisibility":false}} -->
<p>This text should NOT be visible on the front end.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"metadata":{"blockVisibility":true},"backgroundColor":"accent-2"} -->
<p class="has-accent-2-background-color has-background">This text should be visible on the front end. With the "blockVisibility" set to true.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"style":{"elements":{"link":{"color":{"text":"var:preset|color|contrast"}}}},"backgroundColor":"accent-1","textColor":"contrast"} -->
<p class="has-contrast-color has-accent-1-background-color has-text-color has-background has-link-color">This text also should should be visible on the front-end. No "blockVisibility" metadata set</p>
<!-- /wp:paragraph -->

<!-- wp:gallery {"metadata":{"blockVisibility":true},"linkTo":"none"} -->
<figure class="wp-block-gallery has-nested-images columns-default is-cropped"><!-- wp:image {"id":58,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="http://localhost:8889/wp-content/uploads/2025/08/1dabab74-d31e-38a2-b581-3dfc3fe3d8ac-1024x682.jpg" alt="" class="wp-image-58"/></figure>
<!-- /wp:image -->

<!-- wp:image {"id":55,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="http://localhost:8889/wp-content/uploads/2025/08/c6198a5b-4c43-3f7d-9baf-326b72925649-1024x682.jpg" alt="" class="wp-image-55"/></figure>
<!-- /wp:image -->

<!-- wp:image {"id":52,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="http://localhost:8889/wp-content/uploads/2025/08/852f6bfb-b43a-31c8-b33f-82405f9d8fcc-1024x682.jpg" alt="" class="wp-image-52"/></figure>
<!-- /wp:image --></figure>
<!-- /wp:gallery -->

<!-- wp:gallery {"metadata":{"blockVisibility":false},"linkTo":"none"} -->
<figure class="wp-block-gallery has-nested-images columns-default is-cropped"><!-- wp:image {"id":58,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="http://localhost:8889/wp-content/uploads/2025/08/1dabab74-d31e-38a2-b581-3dfc3fe3d8ac-1024x682.jpg" alt="" class="wp-image-58"/></figure>
<!-- /wp:image -->

<!-- wp:image {"id":55,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="http://localhost:8889/wp-content/uploads/2025/08/c6198a5b-4c43-3f7d-9baf-326b72925649-1024x682.jpg" alt="" class="wp-image-55"/></figure>
<!-- /wp:image -->

<!-- wp:image {"id":52,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="http://localhost:8889/wp-content/uploads/2025/08/852f6bfb-b43a-31c8-b33f-82405f9d8fcc-1024x682.jpg" alt="" class="wp-image-52"/></figure>
<!-- /wp:image --></figure>
<!-- /wp:gallery -->

Supplemental Artifacts

https://i.imgur.com/SUSIAhR.png
https://i.imgur.com/P3oemRq.png

#5 @wildworks
7 days ago

  • Keywords gutenberg-merge added

This ticket was mentioned in Slack in #core by welcher. View the logs.


8 hours ago

@adamsilverstein commented on PR #10110:


8 hours ago
#7

@t-hamano - is this one ready for commit?

@wildworks commented on PR #10110:


3 hours ago
#8

@adamsilverstein Yes, I believe so.

Note: See TracTickets for help on using tickets.