diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..c0f424b --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "phpCodeSniffer.standard": "Automatic", + "phpCodeSniffer.exec.osx":"./vendor/bin/phpcs" +} \ No newline at end of file diff --git a/blocks/block-z/.gitkeep b/blocks/block-z/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/blocks/block-z/block.json b/blocks/block-z/block.json new file mode 100644 index 0000000..05a7670 --- /dev/null +++ b/blocks/block-z/block.json @@ -0,0 +1,21 @@ +{ + "$schema": "https://schemas.wp.org/trunk/block.json", + "apiVersion": 2, + "title": "Block Z", + "name": "wxyz-blocks/block-z", + "description": "Block Z", + "version": "1.0.0-beta", + "category": "wxyz-blocks", + "icon": "slides", + "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-z/build/index.asset.php b/blocks/block-z/build/index.asset.php new file mode 100644 index 0000000..e694ae8 --- /dev/null +++ b/blocks/block-z/build/index.asset.php @@ -0,0 +1 @@ + array('react', 'wp-block-editor', 'wp-blocks', 'wp-i18n'), 'version' => 'f3fa4bc34a3507c47b38'); diff --git a/blocks/block-z/build/index.js b/blocks/block-z/build/index.js new file mode 100644 index 0000000..e018a79 --- /dev/null +++ b/blocks/block-z/build/index.js @@ -0,0 +1 @@ +(()=>{"use strict";const e=window.wp.blocks,t=window.React,l=window.wp.i18n,i=window.wp.blockEditor,r=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"title":"Block Z","name":"wxyz-blocks/block-z","description":"Block Z","version":"1.0.0-beta","category":"wxyz-blocks","icon":"slides","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 Z"),(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-z/src/edit.js b/blocks/block-z/src/edit.js new file mode 100644 index 0000000..24d67ee --- /dev/null +++ b/blocks/block-z/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 Z

+

Insert the attribute value below

+ +
+
+ ); +} + +export default Edit; diff --git a/blocks/block-z/src/index.js b/blocks/block-z/src/index.js new file mode 100644 index 0000000..3c5049a --- /dev/null +++ b/blocks/block-z/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-z/src/save.js b/blocks/block-z/src/save.js new file mode 100644 index 0000000..110e95e --- /dev/null +++ b/blocks/block-z/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-z.php b/inc/class-block-z.php new file mode 100644 index 0000000..f7373e6 --- /dev/null +++ b/inc/class-block-z.php @@ -0,0 +1,47 @@ +