Skip to content

Commit

Permalink
Fixes #11949: Error: The block "xxx" can have a maximum of 3 keywords.
Browse files Browse the repository at this point in the history
  • Loading branch information
jameelmoses authored and gziolo committed Feb 13, 2019
1 parent 458b945 commit 02e039a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/blocks/src/api/registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,6 @@ export function registerBlockType( name, settings ) {
);
return;
}
if ( 'keywords' in settings && settings.keywords.length > 3 ) {
console.error(
'The block "' + name + '" can have a maximum of 3 keywords.'
);
return;
}
if ( ! ( 'category' in settings ) ) {
console.error(
'The block "' + name + '" must have a category.'
Expand Down Expand Up @@ -146,6 +140,13 @@ export function registerBlockType( name, settings ) {
return;
}

if ( 'keywords' in settings && settings.keywords.length > 3 ) {
console.error(
'The block "' + name + '" can have a maximum of 3 keywords.'
);
settings.keywords = settings.keywords.slice( 0, 3 );
}

dispatch( 'core/blocks' ).addBlockTypes( settings );

return settings;
Expand Down

0 comments on commit 02e039a

Please sign in to comment.