Skip to content

Instantly share code, notes, and snippets.

@2ndkauboy
Last active December 26, 2015 12:49
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 2ndkauboy/7154341 to your computer and use it in GitHub Desktop.
Save 2ndkauboy/7154341 to your computer and use it in GitHub Desktop.
Removes the id attribute from style tags, enabling mod_pagespeed to combine those files
<?php
/*
Plugin Name: Pagespeed CSS Combination Fix
Plugin URI: https://gist.github.com/2ndkauboy/7154341
Description: Removes the id attribute from style tags, enabling mod_pagespeed to combine those files
Version: 0.1
Author: Bernhard Kau
Author URI: http://kau-boys.de
*/
function remove_id_form_pagespeed_optimization( $style_tag ){
if ( !is_admin() ) {
$style_tag = preg_replace( "/id='.*-css'\s?/", '', $style_tag );
}
return $style_tag;
}
add_filter( 'style_loader_tag', 'remove_id_form_pagespeed_optimization' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment