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
add_action( 'init', function() {
$block_namespace = '<<INSERT BLOCK NAMESPACE HERE>>';
$block_slug = '<<INSERT BLOCK SLUG HERE>>';
global $block_slug, $block_namespace;
$block_namespace = 'namespace'; // TODO
$block_slug = 'slug'; // TODO
if ( ! function_exists( 'register_block_type' ) ) {
return;

View File

@ -12,6 +12,7 @@
"author": "",
"license": "ISC",
"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.
*/
.wp-block-<theme-slug>-<block-slug> { // FIXME use correct class name
.wp-block-namespace-slug { // FIXME use correct class name
border: 1px dotted #f00;
}

View File

@ -4,10 +4,9 @@ import './editor.scss';
import { registerBlockType } from '@wordpress/blocks';
import { __ } from '@wordpress/i18n';
const NAMESPACE = '';
const SLUG = '';
const BLOCK_TITLE= '';
const NAMESPACE = 'namespace'; // TODO
const SLUG = 'slug'; // TODO
const BLOCK_TITLE = 'Block Title'; // TODO
registerBlockType(`${NAMESPACE}/${SLUG}`, {
title: __(BLOCK_TITLE, SLUG),
@ -23,24 +22,16 @@ registerBlockType( `${NAMESPACE}/${SLUG}`, {
name: {
type: 'string',
source: 'text',
selector: 'p'
selector: 'p',
default: __('A default name', NAMESPACE),
},
}
},
edit({ attributes, className }) {
return (
<p className={ className }>
{ attributes.name }
</p>
);
return <p className={className}>{attributes.name}</p>;
},
save() {
return (
<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.
*/
.wp-block-<theme-slug>-<block-slug> { // FIXME use correct class name
.wp-block-namespace-slug { // FIXME use correct class name
background-color: #666;
color: #fff;
padding: 2px;