-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds SlotFills/meta box example (#153)
* Adds SlotFills/meta box example * Address JS formatting issues * Removes unnecessary call to register_block_type
- Loading branch information
Showing
8 changed files
with
13,837 additions
and
0 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,3 @@ | ||
{ | ||
"extends": [ "plugin:@wordpress/eslint-plugin/recommended" ] | ||
} |
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-components', 'wp-core-data', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-plugins', 'wp-polyfill'), 'version' => '24e3bebed355ba21de523036f0729a6b'); |
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,49 @@ | ||
<?php | ||
/** | ||
* Plugin Name: Gutenberg Examples SlotFills ESNext | ||
* Plugin URI: https://github.com/WordPress/gutenberg-examples | ||
* Description: This is a plugin demonstrating how to use SlotFills in the Gutenberg editor. | ||
* Version: 1.0.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_07_esnext_register_dependencies() { | ||
// Automatically load dependencies and version. | ||
$asset_file = include plugin_dir_path( __FILE__ ) . 'build/index.asset.php'; | ||
|
||
wp_register_script( | ||
'gutenberg-examples-07-esnext', | ||
plugins_url( 'build/index.js', __FILE__ ), | ||
$asset_file['dependencies'], | ||
$asset_file['version'], | ||
true | ||
); | ||
|
||
// Register the post meta field the meta box will save to. | ||
register_post_meta( | ||
'post', | ||
'example_meta_field', | ||
array( | ||
'show_in_rest' => true, | ||
'single' => true, | ||
'type' => 'string', | ||
) | ||
); | ||
} | ||
add_action( 'init', 'gutenberg_examples_07_esnext_register_dependencies' ); | ||
|
||
/** | ||
* Enqueue block editor assets for this example. | ||
*/ | ||
function gutenberg_examples_07_esnext_enqueue_assets() { | ||
wp_enqueue_script( 'gutenberg-examples-07-esnext' ); | ||
} | ||
add_action( 'enqueue_block_editor_assets', 'gutenberg_examples_07_esnext_enqueue_assets' ); |
Oops, something went wrong.