populate_taxes(); echo '
'; if ( ! current_user_can('manage_categories') ) { echo '
'; echo '

' . __('Cheatin’ uh?', 'wptaxconvertaffinitomics') . '

'; echo '
'; } else { ?> '; } function populate_taxes() { $taxonomies = get_taxonomies(array('public' => true),'names'); foreach ( $taxonomies as $taxonomy ) { if ($taxonomy !== 'post_format') $this->taxes[$taxonomy] = get_taxonomy($taxonomy); } } function populate_tax($tax) { $terms = get_terms( array($tax), array('get' => 'all') ); foreach ( $terms as $term ) { $this->all_terms[$tax][] = $term; if ( is_array(term_exists( $term->slug )) ) $this->hybrids_ids[] = $term->term_id; } } function tabs($tax) { $this->populate_tax($tax); $num = count($this->all_terms[$tax]); $details = $this->taxes[$tax]; echo '
'; if ( $num > 0 ) { screen_icon(); echo '

' . __( 'Convert or Copy '.$details->label, 'wptaxconvertaffinitomics') . '

'; echo '
'; if ($details->label == 'Categories'){ echo '

' . __(' Copy or convert WordPress Categories into Affinitomic Descriptors. ', 'wptaxconvert') . '

'; } else if ($details->label == 'Tags') { echo '

' . __(' Copy or convert WordPress Tags into Affinitomic Draws. ', 'wptaxconvert') . '

'; } else { echo '

' . __(' Here you can selectively copy or convert existing terms from one taxonomy to another. To get started, choose the original taxonomy (above), choose option to copy or convert, select the terms (below), then click the Go button.', 'wptaxconvert') . '

'; } echo '

' . __(' Keep in mind that "converted" terms are deleted from original taxonomy, and if you convert a term with children, the children become top-level orphans.', 'wptaxconvert') . '

'; $this->terms_form($tax); } else { echo '

'.__('You have no terms to convert', 'wptaxconvertaffinitomics').'

'; } } function terms_form($tax) { ?>

To taxonomy: taxes as $name => $details) { if ( ($details->label == 'Categories') && ($name == $tax) ){ echo ''; continue; } else if ( ($details->label == 'Tags') && ($name == $tax) ) { echo ''; continue; } else if ($name == $tax) { continue; } else { echo ''; } } ?>

hybrids_ids) ) echo '

' . __('* This term is already in another taxonomy, converting will add the new taxonomy term to existing posts in that taxonomy.', 'wptaxconvertaffinitomics') . '

'; ?>

terms_to_convert) || (!isset($_POST['taxes'])) ) { ?>

try again.', 'wptaxconvertaffinitomics'), 'admin.php?import=wptaxconvertaffinitomics&tax='.$tax); ?>

terms_to_convert) ) $this->terms_to_convert = $_POST['terms_to_convert']; $taxonomy = $this->taxes[$tax]; $convert = $_POST['convert']; if ($convert) $c_label = 'Convert'; else $c_label = 'Copy'; $new_taxes = $_POST['taxes']; $num = count($new_taxes); $hier = _get_term_hierarchy($tax); $hybrid_cats = $clear_parents = $parents = false; $clean_term_cache = array(); $default_cat = get_option('default_category'); echo ''; if ( ! empty($clean_term_cache) ) { $clean_term_cache = array_unique(array_values($clean_term_cache)); clean_term_cache($clean_term_cache, $new_tax); } if ( $clear_parents ) delete_option('category_children'); if ( $hybrid_cats ) echo '

' . __('* This term is now in multiple taxonomies. The converter has added the new term to all posts with the original taxonomy term.', 'wptaxconvertaffinitomics') . '

'; echo '

' . sprintf( __('We’re all done here, but you can always convert more.', 'wptaxconvertaffinitomics'), 'admin.php?import=wptaxconvertaffinitomics' ) . '

'; } function init() { $tax = (isset($_GET['tax'])) ? $_GET['tax'] : 'category'; $step = (isset($_GET['step'])) ? (int) $_GET['step'] : 1; $this->header($tax); if ( current_user_can('manage_categories') ) { if ($step == 1) $this->tabs($tax); elseif ($step == 2) $this->process($tax); } $this->footer(); } function WP_Affinitomics_Taxonomy_Converter() { // Do nothing. } } $wp_taxconvert_affinitomics = new WP_Affinitomics_Taxonomy_Converter(); register_importer('wptaxconvertaffinitomics', __('Affinitomics Taxonomy Converter', 'wptaxconvertaffinitomics'), __('Automatically import your existing taxonomies into Affinitomics.', 'wptaxconvertaffinitomics'), array(&$wp_taxconvert_affinitomics, 'init')); } // class_exists( 'WP_Importer' ) function wptaxconvertaffinitomics_init() { load_plugin_textdomain( 'wptaxconvertaffinitomics', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); } add_action( 'init', 'wptaxconvertaffinitomics_init' );