function sb_comment_class($print = true) { global $comment, $post, $sb_comment_alt; // Collects the comment type (comment, trackback), $c = array($comment->comment_type); // Counts trackbacks (t[n]) or comments (c[n]) if ($comment->comment_type == 'comment') { $c[] = "c{$sb_comment_alt}"; } else { $c[] = "t{$sb_comment_alt}"; } // If the comment author has an id (registered), then print the log in name if ($comment->user_id > 0) { $user = get_userdata($comment->user_id); // For all registered users, 'byuser'; to specificy the registered user, 'commentauthor+[log in name]' $c[] = 'byuser comment-author-' . sanitize_title_with_dashes(strtolower($user->user_login)); // For comment authors who are the author of the post if ($comment->user_id === $post->post_author) { $c[] = 'bypostauthor'; } } // If it's the other to the every, then add 'alt' class; collects time- and date-based classes sb_date_classes(mysql2date('U', $comment->comment_date), $c, 'c-'); if (++$sb_comment_alt % 2) { $c[] = 'alt'; } // Separates classes with a single space, collates classes for comment LI $c = join(' ', apply_filters('comment_class', $c)); // Available filter: comment_class return $print ? print $c : $c; }
function sb_body_classes($classes) { global $wp_query; // Determine user browser global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone; 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'; } elseif ($is_iphone) { $classes[] = 'iphone'; } else { $classes[] = 'unknown'; } // Determine IE version, specifically. Credit: http://wordpress.org/extend/plugins/krusty-msie-body-classes/ if (preg_match('/MSIE ([0-9]+)([a-zA-Z0-9.]+)/', $_SERVER['HTTP_USER_AGENT'], $browser_version)) { // add a class with the major version number $classes[] = 'ie' . $browser_version[1]; // add a class with the major and minor version number, if it's MSIE 5.5 if ('5' == $browser_version[1] && isset($browser_version[2]) && '5' == $browser_version[2]) { $classes[] = 'ie' . strtolower(str_replace('.', '-', strtolower($browser_version[0]))); } // add an ie-old and ie-lt7 classes to match MSIE 6 and older if (7 > $browser_version[1]) { $classes[] = 'ie-old'; } $classes[] = 'ie-lt7'; // add an ie-lt8 class to match MSIE 7 and older if (8 > $browser_version[1]) { $classes[] = 'ie-lt8'; } // add an ie-lt9 class to match MSIE 8 and older if (9 > $browser_version[1]) { $classes[] = 'ie-lt9'; } } // Adds category classes for each category on single posts if ($cats = get_the_category()) { foreach ($cats as $cat) { $classes[] = 's-category-' . $cat->slug; } } // Applies the time- and date-based classes sb_date_classes(time(), $classes, $p = null); // Adds classes for the month, day, and hour when the post was published if (is_single()) { sb_date_classes(mysql2date('U', $wp_query->post->post_date), $classes, 's-'); } // Adds post and page slug class, prefixed by 'post-' or 'page-', respectively if (is_single()) { $classes[] = 'post-' . $wp_query->post->post_name; } elseif (is_page()) { $classes[] = 'page-' . $wp_query->post->post_name; } // return the $classes array return $classes; }