trim($style[1]), 'stylelink' => trim($stylelink[1]), 'author' => trim($author[1]), 'site' => trim($site[1]), 'version' => trim($version[1]), 'comments' => trim($comments[1]), 'header_text_color' => trim($header_text_color[1]), 'header_width' => trim($header_width[1]), 'header_height' => trim($header_height[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($query) { global $wpdb; // WP 2.0 if (get_wp_version() < 2.1) { $posts_per = (int) get_option('posts_per_page'); if ( empty($posts_per) ) { $posts_per = 1; } $search = '/FROM\s+?(.*)\s+?GROUP BY/siU'; preg_match($search, $query->request, $matches); if ( 'posts' == get_query_var('what_to_show') ) { $from_where = $matches[1]; $num_posts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $from_where"); } else { $from_where = preg_replace('/( AND )?post_date >= (\'|\")(.*?)(\'|\")( AND post_date <= (\'\")(.*?)(\'\"))?/siU', '', $matches[1]); $num_posts = $wpdb->query("SELECT DISTINCT post_date FROM $from_where GROUP BY year(post_date), month(post_date), dayofmonth(post_date)"); } return ceil($num_posts / $posts_per); } // WP 2.1+ return($query->max_num_pages); } /* 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'); if ( ($k2asidescategory != 0) and (is_active_module('asides_sidebar_module')) 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