-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interactive template: Use viewModule #57712
Changes from 7 commits
32c87f2
cb1417f
8673e10
3e50da3
5d04030
a6b0670
af50d25
26e7b0f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,15 +42,10 @@ if ( ! defined( 'ABSPATH' ) ) { | |
* @see https://developer.wordpress.org/reference/functions/register_block_type/ | ||
*/ | ||
function {{namespaceSnakeCase}}_{{slugSnakeCase}}_block_init() { | ||
register_block_type( __DIR__ . '/build' ); | ||
|
||
if (function_exists('gutenberg_register_module')) { | ||
gutenberg_register_module( | ||
'{{namespace}}-view', | ||
plugin_dir_url( __FILE__ ) . 'src/view.js', | ||
array( '@wordpress/interactivity' ), | ||
'{{version}}' | ||
); | ||
if ( defined( 'GUTENBERG_VERSION' ) && version_compare( GUTENBERG_VERSION, '17.5', '>=' ) ) { | ||
register_block_type_from_metadata( __DIR__ . '/build' ); | ||
return; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's this for? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was intended to work with the following block, we should either drop the conditional here, or revert the commit that removes the manual module registration. The metadata registration won't work prior to Gutenberg 17.5 for viewModule. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, thank you. This template already requires GB 17.2, so why not update it to require 17.5. After all, is just a way to get started with the Interactivity API, so requiring the latest version of Gutenberg makes sense. I've pushed a commit with the changes but please review it yourself as well 🙂 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That seems fine to me 👍 although we will have a window where we require an unreleased Gutenberg version. Maybe we can dist-tag the previous version of this package as latest until 17.5 is released. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's one week only, I think it's fine. |
||
register_block_type( __DIR__ . '/build' ); | ||
} | ||
add_action( 'init', '{{namespaceSnakeCase}}_{{slugSnakeCase}}_block_init' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most other CHANGELOGs in the repo follow this form so I updated these.