Skip to content

Instantly share code, notes, and snippets.

@jaygidwitz
Last active March 22, 2018 22:01
Show Gist options
  • Save jaygidwitz/8742c6931993be3fc497944ec32e679a to your computer and use it in GitHub Desktop.
Save jaygidwitz/8742c6931993be3fc497944ec32e679a to your computer and use it in GitHub Desktop.
Fixes conflict with Nayma on MonsterInsights admin pages
<?php
/*
Plugin Name: MonsterInsights Fix for Nayma Theme
Plugin URI:
Description: Fixes conflict with Nayma on MonsterInsights admin pages
Version: 1.0.0
Author: MonsterInsights Support Team
Author URI: https://www.monsterinsights.com
License:
License URI:
*/
function custom_monsterinsights_remove_conflicting_asset_files() {
// Get current screen.
$screen = get_current_screen();
// Bail if we're not on a MonsterInsights screen.
if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) === false ) {
return;
}
$styles = array();
$scripts = array();
$styles = array(
'qi-framework-styles', // Nayma Theme
'artisan-pages-style', // Artisan Pages
);
$scripts = array(
'adminscripts', // Nayma Theme
'artisan-pages-script', // Artisan Pages
);
if ( ! empty( $styles ) ) {
foreach ( $styles as $style ) {
wp_dequeue_style( $style ); // Remove CSS file from MI screen
wp_deregister_style( $style );
}
}
if ( ! empty( $scripts ) ) {
foreach ( $scripts as $script ) {
wp_dequeue_script( $script ); // Remove JS file from MI screen
wp_deregister_script( $script );
}
}
}
add_action( 'admin_enqueue_scripts', 'custom_monsterinsights_remove_conflicting_asset_files', 9998 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment