'; print '

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

'; } function footer() { print ''; } function populate_all_categories() { global $wpdb; $this->all_categories = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE (type & ~ " . TAXONOMY_TAG . ") != 0 AND category_count > 0 ORDER BY cat_name ASC"); } 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 '
'; print ''; print '

'; print '
'; } function _category_children($parent, $hier) { print ''; } function _category_exists($cat_id) { global $wpdb; $cat_id = (int) $cat_id; $maybe_exists = $wpdb->get_results("SELECT cat_ID from $wpdb->categories WHERE cat_ID = '$cat_id'"); if (count($maybe_exists) > 0) { return true; } else { return false; } } function convert_them() { global $wpdb; if (!isset($_POST['cats_to_convert']) || !is_array($_POST['cats_to_convert'])) { print '
'; print '

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

'; print '
'; } $this->categories_to_convert = $_POST['cats_to_convert']; $hier = _get_category_hierarchy(); print ''; } function convert_all_confirm() { print '
'; print '

' . __('Confirm') . '

'; print '

' . __('You are about to convert all categories to tags. Are you sure you want to continue?') . '

'; print '
'; print '

    

'; print '
'; print '
'; } function convert_all() { global $wpdb; $cats = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE (type & ~ " . TAXONOMY_TAG . ") != 0 AND category_count > 0"); $_POST['cats_to_convert'] = array(); foreach ($cats as $cat) { $_POST['cats_to_convert'][] = $cat->cat_ID; } $this->convert_them(); } function init() { echo ''; if (isset($_POST['maybe_convert_all_cats'])) { $step = 3; } elseif (isset($_POST['yes_convert_all_cats'])) { $step = 4; } elseif (isset($_POST['no_dont_do_it'])) { die('no_dont_do_it'); } else { $step = (isset($_GET['step'])) ? (int) $_GET['step'] : 1; } $this->header(); if (!current_user_can('manage_categories')) { print '
'; print '

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

'; print '
'; } else { switch ($step) { case 1 : $this->welcome(); break; case 2 : $this->convert_them(); break; case 3 : $this->convert_all_confirm(); break; case 4 : $this->convert_all(); 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')); ?>