Skip to content

Instantly share code, notes, and snippets.

@DanielFloeter
Last active September 16, 2020 11:37
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 DanielFloeter/43faed6cf198ecd2c7b72592d22eb7a1 to your computer and use it in GitHub Desktop.
Save DanielFloeter/43faed6cf198ecd2c7b72592d22eb7a1 to your computer and use it in GitHub Desktop.
Dequeue Select2 Add-on
<?php
/*
Plugin Name: TACBPW dequeue Select2 Add-on
Plugin URI: http://tiptoppress.com/downloads/term-and-category-based-posts-widget/
Description: Add-on to dequeue Select2 script and styles for the Term and Category based Posts Widget.
Author: TipTopPress
Version: 1.0
Author URI: http://tiptoppress.com
Installation:
A.) Manual / with a FTP client
- Download the file and rename it to Sort-by-menu-order-add-on.php
- Upload it to the plugins folder [your-wordpress-installation]/wp-content/plugins/sort-by-menu-order-add-on.php
B.) With Plugins admin
- Downlaod the file as ZIP
- Go to Plugins > Install > Upload and select the ZIP file
... than:
- Go to WordPress > Admin > PlugIns and activate the Extension
*/
namespace termCategoryPostsPro\DequeueSelect2Addon;
// Don't call the file directly
if ( !defined( 'ABSPATH' ) ) exit;
/**
* Dequeue Select2 script and styles
*
* @return array void
*
* @since 1.0
*/
function dequeue_admin_scripts ( $hook) {
// select2.
global $wp_scripts;
if ( in_array('yoast-seo-post-edit', $wp_scripts->queue) ) { // enqueue for yoast advanced tab do not open if edit post
wp_dequeue_script( 'select2-jss' );
wp_dequeue_style( 'select2-css' );
}
else if ( 'post.php' == $hook ) { // enqueue only for widget admin and customizer. (add if post.php: fix make widget SiteOrigin Page Builder plugin, GH issue #181)
if ( version_compare( $GLOBALS['wp_version'], '4.4', '>=' ) || ! isset( $GLOBALS['wp_customize'] ) ) {
wp_dequeue_script( 'select2-jss' );
wp_dequeue_style( 'select2-css' );
}
}
}
add_action( 'admin_enqueue_scripts', __NAMESPACE__ . '\dequeue_admin_scripts', 40 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment