fix errors
This commit is contained in:
parent
334332a64f
commit
04976533d5
|
@ -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;
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
"author": "",
|
||||
"license": "ISC",
|
||||
"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.
|
||||
*/
|
||||
|
||||
.wp-block-<theme-slug>-<block-slug> { // FIXME use correct class name
|
||||
.wp-block-namespace-slug { // FIXME use correct class name
|
||||
border: 1px dotted #f00;
|
||||
}
|
||||
|
|
35
src/index.js
35
src/index.js
|
@ -4,13 +4,12 @@ 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),
|
||||
registerBlockType(`${NAMESPACE}/${SLUG}`, {
|
||||
title: __(BLOCK_TITLE, SLUG),
|
||||
|
||||
category: 'widgets',
|
||||
|
||||
|
@ -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>
|
||||
);
|
||||
},
|
||||
|
||||
save() {
|
||||
return (
|
||||
<p>
|
||||
{ attributes.name }
|
||||
</p>;
|
||||
);
|
||||
edit({ attributes, className }) {
|
||||
return <p className={className}>{attributes.name}</p>;
|
||||
},
|
||||
} );
|
||||
|
||||
save({ attributes }) {
|
||||
return <p>{attributes.name}</p>;
|
||||
},
|
||||
});
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue