Skip to content

Fix _doing_it_wrong notice from admin notice script on WP 6.9+ block editor - #864

Open
smoen-godaddy wants to merge 1 commit into
masterfrom
mwc-20359
Open

smoen-godaddy wants to merge 1 commit into
masterfrom
mwc-20359

Conversation

@smoen-godaddy

Copy link
Copy Markdown

Summary

Fixes a _doing_it_wrong notice fired by SV_WC_Admin_Notice_Handler::render_admin_notice_js() on every block editor screen in WP 6.9+, caused by an inline-script timing conflict with WordPress's new iframed editor asset collector.

Story: MWC-20359

Release:

Details

WP 6.9+ introduced _wp_get_iframed_editor_assets(), which calls wp_print_footer_scripts() during block editor initialization — before admin_footer fires — incrementing the global did_action('wp_print_footer_scripts') counter. When render_admin_notice_js() subsequently runs at admin_footer:20, ScriptHelper::addInlineScript() sees the counter already elevated and triggers _doing_it_wrong.

The fix guards the call with did_action('wp_print_footer_scripts'): if it has already fired, the script is output directly via wp_print_inline_script_tag() (available since WP 6.0) instead of routing through ScriptHelper.

This affects all framework-based plugins on WP 6.9+, not just Memberships — companion fix in the woocommerce-memberships repo (MWC-20359) applies the same guard to a plugin-specific override.

UI Changes

None.

QA

Setup

  • WordPress 6.9+
  • Any plugin using this framework version, active
  • WP_DEBUG enabled

Steps

  1. Open any post/CPT edit screen in the block editor
    • No _doing_it_wrong notice referencing ScriptHelper::addInlineScript appears in debug.log
  2. Confirm the admin notice JS still runs correctly (notices dismiss/hide as expected)
    • No regression in notice behavior
  • Code review

Before merge

  • I have confirmed these changes in each supported minor WooCommerce version

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.

1 participant