Here are a few changes I did to some of the functions inside
simple-tags\inc\admin.php to support multiple taxonomies
Here are the sections of code that are different, leave the rest of the function intact.
function deleteTagsByTagList( $delete ) {
if ( trim( str_replace(',', '', stripslashes($delete)) ) == '' ) {
$this->message = __('No tag specified!', 'simpletags');
$this->status = 'error';
return;
}
// In array + filter
$delete_tags = explode(',', $delete);
$delete_tags = array_filter($delete_tags, array(&$this, 'deleteEmptyElement'));
// Delete tags
$counter = 0;
$taxonomies=get_taxonomies(array('public' => true,'_builtin' => true),'names','or');
foreach ($taxonomies as $taxonomy ) {
foreach ( (array) $delete_tags as $tag ) {
$term = get_term_by('name', $tag, $taxonomy);
$term_id = (int) $term->term_id;
if ( $term_id != 0 ) {
wp_delete_term( $term_id, $taxonomy);
clean_term_cache( $term_id, $taxonomy);
$counter++;
}
}
}
function addMatchTags( $match, $new ) {
if ( trim( str_replace(',', '', stripslashes($new)) ) == '' ) {
$this->message = __('No new tag(s) specified!', 'simpletags');
$this->status = 'error';
return;
}
$match_tags = explode(',', $match);
$new_tags = explode(',', $new);
$match_tags = array_filter($match_tags, array(&$this, 'deleteEmptyElement'));
$new_tags = array_filter($new_tags, array(&$this, 'deleteEmptyElement'));
$counter = 0;
if ( !empty($match_tags) ) { // Match and add
// Get terms ID from old match names
$terms_id = array();
$taxonomies=get_taxonomies(array('public' => true,'_builtin' => true),'names','or');
foreach ($taxonomies as $taxonomy ) {
foreach ( (array) $match_tags as $match_tag ) {
$term = get_term_by('name', $match_tag, $taxonomy);
if($term)
$terms_id[(int) $term->term_id] = $term->taxonomy;
}
}
foreach ($taxonomies as $taxonomy ) {
foreach ( (array) $new_tags as $new_tag ) {
$term = get_term_by('name', $new_tag, $taxonomy);
if($term)
$new_terms_id[(int) $term->term_id] = $term->taxonomy;
}
}
// Get object ID with terms ID
$objects_id = array();
foreach($terms_id as $id => $tax){
$objects_id = array_merge($objects_id, get_objects_in_term( $id, $tax, array('fields' => 'all_with_object_id') ));
}
// Add new tags for specified post
foreach ( (array) $objects_id as $object_id ) {
foreach($new_terms_id as $id => $tax){
wp_set_object_terms( $object_id, $id, $tax, true ); // Append tags
$counter++;
}
}
function ajaxLocalTags( $format = 'html_span' ) {
status_header( 200 ); // Send good header HTTP
header("Content-Type: text/javascript; charset=" . get_bloginfo('charset'));
if ((int) wp_count_terms($this->taxonomy, 'ignore_empty=true') == 0 ) { // No tags to suggest
if ( $format == 'html_span' ) {
echo '<p>'.__('No terms in your WordPress database.', 'simpletags').'</p>';
}
exit();
}
// Prepare search
$search = trim(stripslashes($_GET['q']));
$terms = array();
$taxonomies=get_taxonomies(array('public' => true,'_builtin' => true),'names','or');
foreach ($taxonomies as $taxonomy ) {
$terms = array_merge($terms, $this->getTermsForAjax( $taxonomy, $search, $format ));
}