diff --git a/apps/full-site-editing/full-site-editing-plugin/blocks/content-slot/index.js b/apps/full-site-editing/full-site-editing-plugin/blocks/content-slot/index.js index 4c4e50cacb37f..366051428f3ae 100644 --- a/apps/full-site-editing/full-site-editing-plugin/blocks/content-slot/index.js +++ b/apps/full-site-editing/full-site-editing-plugin/blocks/content-slot/index.js @@ -2,6 +2,8 @@ * WordPress dependencies */ import { registerBlockType } from '@wordpress/blocks'; +import { select } from '@wordpress/data'; +import domReady from '@wordpress/dom-ready'; import { __ } from '@wordpress/i18n'; /** @@ -10,18 +12,22 @@ import { __ } from '@wordpress/i18n'; import edit from './edit'; import './style.scss'; -registerBlockType( 'a8c/content-slot', { - title: __( 'Content Slot' ), - description: __( 'Placeholder for a post or a page.' ), - icon: 'layout', - category: 'layout', - supports: { - align: [ 'wide', 'full' ], - anchor: true, - html: false, - multiple: false, - reusable: false, - }, - edit, - save: () => null, +domReady( () => { + if ( 'wp_template' === select( 'core/editor' ).getCurrentPostType() ) { + registerBlockType( 'a8c/content-slot', { + title: __( 'Content Slot' ), + description: __( 'Placeholder for a post or a page.' ), + icon: 'layout', + category: 'layout', + supports: { + align: [ 'wide', 'full' ], + anchor: true, + html: false, + multiple: false, + reusable: false, + }, + edit, + save: () => null, + } ); + } } ); diff --git a/apps/full-site-editing/full-site-editing-plugin/blocks/template-part/index.js b/apps/full-site-editing/full-site-editing-plugin/blocks/template-part/index.js index 488aea091c671..0ebbef25b7963 100644 --- a/apps/full-site-editing/full-site-editing-plugin/blocks/template-part/index.js +++ b/apps/full-site-editing/full-site-editing-plugin/blocks/template-part/index.js @@ -2,6 +2,8 @@ * WordPress dependencies */ import { registerBlockType } from '@wordpress/blocks'; +import { select } from '@wordpress/data'; +import domReady from '@wordpress/dom-ready'; import { __ } from '@wordpress/i18n'; /** @@ -10,21 +12,25 @@ import { __ } from '@wordpress/i18n'; import edit from './edit'; import './style.scss'; -registerBlockType( 'a8c/template-part', { - title: __( 'Template Part' ), - description: __( 'Display a template part.' ), - icon: 'layout', - category: 'layout', - attributes: { - selectedPostId: { type: 'number' }, - selectedPostType: { type: 'string' }, - }, - supports: { - align: [ 'wide', 'full' ], - anchor: true, - html: false, - reusable: false, - }, - edit, - save: () => null, +domReady( () => { + if ( 'wp_template' === select( 'core/editor' ).getCurrentPostType() ) { + registerBlockType( 'a8c/template-part', { + title: __( 'Template Part' ), + description: __( 'Display a template part.' ), + icon: 'layout', + category: 'layout', + attributes: { + selectedPostId: { type: 'number' }, + selectedPostType: { type: 'string' }, + }, + supports: { + align: [ 'wide', 'full' ], + anchor: true, + html: false, + reusable: false, + }, + edit, + save: () => null, + } ); + } } ); diff --git a/apps/full-site-editing/package.json b/apps/full-site-editing/package.json index ece6720093d31..513970231cae3 100644 --- a/apps/full-site-editing/package.json +++ b/apps/full-site-editing/package.json @@ -31,6 +31,7 @@ "@wordpress/components": "^7.3.0", "@wordpress/compose": "^3.2.0", "@wordpress/data": "^4.4.0", + "@wordpress/dom-ready": "^2.2.0", "@wordpress/editor": "^9.2.4", "@wordpress/element": "^2.3.0", "@wordpress/i18n": "^3.3.0",