Help with dequeue-ing and re-queuing a script in the admin
-
I’m using WordPress 5.6, the Classic Editor plugin, and several aging custom plugins in a legacy code base.
An error in
/wp-includes/js/media-views.min.js
is causing the JavaScript in one of our plugins to fail. The issue seems to be that the script refers tothis.collection.mirroring.args
without checking whethermirroring
(orargs
) exists. This is a sort of a known issue, but as yet, there is no fix.Until there IS one, I’d like to use a plugin to fix it, ideally by dequeuing
/wp-includes/js/media-views.min.js
and enqueuing a temporary replacement.I’ve tried to dequeue media-views.min.js using the following.
function dequeue_media_views() { if ( is_admin() ) : wp_dequeue_script( 'media-views' ); endif; } add_action( 'admin_enqueue_scripts', 'dequeue_media_views', 10);
And then enqueuing it using:
function enqueue_replacements() { wp_enqueue_script( 'media-views', plugins_url( 'admin/media-views.min.js', dirname( __FILE__ ) ), array(), false, true ); } add_action( 'admin_enqueue_scripts', 'enqueue_replacements', 11);
But that is not working. (And by “not working,” I mean I still see a “this.collection.mirroring is undefined” error in
/wp-includes/js/media-views.min.js:2
reported in the console).
- The topic ‘Help with dequeue-ing and re-queuing a script in the admin’ is closed to new replies.