trim($style[1]), 'stylelink' => trim($stylelink[1]), 'author' => trim($author[1]), 'site' => trim($site[1]), 'version' => trim($version[1]), 'comments' => trim($comments[1])); } function get_k2_ping_type($trackbacktxt = 'Trackback', $pingbacktxt = 'Pingback') { $type = get_comment_type(); switch( $type ) { case 'trackback' : return $trackbacktxt; break; case 'pingback' : return $pingbacktxt; break; } return false; } function k2countpages($request) { global $wpdb; // get number of posts per page if (preg_match('/LIMIT \d+, (\d+)/', $request, $matches)) { $posts_per_page = $matches[1]; } else { $posts_per_page = get_option('posts_per_page'); } // modify the sql query $search = array('/\* FROM/', '/LIMIT \d+, \d+/'); $replace = array('ID FROM', ''); $request = preg_replace($search, $replace, $request); // get post count $post_count = count($wpdb->get_results($request)); return ceil($post_count / $posts_per_page); } /* By Mark Jaquith, http://txfx.net */ function k2_nice_category($normal_separator = ', ', $penultimate_separator = ' and ') { $categories = get_the_category(); if (empty($categories)) { _e('Uncategorized','k2_domain'); return; } $thelist = ''; $i = 1; $n = count($categories); foreach ($categories as $category) { if (1 < $i and $i != $n) { $thelist .= $normal_separator; } if (1 < $i and $i == $n) { $thelist .= $penultimate_separator; } $thelist .= 'cat_name) . '">'.$category->cat_name.''; ++$i; } return apply_filters('the_category', $thelist, $normal_separator); } function k2asides_filter($query) { $k2asidescategory = get_option('k2asidescategory'); $k2asidesposition = get_option('k2asidesposition'); if ( ($k2asidescategory != 0) and ($k2asidesposition == 1) and ($query->is_home) ) { $query->set('cat', '-'.$k2asidescategory); } return $query; } function k2_body_id() { if (get_option('permalink_structure') != '' and is_page()) { echo "id='" . get_query_var('name') . "'"; } } // Semantic class functions from Sandbox 0.6.1 (http://www.plaintxt.org/themes/sandbox/) // Template tag: echoes semantic classes in the
function k2_body_class() { global $wp_query, $current_user; $c = array('wordpress', 'k2'); k2_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) ) { k2_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