'; echo '

' . __('Convert Categories to Tags') . '

'; } function footer() { echo ''; } function populate_all_categories() { global $wpdb; $categories = get_categories('get=all'); foreach ( $categories as $category ) { if ( !tag_exists($wpdb->escape($category->name)) ) $this->all_categories[] = $category; } } function welcome() { $this->populate_all_categories(); echo '
'; if (count($this->all_categories) > 0) { echo '

' . __('Hey there. Here you can selectively converts existing categories to tags. To get started, check the categories you wish to be converted, then click the Convert button.') . '

'; echo '

' . __('Keep in mind that if you convert a category with child categories, the children become top-level orphans.') . '

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

'.__('You have no categories to convert!').'

'; } echo '
'; } function categories_form() { ?>

'; wp_nonce_field('import-cat2tag'); echo ''; echo '

'; echo ''; } function _category_children($parent, $hier) { echo ''; } function _category_exists($cat_id) { $cat_id = (int) $cat_id; $maybe_exists = category_exists($cat_id); if ( $maybe_exists ) { return true; } else { return false; } } function convert_them() { global $wpdb; if ( (!isset($_POST['cats_to_convert']) || !is_array($_POST['cats_to_convert'])) && empty($this->categories_to_convert)) { echo '
'; echo '

' . sprintf(__('Uh, oh. Something didn’t work. Please try again.'), 'admin.php?import=wp-cat2tag') . '

'; echo '
'; return; } if ( empty($this->categories_to_convert) ) $this->categories_to_convert = $_POST['cats_to_convert']; $hier = _get_term_hierarchy('category'); echo ''; echo '

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

'; } function init() { $step = (isset($_GET['step'])) ? (int) $_GET['step'] : 1; $this->header(); if (!current_user_can('manage_categories')) { echo '
'; echo '

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

'; echo '
'; } else { if ( $step > 1 ) check_admin_referer('import-cat2tag'); switch ($step) { case 1 : $this->welcome(); break; case 2 : $this->convert_them(); break; } } $this->footer(); } function WP_Categories_to_Tags() { // Do nothing. } } $wp_cat2tag_importer = new WP_Categories_to_Tags(); register_importer('wp-cat2tag', __('Categories to Tags Converter'), __('Convert existing categories to tags, selectively.'), array(&$wp_cat2tag_importer, 'init')); ?>