fix errors
This commit is contained in:
parent
334332a64f
commit
04976533d5
|
@ -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;
|
||||||
|
|
|
@ -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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
25
src/index.js
25
src/index.js
|
@ -4,10 +4,9 @@ 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),
|
||||||
|
@ -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 }) {
|
edit({ attributes, className }) {
|
||||||
return (
|
return <p className={className}>{attributes.name}</p>;
|
||||||
<p className={ className }>
|
|
||||||
{ attributes.name }
|
|
||||||
</p>
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
save() {
|
save({ attributes }) {
|
||||||
return (
|
return <p>{attributes.name}</p>;
|
||||||
<p>
|
|
||||||
{ attributes.name }
|
|
||||||
</p>;
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue