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

Add filter to exclude blocks with isAllowedForBlockType #835

Closed
pcfreak30 opened this issue Jul 2, 2020 · 6 comments · Fixed by #911
Closed

Add filter to exclude blocks with isAllowedForBlockType #835

pcfreak30 opened this issue Jul 2, 2020 · 6 comments · Fixed by #911
Milestone

Comments

@pcfreak30
Copy link

Right now excludedBlocks is a hard coded list. Some plugins dont like having the additional openPopupId added in and will cause a 400 api error.

In my case, it is gravity forms doing this. I manually changed excludedBlocks to var excludedBlocks = ['core/nextpage', 'gravityforms/form'];

There should be a php filter to output with ex pum_block_editor_vars to dynamically add compatibility with different plugins.

Thanks :)

@danieliser
Copy link
Member

@pcfreak30 - Sounds reasonable enough.

@danieliser
Copy link
Member

@fpcorso fpcorso added this to the v1.13 milestone Sep 15, 2020
@fpcorso fpcorso modified the milestones: v1.13, v1.14 Oct 1, 2020
fpcorso added a commit that referenced this issue Dec 4, 2020
Add filter to allow excluding Popup Trigger field from specific blocks #835
@fpcorso
Copy link
Contributor

fpcorso commented Dec 4, 2020

@pcfreak30 We added a new filter in a recent commit which should appear in our upcoming 1.14 release. The new filter will be pum_block_editor_popup_trigger_excluded_blocks.

I already tested it with the Gravity Forms block using the following code and it works as expected. You should be able to use this going forward after the update is out.

add_filter( 'pum_block_editor_popup_trigger_excluded_blocks', function( $blocks ) {
    $blocks[] = 'gravityforms/form';
    return $blocks;
});

@fpcorso fpcorso closed this as completed Dec 4, 2020
@fpcorso fpcorso mentioned this issue Dec 15, 2020
@WMNF-web
Copy link

WMNF-web commented Dec 19, 2020

I hope it's ok to add a comment on how you can find block names you want to exclude. The way I did this was to search for the register_block_type function in the plugin directory. For instance, I had this same issue with the All In One Video Gallery plugin blocks. To find all the blocks via an SSH session, I changed to the plugin directory and ran grep as shown below ...

[user@www all-in-one-video-gallery-premium]$ grep -r register_block_type .
./blocks/blocks.php:    public function register_block_types() {
./blocks/blocks.php:            if ( function_exists( 'register_block_type' ) ) {
./blocks/blocks.php:                    register_block_type( 'aiovg/categories', array(
./blocks/blocks.php:                    register_block_type( 'aiovg/videos', array(
./blocks/blocks.php:                    register_block_type( 'aiovg/search', array(
./blocks/blocks.php:                    register_block_type( 'aiovg/video', array(
./includes/init.php:            $this->loader->add_action( 'init', $blocks, 'register_block_types' );

Then added to the list of blocks to exclude as needed ...

add_filter( 'pum_block_editor_popup_trigger_excluded_blocks', function( $blocks ) {
    $blocks[] = 'gravityforms/form';
    $blocks[] = 'aiovg/categories';
    $blocks[] = 'aiovg/search';
    $blocks[] = 'aiovg/video';
    $blocks[] = 'aiovg/videos';
    return $blocks;
});

Thanks for the filter!

@danieliser
Copy link
Member

@pcfreak30 I will add to that, I found that you can get all of a current blocks info, including the block name for this filter by adding it to a builder and while it is selected entering this into the browser console.

wp.data.select( 'core/block-editor' ).getSelectedBlock().attributes;

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 a pull request may close this issue.

4 participants