Skip to content

Commit

Permalink
Full Site Editing: Only allow FSE blocks in wp_template CPT (#32657)
Browse files Browse the repository at this point in the history
  • Loading branch information
Copons authored Apr 30, 2019
1 parent 17bcd8c commit b2440a0
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand All @@ -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,
} );
}
} );
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand All @@ -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,
} );
}
} );
1 change: 1 addition & 0 deletions apps/full-site-editing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit b2440a0

Please sign in to comment.