Skip to content

Instantly share code, notes, and snippets.

@royboy789
royboy789 / single.php
Created Apr 24, 2018
Using Gutenberg Block Data
View single.php
<?php
get_header();
the_post();
$blocks = get_editor_blocks( $post->ID );
if ( empty( $blocks ) ) {
echo '<p>No Blocks Found</p>';
} else {
@royboy789
royboy789 / Select.react.js
Created Jan 24, 2018
Gutenberg React state example
View Select.react.js
const { __ } = wp.i18n;
const { Component } = wp.element;
const el = wp.element.createElement;
export default class Select extends Component {
constructor( props ) {
super( ...props );
this.selectCallback = this.selectCallback.bind(this);
this.state = {
@royboy789
royboy789 / Input.es6.js
Last active Jan 24, 2018
Gutenberg React Component
View Input.es6.js
const { __ } = wp.i18n;
const { Component } = wp.element;
const el = wp.element.createElement;
export default function Input( className, id, value, label, changeHandler ) {
return el(
'div',
{
className: className
},
@royboy789
royboy789 / Input.React.js
Created Jan 23, 2018
Enough React for Gutenberg
View Input.React.js
const { __ } = wp.i18n;
const { Component } = wp.element;
const el = wp.element.createElement;
export class Input extends Component {
constructor( props ) {
super( ...arguments );
}
@royboy789
royboy789 / Input.es5.js
Last active Nov 21, 2018
Learn Gutenberg es5 tutorial
View Input.es5.js
var myComponents = myComponents || {};
var el = wp.element.createElement;
var __ = wp.i18n.__;
myComponents.inputComponent = function( id, attributes, changeCallback ) {
return el(
'input',
{
id: id + '-control',
value: attributes.who,
@royboy789
royboy789 / gutenberg_es6_modular_components.js
Last active Jan 23, 2018
Gutenberg Modular Components
View gutenberg_es6_modular_components.js
import Input from './components/Input.es6';
const { __ } = wp.i18n;
const { registerBlockType } = wp.blocks;
const el = wp.element.createElement;
registerBlockType( 'learn-gutenberg/ex2-react', {
title: __( 'Learn Gutenberg Example 2: React', 'learn-gutenberg' ),
category: 'widgets',
supportHTML: false,
@royboy789
royboy789 / gutenberg_es5_registerBlockType.js
Last active Jan 18, 2018
Gutenberg ES5 wp.blocks.registerBlockType with wp.element.createElement
View gutenberg_es5_registerBlockType.js
wp.blocks.registerBlockType( 'learn-gutenberg/ex2-plainjs', {
title: __( 'Learn Gutenberg Example 2: Plain JS', 'learn-gutenberg' ),
category: 'widgets',
icon: 'admin-users',
keywords: [
__( 'lesson', 'ex2-plainjs' ),
__( 'tutorial', 'ex2-plainjs' ),
__( 'javascript', 'ex2-plainjs' )
],
attributes: {
@royboy789
royboy789 / gutenberg_es5_vs_es6.js
Created Jan 18, 2018
ES5 vs ES6 edit callback
View gutenberg_es5_vs_es6.js
// the edit callback for wp.blocks.registerBlockTypes()
/**
* ES5
*
*/
edit: function( props ) {
var attributes = props.attributes,
setAttributes = props.setAttributes,
@royboy789
royboy789 / guten-vue.js
Created Jan 17, 2018
This is a Gutenberg Block built with Vue.js
View guten-vue.js
( function( wp ) {
var el = wp.element.createElement;
var __ = wp.i18n.__;
wp.blocks.registerBlockType( 'learn-gutenberg/ex2-vue', {
title: __( 'Learn Gutenberg Example 2: VueJS', 'learn-gutenberg' ),
category: 'widgets',
supportHTML: false,
attributes: {
who: {
View EZData_PHPLIB.php
<?php
global $EZData;
$group_id = 12;
$data = array(
'value' => 123,
'misc_three' => 'testing',
):