'; print '

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

'; } function footer() { print ''; } 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(); print '
'; if (count($this->all_categories) > 0) { print '

' . __('Howdy! This converter allows you to selectively convert existing categories to tags. To get started, check the checkboxes of the categories you wish to be converted, then click the Convert button.') . '

'; print '

' . __('Keep in mind that if you convert a category with child categories, those child categories get their parent setting removed, so they\'re in the root.') . '

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

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

'; } print '
'; } function categories_form() { print '
'; wp_nonce_field('import-cat2tag'); print ''; print '

'; print '
'; } function _category_children($parent, $hier) { print ''; } function _category_exists($cat_id) { global $wpdb; $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)) { print '
'; print '

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

'; print '
'; return; } if ( empty($this->categories_to_convert) ) $this->categories_to_convert = $_POST['cats_to_convert']; $hier = _get_term_hierarchy('category'); print ''; } function init() { $step = (isset($_GET['step'])) ? (int) $_GET['step'] : 1; $this->header(); if (!current_user_can('manage_categories')) { print '
'; print '

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

'; print '
'; } 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')); ?>