Skip to content

Commit

Permalink
Create-block-interactive-template: Prevent crash when Gutenberg plugi…
Browse files Browse the repository at this point in the history
…n is not installed (#56941)

* Prevent crash when Gutenberg plugin is not installed

* Update changelog
  • Loading branch information
luisherranz authored Dec 11, 2023
1 parent 1f75b41 commit 22c7c16
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 2 additions & 0 deletions packages/create-block-interactive-template/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Prevent crash when Gutenberg plugin is not installed. [#56941](https://github.com/WordPress/gutenberg/pull/56941)

## 1.10.1 (2023-12-07)

- Update template to use modules instead of scripts. [#56694](https://github.com/WordPress/gutenberg/pull/56694)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
$unique_id = wp_unique_id( 'p-' );

// Enqueue the view file.
gutenberg_enqueue_module( '{{namespace}}-view' );
if (function_exists('gutenberg_enqueue_module')) {
gutenberg_enqueue_module( '{{namespace}}-view' );
}
?>

<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ if ( ! defined( 'ABSPATH' ) ) {
function {{namespaceSnakeCase}}_{{slugSnakeCase}}_block_init() {
register_block_type( __DIR__ . '/build' );
gutenberg_register_module(
'{{namespace}}-view',
plugin_dir_url( __FILE__ ) . 'src/view.js',
array( '@wordpress/interactivity' ),
'{{version}}'
);
if (function_exists('gutenberg_register_module')) {
gutenberg_register_module(
'{{namespace}}-view',
plugin_dir_url( __FILE__ ) . 'src/view.js',
array( '@wordpress/interactivity' ),
'{{version}}'
);
}
}
add_action( 'init', '{{namespaceSnakeCase}}_{{slugSnakeCase}}_block_init' );

1 comment on commit 22c7c16

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 22c7c16.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7167920611
📝 Reported issues:

Please sign in to comment.