Skip to content

Commit

Permalink
Adds SlotFills/meta box example (#153)
Browse files Browse the repository at this point in the history
* Adds SlotFills/meta box example

* Address JS formatting issues

* Removes unnecessary call to register_block_type
  • Loading branch information
mboynes authored Oct 25, 2021
1 parent e0a2b27 commit 0a0142e
Show file tree
Hide file tree
Showing 8 changed files with 13,837 additions and 0 deletions.
3 changes: 3 additions & 0 deletions 07-slotfills-esnext/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": [ "plugin:@wordpress/eslint-plugin/recommended" ]
}
1 change: 1 addition & 0 deletions 07-slotfills-esnext/build/index.asset.php
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');
1 change: 1 addition & 0 deletions 07-slotfills-esnext/build/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 49 additions & 0 deletions 07-slotfills-esnext/index.php
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' );
Loading

0 comments on commit 0a0142e

Please sign in to comment.