Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blocks not allowed for a post type are shown in the Pattern directory #24505

Closed
chvillanuevap opened this issue Aug 12, 2020 · 4 comments
Closed
Labels
[Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced [Type] Bug An existing feature does not function as intended

Comments

@chvillanuevap
Copy link

chvillanuevap commented Aug 12, 2020

Describe the bug
Blocks types that are not allowed using the allowed_block_types filters are still shown in the Pattern directory.
To reproduce
Steps to reproduce the behavior:

  1. Select which blocks are allowed using the allowed_block_types filter.
add_filter( 'allowed_block_types', array( 'my_allowed_block_types' ), PHP_INT_MAX, 2 );
function my_allowed_block_types( $allowed_blocks, $post ) {
    if ( in_array( $post->post_type, [ 'mycpt' ], true ) ) {
        return [
            ... // my allowed block types
        ];
    }

    return $allowed_blocks;
}
  1. Click on the appender "+" button in your post type.
  2. Select the Patterns tab.
  3. See error.

Expected behavior
Since I'm only allowing custom blocks that I built myself in my post type, the pattern directory should be empty because I haven't added any patterns that use my block.

Editor version (please complete the following information):

  • WordPress version: 5.5
  • Does the website has Gutenberg plugin installed, or is it using the block editor that comes by default? Default.
@annezazu annezazu added [Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced [Type] Bug An existing feature does not function as intended labels Aug 14, 2020
@jeremyfelt
Copy link
Member

Related: #23275

@jeremyfelt
Copy link
Member

This was partially addressed in #30300. I think this ticket (#24505) can be closed as a duplicate of #23275.

@Mamaduka
Copy link
Member

Mamaduka commented Aug 9, 2021

I think this should be fixed after #30366.

@youknowriad
Copy link
Contributor

Closing as the linked PR is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

5 participants