Archived Page

You're reading an archived page of the site. The content is probably out of date. Try the homepage for more current content.

Real Global Terms

Please Note: This is a WordPress MU plugin, do not install it on a standalone version of WordPress. WPMU and this plugin require some PHP knowledge. It’s not intended for end users. You have been warned! 🙂

Intro

The sitecategories table in WPMU is somewhat broken. It’s a left over from the upgrade to the new term / taxonomy structure introduced in WordPress 2.2. This plugin removes the filter that keeps the sitecategories table up to date. Instead, it creates two new tables ‘site_terms’ and ‘site_term_taxonomy’.

Then it populates these tables every time a new term or term_taxonomy is created, and keeps the IDs in sync on each individual blog. The end result is that you have a global term / term_taxonomy system.

This is fairly useless in itself. However, it provides the foundation for the SH Global Posts plugin which provides global categories, global tags, global search, etc.

Core code

This plugin relies on a core code change. I’ve requested that this be included in WP core, but as at May 2008 that hasn’t been done. So, you will need to edit the file manually.

You can download the patch here. Or, you can edit the files manually. Look for this line in wp-includes/taxonomy.php:

$term_id = apply_filters('term_id_filter', $term_id, $tt_id);

Then immediately following it, add this line:

$tt_id = apply_filters('term_taxonomy_id_filter', $tt_id, $term_id);

So the end result will be this:

$term_id = apply_filters('term_id_filter', $term_id, $tt_id);
    $tt_id = apply_filters('term_taxonomy_id_filter', $tt_id, $term_id);

As at revision 1260 (27 May 2008) this code appears twice in the wp-includes/taxonomy.php file, at lines 1228 and 1484. The quickest way to find these lines is search the code for “term_id_filter”.

After Install

When you install the plugin, it will check if it has already been installed (using a site option) and then globalise all your existing terms / term_taxonomies. This could take some time and will happen on the first page request (anywhere on the site) immediately after install. So I’d suggest installing when the site is quiet and hitting a page immediately.

MU Plugins

This plugin must be installed for all blogs on your site, so it must be in the ‘wp-content/mu-plugins’ directory. If you install it in the ‘wp-content/plugins’ directory the world may very well end. 🙂

Support

I’m happy to answer developer questions here and there, but I can’t provide end user support for this plugin. If you can’t read the code and understand what it does, I’d suggest avoid using the plugin. If you ask me very nicely and promise to send me chocolate cake, I might be able to help. But it’s strictly at your own risk. Please post any questions in the comments on this page.

Download

If you have made it this far and still want to proceed, please go ahead and download the code here. I’d strongly recommend you subscribe to this feed to be kept informed about updates to the plugin.

Gratitude

This plugin was created as part of my work with SmartHippo. If you’d like to show gratitude, please register with SmartHippo and post a rate.

Changelog

0.1.1 – Updated plugin description

0.1 – First public release

Comments

Chris L at 2008-09-27 07:46:39

Do you still plan to update this? I like Donncha's plugin OK, but it doesn't ahve the ability to integrate existing posts and terms like yours does, which is important for me...

Chris at 2008-07-19 01:14:38

Urrgh, timeout. ok, forget all of that. PHP5. Jason, I feel your pain. Managed to create tables using: `` Clicked on a tag and poof! Categories listed (still no content). err log: `WordPress database error Unknown column 'tt.count' in 'where clause' for query SELECT t.*, tt.* FROM wp_site_terms AS t INNER JOIN wp_site_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('post_tag') AND tt.count > 0 ORDER BY tt.count DESC LIMIT 45 made by get_terms` There also appears to have been a change in the cat_id as my template supresses certain cat_id, no more... I'll play with that later. Hopefully that value is static.

Justin at 2008-06-17 01:48:05

I ran a sql query and created the tables from the global_terms.php. I also edited the taxonomy.php per your instructions. But I put the sh_global_posts.php in the mu_plugin floder all categories dissapear from wpmu admin. When I try to create a new category from wpmy admin it states "undefined error. If I remove the sh_global_posts.php the original categories are still there and there is no error but the site seems unchanged from the original mu (no global changes). I am using wpmu 1.5.1 php 4.4.8 mysql 5.0,51a Any help soon will be greatly appreciated

Callum at 2008-06-17 11:45:17

@<a href="http://www.callum-macdonald.com/code/real-global-terms/#comment-28150" rel="nofollow">Justin</a>: Sorry to hear about your problems. I'm not sure what's going on to be honest. Has the initial import run? Do you see any data in the global tables? Perhaps if you have a lot of data it's causing a PHP timeout or something. Anything in the PHP error logs?

Callum at 2008-07-28 15:53:36

This plugin hasn't been updated to the latest version of WPMU yet. I'm waiting for some stuff to happen internally at work before that goes through. It should be soon though, then I'll post the updated code. Although this may be superseded by <a href="http://ocaoimh.ie/wordpress-mu-sitewide-tags/" rel="nofollow">Donncha's plugin</a>.

Callum at 2008-09-27 12:58:57

@<a href="http://www.callum-macdonald.com/code/real-global-terms/#comment-29864" rel="nofollow">Chris L</a>: Yes, I will have to update the plugin. I'm about to roll out the latest WPMU onto our production site, so I'll have to fix any issues then. :) I should have an update ready in the next 2-4 weeks I'd guess. But feel free to keep hassling me by email! :)

Two WPMU plugins published at Callum Macdonald at 2008-05-27 18:20:36

[...] published the Real Global Terms and the SH Global Posts plugins today. It&#8217;s code I&#8217;ve had running for ages and have [...]

Cretch at 2008-05-27 20:02:18

I think you should put the SQL query to create the tables needed. Would be very useful

Callum at 2008-05-27 22:26:50

@<a href="http://www.callum-macdonald.com/code/real-global-terms/#comment-27667" rel="nofollow">Cretch</a>: The plugin will create the new tables itself, no need to do that. At least it should, but if that doesn't work, please do let me know.

Cretch at 2008-05-27 22:41:02

The plugin didn't change my tables. And as stated in real-global-terms.php: "Currently does not create the global term tables, they must be created manually." Did I miss some point?

Callum at 2008-05-27 23:00:51

@<a href="http://www.callum-macdonald.com/code/real-global-terms/#comment-27682" rel="nofollow">Cretch</a>: Ignore that in the plugin description, that's out of date! I've updated it, the latest code does the same thing, but has an updated description and version no.

demonicume at 2008-06-13 20:29:31

it doesn't look like the tables were created. I'm not seeing them. i'll glance thru the code and try to create them manually.

Deryk at 2008-10-04 09:23:53

I'm really looking forward to the update of this plugin. I hope I can offer support for it after I install and understand it.