item in posts */ add_filter("the_content",array("hotcats","hotcats_filter")); /* allows you to show HotCats if the footer feature is disabled */ function hotcats_show(){ echo hotcats::show_hotcats(); } /* This plugin generates a list of catagories with more than one post in them. It displays this list as text, with a larger font size for a catagory with more posts in. The text size is rounded up to the nearest pixel and set using the CSS font-size attribute. Using the options panel, settings can be altered such as the minimum and maximum text sizes, as well as whether to display HotCats in the footer or not. HotCats can also be displayed by calling the function hotcats_show();. TODO: - Add support for excluding catagories through options panel - Add option panel - Support for multiple blogs (i.e. blog id) */ class hotcats{ function show_hotcats(){ global $wpdb, $table_prefix; $mintextsize = get_option("wphotcats_mincatsize"); $maxtextsize = get_option("wphotcats_maxcatsize"); $bloghome = get_option("siteurl"); // get all catagories and post counts from the wpdb $cats = $wpdb->get_results("SELECT cat_ID, cat_name, category_count FROM ".$table_prefix."categories ORDER BY cat_name",ARRAY_A); // find catagory with biggest number of posts $num_posts = 0; foreach($cats as $cat){ if($cat['category_count'] > $num_posts){ $num_posts = $cat['category_count']; } $totalposts += $cat['category_count']; } // now show each and size text accordingly $post_step = ($maxtextsize-$mintextsize)/$mintextsize; foreach($cats as $cat){ $textsize = (($maxtextsize/$num_posts)*$cat['category_count']) + $mintextsize; if($textsize > $maxtextsize){ $textsize = $maxtextsize; } if($cat['cat_name'] != "Uncategorized" && $cat['category_count'] > 0){ $hotcats .= "".$cat['cat_name'].", "; } if($wphotcats_debug){ echo "(font-size: $textsize; steps: $num_steps; posts: ".$cat['category_count'].")"; } } return $hotcats; } function hotcats_footer(){ // add the javascript to put it inside the page div echo ""; } function add_admin_panel(){ add_options_page('HotCats', 'HotCats', 8, __FILE__, array("hotcats",'hotcats_options')); } function hotcats_options(){ $error_string = ""; // process $_GET headers and then show the actual panel if(isset($_GET['hotcats_update'])){ if(isset($_GET['hotcats_min_text_size'])){ update_option("wphotcats_mincatsize",$_GET['hotcats_min_text_size']); }else{ $error_string += "Minimum text size was not set.
"; } if(isset($_GET['hotcats_max_text_size'])){ update_option("wphotcats_maxcatsize",$_GET['hotcats_max_text_size']); }else{ $error_string += "Maximum text size not set.
"; } update_option("wphotcats_dofooter",$_GET['hotcats_footer_on']); if(isset($error_string)){ echo "

Options saved.

"; }else{ echo "

$error_string

"; } } ?>
">

HotCats Options

> Show HotCats in the footer (uses a JavaScript hack)

Minimum text size:" size="4"/> px
Maximum text size:" size="4"/> px


How to use

You can display HotCats on your blog in 3 ways:
  1. You can enable it in the footer of your blog above by selecting 'Show HotCats in the footer'
  2. HotCats can be called from your blog's template using this bit of code: <?php hotcats_show(); ?>
  3. And finally, you can add HotCats to your individual posts by using <hotcats/>

HotCats version 1.1 by Matt. Thanks to James for help with testing.
tags with the hotcats */ function hotcats_filter($content){ $contentOut = str_replace("",hotcats::show_hotcats(),$content); return $contentOut; } } ?>