Skip to content

Instantly share code, notes, and snippets.

@tripflex
Created February 3, 2017 22:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tripflex/ba94d72b375a6ca1c9d2094486e0f189 to your computer and use it in GitHub Desktop.
Save tripflex/ba94d72b375a6ca1c9d2094486e0f189 to your computer and use it in GitHub Desktop.
Death to sloppy developers (dequeue method for sloppy developers that load their javascript on every page ... ugh)
<?php
// ^ do not include this, it's only for code highlighting purposes
// Update the method/function in wp-job-manager-field-editor/classes/admin/assets.php with the function/method below
function death_to_sloppy_devs( $hook ){
// Return if not on plugin page, which some devs fail to check!
if ( empty( $hook ) || ( ! empty( $hook ) && ! in_array( $hook, $this->hooks ) ) ) return;
$assets = array( 'wpum-admin-js', 'jquery-ui-sortable', 'jquery-ui-draggable', 'scporderjs', 'kwayyhs-custom-js', 'mobiloud-menu-config', 'wp-seo-premium-quickedit-notification' );
foreach( $assets as $asset ){ if( wp_script_is( $asset, 'enqueued' ) ) wp_dequeue_script( $asset ); }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment