Move render_js() call to enqueue scripts callback#848
Merged
Conversation
agibson-godaddy
added a commit
that referenced
this pull request
Jun 23, 2026
* Version 6.2.3 * Move render_js() call to enqueue scripts callback (#848) * Move render_js() call to enqueue scripts callback * Switch to inline jQuery * Fill out date --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Ashley Gibson <99189195+agibson-godaddy@users.noreply.github.com> Co-authored-by: Ashley Gibson <agibson@godaddy.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SV_WP_Job_Batch_Handler::__construct()was calling$this->render_js()directly. Consumers typically instantiate the handler duringplugins_loaded(e.g. CSV Export'sincludes()), sorender_js()— which callsScriptHelper::addInlineScript()→wp_register_script()— ran beforeadmin_enqueue_scripts. As of WP 6.7, that trips a_doing_it_wrongnotice on every admin page load.This PR moves the
render_js()call intoenqueue_scripts(), which is already hooked toadmin_enqueue_scriptsinadd_hooks()and is also where the script handle the inline JS attaches to is registered.Story: MWC-20065
Release: #847
Details
__construct()no longer callsrender_js().enqueue_scripts()callsrender_js()after enqueuing the handler script, so the inlinenew SV_WP_Job_Batch_Handler(...)snippet is still attached to the right handle and emitted on the same admin pages as before.enqueue_scripts()and callparent::enqueue_scripts()(the documented pattern) pick up the new behavior automatically.QA
Setup
_doing_it_wrongnotice is emitted).WP_DEBUGandWP_DEBUG_LOGenabled, ordefine( 'WP_DEBUG_DISPLAY', true )so notices surface.composer.jsonat this branch (mwc-20065) andcomposer update skyverge/wc-plugin-frameworkso it loads the patched framework copy.Steps
debug.log/ on-screen notice contains: "Function wp_register_script was called incorrectly... triggered by thewc_customer_order_export_background_export_batch_handlerhandle." (baseline — confirm the bug reproduces before fixing)_doing_it_wrongnotice is gone fromdebug.logand the page.window.wc_customer_order_export_background_export_batch_handler.SV_WP_Job_Batch_Handler(notundefined). This proves the inlinerender_js()snippet executed on the page.new SV_WP_Job_Batch_Handler(.cancel_jobAJAX path wired up via the same inline JS).Before merge