Skip to content

Conversation

@donnapep
Copy link

@donnapep donnapep commented Sep 3, 2025

Fixes this error:

Screenshot 2025-09-03 at 8 56 59 AM

Here's the gist of the problem:

  • WordPress Core fires the enqueue_block_editor_assets action.
  • WooCommerce email editor fires the enqueue_block_editor_assets action again.
  • This results in the Block Visibility plugin's enqueue_editor_scripts function being called and executed twice.
  • The Block Visibility plugin's enqueue_editor_scripts function defines a JavaScript constant.
  • This results in a duplicate JS constant declaration. Since constants can't be redeclared, it causes the JS error:

Image

Backtrace

[29-Aug-2025 19:31:36 UTC] enqueue_editor_scripts called - Backtrace: require('wp-admin/post-new.php'),
require('wp-admin/edit-form-blocks.php'), do_action('enqueue_block_editor_assets'), WP_Hook->do_action,
WP_Hook->apply_filters, BlockVisibility\Admin\enqueue_editor_scripts
[29-Aug-2025 19:31:36 UTC] enqueue_editor_scripts called - Backtrace: require('wp-admin/post-new.php'),
require('wp-admin/edit-form-blocks.php'), require_once('wp-admin/admin-header.php'),
do_action('admin_enqueue_scripts'), WP_Hook->do_action, WP_Hook->apply_filters,
Automattic\WooCommerce\EmailEditor\Engine\Email_Editor->enqueue_admin_styles,
do_action('enqueue_block_editor_assets'), WP_Hook->do_action, WP_Hook->apply_filters,
BlockVisibility\Admin\enqueue_editor_scripts

To reproduce:

  • Enable WooCommerce.
  • In WooCommerce > Settings > Advanced > Features, enable the Block Email Editor (Alpha) feature.
  • Add a new post or page.
  • See white screen and console error.

@donnapep
Copy link
Author

donnapep commented Sep 3, 2025

Hey @ndiego. A quick ping to let you know we found this issue on a Team 51 partner site.

@ndiego
Copy link
Owner

ndiego commented Sep 3, 2025

Hi @donnapep, I just tested with a fresh copy of Woo and Block Visibility on a local site, and I'm not seeing this issue. Is the email editor an extension? If so, any chance it's using similar code to Mailpoet? There was a similar issue recently in v5.13. While this PR may fix Block Visibility, the issue remains for any other plugin that does something similar, which I believe stems from the WooCommerce email editor firing the enqueue_block_editor_assets action again.

@donnapep
Copy link
Author

donnapep commented Sep 4, 2025

Hi @ndiego. You're right! I looked into the partner's Woo configuration and this issue only occurs when this setting is enabled:

Screenshot 2025-09-04 at 10 04 25 AM

You can find it in WooCommerce > Settings > Advanced > Features.

I wasn't sure if this was more of a Woo issue, so we can report it there as well. But it seems to me as though this PR could harden the plugin and prevent any nasty future surprises with things like this that may come up in the future. 🥂

@donnapep donnapep changed the title Fix conflict with WooCommerce Fix conflict with WooCommerce when Block Email Editor feature is enabled Sep 4, 2025
@ndiego
Copy link
Owner

ndiego commented Sep 10, 2025

It looks like the source issue will be resolved in the next version of WooCommerce (v10.2). I'll keep this open until v10.2 is released to confirm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants