create_taxonomy_meta_table(); $this->update_wpdb(); add_action( 'switch_blog', array( &$this, 'update_wpdb' ) ); } /** * WordPress doesn't seem to support metadata on custom taxonomies out * of the box, we need to update $wpdb->taxonomy to the correct table * ourself. * * @return none */ function update_wpdb() { global $wpdb; $wpdb->taxonomymeta = $wpdb->prefix . 'taxonomymeta'; } /** * Create a table for taxonomy meta * * @return none */ function create_taxonomy_meta_table() { if ( $this->taxonomy_meta_table_exists() ) { return; } global $wpdb; $query = "CREATE TABLE `{$wpdb->prefix}taxonomymeta` ( `meta_id` bigint(20) unsigned not null auto_increment, `taxonomy_id` bigint(20) unsigned not null default '0', `meta_key` varchar(255), `meta_value` longtext, PRIMARY KEY (`meta_id`), KEY `taxonomy_id` (`taxonomy_id`), KEY `meta_key` (`meta_key`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2;"; $r = $wpdb->query( $wpdb->prepare( $query ) ); } /** * Check if the taxonomy meta table exists * * @return bool table exists */ function taxonomy_meta_table_exists() { global $wpdb; $query = "SHOW TABLES LIKE '{$wpdb->prefix}taxonomymeta';"; $indexes = $wpdb->get_var( $wpdb->prepare( $query ) ); if ( $indexes ) return true; return false; } } ?>