48 | | $thelist = ''; |
49 | | if ('' == $separator) { |
50 | | $thelist .= '<ul class="post-categories">'; |
51 | | foreach ($categories as $category) { |
52 | | $category->cat_name = $category->cat_name; |
53 | | $thelist .= "\n\t<li>"; |
54 | | switch(strtolower($parents)) { |
55 | | case 'multiple': |
56 | | if ($category->category_parent) { |
57 | | $thelist .= get_category_parents($category->category_parent, TRUE); |
58 | | } |
59 | | $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a></li>'; |
60 | | break; |
61 | | case 'single': |
62 | | $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . ' rel="category tag">'; |
63 | | if ($category->category_parent) { |
64 | | $thelist .= get_category_parents($category->category_parent, FALSE); |
65 | | } |
66 | | $thelist .= $category->cat_name.'</a></li>'; |
67 | | break; |
68 | | case '': |
69 | | default: |
70 | | $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a></li>'; |
71 | | } |
72 | | } |
73 | | $thelist .= '</ul>'; |
74 | | } else { |
75 | | $i = 0; |
76 | | foreach ($categories as $category) { |
77 | | $category->cat_name = $category->cat_name; |
78 | | if (0 < $i) $thelist .= $separator . ' '; |
79 | | switch(strtolower($parents)) { |
80 | | case 'multiple': |
81 | | if ($category->category_parent) $thelist .= get_category_parents($category->category_parent, TRUE); |
82 | | $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a>'; |
83 | | break; |
84 | | case 'single': |
85 | | $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'; |
86 | | if ($category->category_parent) $thelist .= get_category_parents($category->category_parent, FALSE); |
87 | | $thelist .= "$category->cat_name</a>"; |
88 | | break; |
89 | | case '': |
90 | | default: |
91 | | $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a>'; |
92 | | } |
93 | | ++$i; |
94 | | } |
95 | | } |
96 | | return apply_filters('the_category', $thelist, $separator, $parents); |
| 47 | $thelist = ''; |
| 48 | if ( '' == $separator ) { |
| 49 | $thelist .= '<ul class="post-categories">'; |
| 50 | foreach ( $categories as $category ) { |
| 51 | $category->cat_name = $category->cat_name; |
| 52 | $thelist .= "\n\t<li>"; |
| 53 | switch ( strtolower($parents) ) { |
| 54 | case 'multiple': |
| 55 | if ($category->category_parent) |
| 56 | $thelist .= get_category_parents($category->category_parent, TRUE); |
| 57 | $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a></li>'; |
| 58 | break; |
| 59 | case 'single': |
| 60 | $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . ' rel="category tag">'; |
| 61 | if ($category->category_parent) |
| 62 | $thelist .= get_category_parents($category->category_parent, FALSE); |
| 63 | $thelist .= $category->cat_name.'</a></li>'; |
| 64 | break; |
| 65 | case '': |
| 66 | default: |
| 67 | $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a></li>'; |
| 68 | } |
| 69 | } |
| 70 | $thelist .= '</ul>'; |
| 71 | } else { |
| 72 | $i = 0; |
| 73 | foreach ( $categories as $category ) { |
| 74 | $category->cat_name = $category->cat_name; |
| 75 | if ( 0 < $i ) |
| 76 | $thelist .= $separator . ' '; |
| 77 | switch ( strtolower($parents) ) { |
| 78 | case 'multiple': |
| 79 | if ( $category->category_parent ) |
| 80 | $thelist .= get_category_parents($category->category_parent, TRUE); |
| 81 | $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a>'; |
| 82 | break; |
| 83 | case 'single': |
| 84 | $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'; |
| 85 | if ( $category->category_parent ) |
| 86 | $thelist .= get_category_parents($category->category_parent, FALSE); |
| 87 | $thelist .= "$category->cat_name</a>"; |
| 88 | break; |
| 89 | case '': |
| 90 | default: |
| 91 | $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a>'; |
| 92 | } |
| 93 | ++$i; |
| 94 | } |
| 95 | } |
| 96 | return apply_filters('the_category', $thelist, $separator, $parents); |
110 | | $chain = ''; |
111 | | $parent = &get_category($id); |
112 | | if ($nicename) { |
113 | | $name = $parent->category_nicename; |
114 | | } else { |
115 | | $name = $parent->cat_name; |
116 | | } |
117 | | if ($parent->category_parent) $chain .= get_category_parents($parent->category_parent, $link, $separator, $nicename); |
118 | | if ($link) { |
119 | | $chain .= '<a href="' . get_category_link($parent->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $parent->cat_name) . '">'.$name.'</a>' . $separator; |
120 | | } else { |
121 | | $chain .= $name.$separator; |
122 | | } |
123 | | return $chain; |
| 110 | $chain = ''; |
| 111 | $parent = &get_category($id); |
| 112 | |
| 113 | if ( $nicename ) |
| 114 | $name = $parent->category_nicename; |
| 115 | else |
| 116 | $name = $parent->cat_name; |
| 117 | |
| 118 | if ( $parent->category_parent ) |
| 119 | $chain .= get_category_parents($parent->category_parent, $link, $separator, $nicename); |
| 120 | |
| 121 | if ( $link ) |
| 122 | $chain .= '<a href="' . get_category_link($parent->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $parent->cat_name) . '">'.$name.'</a>' . $separator; |
| 123 | else |
| 124 | $chain .= $name.$separator; |
| 125 | return $chain; |
156 | | global $currentcat, $previouscat; |
157 | | // Grab the first cat in the list. |
158 | | $categories = get_the_category(); |
159 | | $currentcat = $categories[0]->category_id; |
160 | | if ($currentcat != $previouscat) { |
161 | | echo $before; |
162 | | echo get_the_category_by_ID($currentcat); |
163 | | echo $after; |
164 | | $previouscat = $currentcat; |
165 | | } |
| 159 | global $currentcat, $previouscat; |
| 160 | // Grab the first cat in the list. |
| 161 | $categories = get_the_category(); |
| 162 | $currentcat = $categories[0]->category_id; |
| 163 | if ( $currentcat != $previouscat ) { |
| 164 | echo $before; |
| 165 | echo get_the_category_by_ID($currentcat); |
| 166 | echo $after; |
| 167 | $previouscat = $currentcat; |
| 168 | } |
184 | | $query = " |
185 | | SELECT cat_ID, cat_name, category_nicename,category_parent, |
186 | | COUNT($wpdb->post2cat.post_id) AS cat_count, |
187 | | DAYOFMONTH(MAX(post_date)) AS lastday, MONTH(MAX(post_date)) AS lastmonth |
188 | | FROM $wpdb->categories LEFT JOIN $wpdb->post2cat ON (cat_ID = category_id) |
189 | | LEFT JOIN $wpdb->posts ON (ID = post_id) |
190 | | WHERE cat_ID > 0 |
191 | | "; |
192 | | if ($hide) { |
193 | | $query .= " AND cat_ID != $hide"; |
194 | | $query .= get_category_children($hide, " AND cat_ID != "); |
195 | | } |
196 | | $query .=" GROUP BY cat_ID"; |
197 | | if (intval($hide_empty) == 1) $query .= " HAVING cat_count > 0"; |
198 | | $query .= " ORDER BY $sort_column $sort_order, post_date DESC"; |
| 190 | $query = " |
| 191 | SELECT cat_ID, cat_name, category_nicename,category_parent, |
| 192 | COUNT($wpdb->post2cat.post_id) AS cat_count, |
| 193 | DAYOFMONTH(MAX(post_date)) AS lastday, MONTH(MAX(post_date)) AS lastmonth |
| 194 | FROM $wpdb->categories LEFT JOIN $wpdb->post2cat ON (cat_ID = category_id) |
| 195 | LEFT JOIN $wpdb->posts ON (ID = post_id) |
| 196 | WHERE cat_ID > 0 |
| 197 | "; |
| 198 | if ( $hide ) { |
| 199 | $query .= " AND cat_ID != $hide"; |
| 200 | $query .= get_category_children($hide, " AND cat_ID != "); |
| 201 | } |
| 202 | $query .=" GROUP BY cat_ID"; |
| 203 | if ( intval($hide_empty) == 1 ) |
| 204 | $query .= " HAVING cat_count > 0"; |
| 205 | $query .= " ORDER BY $sort_column $sort_order, post_date DESC"; |
200 | | $categories = $wpdb->get_results($query); |
201 | | echo "<select name='cat' class='postform'>\n"; |
202 | | if (intval($optionall) == 1) { |
203 | | $all = apply_filters('list_cats', $all); |
204 | | echo "\t<option value='0'>$all</option>\n"; |
205 | | } |
206 | | if (intval($optionnone) == 1) echo "\t<option value='-1'>".__('None')."</option>\n"; |
207 | | if ($categories) { |
208 | | foreach ($categories as $category) { |
209 | | $cat_name = apply_filters('list_cats', $category->cat_name, $category); |
210 | | echo "\t<option value=\"".$category->cat_ID."\""; |
211 | | if ($category->cat_ID == $selected) |
212 | | echo ' selected="selected"'; |
213 | | echo '>'; |
214 | | echo $cat_name; |
215 | | if (intval($optioncount) == 1) echo ' ('.$category->cat_count.')'; |
216 | | if (intval($optiondates) == 1) echo ' '.$category->lastday.'/'.$category->lastmonth; |
217 | | echo "</option>\n"; |
218 | | } |
219 | | } |
220 | | echo "</select>\n"; |
| 207 | $categories = $wpdb->get_results($query); |
| 208 | echo "<select name='cat' class='postform'>\n"; |
| 209 | if ( intval($optionall) == 1 ) { |
| 210 | $all = apply_filters('list_cats', $all); |
| 211 | echo "\t<option value='0'>$all</option>\n"; |
| 212 | } |
| 213 | if ( intval($optionnone) == 1 ) |
| 214 | echo "\t<option value='-1'>".__('None')."</option>\n"; |
| 215 | if ( $categories ) { |
| 216 | foreach ( $categories as $category ) { |
| 217 | $cat_name = apply_filters('list_cats', $category->cat_name, $category); |
| 218 | echo "\t<option value=\"".$category->cat_ID."\""; |
| 219 | if ( $category->cat_ID == $selected ) |
| 220 | echo ' selected="selected"'; |
| 221 | echo '>'; |
| 222 | echo $cat_name; |
| 223 | if ( intval($optioncount) == 1 ) |
| 224 | echo ' ('.$category->cat_count.')'; |
| 225 | if ( intval($optiondates) == 1 ) |
| 226 | echo ' '.$category->lastday.'/'.$category->lastmonth; |
| 227 | echo "</option>\n"; |
| 228 | } |
| 229 | } |
| 230 | echo "</select>\n"; |
226 | | if (!isset($r['optionall'])) $r['optionall'] = 0; |
227 | | if (!isset($r['all'])) $r['all'] = 'All'; |
228 | | if (!isset($r['sort_column'])) $r['sort_column'] = 'ID'; |
229 | | if (!isset($r['sort_order'])) $r['sort_order'] = 'asc'; |
230 | | if (!isset($r['file'])) $r['file'] = ''; |
231 | | if (!isset($r['list'])) $r['list'] = true; |
232 | | if (!isset($r['optiondates'])) $r['optiondates'] = 0; |
233 | | if (!isset($r['optioncount'])) $r['optioncount'] = 0; |
234 | | if (!isset($r['hide_empty'])) $r['hide_empty'] = 1; |
235 | | if (!isset($r['use_desc_for_title'])) $r['use_desc_for_title'] = 1; |
236 | | if (!isset($r['children'])) $r['children'] = true; |
237 | | if (!isset($r['child_of'])) $r['child_of'] = 0; |
238 | | if (!isset($r['categories'])) $r['categories'] = 0; |
239 | | if (!isset($r['recurse'])) $r['recurse'] = 0; |
240 | | if (!isset($r['feed'])) $r['feed'] = ''; |
241 | | if (!isset($r['feed_image'])) $r['feed_image'] = ''; |
242 | | if (!isset($r['exclude'])) $r['exclude'] = ''; |
243 | | if (!isset($r['hierarchical'])) $r['hierarchical'] = true; |
| 236 | if ( !isset($r['optionall'])) |
| 237 | $r['optionall'] = 0; |
| 238 | if ( !isset($r['all'])) |
| 239 | $r['all'] = 'All'; |
| 240 | if ( !isset($r['sort_column']) ) |
| 241 | $r['sort_column'] = 'ID'; |
| 242 | if ( !isset($r['sort_order']) ) |
| 243 | $r['sort_order'] = 'asc'; |
| 244 | if ( !isset($r['file']) ) |
| 245 | $r['file'] = ''; |
| 246 | if ( !isset($r['list']) ) |
| 247 | $r['list'] = true; |
| 248 | if ( !isset($r['optiondates']) ) |
| 249 | $r['optiondates'] = 0; |
| 250 | if ( !isset($r['optioncount']) ) |
| 251 | $r['optioncount'] = 0; |
| 252 | if ( !isset($r['hide_empty']) ) |
| 253 | $r['hide_empty'] = 1; |
| 254 | if ( !isset($r['use_desc_for_title']) ) |
| 255 | $r['use_desc_for_title'] = 1; |
| 256 | if ( !isset($r['children']) ) |
| 257 | $r['children'] = true; |
| 258 | if ( !isset($r['child_of']) ) |
| 259 | $r['child_of'] = 0; |
| 260 | if ( !isset($r['categories']) ) |
| 261 | $r['categories'] = 0; |
| 262 | if ( !isset($r['recurse']) ) |
| 263 | $r['recurse'] = 0; |
| 264 | if ( !isset($r['feed']) ) |
| 265 | $r['feed'] = ''; |
| 266 | if ( !isset($r['feed_image']) ) |
| 267 | $r['feed_image'] = ''; |
| 268 | if ( !isset($r['exclude']) ) |
| 269 | $r['exclude'] = ''; |
| 270 | if ( !isset($r['hierarchical']) ) |
| 271 | $r['hierarchical'] = true; |
366 | | } |
367 | | 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); |
368 | | if ($list) $thelist .= "</li>\n"; |
369 | | } |
| 390 | |
| 391 | if ($hierarchical && $children) |
| 392 | $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); |
| 393 | if ($list) |
| 394 | $thelist .= "</li>\n"; |
| 395 | } |