Skip to content

Commit

Permalink
specify allowed blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidsector9 committed Mar 29, 2024
1 parent 9ff6271 commit 7d3e318
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/js/extend-image-block-generate-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ import { Button } from '@wordpress/components';
import { _nx } from '@wordpress/i18n';
import { useBlockProps } from '@wordpress/block-editor';

const allowedCoreBlocks = [
'core/image',
'core/gallery',
'core/media-text',
'core/cover',
];

/**
* Adds a `Generate image` button to the media-related blocks.
* @see {@link https://github.com/10up/classifai/issues/724}
Expand All @@ -22,6 +29,10 @@ function addImageGenerationLink( Component ) {

const { 'data-type': blockName } = blockProps;

if ( ! allowedCoreBlocks.includes( blockName ) ) {
return <Component { ...props } />;
}

let isSingle = 1;

if ( blockName && 'core/gallery' === blockName ) {
Expand Down

0 comments on commit 7d3e318

Please sign in to comment.