From b1f86c0a51506c9edf9f0b054041040e20e13145 Mon Sep 17 00:00:00 2001 From: ryan Date: Wed, 12 Oct 2005 17:01:50 +0000 Subject: [PATCH] Code cleanup from Mark Jaquith. fixes #1746 git-svn-id: http://svn.automattic.com/wordpress/trunk@2943 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/template-functions-author.php | 223 +++++----- wp-includes/template-functions-category.php | 443 +++++++++++--------- 2 files changed, 357 insertions(+), 309 deletions(-) diff --git a/wp-includes/template-functions-author.php b/wp-includes/template-functions-author.php index 890e87bee2..8591ac8f8e 100644 --- a/wp-includes/template-functions-author.php +++ b/wp-includes/template-functions-author.php @@ -1,56 +1,65 @@ display_name); + global $authordata; + return apply_filters('the_author', $authordata->display_name); } function the_author($idmode = '', $echo = true) { - if ($echo) echo get_the_author($idmode); + if ( $echo ) + echo get_the_author($idmode); return get_the_author($idmode); } function get_the_author_description() { - global $authordata; - return $authordata->user_description; + global $authordata; + return $authordata->user_description; } function the_author_description() { - echo get_the_author_description(); + echo get_the_author_description(); } function get_the_author_login() { - global $id,$authordata; return $authordata->user_login; + global $authordata; + return $authordata->user_login; } + function the_author_login() { - echo get_the_author_login(); + echo get_the_author_login(); } function get_the_author_firstname() { - global $id,$authordata; return $authordata->first_name; + global $authordata; + return $authordata->first_name; } function the_author_firstname() { - echo get_the_author_firstname(); + echo get_the_author_firstname(); } function get_the_author_lastname() { - global $id,$authordata; return $authordata->last_name; + global $authordata; + return $authordata->last_name; } + function the_author_lastname() { - echo get_the_author_lastname(); + echo get_the_author_lastname(); } function get_the_author_nickname() { - global $id,$authordata; return $authordata->nickname; + global $authordata; + return $authordata->nickname; } + function the_author_nickname() { - echo get_the_author_nickname(); + echo get_the_author_nickname(); } function get_the_author_ID() { - global $id,$authordata; return $authordata->ID; + global $authordata; + return $authordata->ID; } function the_author_ID() { - echo get_the_author_id(); + echo get_the_author_id(); } function get_the_author_email() { @@ -63,149 +72,163 @@ function the_author_email() { } function get_the_author_url() { - global $id,$authordata; return $authordata->user_url; + global $authordata; + return $authordata->user_url; } + function the_author_url() { - echo get_the_author_url(); + echo get_the_author_url(); } function get_the_author_icq() { - global $id,$authordata; return $authordata->icq; + global $authordata; + return $authordata->icq; } + function the_author_icq() { - echo get_the_author_icq(); + echo get_the_author_icq(); } function get_the_author_aim() { - global $id,$authordata; return str_replace(' ', '+', $authordata->aim); + global $authordata; + return str_replace(' ', '+', $authordata->aim); } + function the_author_aim() { - echo get_the_author_aim(); + echo get_the_author_aim(); } function get_the_author_yim() { - global $id,$authordata; return $authordata->yim; + global $authordata; + return $authordata->yim; } + function the_author_yim() { - echo get_the_author_yim(); + echo get_the_author_yim(); } function get_the_author_msn() { - global $id,$authordata; return $authordata->msn; + global $authordata; + return $authordata->msn; } + function the_author_msn() { - echo get_the_author_msn(); + echo get_the_author_msn(); } function get_the_author_posts() { - global $id,$post; - $posts=get_usernumposts($post->post_author); + global $post; + $posts = get_usernumposts($post->post_author); return $posts; } + function the_author_posts() { - echo get_the_author_posts(); + echo get_the_author_posts(); } /* the_author_posts_link() requires no get_, use get_author_link() */ function the_author_posts_link($idmode='') { - global $id, $authordata; + global $authordata; - echo '' . the_author($idmode, false) . ''; + echo '' . the_author($idmode, false) . ''; } - function get_author_link($echo = false, $author_id, $author_nicename) { global $wpdb, $wp_rewrite, $post, $cache_userdata; - $auth_ID = $author_id; - $link = $wp_rewrite->get_author_permastruct(); - - if (empty($link)) { - $file = get_settings('home') . '/'; - $link = $file . '?author=' . $auth_ID; - } else { - if ('' == $author_nicename) $author_nicename = $cache_userdata[$author_id]->user_nicename; - $link = str_replace('%author%', $author_nicename, $link); - $link = get_settings('home') . trailingslashit($link); - } + $auth_ID = $author_id; + $link = $wp_rewrite->get_author_permastruct(); - $link = apply_filters('author_link', $link, $author_id, $author_nicename); - if ($echo) echo $link; - return $link; + if ( empty($link) ) { + $file = get_settings('home') . '/'; + $link = $file . '?author=' . $auth_ID; + } else { + if ( '' == $author_nicename ) + $author_nicename = $cache_userdata[$author_id]->user_nicename; + $link = str_replace('%author%', $author_nicename, $link); + $link = get_settings('home') . trailingslashit($link); + } + + $link = apply_filters('author_link', $link, $author_id, $author_nicename); + + if ( $echo ) + echo $link; + return $link; } function wp_list_authors($args = '') { parse_str($args, $r); - if (!isset($r['optioncount'])) $r['optioncount'] = false; - if (!isset($r['exclude_admin'])) $r['exclude_admin'] = true; - if (!isset($r['show_fullname'])) $r['show_fullname'] = false; - if (!isset($r['hide_empty'])) $r['hide_empty'] = true; - if (!isset($r['feed'])) $r['feed'] = ''; - if (!isset($r['feed_image'])) $r['feed_image'] = ''; + + if ( !isset($r['optioncount']) ) + $r['optioncount'] = false; + if ( !isset($r['exclude_admin']) ) + $r['exclude_admin'] = true; + if ( !isset($r['show_fullname']) ) + $r['show_fullname'] = false; + if ( !isset($r['hide_empty']) ) + $r['hide_empty'] = true; + if ( !isset($r['feed']) ) + $r['feed'] = ''; + if ( !isset($r['feed_image']) ) + $r['feed_image'] = ''; list_authors($r['optioncount'], $r['exclude_admin'], $r['show_fullname'], $r['hide_empty'], $r['feed'], $r['feed_image']); } function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '') { - global $wpdb; + global $wpdb; + $query = "SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name"; + $authors = $wpdb->get_results($query); - $query = "SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name"; - $authors = $wpdb->get_results($query); - - foreach($authors as $author) { + foreach ( $authors as $author ) { $author = get_userdata( $author->ID ); - $posts = get_usernumposts($author->ID); - $name = $author->nickname; + $posts = get_usernumposts($author->ID); + $name = $author->nickname; - if ($show_fullname && ($author->first_name != '' && $author->last_name != '')) { - $name = "$author->first_name $author->last_name"; - } - - if (! ($posts == 0 && $hide_empty)) echo "
  • "; - if ($posts == 0) { - if ( !$hide_empty ) + if ( $show_fullname && ($author->first_name != '' && $author->last_name != '') ) + $name = "$author->first_name $author->last_name"; + + if ( !($posts == 0 && $hide_empty) ) + echo "
  • "; + if ( $posts == 0 ) { + if ( !$hide_empty ) $link = $name; - } else { - $link = 'display_name)) . '">' . $name . ''; + } else { + $link = 'display_name)) . '">' . $name . ''; - if ( (! empty($feed_image)) || (! empty($feed)) ) { - - $link .= ' '; + if ( (! empty($feed_image)) || (! empty($feed)) ) { + $link .= ' '; + if (empty($feed_image)) + $link .= '('; + $link .= 'ID, $author->user_nicename) . '"'; + $link .= '>'; - if (! empty($feed)) { - $title = ' title="' . $feed . '"'; - $alt = ' alt="' . $feed . '"'; - $name = $feed; - $link .= $title; - } + if ( !empty($feed_image) ) + $link .= "'; + else + $link .= $name; - $link .= '>'; + $link .= ''; - if (! empty($feed_image)) { - $link .= "'; - } else { - $link .= $name; - } - - $link .= ''; + if ( empty($feed_image) ) + $link .= ')'; + } - if (empty($feed_image)) { - $link .= ')'; - } - } + if ( $optioncount ) + $link .= ' ('. $posts . ')'; - if ($optioncount) { - $link .= ' ('. $posts . ')'; - } - } + } - if (! ($posts == 0 && $hide_empty)) echo "$link
  • "; - } + if ( !($posts == 0 && $hide_empty) ) + echo "$link"; + } } -?> +?> \ No newline at end of file diff --git a/wp-includes/template-functions-category.php b/wp-includes/template-functions-category.php index 9a4a208357..d21cfdaaa6 100644 --- a/wp-includes/template-functions-category.php +++ b/wp-includes/template-functions-category.php @@ -1,17 +1,17 @@ ID; - if ( ! isset($category_cache[$id]) ) + if ( !isset($category_cache[$id]) ) update_post_category_cache($id); $categories = $category_cache[$id]; - if (!empty($categories)) + if ( !empty($categories) ) sort($categories); else $categories = array(); @@ -30,7 +30,7 @@ function get_category_link($category_id) { $category = &get_category($category_id); $category_nicename = $category->category_nicename; - if ($parent = $category->category_parent) + if ( $parent = $category->category_parent ) $category_nicename = get_category_parents($parent, false, '/', true) . $category_nicename . '/'; $catlink = str_replace('%category%', $category_nicename, $catlink); @@ -40,60 +40,60 @@ function get_category_link($category_id) { } function get_the_category_list($separator = '', $parents='') { - $categories = get_the_category(); - if (empty($categories)) { - return apply_filters('the_category', __('Uncategorized'), $separator, $parents); - } + $categories = get_the_category(); + if (empty($categories)) + return apply_filters('the_category', __('Uncategorized'), $separator, $parents); - $thelist = ''; - if ('' == $separator) { - $thelist .= ''; - } else { - $i = 0; - foreach ($categories as $category) { - $category->cat_name = $category->cat_name; - if (0 < $i) $thelist .= $separator . ' '; - switch(strtolower($parents)) { - case 'multiple': - if ($category->category_parent) $thelist .= get_category_parents($category->category_parent, TRUE); - $thelist .= 'cat_name) . '" rel="category tag">'.$category->cat_name.''; - break; - case 'single': - $thelist .= 'cat_name) . '" rel="category tag">'; - if ($category->category_parent) $thelist .= get_category_parents($category->category_parent, FALSE); - $thelist .= "$category->cat_name"; - break; - case '': - default: - $thelist .= 'cat_name) . '" rel="category tag">'.$category->cat_name.''; - } - ++$i; - } - } - return apply_filters('the_category', $thelist, $separator, $parents); + $thelist = ''; + if ( '' == $separator ) { + $thelist .= ''; + } else { + $i = 0; + foreach ( $categories as $category ) { + $category->cat_name = $category->cat_name; + if ( 0 < $i ) + $thelist .= $separator . ' '; + switch ( strtolower($parents) ) { + case 'multiple': + if ( $category->category_parent ) + $thelist .= get_category_parents($category->category_parent, TRUE); + $thelist .= 'cat_name) . '" rel="category tag">'.$category->cat_name.''; + break; + case 'single': + $thelist .= 'cat_name) . '" rel="category tag">'; + if ( $category->category_parent ) + $thelist .= get_category_parents($category->category_parent, FALSE); + $thelist .= "$category->cat_name"; + break; + case '': + default: + $thelist .= 'cat_name) . '" rel="category tag">'.$category->cat_name.''; + } + ++$i; + } + } + return apply_filters('the_category', $thelist, $separator, $parents); } function the_category($separator = '', $parents='') { @@ -107,32 +107,34 @@ function get_the_category_by_ID($cat_ID) { } function get_category_parents($id, $link = FALSE, $separator = '/', $nicename = FALSE){ - $chain = ''; - $parent = &get_category($id); - if ($nicename) { - $name = $parent->category_nicename; - } else { - $name = $parent->cat_name; - } - if ($parent->category_parent) $chain .= get_category_parents($parent->category_parent, $link, $separator, $nicename); - if ($link) { - $chain .= 'cat_name) . '">'.$name.'' . $separator; - } else { - $chain .= $name.$separator; - } - return $chain; + $chain = ''; + $parent = &get_category($id); + + if ( $nicename ) + $name = $parent->category_nicename; + else + $name = $parent->cat_name; + + if ( $parent->category_parent ) + $chain .= get_category_parents($parent->category_parent, $link, $separator, $nicename); + + if ( $link ) + $chain .= 'cat_name) . '">'.$name.'' . $separator; + else + $chain .= $name.$separator; + return $chain; } function get_category_children($id, $before = '/', $after = '') { global $cache_categories; - if ( ! isset($cache_categories)) + if ( !isset($cache_categories) ) update_category_cache(); - + $c_cache = $cache_categories; // Can't do recursive foreach on a global, have to make a copy $chain = ''; - foreach ($c_cache as $category){ - if ($category->category_parent == $id){ + foreach ( $c_cache as $category ) { + if ( $category->category_parent == $id ) { $chain .= $before.$category->cat_ID.$after; $chain .= get_category_children($category->cat_ID, $before, $after); } @@ -142,105 +144,131 @@ function get_category_children($id, $before = '/', $after = '') { // Deprecated. function the_category_ID($echo = true) { - // Grab the first cat in the list. - $categories = get_the_category(); - $cat = $categories[0]->cat_ID; - - if ($echo) echo $cat; + // Grab the first cat in the list. + $categories = get_the_category(); + $cat = $categories[0]->cat_ID; - return $cat; + if ( $echo ) + echo $cat; + + return $cat; } // Deprecated. function the_category_head($before='', $after='') { - global $currentcat, $previouscat; - // Grab the first cat in the list. - $categories = get_the_category(); - $currentcat = $categories[0]->category_id; - if ($currentcat != $previouscat) { - echo $before; - echo get_the_category_by_ID($currentcat); - echo $after; - $previouscat = $currentcat; - } + global $currentcat, $previouscat; + // Grab the first cat in the list. + $categories = get_the_category(); + $currentcat = $categories[0]->category_id; + if ( $currentcat != $previouscat ) { + echo $before; + echo get_the_category_by_ID($currentcat); + echo $after; + $previouscat = $currentcat; + } } function category_description($category = 0) { - global $cat; - if (!$category) $category = $cat; - $category = & get_category($category); - return apply_filters('category_description', $category->category_description, $category->cat_ID); + global $cat; + if ( !$category ) + $category = $cat; + $category = & get_category($category); + return apply_filters('category_description', $category->category_description, $category->cat_ID); } // out of the WordPress loop function dropdown_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', - $optiondates = 0, $optioncount = 0, $hide_empty = 1, $optionnone=FALSE, - $selected=0, $hide=0) { - global $wpdb; - if (($file == 'blah') || ($file == '')) $file = get_settings('home') . '/'; - if (!$selected) $selected=$cat; - $sort_column = 'cat_'.$sort_column; + $optiondates = 0, $optioncount = 0, $hide_empty = 1, $optionnone=FALSE, + $selected=0, $hide=0) { + global $wpdb; + if ( ($file == 'blah') || ($file == '') ) + $file = get_settings('home') . '/'; + if ( !$selected ) + $selected=$cat; + $sort_column = 'cat_'.$sort_column; - $query = " - SELECT cat_ID, cat_name, category_nicename,category_parent, - COUNT($wpdb->post2cat.post_id) AS cat_count, - DAYOFMONTH(MAX(post_date)) AS lastday, MONTH(MAX(post_date)) AS lastmonth - FROM $wpdb->categories LEFT JOIN $wpdb->post2cat ON (cat_ID = category_id) - LEFT JOIN $wpdb->posts ON (ID = post_id) - WHERE cat_ID > 0 - "; - if ($hide) { - $query .= " AND cat_ID != $hide"; - $query .= get_category_children($hide, " AND cat_ID != "); - } - $query .=" GROUP BY cat_ID"; - if (intval($hide_empty) == 1) $query .= " HAVING cat_count > 0"; - $query .= " ORDER BY $sort_column $sort_order, post_date DESC"; + $query = " + SELECT cat_ID, cat_name, category_nicename,category_parent, + COUNT($wpdb->post2cat.post_id) AS cat_count, + DAYOFMONTH(MAX(post_date)) AS lastday, MONTH(MAX(post_date)) AS lastmonth + FROM $wpdb->categories LEFT JOIN $wpdb->post2cat ON (cat_ID = category_id) + LEFT JOIN $wpdb->posts ON (ID = post_id) + WHERE cat_ID > 0 + "; + if ( $hide ) { + $query .= " AND cat_ID != $hide"; + $query .= get_category_children($hide, " AND cat_ID != "); + } + $query .=" GROUP BY cat_ID"; + if ( intval($hide_empty) == 1 ) + $query .= " HAVING cat_count > 0"; + $query .= " ORDER BY $sort_column $sort_order, post_date DESC"; - $categories = $wpdb->get_results($query); - echo "\n"; + $categories = $wpdb->get_results($query); + echo "\n"; } // out of the WordPress loop function wp_list_cats($args = '') { parse_str($args, $r); - if (!isset($r['optionall'])) $r['optionall'] = 0; - if (!isset($r['all'])) $r['all'] = 'All'; - if (!isset($r['sort_column'])) $r['sort_column'] = 'ID'; - if (!isset($r['sort_order'])) $r['sort_order'] = 'asc'; - if (!isset($r['file'])) $r['file'] = ''; - if (!isset($r['list'])) $r['list'] = true; - if (!isset($r['optiondates'])) $r['optiondates'] = 0; - if (!isset($r['optioncount'])) $r['optioncount'] = 0; - if (!isset($r['hide_empty'])) $r['hide_empty'] = 1; - if (!isset($r['use_desc_for_title'])) $r['use_desc_for_title'] = 1; - if (!isset($r['children'])) $r['children'] = true; - if (!isset($r['child_of'])) $r['child_of'] = 0; - if (!isset($r['categories'])) $r['categories'] = 0; - if (!isset($r['recurse'])) $r['recurse'] = 0; - if (!isset($r['feed'])) $r['feed'] = ''; - if (!isset($r['feed_image'])) $r['feed_image'] = ''; - if (!isset($r['exclude'])) $r['exclude'] = ''; - if (!isset($r['hierarchical'])) $r['hierarchical'] = true; + if ( !isset($r['optionall'])) + $r['optionall'] = 0; + if ( !isset($r['all'])) + $r['all'] = 'All'; + if ( !isset($r['sort_column']) ) + $r['sort_column'] = 'ID'; + if ( !isset($r['sort_order']) ) + $r['sort_order'] = 'asc'; + if ( !isset($r['file']) ) + $r['file'] = ''; + if ( !isset($r['list']) ) + $r['list'] = true; + if ( !isset($r['optiondates']) ) + $r['optiondates'] = 0; + if ( !isset($r['optioncount']) ) + $r['optioncount'] = 0; + if ( !isset($r['hide_empty']) ) + $r['hide_empty'] = 1; + if ( !isset($r['use_desc_for_title']) ) + $r['use_desc_for_title'] = 1; + if ( !isset($r['children']) ) + $r['children'] = true; + if ( !isset($r['child_of']) ) + $r['child_of'] = 0; + if ( !isset($r['categories']) ) + $r['categories'] = 0; + if ( !isset($r['recurse']) ) + $r['recurse'] = 0; + if ( !isset($r['feed']) ) + $r['feed'] = ''; + if ( !isset($r['feed_image']) ) + $r['feed_image'] = ''; + if ( !isset($r['exclude']) ) + $r['exclude'] = ''; + if ( !isset($r['hierarchical']) ) + $r['hierarchical'] = true; return list_cats($r['optionall'], $r['all'], $r['sort_column'], $r['sort_order'], $r['file'], $r['list'], $r['optiondates'], $r['optioncount'], $r['hide_empty'], $r['use_desc_for_title'], $r['children'], $r['child_of'], $r['categories'], $r['recurse'], $r['feed'], $r['feed_image'], $r['exclude'], $r['hierarchical']); } @@ -248,15 +276,14 @@ function wp_list_cats($args = '') { function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=FALSE, $child_of=0, $categories=0, $recurse=0, $feed = '', $feed_image = '', $exclude = '', $hierarchical=FALSE) { global $wpdb, $category_posts; // Optiondates now works - if ('' == $file) { + if ( '' == $file ) $file = get_settings('home') . '/'; - } $exclusions = ''; - if (!empty($exclude)) { + if ( !empty($exclude) ) { $excats = preg_split('/[\s,]+/',$exclude); - if (count($excats)) { - foreach ($excats as $excat) { + if ( count($excats) ) { + foreach ( $excats as $excat ) { $exclusions .= ' AND cat_ID <> ' . intval($excat) . ' '; } } @@ -264,10 +291,10 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde $exclusions = apply_filters('list_cats_exclusions', $exclusions ); - if (intval($categories)==0){ + if ( intval($categories) == 0 ) { $sort_column = 'cat_'.$sort_column; - $query = " + $query = " SELECT cat_ID, cat_name, category_nicename, category_description, category_parent FROM $wpdb->categories WHERE cat_ID > 0 $exclusions @@ -275,63 +302,60 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde $categories = $wpdb->get_results($query); } - if (!count($category_posts)) { + if ( !count($category_posts) ) { $now = current_time('mysql', 1); $cat_counts = $wpdb->get_results(" SELECT cat_ID, COUNT($wpdb->post2cat.post_id) AS cat_count - FROM $wpdb->categories + FROM $wpdb->categories INNER JOIN $wpdb->post2cat ON (cat_ID = category_id) INNER JOIN $wpdb->posts ON (ID = post_id) WHERE post_status = 'publish' AND post_date_gmt < '$now' $exclusions GROUP BY category_id"); - if (! empty($cat_counts)) { - foreach ($cat_counts as $cat_count) { - if (1 != intval($hide_empty) || $cat_count > 0) { - $category_posts["$cat_count->cat_ID"] = $cat_count->cat_count; - } - } - } + if ( !empty($cat_counts) ) { + foreach ( $cat_counts as $cat_count ) { + if ( 1 != intval($hide_empty) || $cat_count > 0 ) + $category_posts["$cat_count->cat_ID"] = $cat_count->cat_count; + } + } } - + if ( $optiondates ) { $cat_dates = $wpdb->get_results(" SELECT category_id, UNIX_TIMESTAMP( MAX(post_date) ) AS ts - FROM $wpdb->posts, $wpdb->post2cat, $wpdb->categories + FROM $wpdb->posts, $wpdb->post2cat, $wpdb->categories WHERE post_status = 'publish' AND post_id = ID $exclusions GROUP BY category_id"); - foreach ($cat_dates as $cat_date) { + foreach ( $cat_dates as $cat_date ) { $category_timestamp["$cat_date->category_id"] = $cat_date->ts; } } - + $num_found=0; $thelist = ""; - - foreach ($categories as $category) { - if ((intval($hide_empty) == 0 || isset($category_posts["$category->cat_ID"])) && (!$hierarchical || $category->category_parent == $child_of) ) { + + foreach ( $categories as $category ) { + if ( (intval($hide_empty) == 0 || isset($category_posts["$category->cat_ID"])) && (!$hierarchical || $category->category_parent == $child_of) ) { $num_found++; $link = 'category_description)) { + if ( $use_desc_for_title == 0 || empty($category->category_description) ) $link .= 'title="'. sprintf(__("View all posts filed under %s"), wp_specialchars($category->cat_name)) . '"'; - } else { + else $link .= 'title="' . wp_specialchars(apply_filters('category_description',$category->category_description,$category)) . '"'; - } $link .= '>'; $link .= apply_filters('list_cats', $category->cat_name, $category).''; if ( (! empty($feed_image)) || (! empty($feed)) ) { - + $link .= ' '; - if (empty($feed_image)) { + if ( empty($feed_image) ) $link .= '('; - } - $link .= 'cat_ID, $category->category_nicename) . '"'; if ( !empty($feed) ) { - $title = ' title="' . $feed . '"'; + $title = ' title="' . $feed . '"'; $alt = ' alt="' . $feed . '"'; $name = $feed; $link .= $title; @@ -339,66 +363,67 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde $link .= '>'; - if (! empty($feed_image)) { + if ( !empty($feed_image) ) $link .= "'; - } else { + else $link .= $name; - } - + $link .= ''; - if (empty($feed_image)) { + if (empty($feed_image)) $link .= ')'; - } } - if (intval($optioncount) == 1) { + if ( intval($optioncount) == 1 ) $link .= ' ('.intval($category_posts["$category->cat_ID"]).')'; - } + if ( $optiondates ) { - if ( $optiondates == 1 ) $optiondates = 'Y-m-d'; + if ( $optiondates == 1 ) + $optiondates = 'Y-m-d'; $link .= ' ' . gmdate($optiondates, $category_timestamp["$category->cat_ID"]); } - if ($list) { + + if ( $list ) $thelist .= "\t
  • $link\n"; - } else { + else $thelist .= "\t$link
    \n"; - } - if ($hierarchical && $children) $thelist .= list_cats($optionall, $all, $sort_column, $sort_order, $file, $list, $optiondates, $optioncount, $hide_empty, $use_desc_for_title, $hierarchical, $category->cat_ID, $categories, 1, $feed, $feed_image, $exclude, $hierarchical); - if ($list) $thelist .= "
  • \n"; - } + + if ($hierarchical && $children) + $thelist .= list_cats($optionall, $all, $sort_column, $sort_order, $file, $list, $optiondates, $optioncount, $hide_empty, $use_desc_for_title, $hierarchical, $category->cat_ID, $categories, 1, $feed, $feed_image, $exclude, $hierarchical); + if ($list) + $thelist .= "\n"; + } } - if (!$num_found && !$child_of){ - if ($list) { + if ( !$num_found && !$child_of ) { + if ( $list ) { $before = '
  • '; $after = '
  • '; } echo $before . __("No categories") . $after . "\n"; return; } - if ($list && $child_of && $num_found && $recurse) { + if ( $list && $child_of && $num_found && $recurse ) { $pre = "\t\t\n"; } else { $pre = $post = ''; } $thelist = $pre . $thelist . $post; - if ($recurse) { + if ( $recurse ) return $thelist; - } echo apply_filters('list_cats', $thelist); } function in_category($category) { // Check if the current post is in the given category global $post, $category_cache; $cats = ''; - foreach ($category_cache[$post->ID] as $cat) : + foreach ( $category_cache[$post->ID] as $cat ) { $cats[] = $cat->cat_ID; - endforeach; + } if ( in_array($category, $cats) ) return true; else return false; } -?> +?> \ No newline at end of file