• Resolved webinista

    (@webinista)


    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 to this.collection.mirroring.args without checking whether mirroring (or args) 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).

    • This topic was modified 4 years, 2 months ago by webinista.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Help with dequeue-ing and re-queuing a script in the admin’ is closed to new replies.