function get_TagsBit() { global $wpdb; $bon_TechnoTaggingOptions = bon_technoratiTaggingLoadOptions(); if ($technoTag_tagbitlink == '') { $technoTag_tagbitlink = $bon_TechnoTaggingOptions['technoTag_link']; } $where = ''; $limit = ''; if ($bon_TechnoTaggingOptions['technoTag_tagbit_numdays'] > 0) { $where = " AND post_date >= '" . date('Y-m-d H:i:00', time() - ($bon_TechnoTaggingOptions['technoTag_tagbit_numdays'] * 86400)) . "'"; } if ($bon_TechnoTaggingOptions['technoTag_tagbit_numposts'] > 0) { $limit = ' LIMIT ' . $bon_TechnoTaggingOptions['technoTag_tagbit_numposts']; } // load the tags $tagData = implode(",", $wpdb->get_col("SELECT meta_value FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON $wpdb->posts.ID=$wpdb->postmeta.post_id WHERE (meta_key='ttaglist' OR meta_key='technorati') AND post_status='publish'$where ORDER BY post_date DESC$limit")); $tagArray = preg_split("/[,]+/", $tagData); $tagsFreqData = array(); // work out the frequency of each of the tags foreach ($tagArray as $tag) { $tag = trim(strtolower($tag)); if ($tag != '') { if (!isset($tagsFreqData[$tag])) $tagsFreqData[$tag] = 1; else $tagsFreqData[$tag]++; } } // sort into order arsort($tagsFreqData, SORT_NUMERIC); // get the min/max frequency $freqMin = end($tagsFreqData); $freqMax = reset($tagsFreqData); // make sure we have the right number of tags if ($bon_TechnoTaggingOptions['technoTag_tagbits_count'] > 0) { if (count($tagsFreqData) > $bon_TechnoTaggingOptions['technoTag_tagbits_count']) $tagsFreqData = array_slice($tagsFreqData, 0, $bon_TechnoTaggingOptions['technoTag_tagbits_count']); } // get the names of the tags in alphabetical order, used to output // the list in alphabetical order. $tagNames = array_keys($tagsFreqData); sort($tagNames); $tagDoneData = array(); foreach ($tagNames as $tag) { $size = bon_technoratiTagging_get_tagbit_fontsize($tagsFreqData[$tag], $freqMax, $freqMin); $colour = bon_technoratiTagging_get_tagbit_color($tagsFreqData[$tag], $freqMax, $freqMin); $tagFixed = bon_technorati_fixTag($tag); $tagDoneData[] = ' ' . $tag . ' '; } echo '
' . implode('', $tagDoneData) . '
'; }