Skip to content

Instantly share code, notes, and snippets.

@jtsternberg
Created February 27, 2017 15:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtsternberg/8d95f6e6f16d5c20fa13eca3e70bbc23 to your computer and use it in GitHub Desktop.
Save jtsternberg/8d95f6e6f16d5c20fa13eca3e70bbc23 to your computer and use it in GitHub Desktop.
Fix problem with badgeos old select2 version when using gathercontent
<?php
/**
* If badgeos select2 is enqueued, remove it, as it causes conflicts.
*/
function fix_badgeos_bug_for_gathercontent( $data ) {
// BadgeOS is a bad citizen as it is enqueueing its (old) version of select2 in the entire admin.
// It is incompatible with the new version, so we need to remove it on our pages.
if ( wp_script_is( 'badgeos-select2', 'enqueued' ) ) {
wp_dequeue_script( 'badgeos-select2' );
wp_deregister_script( 'badgeos-select2' );
wp_dequeue_style( 'badgeos-select2-css' );
wp_deregister_style( 'badgeos-select2-css' );
}
return $data;
}
add_filter( 'gathercontent_localized_data', 'fix_badgeos_bug_for_gathercontent' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment