function redo_body_class() {
global $wp_query, $current_user;
$c = array('wordpress', 'k2');
redo_date_classes(time(), $c);
is_home() ? $c[] = 'home' : null;
is_archive() ? $c[] = 'archive' : null;
is_date() ? $c[] = 'date' : null;
is_search() ? $c[] = 'search' : null;
is_paged() ? $c[] = 'paged' : null;
is_attachment() ? $c[] = 'attachment' : null;
is_404() ? $c[] = 'four04' : null; // CSS does not allow a digit as first character
if ( is_single() ) {
the_post();
$c[] = 'single';
if ( isset($wp_query->post->post_date) ) {
redo_date_classes(mysql2date('U', $wp_query->post->post_date), $c, 's-');
}
foreach ( (array) get_the_category() as $cat ) {
$c[] = 's-category-' . $cat->category_nicename;
}
$c[] = 's-author-' . get_the_author_login();
rewind_posts();
}
else if ( is_author() ) {
$author = $wp_query->get_queried_object();
$c[] = 'author';
$c[] = 'author-' . $author->user_nicename;
}
else if ( is_category() ) {
$cat = $wp_query->get_queried_object();
$c[] = 'category';
$c[] = 'category-' . $cat->category_nicename;
}
else if ( is_page() ) {
the_post();
$c[] = 'page';
$c[] = 'page-author-' . get_the_author_login();
rewind_posts();
}
if ( $current_user->ID )
$c[] = 'loggedin';
echo join(' ', apply_filters('body_class', $c));
}
// Template tag: echoes semantic classes in each post
function redo_post_class( $post_count = 1, $post_asides = false ) {
global $post;
$c = array('hentry', "p$post_count", $post->post_type, $post->post_status);
$c[] = 'author-' . get_the_author_login();
foreach ( (array) get_the_category() as $cat ) {
$c[] = 'category-' . $cat->category_nicename;
}
redo_date_classes(mysql2date('U', $post->post_date), $c);
if ( $post_asides ) {
$c[] = 'redo-asides';
}
if ( $post_count & 1 == 1 ) {
$c[] = 'alt';
}
echo join(' ', apply_filters('post_class', $c));
}
// Template tag: echoes semantic classes for a comment
function redo_comment_class( $comment_count = 1 ) {
global $comment, $post;
$c = array($comment->comment_type, "c$comment_count");
if ( $comment->user_id > 0 ) {
$user = get_userdata($comment->user_id);
$c[] = "byuser commentauthor-$user->user_login";
if ( $comment->user_id === $post->post_author ) {
$c[] = 'bypostauthor';
}
}
redo_date_classes(mysql2date('U', $comment->comment_date), $c, 'c-');
if ( $comment_count & 1 == 1 ) {
$c[] = 'alt';
}
if ( is_trackback() ) {
$c[] = 'trackback';
}
echo join(' ', apply_filters('comment_class', $c));
}
// Adds four time- and date-based classes to an array
// with all times relative to GMT (sometimes called UTC)
function redo_date_classes($t, &$c, $p = '') {
$t = $t + (get_option('gmt_offset') * 3600);
$c[] = $p . 'y' . gmdate('Y', $t); // Year
$c[] = $p . 'm' . gmdate('m', $t); // Month
$c[] = $p . 'd' . gmdate('d', $t); // Day
$c[] = $p . 'h' . gmdate('h', $t); // Hour
}
// Filter to remove asides from the loop
add_filter('pre_get_posts', 'redo_asides_filter');
?>
Rödapudlar | hundar, hund, hundblogg