fix errors

This commit is contained in:
Ray Elliott 2020-08-16 19:10:22 +01:00
parent 334332a64f
commit 04976533d5
5 changed files with 19 additions and 29 deletions

View File

@ -1,9 +1,7 @@
<?php <?php
add_action( 'init', function() { add_action( 'init', function() {
$block_namespace = '<<INSERT BLOCK NAMESPACE HERE>>'; $block_namespace = 'namespace'; // TODO
$block_slug = '<<INSERT BLOCK SLUG HERE>>'; $block_slug = 'slug'; // TODO
global $block_slug, $block_namespace;
if ( ! function_exists( 'register_block_type' ) ) { if ( ! function_exists( 'register_block_type' ) ) {
return; return;

View File

@ -12,6 +12,7 @@
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"devDependencies": { "devDependencies": {
"@wordpress/scripts": "12.1.1" "@wordpress/scripts": "12.1.1",
"prettier": "^2.0.5"
} }
} }

View File

@ -4,6 +4,6 @@
* Replace them with your own styles or remove the file completely. * Replace them with your own styles or remove the file completely.
*/ */
.wp-block-<theme-slug>-<block-slug> { // FIXME use correct class name .wp-block-namespace-slug { // FIXME use correct class name
border: 1px dotted #f00; border: 1px dotted #f00;
} }

View File

@ -4,13 +4,12 @@ import './editor.scss';
import { registerBlockType } from '@wordpress/blocks'; import { registerBlockType } from '@wordpress/blocks';
import { __ } from '@wordpress/i18n'; import { __ } from '@wordpress/i18n';
const NAMESPACE = ''; const NAMESPACE = 'namespace'; // TODO
const SLUG = ''; const SLUG = 'slug'; // TODO
const BLOCK_TITLE= ''; const BLOCK_TITLE = 'Block Title'; // TODO
registerBlockType(`${NAMESPACE}/${SLUG}`, {
registerBlockType( `${NAMESPACE}/${SLUG}`, { title: __(BLOCK_TITLE, SLUG),
title: __( BLOCK_TITLE, SLUG),
category: 'widgets', category: 'widgets',
@ -23,24 +22,16 @@ registerBlockType( `${NAMESPACE}/${SLUG}`, {
name: { name: {
type: 'string', type: 'string',
source: 'text', source: 'text',
selector: 'p' selector: 'p',
default: __('A default name', NAMESPACE), default: __('A default name', NAMESPACE),
}, },
}
edit( { attributes, className } ) {
return (
<p className={ className }>
{ attributes.name }
</p>
);
}, },
save() { edit({ attributes, className }) {
return ( return <p className={className}>{attributes.name}</p>;
<p>
{ attributes.name }
</p>;
);
}, },
} );
save({ attributes }) {
return <p>{attributes.name}</p>;
},
});

View File

@ -4,7 +4,7 @@
* Replace them with your own styles or remove the file completely. * Replace them with your own styles or remove the file completely.
*/ */
.wp-block-<theme-slug>-<block-slug> { // FIXME use correct class name .wp-block-namespace-slug { // FIXME use correct class name
background-color: #666; background-color: #666;
color: #fff; color: #fff;
padding: 2px; padding: 2px;