Skip to content

Conversation

t-hamano
Copy link

@t-hamano t-hamano commented Oct 1, 2025

Trac ticket: https://core.trac.wordpress.org/ticket/64061

Testing Instructions

  • Create a new post.
  • Create content by using the following HTML:
    <!-- wp:paragraph {"metadata":{"blockVisibility":false}} -->
    <p>This text should NOT be visible on the front end.</p>
    <!-- /wp:paragraph -->
    
    <!-- wp:paragraph {"metadata":{"blockVisibility":true}} -->
    <p>This text should be visible on the front end.</p>
    <!-- /wp:paragraph -->
    
    <!-- wp:paragraph-->
    <p>This text should be visible on the front end.</p>
    <!-- /wp:post-content -->
  • Confirm that the first block of three paragraphs does not render anything on the frontend.

This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@t-hamano t-hamano force-pushed the 64061/block-visibility-support branch from d54a7f8 to 05a4a11 Compare October 1, 2025 07:03
@t-hamano t-hamano marked this pull request as ready for review October 1, 2025 07:09
Copy link

github-actions bot commented Oct 1, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props wildworks, mukesh27.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Co-authored-by: Mukesh Panchal <mukeshpanchal27@users.noreply.github.com>
Comment on lines +26 to +28
if ( isset( $block['attrs']['metadata']['blockVisibility'] ) && false === $block['attrs']['metadata']['blockVisibility'] ) {
return '';
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, we should move these checks to the top. If the attribute is already set, we can return early and avoid registering the type unnecessarily. WDYT?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should move these checks to the top

I understand the intention, but I think we should check the block support first. Otherwise, the block may return an empty string even though it doesn't support blockVisibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants