diff --git a/blocks/block-w/.gitkeep b/blocks/block-w/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/blocks/block-w/block.json b/blocks/block-w/block.json new file mode 100644 index 0000000..e205ae9 --- /dev/null +++ b/blocks/block-w/block.json @@ -0,0 +1,21 @@ +{ + "$schema": "https://schemas.wp.org/trunk/block.json", + "apiVersion": 2, + "title": "Block W", + "name": "xywz-blocks/block-w", + "description": "Block X", + "version": "1.0.0-beta", + "category": "xywz-blocks", + "icon": "feedback", + "supports": { + "html": true + }, + "attributes": { + "exampleAttribute": { + "type": "string" + } + }, + "keywords": ["basic", "model"], + "editorScript": "file:./build/index.js", + "editorStyle": "file:./src/style.css" +} diff --git a/blocks/block-w/build/index.asset.php b/blocks/block-w/build/index.asset.php new file mode 100644 index 0000000..0ffe47c --- /dev/null +++ b/blocks/block-w/build/index.asset.php @@ -0,0 +1 @@ + array('react', 'wp-block-editor', 'wp-blocks', 'wp-element', 'wp-i18n'), 'version' => '0b7ff61aac7e64581ba9'); diff --git a/blocks/block-w/build/index.js b/blocks/block-w/build/index.js new file mode 100644 index 0000000..9ea2b18 --- /dev/null +++ b/blocks/block-w/build/index.js @@ -0,0 +1 @@ +(()=>{"use strict";const e=window.wp.blocks,t=window.wp.element,l=(window.React,window.wp.i18n),i=window.wp.blockEditor,r=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"title":"Block W","name":"xywz-blocks/block-w","description":"Block X","version":"1.0.0-beta","category":"xywz-blocks","icon":"feedback","supports":{"html":true},"attributes":{"exampleAttribute":{"type":"string"}},"keywords":["basic","model"],"editorScript":"file:./build/index.js","editorStyle":"file:./src/style.css"}');(0,e.registerBlockType)(r,{edit:function(e){return(0,t.createElement)("div",{...(0,i.useBlockProps)()},(0,t.createElement)("div",null,(0,t.createElement)("h4",null,"Block W"),(0,t.createElement)("p",null,"Insert the attribute value below"),(0,t.createElement)("input",{type:"text",value:e.attributes.exampleAttribute,onChange:function(t){e.setAttributes({exampleAttribute:t.target.value})},placeholder:"Attribute value that will be displayed in the frontend"})))},save:function(e){return(0,t.createElement)("p",{...i.useBlockProps.save()},(0,l.__)((0,t.createElement)("div",null,e.attributes.exampleAttribute)))}})})(); \ No newline at end of file diff --git a/blocks/block-w/src/edit.js b/blocks/block-w/src/edit.js new file mode 100644 index 0000000..55eb364 --- /dev/null +++ b/blocks/block-w/src/edit.js @@ -0,0 +1,26 @@ +import React from "react"; +import { __ } from "@wordpress/i18n"; +import { useBlockProps } from "@wordpress/block-editor"; + +function Edit(props) { + function setExampleAttribute(e) { + props.setAttributes({ exampleAttribute: e.target.value }); + } + + return ( +
+
+

Block W

+

Insert the attribute value below

+ +
+
+ ); +} + +export default Edit; diff --git a/blocks/block-w/src/index.js b/blocks/block-w/src/index.js new file mode 100644 index 0000000..5f0c096 --- /dev/null +++ b/blocks/block-w/src/index.js @@ -0,0 +1,10 @@ +import { registerBlockType } from "@wordpress/blocks"; + +import Edit from "./edit"; +import Save from "./save"; +import metadata from "../block.json"; + +registerBlockType(metadata, { + edit: Edit, + save: Save, +}); diff --git a/blocks/block-w/src/save.js b/blocks/block-w/src/save.js new file mode 100644 index 0000000..d56d252 --- /dev/null +++ b/blocks/block-w/src/save.js @@ -0,0 +1,12 @@ +import { __ } from "@wordpress/i18n"; +import { useBlockProps } from "@wordpress/block-editor"; + +function Save(props) { + return ( +

+ {__(

{props.attributes.exampleAttribute}
)} +

+ ); +} + +export default Save; diff --git a/inc/class-block-w.php b/inc/class-block-w.php new file mode 100644 index 0000000..845837c --- /dev/null +++ b/inc/class-block-w.php @@ -0,0 +1,60 @@ + 'xywz-blocks', + 'title' => 'XYW...Z Blocks', + ]; + + return $categories; + } +} diff --git a/package.json b/package.json index 6a6dad3..e3a7da3 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,9 @@ "start:block-x": "wp-scripts start ./blocks/block-x/src/index.js --output-path=./blocks/block-x/build", "build:block-x": "wp-scripts build ./blocks/block-x/src/index.js --output-path=./blocks/block-x/build", "start:block-y": "wp-scripts start ./blocks/block-y/src/index.js --output-path=./blocks/block-y/build", - "build:block-y": "wp-scripts build ./blocks/block-y/src/index.js --output-path=./blocks/block-y/build" + "build:block-y": "wp-scripts build ./blocks/block-y/src/index.js --output-path=./blocks/block-y/build", + "start:block-w": "wp-scripts start ./blocks/block-w/src/index.js --output-path=./blocks/block-w/build", + "build:block-w": "wp-scripts build ./blocks/block-w/src/index.js --output-path=./blocks/block-w/build" }, "repository": { "type": "git", diff --git a/xywz-blocks.php b/xywz-blocks.php index b57fd7b..750dec4 100644 --- a/xywz-blocks.php +++ b/xywz-blocks.php @@ -32,3 +32,10 @@ require dirname( __FILE__ ) . '/inc/class-block-y.php'; use XYWZBlocks\Inc\Block_Y; new Block_Y(); + +/** + * Block W + */ +require dirname( __FILE__ ) . '/inc/class-block-w.php'; +use XYWZBlocks\Inc\Block_W; +new Block_W();