Smarter Cleaner Gallery
Justin Tadlock’s Cleaner Gallery plugin fixes the semantics of the WordPress built-in gallery feature by placing all of the gallery related CSS in an external file instead of the inline CSS produced by WordPress core.
However, the problem is that this CSS file is loaded on every page request. Therefore, until WordPress supports combining all CSS files into one, here is a quick way to hide this CSS file on all pages that don’t contain a gallery (line 128 of cleaner-gallery.php):
Note: this will add cleaner-gallery.css only on single post and page views (not indexes or archives).
add_action('wp_head', 'cleaner_gallery_head', 0);
function cleaner_gallery_head() {
global $post;
if (strstr($post->post_content, '[gallery'))
wp_enqueue_style( 'cleaner-gallery', CLEANER_GALLERY_URL . '/cleaner-gallery.css', false, 0.7, 'all' );
}
Hopefully, Justin can incorporate this into the next release of this handy plugin.
