2009-08-21 19:29:45 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2009-09-02 19:54:50 +00:00
|
|
|
* Body Classes
|
|
|
|
* function function comicpress_body_class
|
2009-08-21 19:29:45 +00:00
|
|
|
*
|
|
|
|
* This has two functions, the first being it adds the browser type as a class
|
|
|
|
* in the <body> tag where you can then do .ie #page and do things specific
|
2009-09-02 19:54:50 +00:00
|
|
|
* for each browser type as well as a few other classes that the normal body_class
|
|
|
|
* does not yet support.
|
2009-08-21 19:29:45 +00:00
|
|
|
*
|
|
|
|
* The second is you can write code specific for a particular browser.
|
|
|
|
*
|
|
|
|
* example: if (reset(browser_body_class()) == 'ie') {
|
|
|
|
*
|
|
|
|
* the reset() portion resets the array to a string.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2009-09-02 19:54:50 +00:00
|
|
|
add_filter('body_class','comicpress_body_class');
|
2009-08-21 19:29:45 +00:00
|
|
|
|
2009-09-02 19:54:50 +00:00
|
|
|
function comicpress_body_class($classes = '') {
|
|
|
|
global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone, $post, $wp_query;
|
2009-08-21 19:29:45 +00:00
|
|
|
|
|
|
|
if($is_lynx) $classes[] = 'lynx';
|
|
|
|
elseif($is_gecko) $classes[] = 'gecko';
|
|
|
|
elseif($is_opera) $classes[] = 'opera';
|
|
|
|
elseif($is_NS4) $classes[] = 'ns4';
|
|
|
|
elseif($is_safari) $classes[] = 'safari';
|
|
|
|
elseif($is_chrome) $classes[] = 'chrome';
|
|
|
|
elseif($is_IE) $classes[] = 'ie';
|
|
|
|
else $classes[] = 'unknown';
|
|
|
|
if($is_iphone) $classes[] = 'iphone';
|
2009-09-02 19:54:50 +00:00
|
|
|
|
|
|
|
// Hijacked from the hybrid theme, http://themehybrid.com/
|
|
|
|
if (is_single()) {
|
|
|
|
foreach ( (array)get_the_category( $wp_query->post->ID ) as $cat ) :
|
|
|
|
$classes[] = 'single-category-' . sanitize_html_class( $cat->slug, $cat->term_id );
|
|
|
|
endforeach;
|
|
|
|
|
|
|
|
$classes[] = 'single-author-' . get_the_author_meta( 'user_nicename', $wp_query->post->post_author );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( is_sticky( $wp_query->post->ID ) ) {
|
|
|
|
$classes[] = 'single-sticky';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( is_attachment() ) {
|
|
|
|
$classes[] = 'attachment attachment-' . $wp_query->post->ID;
|
|
|
|
$mime_type = explode( '/', get_post_mime_type() );
|
|
|
|
foreach ( $mime_type as $type ) :
|
|
|
|
$classes[] = 'attachment-' . $type;
|
|
|
|
endforeach;
|
|
|
|
}
|
|
|
|
|
2009-08-21 19:29:45 +00:00
|
|
|
return $classes;
|
|
|
|
}
|
|
|
|
|
2009-08-21 17:45:23 +00:00
|
|
|
?>
|