From 04976533d58975a7b2054513c24f893de704f6eb Mon Sep 17 00:00:00 2001 From: ray Date: Sun, 16 Aug 2020 19:10:22 +0100 Subject: [PATCH] fix errors --- index.php | 6 ++---- package.json | 3 ++- src/editor.scss | 2 +- src/index.js | 35 +++++++++++++---------------------- src/style.scss | 2 +- 5 files changed, 19 insertions(+), 29 deletions(-) diff --git a/index.php b/index.php index 4c676fa..eb53c24 100644 --- a/index.php +++ b/index.php @@ -1,9 +1,7 @@ >'; - $block_slug = '<>'; - - global $block_slug, $block_namespace; + $block_namespace = 'namespace'; // TODO + $block_slug = 'slug'; // TODO if ( ! function_exists( 'register_block_type' ) ) { return; diff --git a/package.json b/package.json index cf3ff02..23d17cd 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "author": "", "license": "ISC", "devDependencies": { - "@wordpress/scripts": "12.1.1" + "@wordpress/scripts": "12.1.1", + "prettier": "^2.0.5" } } diff --git a/src/editor.scss b/src/editor.scss index f18101f..ce34563 100644 --- a/src/editor.scss +++ b/src/editor.scss @@ -4,6 +4,6 @@ * Replace them with your own styles or remove the file completely. */ -.wp-block-- { // FIXME use correct class name +.wp-block-namespace-slug { // FIXME use correct class name border: 1px dotted #f00; } diff --git a/src/index.js b/src/index.js index 2a0cb86..26345a2 100644 --- a/src/index.js +++ b/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 ( -

- { attributes.name } -

- ); }, - save() { - return ( -

- { attributes.name } -

; - ); + edit({ attributes, className }) { + return

{attributes.name}

; }, -} ); + + save({ attributes }) { + return

{attributes.name}

; + }, +}); diff --git a/src/style.scss b/src/style.scss index 9b8eaa3..0c862aa 100644 --- a/src/style.scss +++ b/src/style.scss @@ -4,7 +4,7 @@ * Replace them with your own styles or remove the file completely. */ -.wp-block-- { // FIXME use correct class name +.wp-block-namespace-slug { // FIXME use correct class name background-color: #666; color: #fff; padding: 2px;