-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from sarahcssiqueira/develop
Block Z - structure & .vscode settings
- Loading branch information
Showing
11 changed files
with
133 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"phpCodeSniffer.standard": "Automatic", | ||
"phpCodeSniffer.exec.osx":"./vendor/bin/phpcs" | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-i18n'), 'version' => 'f3fa4bc34a3507c47b38'); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<div {...useBlockProps()}> | ||
<div> | ||
<h4>Block Z</h4> | ||
<p>Insert the attribute value below</p> | ||
<input | ||
type="text" | ||
value={props.attributes.exampleAttribute} | ||
onChange={setExampleAttribute} | ||
placeholder="Attribute value that will be displayed in the frontend" | ||
/> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default Edit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { __ } from "@wordpress/i18n"; | ||
import { useBlockProps } from "@wordpress/block-editor"; | ||
|
||
function Save(props) { | ||
return ( | ||
<p {...useBlockProps.save()}> | ||
{__(<div>{props.attributes.exampleAttribute}</div>)} | ||
</p> | ||
); | ||
} | ||
|
||
export default Save; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
/** | ||
* Block Z | ||
* | ||
* @package wxyzblocks | ||
*/ | ||
|
||
namespace WXYZBlocks\Inc; | ||
|
||
/** | ||
* Block Y | ||
*/ | ||
class BlockZ { | ||
|
||
|
||
/** | ||
* Constructor for handle WordPress Hooks | ||
*/ | ||
public function __construct() { | ||
add_action( 'init', [ $this, 'block_z_register' ] ); | ||
add_action( 'enqueue_block_editor_assets', [ $this, 'block_z_enqueues' ] ); | ||
} | ||
|
||
/** | ||
* Register Block | ||
*/ | ||
public function block_z_register() { | ||
register_block_type( __DIR__ ); | ||
} | ||
|
||
/** | ||
* Enqueues | ||
*/ | ||
public function block_z_enqueues() { | ||
wp_enqueue_script( | ||
'block-z', | ||
plugin_dir_url( __FILE__ ) . '../blocks/block-z/build/index.js', | ||
[ 'wp-blocks', 'wp-i18n', 'wp-editor' ] | ||
); | ||
|
||
wp_enqueue_style( | ||
'block-z', | ||
plugin_dir_url( __FILE__ ) . '..style/style.css', | ||
[], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters