diff --git a/extensions/blocks/amazon/index.js b/extensions/blocks/amazon/index.js
index 0289b0f0c55e7..61684212d832e 100644
--- a/extensions/blocks/amazon/index.js
+++ b/extensions/blocks/amazon/index.js
@@ -14,6 +14,7 @@ import edit from './edit';
* Style dependencies
*/
import './editor.scss';
+import { supportsCollections } from '../../shared/block-category';
export const name = 'amazon';
export const title = __( 'Amazon', 'jetpack' );
@@ -22,7 +23,7 @@ export const settings = {
title,
description: __( 'Promote Amazon products and earn a commission from sales.', 'jetpack' ),
icon,
- category: 'jetpack',
+ category: supportsCollections() ? 'earn' : 'jetpack',
keywords: [ __( 'amazon', 'jetpack' ), __( 'affiliate', 'jetpack' ) ],
supports: {
align: true,
diff --git a/extensions/blocks/business-hours/index.js b/extensions/blocks/business-hours/index.js
index be50d09c721f2..66bfe769ece44 100644
--- a/extensions/blocks/business-hours/index.js
+++ b/extensions/blocks/business-hours/index.js
@@ -11,6 +11,7 @@ import './editor.scss';
import './style.scss';
import BusinessHours from './edit';
import renderMaterialIcon from '../../shared/render-material-icon';
+import { supportsCollections } from '../../shared/block-category';
/**
* Block Registrations:
@@ -82,7 +83,7 @@ export const settings = {
title: __( 'Business Hours', 'jetpack' ),
description: __( 'Display opening hours for your business.', 'jetpack' ),
icon,
- category: 'jetpack',
+ category: supportsCollections() ? 'grow' : 'jetpack',
supports: {
html: true,
},
diff --git a/extensions/blocks/calendly/index.js b/extensions/blocks/calendly/index.js
index 243d598a9a0e0..b449f0ab9df6c 100644
--- a/extensions/blocks/calendly/index.js
+++ b/extensions/blocks/calendly/index.js
@@ -16,6 +16,7 @@ import { getAttributesFromEmbedCode, REGEX } from './utils';
* Style dependencies
*/
import './editor.scss';
+import { supportsCollections } from '../../shared/block-category';
export const CALENDLY_EXAMPLE_URL = 'https://calendly.com/wordpresscom/jetpack-block-example';
@@ -25,7 +26,7 @@ export const settings = {
title,
description: __( 'Embed a calendar for customers to schedule appointments', 'jetpack' ),
icon,
- category: 'jetpack',
+ category: supportsCollections() ? 'grow' : 'jetpack',
keywords: [
_x( 'calendar', 'block search term', 'jetpack' ),
_x( 'schedule', 'block search term', 'jetpack' ),
diff --git a/extensions/blocks/contact-form/index.js b/extensions/blocks/contact-form/index.js
index 50c52f2005161..9423ba570f521 100644
--- a/extensions/blocks/contact-form/index.js
+++ b/extensions/blocks/contact-form/index.js
@@ -18,6 +18,7 @@ import JetpackFieldCheckbox from './components/jetpack-field-checkbox';
import JetpackFieldMultiple from './components/jetpack-field-multiple';
import renderMaterialIcon from '../../shared/render-material-icon';
import colorValidator from '../../shared/colorValidator';
+import { supportsCollections } from '../../shared/block-category';
export const name = 'contact-form';
@@ -32,7 +33,7 @@ export const settings = {
_x( 'feedback', 'block search term', 'jetpack' ),
_x( 'contact form', 'block search term', 'jetpack' ),
],
- category: 'jetpack',
+ category: supportsCollections() ? 'grow' : 'jetpack',
supports: {
html: false,
},
@@ -174,7 +175,7 @@ export const settings = {
};
const FieldDefaults = {
- category: 'jetpack',
+ category: supportsCollections() ? 'grow' : 'jetpack',
parent: [ 'jetpack/contact-form' ],
supports: {
reusable: false,
diff --git a/extensions/blocks/contact-info/address/index.js b/extensions/blocks/contact-info/address/index.js
index f94259f4577d7..6f8b64b94372b 100644
--- a/extensions/blocks/contact-info/address/index.js
+++ b/extensions/blocks/contact-info/address/index.js
@@ -11,6 +11,7 @@ import { Path, Circle } from '@wordpress/components';
import edit from './edit';
import save from './save';
import renderMaterialIcon from '../../../shared/render-material-icon';
+import { supportsCollections } from '../../../shared/block-category';
const attributes = {
address: {
@@ -63,7 +64,7 @@ export const settings = {
),
- category: 'jetpack',
+ category: supportsCollections() ? 'grow' : 'jetpack',
attributes,
parent: [ 'jetpack/contact-info' ],
edit,
diff --git a/extensions/blocks/contact-info/email/index.js b/extensions/blocks/contact-info/email/index.js
index db086dd091826..c2a4e6a0ba024 100644
--- a/extensions/blocks/contact-info/email/index.js
+++ b/extensions/blocks/contact-info/email/index.js
@@ -10,6 +10,7 @@ import { Path } from '@wordpress/components';
import edit from './edit';
import renderMaterialIcon from '../../../shared/render-material-icon';
import save from './save';
+import { supportsCollections } from '../../../shared/block-category';
const attributes = {
email: {
@@ -34,7 +35,7 @@ export const settings = {
icon: renderMaterialIcon(
),
- category: 'jetpack',
+ category: supportsCollections() ? 'grow' : 'jetpack',
attributes,
edit,
save,
diff --git a/extensions/blocks/contact-info/index.js b/extensions/blocks/contact-info/index.js
index 9307e8110951d..8d6f907c07f61 100644
--- a/extensions/blocks/contact-info/index.js
+++ b/extensions/blocks/contact-info/index.js
@@ -15,6 +15,7 @@ import './style.scss';
import { name as addressName, settings as addressSettings } from './address/';
import { name as emailName, settings as emailSettings } from './email/';
import { name as phoneName, settings as phoneSettings } from './phone/';
+import { supportsCollections } from '../../shared/block-category';
const attributes = {};
@@ -40,7 +41,7 @@ export const settings = {
icon: renderMaterialIcon(
),
- category: 'jetpack',
+ category: supportsCollections() ? 'grow' : 'jetpack',
supports: {
align: [ 'wide', 'full' ],
html: false,
diff --git a/extensions/blocks/contact-info/phone/index.js b/extensions/blocks/contact-info/phone/index.js
index 17c51924d7cd4..133bc7750de79 100644
--- a/extensions/blocks/contact-info/phone/index.js
+++ b/extensions/blocks/contact-info/phone/index.js
@@ -10,6 +10,7 @@ import { Path } from '@wordpress/components';
import edit from './edit';
import renderMaterialIcon from '../../../shared/render-material-icon';
import save from './save';
+import { supportsCollections } from '../../../shared/block-category';
const attributes = {
phone: {
@@ -34,7 +35,7 @@ export const settings = {
icon: renderMaterialIcon(
),
- category: 'jetpack',
+ category: supportsCollections() ? 'grow' : 'jetpack',
attributes,
parent: [ 'jetpack/contact-info' ],
edit,
diff --git a/extensions/blocks/eventbrite/index.js b/extensions/blocks/eventbrite/index.js
index 67a79f1839c13..2dcccf61ed39d 100644
--- a/extensions/blocks/eventbrite/index.js
+++ b/extensions/blocks/eventbrite/index.js
@@ -12,6 +12,7 @@ import attributes from './attributes';
import deprecated from './deprecated/v1';
import edit from './edit';
import save from './save';
+import { supportsCollections } from '../../shared/block-category';
// Example URLs
// https://www.eventbrite.com/e/test-event-tickets-123456789
@@ -41,7 +42,7 @@ export const settings = {
title,
description: __( 'Embed Eventbrite event details and ticket checkout.', 'jetpack' ),
icon,
- category: 'jetpack',
+ category: supportsCollections() ? 'embed' : 'jetpack',
keywords: [
_x( 'events', 'block search term', 'jetpack' ),
_x( 'tickets', 'block search term', 'jetpack' ),
diff --git a/extensions/blocks/gif/index.js b/extensions/blocks/gif/index.js
index 17a1967a3a592..2898a3b57b492 100644
--- a/extensions/blocks/gif/index.js
+++ b/extensions/blocks/gif/index.js
@@ -12,6 +12,7 @@ import edit from './edit';
// Ordering is important! Editor overrides style!
import './style.scss';
import './editor.scss';
+import { supportsCollections } from '../../shared/block-category';
export const name = 'gif';
export const title = __( 'GIF', 'jetpack' );
@@ -26,7 +27,7 @@ export const icon = (
export const settings = {
title,
icon,
- category: 'jetpack',
+ category: supportsCollections() ? 'embed' : 'jetpack',
keywords: [
_x( 'animated', 'block search term', 'jetpack' ),
_x( 'giphy', 'block search term', 'jetpack' ),
diff --git a/extensions/blocks/google-calendar/index.js b/extensions/blocks/google-calendar/index.js
index 83a606e18f09d..39f2e5629e711 100644
--- a/extensions/blocks/google-calendar/index.js
+++ b/extensions/blocks/google-calendar/index.js
@@ -11,6 +11,7 @@ import edit from './edit';
import { extractAttributesFromIframe, URL_REGEX, IFRAME_REGEX } from './utils';
import './editor.scss';
import icon from './icon';
+import { supportsCollections } from '../../shared/block-category';
export const name = 'google-calendar';
export const title = __( 'Google Calendar', 'jetpack' );
@@ -25,7 +26,7 @@ export const settings = {
_x( 'appointments', 'block search term', 'jetpack' ),
],
icon,
- category: 'jetpack',
+ category: supportsCollections() ? 'embed' : 'jetpack',
supports: {
align: true,
alignWide: true,
diff --git a/extensions/blocks/instagram-gallery/index.js b/extensions/blocks/instagram-gallery/index.js
index 10f5a8d1e7cfe..be8e8b1c869e8 100644
--- a/extensions/blocks/instagram-gallery/index.js
+++ b/extensions/blocks/instagram-gallery/index.js
@@ -8,6 +8,7 @@ import { __, _x } from '@wordpress/i18n';
*/
import attributes from './attributes';
import edit from './edit';
+import { supportsCollections } from '../../shared/block-category';
export const name = 'instagram-gallery';
@@ -15,7 +16,7 @@ export const settings = {
title: __( 'Instagram Gallery', 'jetpack' ),
description: __( 'Embed posts from your Instagram account', 'jetpack' ),
icon: 'instagram',
- category: 'jetpack',
+ category: supportsCollections() ? 'embed' : 'jetpack',
keywords: [
_x( 'images', 'block search term', 'jetpack' ),
_x( 'photos', 'block search term', 'jetpack' ),
diff --git a/extensions/blocks/mailchimp/index.js b/extensions/blocks/mailchimp/index.js
index d9e808554ed8d..e1ce8168e30d6 100644
--- a/extensions/blocks/mailchimp/index.js
+++ b/extensions/blocks/mailchimp/index.js
@@ -9,6 +9,7 @@ import { Path, SVG } from '@wordpress/components';
*/
import edit from './edit';
import './editor.scss';
+import { supportsCollections } from '../../shared/block-category';
export const name = 'mailchimp';
@@ -23,7 +24,7 @@ export const settings = {
title: __( 'Mailchimp', 'jetpack' ),
icon,
description: __( 'A form enabling readers to join a Mailchimp list.', 'jetpack' ),
- category: 'jetpack',
+ category: supportsCollections() ? 'grow' : 'jetpack',
keywords: [
_x( 'email', 'block search term', 'jetpack' ),
_x( 'subscription', 'block search term', 'jetpack' ),
diff --git a/extensions/blocks/map/settings.js b/extensions/blocks/map/settings.js
index c5bcc22871b51..8b4a670e4a6f4 100644
--- a/extensions/blocks/map/settings.js
+++ b/extensions/blocks/map/settings.js
@@ -13,6 +13,7 @@ import defaultTheme from './map-theme_default.jpg';
import blackAndWhiteTheme from './map-theme_black_and_white.jpg';
import satelliteTheme from './map-theme_satellite.jpg';
import terrainTheme from './map-theme_terrain.jpg';
+import { supportsCollections } from '../../shared/block-category';
export const settings = {
name: 'map',
@@ -33,7 +34,7 @@ export const settings = {
),
- category: 'jetpack',
+ category: supportsCollections() ? 'embed' : 'jetpack',
keywords: [
_x( 'maps', 'block search term', 'jetpack' ),
_x( 'location', 'block search term', 'jetpack' ),
diff --git a/extensions/blocks/markdown/index.js b/extensions/blocks/markdown/index.js
index a8b0bb7b74957..6e1369d28ddd2 100644
--- a/extensions/blocks/markdown/index.js
+++ b/extensions/blocks/markdown/index.js
@@ -12,6 +12,7 @@ import './editor.scss';
import { isAtomicSite, isSimpleSite } from '../../shared/site-type-utils';
import edit from './edit';
import save from './save';
+import { supportsCollections } from '../../shared/block-category';
export const name = 'markdown';
@@ -57,7 +58,7 @@ export const settings = {
),
- category: 'jetpack',
+ category: supportsCollections() ? 'formatting' : 'jetpack',
keywords: [
_x( 'formatting', 'block search term', 'jetpack' ),
diff --git a/extensions/blocks/opentable/index.js b/extensions/blocks/opentable/index.js
index 01f92767e4e99..79bca0cfc8f3c 100644
--- a/extensions/blocks/opentable/index.js
+++ b/extensions/blocks/opentable/index.js
@@ -20,12 +20,13 @@ import './view.scss';
export const name = 'opentable';
export const title = __( 'OpenTable', 'jetpack' );
import { getAttributesFromEmbedCode, restRefRegex, ridRegex } from './utils';
+import { supportsCollections } from '../../shared/block-category';
export const settings = {
title,
description: __( 'Allow visitors to book a reservation with OpenTable', 'jetpack' ),
icon,
- category: 'jetpack',
+ category: supportsCollections() ? 'earn' : 'jetpack',
keywords: [
_x( 'booking', 'block search term', 'jetpack' ),
_x( 'reservation', 'block search term', 'jetpack' ),
diff --git a/extensions/blocks/pinterest/index.js b/extensions/blocks/pinterest/index.js
index 2ec5d591dee5b..781726be7df61 100644
--- a/extensions/blocks/pinterest/index.js
+++ b/extensions/blocks/pinterest/index.js
@@ -10,6 +10,7 @@ import { createBlock } from '@wordpress/blocks';
*/
import edit from './edit';
import { pinType } from './utils';
+import { supportsCollections } from '../../shared/block-category';
export const URL_REGEX = /^\s*https?:\/\/(?:www\.)?(?:[a-z]{2}\.)?(?:pinterest\.[a-z.]+|pin\.it)\/([^/]+)(\/[^/]+)?/i;
@@ -32,7 +33,7 @@ export const settings = {
icon,
- category: 'jetpack',
+ category: supportsCollections() ? 'embed' : 'jetpack',
keywords: [
_x( 'social', 'block search term', 'jetpack' ),
diff --git a/extensions/blocks/podcast-player/index.js b/extensions/blocks/podcast-player/index.js
index 67401edc77368..41acbf4f8a851 100644
--- a/extensions/blocks/podcast-player/index.js
+++ b/extensions/blocks/podcast-player/index.js
@@ -19,6 +19,7 @@ import { queueMusic } from './icons/';
*/
import './style.scss';
import './editor.scss';
+import { supportsCollections } from '../../shared/block-category';
export const name = 'podcast-player';
export const namespaceName = `jetpack/${ name }`;
@@ -27,7 +28,7 @@ export const settings = {
title,
description: __( 'Select and play episodes from a single podcast.', 'jetpack' ),
icon: queueMusic,
- category: 'jetpack',
+ category: supportsCollections() ? 'embed' : 'jetpack',
keywords: [
_x( 'audio', 'block search term', 'jetpack' ),
_x( 'embed', 'block search term', 'jetpack' ),
diff --git a/extensions/blocks/rating-star/index.js b/extensions/blocks/rating-star/index.js
index cacaf0451b900..727562132e94c 100644
--- a/extensions/blocks/rating-star/index.js
+++ b/extensions/blocks/rating-star/index.js
@@ -11,6 +11,7 @@ import save from './save';
import { StarIcon, StarBlockIcon } from './icon';
import './editor.scss';
import './style.scss';
+import { supportsCollections } from '../../shared/block-category';
export const name = 'rating-star';
@@ -26,7 +27,7 @@ export const settings = {
_x( 'rating', 'block search term', 'jetpack' ),
_x( 'review', 'block search term', 'jetpack' ),
],
- category: 'jetpack',
+ category: supportsCollections() ? 'formatting' : 'jetpack',
example: {},
styles: [
{
diff --git a/extensions/blocks/recurring-payments/index.js b/extensions/blocks/recurring-payments/index.js
index f199e3c941385..e36ea77353831 100644
--- a/extensions/blocks/recurring-payments/index.js
+++ b/extensions/blocks/recurring-payments/index.js
@@ -11,6 +11,7 @@ import { trimEnd } from 'lodash';
import { __, _x } from '@wordpress/i18n';
import edit from './edit';
import './editor.scss';
+import { supportsCollections } from '../../shared/block-category';
export const name = 'recurring-payments';
@@ -27,7 +28,7 @@ export const settings = {
title: __( 'Recurring Payments', 'jetpack' ),
icon,
description: __( 'Button allowing you to sell subscription products.', 'jetpack' ),
- category: 'jetpack',
+ category: supportsCollections() ? 'earn' : 'jetpack',
keywords: [
_x( 'sell', 'block search term', 'jetpack' ),
_x( 'subscriptions', 'block search term', 'jetpack' ),
diff --git a/extensions/blocks/related-posts/index.js b/extensions/blocks/related-posts/index.js
index 31763fab084b2..d52e81de8eaf3 100644
--- a/extensions/blocks/related-posts/index.js
+++ b/extensions/blocks/related-posts/index.js
@@ -9,6 +9,7 @@ import { G, Path, SVG } from '@wordpress/components';
*/
import edit from './edit';
import './style.scss';
+import { supportsCollections } from '../../shared/block-category';
export const name = 'related-posts';
@@ -23,7 +24,7 @@ export const settings = {
),
- category: 'jetpack',
+ category: supportsCollections() ? 'embed' : 'jetpack',
keywords: [
_x( 'similar content', 'block search term', 'jetpack' ),
diff --git a/extensions/blocks/repeat-visitor/index.js b/extensions/blocks/repeat-visitor/index.js
index 25ead8b3376b8..418aba2f431f3 100644
--- a/extensions/blocks/repeat-visitor/index.js
+++ b/extensions/blocks/repeat-visitor/index.js
@@ -12,6 +12,7 @@ import edit from './components/edit';
import save from './components/save';
import { CRITERIA_AFTER, DEFAULT_THRESHOLD } from './constants';
import './editor.scss';
+import { supportsCollections } from '../../shared/block-category';
export const name = 'repeat-visitor';
export const icon = renderMaterialIcon(
@@ -28,7 +29,7 @@ export const settings = {
default: DEFAULT_THRESHOLD,
},
},
- category: 'jetpack',
+ category: supportsCollections() ? 'widgets' : 'jetpack',
description: __(
'Control block visibility based on how often a visitor has viewed the page.',
'jetpack'
diff --git a/extensions/blocks/revue/index.js b/extensions/blocks/revue/index.js
index 707b5c457f793..68d44a4fb5942 100644
--- a/extensions/blocks/revue/index.js
+++ b/extensions/blocks/revue/index.js
@@ -9,6 +9,7 @@ import { __, _x } from '@wordpress/i18n';
import attributes from './attributes';
import edit from './edit';
import icon from './icon';
+import { supportsCollections } from '../../shared/block-category';
export const name = 'revue';
@@ -16,7 +17,7 @@ export const settings = {
title: __( 'Revue', 'jetpack' ),
description: __( 'Add a subscription form for your Revue newsletter.', 'jetpack' ),
icon,
- category: 'jetpack',
+ category: supportsCollections() ? 'grow' : 'jetpack',
keywords: [
_x( 'email', 'block search term', 'jetpack' ),
_x( 'subscription', 'block search term', 'jetpack' ),
diff --git a/extensions/blocks/simple-payments/index.js b/extensions/blocks/simple-payments/index.js
index 97a17fad933c5..2eb8d284d20ce 100644
--- a/extensions/blocks/simple-payments/index.js
+++ b/extensions/blocks/simple-payments/index.js
@@ -22,6 +22,7 @@ import simplePaymentsExample1 from './simple-payments_example-1.jpg';
* Styles
*/
import './editor.scss';
+import { supportsCollections } from '../../shared/block-category';
export const name = 'simple-payments';
@@ -55,7 +56,7 @@ export const settings = {
),
- category: 'jetpack',
+ category: supportsCollections() ? 'earn' : 'jetpack',
keywords: [
_x( 'buy', 'block search term', 'jetpack' ),
diff --git a/extensions/blocks/slideshow/index.js b/extensions/blocks/slideshow/index.js
index 7669de30a4be7..e9444e03107e2 100644
--- a/extensions/blocks/slideshow/index.js
+++ b/extensions/blocks/slideshow/index.js
@@ -10,6 +10,7 @@ import { Path, SVG } from '@wordpress/components';
import edit from './edit';
import save from './save';
import transforms from './transforms';
+import { supportsCollections } from '../../shared/block-category';
/**
* Example Images
@@ -111,7 +112,7 @@ export const name = 'slideshow';
export const settings = {
title: __( 'Slideshow', 'jetpack' ),
- category: 'jetpack',
+ category: supportsCollections() ? 'layout' : 'jetpack',
keywords: [
_x( 'image', 'block search term', 'jetpack' ),
_x( 'gallery', 'block search term', 'jetpack' ),
diff --git a/extensions/blocks/subscriptions/index.js b/extensions/blocks/subscriptions/index.js
index 783c695339eac..805615fdbfaad 100644
--- a/extensions/blocks/subscriptions/index.js
+++ b/extensions/blocks/subscriptions/index.js
@@ -12,6 +12,7 @@ import { RawHTML } from '@wordpress/element';
import edit from './edit';
import save from './save';
import renderMaterialIcon from '../../shared/render-material-icon';
+import { supportsCollections } from '../../shared/block-category';
export const name = 'subscriptions';
export const settings = {
@@ -28,7 +29,7 @@ export const settings = {
icon: renderMaterialIcon(
),
- category: 'jetpack',
+ category: supportsCollections() ? 'grow' : 'jetpack',
keywords: [
_x( 'subscribe', 'block search term', 'jetpack' ),
diff --git a/extensions/blocks/tiled-gallery/index.js b/extensions/blocks/tiled-gallery/index.js
index a4fca42d5a7e2..df86135ff34e6 100644
--- a/extensions/blocks/tiled-gallery/index.js
+++ b/extensions/blocks/tiled-gallery/index.js
@@ -36,6 +36,7 @@ import tiledGalleryExample3 from './tiled-gallery_example-3.jpg';
import tiledGalleryExample4 from './tiled-gallery_example-4.jpg';
import tiledGalleryExample5 from './tiled-gallery_example-5.jpg';
import tiledGalleryExample6 from './tiled-gallery_example-6.jpg';
+import { supportsCollections } from '../../shared/block-category';
// Style names are translated. Avoid introducing an i18n dependency elsewhere (view)
// by only including the labels here, the only place they're needed.
@@ -197,7 +198,7 @@ export const icon = (
export const settings = {
attributes: blockAttributes,
- category: 'jetpack',
+ category: supportsCollections() ? 'layout' : 'jetpack',
description:
__( 'Display multiple images in an elegantly organized tiled layout.', 'jetpack' ) +
( ! isSimpleSite()
diff --git a/extensions/blocks/wordads/index.js b/extensions/blocks/wordads/index.js
index 2ec3769ee01ae..f83a5450462ff 100644
--- a/extensions/blocks/wordads/index.js
+++ b/extensions/blocks/wordads/index.js
@@ -10,6 +10,7 @@ import { Fragment } from '@wordpress/element';
*/
import edit from './edit';
import { DEFAULT_FORMAT } from './constants';
+import { supportsCollections } from '../../shared/block-category';
export const name = 'wordads';
export const title = __( 'Ad', 'jetpack' );
@@ -56,7 +57,7 @@ export const settings = {
attributes: {},
},
- category: 'jetpack',
+ category: supportsCollections() ? 'earn' : 'jetpack',
keywords: [
_x( 'ads', 'block search term', 'jetpack' ),
diff --git a/extensions/shared/block-category.js b/extensions/shared/block-category.js
index 571ac1127c29f..abe0ec106026f 100644
--- a/extensions/shared/block-category.js
+++ b/extensions/shared/block-category.js
@@ -1,19 +1,59 @@
/**
* External dependencies
*/
-import { getCategories, setCategories } from '@wordpress/blocks';
+import { getCategories, setCategories, registerBlockCollection } from '@wordpress/blocks';
+import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import JetpackLogo from '../shared/jetpack-logo';
+/**
+ * Return bool depending on registerBlockCollection compatibility.
+ *
+ * @todo When Jetpack's minimum is WP 5.4. Remove this function and update all block categories.
+ *
+ * @return {boolean} Value to indicate function support.
+ */
+export const supportsCollections = () => {
+ return typeof registerBlockCollection === 'function';
+};
+
+if ( supportsCollections() ) {
+ registerBlockCollection( 'jetpack', {
+ title: 'Jetpack',
+ icon: ,
+ } );
+} else {
+ // This can be removed once Jetpack's minimum is Core 5.4.
+ setCategories( [
+ ...getCategories().filter( ( { slug } ) => slug !== 'jetpack' ),
+ // Add a Jetpack block category
+ {
+ slug: 'jetpack',
+ title: 'Jetpack',
+ icon: ,
+ },
+ ] );
+}
+
setCategories( [
- ...getCategories().filter( ( { slug } ) => slug !== 'jetpack' ),
- // Add a Jetpack block category
+ ...getCategories().filter( ( { slug } ) => slug !== 'earn' ),
+ // Add a Earn block category
{
- slug: 'jetpack',
- title: 'Jetpack',
+ slug: 'earn',
+ title: __( 'Earn', 'jetpack' ),
+ icon: ,
+ },
+] );
+
+setCategories( [
+ ...getCategories().filter( ( { slug } ) => slug !== 'grow' ),
+ // Add a Grow block category
+ {
+ slug: 'grow',
+ title: __( 'Grow', 'jetpack' ),
icon: ,
},
] );