Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full Site Editing: Only allow FSE blocks in wp_template CPT #32657

Merged
merged 1 commit into from
Apr 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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