-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
155 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 @@ | ||
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-element', 'wp-polyfill'), 'version' => '73081aec5377b14fa69c20dbe99f4996'); |
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,45 @@ | ||
<?php | ||
|
||
/** | ||
* Plugin Name: Gutenberg Examples Inner Blocks ESNext | ||
* Plugin URI: https://github.com/WordPress/gutenberg-examples | ||
* Description: This is a plugin demonstrating how to use nested and inner blocks in the Gutenberg editor. | ||
* Version: 1.1.0 | ||
* Author: the Gutenberg Team | ||
* | ||
* @package gutenberg-examples | ||
*/ | ||
|
||
defined( 'ABSPATH' ) || exit; | ||
|
||
/** | ||
* Registers all block assets so that they can be enqueued through Gutenberg in | ||
* the corresponding context. | ||
*/ | ||
function gutenberg_examples_06_esnext_register_block() { | ||
|
||
if ( ! function_exists( 'register_block_type' ) ) { | ||
// Gutenberg is not active. | ||
return; | ||
} | ||
|
||
// automatically load dependencies and version | ||
$asset_file = include(plugin_dir_path(__FILE__) . 'build/index.asset.php'); | ||
|
||
wp_register_script( | ||
'gutenberg-examples-06-esnext', | ||
plugins_url( 'build/index.js', __FILE__ ), | ||
$asset_file['dependencies'], | ||
$asset_file['version'], | ||
true | ||
); | ||
|
||
register_block_type( | ||
'gutenberg-examples/example-06-esnext', | ||
[ | ||
'editor_script' => 'gutenberg-examples-06-esnext', | ||
] | ||
); | ||
|
||
} | ||
add_action( 'init', 'gutenberg_examples_06_esnext_register_block' ); |
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,14 @@ | ||
{ | ||
"name": "06-inner-blocks-esnext", | ||
"version": "1.1.0", | ||
"license": "GPL-2.0-or-later", | ||
"main": "build/index.js", | ||
"devDependencies": { | ||
"@wordpress/scripts": "^5.0.0" | ||
}, | ||
"scripts": { | ||
"start": "wp-scripts start", | ||
"build": "wp-scripts build", | ||
"lint-js": "wp-scripts lint-js" | ||
} | ||
} |
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 @@ | ||
import { registerBlockType } from '@wordpress/blocks'; | ||
import { InnerBlocks } from '@wordpress/block-editor'; | ||
|
||
registerBlockType( 'gutenberg-examples/example-06-esnext', { | ||
title: 'Example: Inner Blocks (ESNext)', | ||
category: 'layout', | ||
edit: ( { className } ) => { | ||
return ( | ||
<div className={ className }> | ||
<InnerBlocks /> | ||
</div> | ||
); | ||
}, | ||
save: ( { className } ) => { | ||
return ( | ||
<div className={ className } > | ||
<InnerBlocks.Content /> | ||
</div> | ||
); | ||
}, | ||
} ); |
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 @@ | ||
( function( blocks, element, blockEditor ) { | ||
var el = element.createElement; | ||
var InnerBlocks = blockEditor.InnerBlocks; | ||
blocks.registerBlockType( 'gutenberg-examples/example-06', { | ||
title: 'Example: Inner Blocks', | ||
category: 'layout', | ||
edit: function( props ) { | ||
return el( | ||
'div', | ||
{ className: props.className }, | ||
el( InnerBlocks ) | ||
); | ||
}, | ||
save: function( props ) { | ||
return el( | ||
'div', | ||
{ className: props.className }, | ||
el( InnerBlocks.Content ) | ||
); | ||
}, | ||
} ); | ||
}( | ||
window.wp.blocks, | ||
window.wp.element, | ||
window.wp.blockEditor, | ||
) ); |
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,42 @@ | ||
<?php | ||
|
||
/** | ||
* Plugin Name: Gutenberg Examples Inner Blocks | ||
* Plugin URI: https://github.com/WordPress/gutenberg-examples | ||
* Description: This is a plugin demonstrating how to use nested and inner blocks in the Gutenberg editor. | ||
* Version: 1.1.0 | ||
* Author: the Gutenberg Team | ||
* | ||
* @package gutenberg-examples | ||
*/ | ||
|
||
defined( 'ABSPATH' ) || exit; | ||
|
||
/** | ||
* Registers all block assets so that they can be enqueued through Gutenberg in | ||
* the corresponding context. | ||
*/ | ||
function gutenberg_examples_06_register_block() { | ||
|
||
if ( ! function_exists( 'register_block_type' ) ) { | ||
// Gutenberg is not active. | ||
return; | ||
} | ||
|
||
wp_register_script( | ||
'gutenberg-examples-06', | ||
plugins_url( 'block.js', __FILE__ ), | ||
[ 'wp-blocks', 'wp-element', 'wp-block-editor' ], | ||
filemtime( plugin_dir_path( __FILE__ ) . 'block.js' ), | ||
true | ||
); | ||
|
||
register_block_type( | ||
'gutenberg-examples/example-06', | ||
[ | ||
'editor_script' => 'gutenberg-examples-06', | ||
] | ||
); | ||
|
||
} | ||
add_action( 'init', 'gutenberg_examples_06_register_block' ); |
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