Skip to content

Instantly share code, notes, and snippets.

@robneu
Last active December 18, 2015 22:19
Show Gist options
  • Save robneu/5853892 to your computer and use it in GitHub Desktop.
Save robneu/5853892 to your computer and use it in GitHub Desktop.
Prevent MP6 Admin Styles from Loading on the Front End
<?php
/**
* Prevent unnecessary styles from
* loading on the front end
*
* @author FAT Media <http://youneedfat.com>
* @copyright Copyright (c) 2013, FAT Media, LLC
* @license GPL-2.0+
*/
/**
* The following code replaces the code block
* starting on line 26 of moby6.php in Version: 1.7
*/
function moby6_add_toolbar_css() {
if ( is_admin_bar_showing() ) {
$modtime = filemtime( plugin_dir_path( __FILE__ ) . 'css/admin-bar.css' );
wp_enqueue_style( 'moby6-admin-bar', plugins_url( 'css/admin-bar.css', __FILE__ ), false, $modtime );
}
}
/**
* The following code replaces the code block
* starting on line 77 of mp6.php in Version: 1.7
*
* I'm not entirely sure if the check is necessary
* here. It looks like it isn't, but I figured I'd
* include it just in case.
*/
// replace default admin-bar.css with MP6's
add_action( 'init', 'mp6_replace_admin_bar_style' );
function mp6_replace_admin_bar_style() {
if ( is_admin_bar_showing() ) {
global $wp_styles;
$wp_styles->registered[ 'admin-bar' ]->src = plugins_url( 'css/admin-bar.css', __FILE__ );
$wp_styles->registered[ 'admin-bar' ]->ver = filemtime( plugin_dir_path( __FILE__ ) . 'css/admin-bar.css' );
$wp_styles->registered[ 'admin-bar' ]->deps[] = 'open-sans';
$wp_styles->registered[ 'admin-bar' ]->deps[] = 'dashicons';
$wp_styles->registered[ 'admin-bar' ]->extra[ 'suffix' ] = '';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment