Adds SlotFills/meta box example#153
Conversation
ryanwelcher
left a comment
There was a problem hiding this comment.
Thank you for putting this together! I just had one suggestion and there are some minor phpcs/linting items. I am actively working to improve the tooling here so I am not too concerned with those at the moment.
This is a great addition to the examples, thanks again!
07-slotfills-esnext/index.php
Outdated
| wp_register_script( | ||
| 'gutenberg-examples-07-esnext', | ||
| plugins_url( 'build/index.js', __FILE__ ), | ||
| $asset_file['dependencies'], | ||
| $asset_file['version'], | ||
| true | ||
| ); | ||
|
|
||
| register_block_type( | ||
| 'gutenberg-examples/example-07-esnext', | ||
| [ | ||
| 'editor_script' => 'gutenberg-examples-07-esnext', | ||
| ] | ||
| ); |
There was a problem hiding this comment.
This is a little confusing to me as to why we're calling register_block_type when this feature doesn't actually register a block. I understand the use-case ( to enqueue the script ) but we can do this by calling wp_enqueue_script instead of wp_register_script above. If there are concerns about when loading the script at the correct time, I'd think that the dependencies should handle that correctly. Is there another benefit of this approach I am not aware of?
07-slotfills-esnext/index.php
Outdated
| } | ||
|
|
||
| // automatically load dependencies and version. | ||
| $asset_file = include(plugin_dir_path(__FILE__) . 'build/index.asset.php'); |
There was a problem hiding this comment.
Minor coding standards issue
| $asset_file = include(plugin_dir_path(__FILE__) . 'build/index.asset.php'); | |
| $asset_file = include( plugin_dir_path( __FILE__ ) . 'build/index.asset.php' ); |
| @@ -0,0 +1,58 @@ | |||
| import { TextControl } from '@wordpress/components'; | |||
There was a problem hiding this comment.
Some minor eslint items in this file - there is a .eslintrc file in some of the earlier examples that you can copy into this directory.
| @@ -0,0 +1,58 @@ | |||
| import { TextControl } from '@wordpress/components'; | |||
| import { useEntityProp } from '@wordpress/core-data'; | |||
There was a problem hiding this comment.
| import { useEntityProp } from '@wordpress/core-data'; | |
| /** | |
| * WordPress dependencies | |
| */ | |
| import { useEntityProp } from '@wordpress/core-data'; |
|
Hey @ryanwelcher, thanks for the review! I believe I've addressed everything requested. My only point of confusion was the "WordPress dependencies" docblock. Your suggestion was adding it to line 2, below the |
This PR adds an example of using the
PluginDocumentSettingPanelSlotFill to mimic a "legacy" meta box, purely in Gutenberg. This component then usesuseEntityProp()to read and write post meta.Here's a screenshot of the rendered meta box:
TODO:
Resolves #12.