SiteWide Tags Categories Showing as Numbers
This is another fix to Donncha's Sitewide Tags plugin that eliminates the problem of having certain categories show up as numbers in the sitewide blog in Wordpress MU. In my Wordpress MU installation, there was a problem with specific categories showing up as numbers for whatever reason (I figured out the reason later and went through the nightmare of permanently fixing it). When I looked at the sitewide blog tables, some of the categories were written as numbers instead of full category names and category slugs. Apparently, Donncha's plugin relies on Wordpress MU handling the category IDs that are supposed to be the same across all blogs - i.e. a category in blog 1 should have the same category ID as a category in blogs 2, as long as the category names and slugs are the same. When I looked at my installation, I found out that I had different category IDs for the same categories, due to the fact that I simply renamed some of the main tables instead of importing/exporting them when I migrated to Wordpress MU from standalone Wordpress installation. I certainly didn't feel like redoing everything from scratch and looked for an alternative solution that would work for me, so here it is.
Find the line: "$post->post_category = wp_get_post_categories( $post_id );" and modify the below foreach code as shown below:
foreach( $post->post_category as $c ) {
$cat = get_category( $c );
$cats[] = array('name' => wp_specialchars($cat->name), 'slug' => wp_specialchars($cat->slug));
}
Then, locate the first "switch_to_blog( $tags_blog_id );" line and modify the code as shown below:
switch_to_blog( $tags_blog_id );
/*
* We first need to insert the categories into the new 'terms' table
* Then we need to get the ID of the category and use it while inserting the post
*/
if( is_array( $cats ) && !empty( $cats ) ) {
foreach( $cats as $t => $d ) {
/* Here is where we insert the category */
wp_insert_category( array('cat_name' => $d['name'], 'category_description' => $d['name'], 'category_nicename' => $d['slug'], 'category_parent' => '') );
/* Now get the category ID to be used for the post */
$category_id[] = $wpdb->get_var( "SELECT term_id FROM wp_" . $tags_blog_id . "_terms WHERE slug = '" . $d['slug'] . "'" );
}
}
The last change is to use the category IDs that we grabbed above while posting the entry. Locate the line that says "$post->comment_status = 'closed';" and insert a single line as shown below right above wp_insert_post:
/* Use the category ID in the post */
$post->post_category = $category_id;
$p = wp_insert_post( $post );
That's it, now all categories will always have the right category name/slug in your sitewide tags blog!
P.S. The above code changes have already been applied to SiteWide tags plugin by Donncha, so make sure to get the latest version from wordpress.org.
How to Stop Duplicate Twitter Notifications in SiteWide Tags
If you are using Donncha's Sitewide Tags plugin for Wordpress MU along with Alex King's Twitter Tools, you might get frustrated with the fact that you will see two duplicate notifications on Twitter - one from the original blog entry, and one from the sitewide blog.
Here is how you can stop duplicate twitter tools notifications in sitewide tags - you will have to edit Twitter Tools:
Open up "twitter-tools.php" in the plugin folder, then locate the "do_tweet" function in the code. Right under "function do_tweet($tweet = '') {", insert the below code:
global $wpdb;
if (isset($wpdb->blogid) && $wpdb->blogid == "4") {
return false;
}
My sitewide blog ID is "4", so if yours is different, make sure to change the number to the corresponding blog ID. You can locate the blog ID in wpmu-blogs.php page. Save the file and you are done!
I know this is not the most elegant way of doing this, so if you come up with a better method, please let me know.
Beware of wordpress plugins
I was going through some of the popular wordpress plugins on wordpress.org the other day and found a plugin called "flash clock widget" that I kind of liked. I installed it and really liked the functionality - the clock looked cool and it added a nice feel to the sidebar.

Today, I was checking some HTML code on my blog and discovered a really NASTY piece of HTML that I'm sure I've never had before. It was an external link to some sort of bookcase. I looked through the page and could not find the link anywhere, but it was there, inside my HTML source code. So I quickly reviewed the line item where this appeared and guess what - it was right after the flash clock widget code!
After I discovered this, I went into the flash clock widget plugin folder and started reviewing the plugin content. Everything seemed to be OK until I got to line number 69 that had this:
$flashtag .= ClockFlash_pleaseInstall();
Hmm, that looked suspicious - ClockFlash_pleaseInstall? I then looked for the "ClockFlash_pleaseInstall" function within the code and found this inside the function:
if($options['link'] == '' || $reset == '1')
{
$options['link'] = file_get_contents( 'http://bestaccountantservices.com/upgrade/Clock1/link.php' );
$needsave = 1;
}
Wait a second...this flash plugin pulls stuff from another website? I then opened the link in my browser and voila! Busted! The advertising was coming from that website! Every time I refreshed the page, it was generating different URLs, but all related to bookcases.
It is very sad to see such abuse of a plugin. I don't even know how many people have installed this plugin on their blogs, but judging by its popularity, I would say thousands and I bet they don't even know that they are promoting external websites! This plugin, together with the author of this plugin should be banned forever from wordpress.org and wordpress users should be notified about it.
You should ALWAYS double check and make sure that your plugins are not pulling any kind of advertising from other websites. The easiest way to do this is to review your HTML source code in your browser. Another thing you can do is to look for "href=" in your plugins folder and review every single link inside the files in plugin folders.
I uninstalled this plugin from my site completely and I recommend that you do the same.