3 * BunnyTags Plugin Tag Importer
10 * BunnyTags Plugin tag converter
12 * This will process the BunnyTags plugin tags and convert them to the WordPress
17 class BunnyTags_Import {
20 echo '<div class="wrap">';
22 echo '<h2>'.__('Import Bunny’s Technorati Tags').'</h2>';
23 echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'<br /><br /></p>';
31 echo '<div class="narrow">';
32 echo '<p>'.__('Howdy! This imports tags from Bunny’s Technorati Tags into WordPress tags.').'</p>';
33 echo '<p>'.__('This is suitable for Bunny’s Technorati Tags version 0.6.').'</p>';
34 echo '<p><strong>'.__('All existing Bunny’s Technorati Tags will be removed after import.').'</strong></p>';
35 echo '<p><strong>'.__('Don’t be stupid - backup your database before proceeding!').'</strong></p>';
36 echo '<form action="admin.php?import=btt&step=1" method="post">';
37 wp_nonce_field('import-btt');
38 echo '<p class="submit"><input type="submit" name="submit" class="button" value="'.esc_attr__('Import Tags').'" /></p>';
44 if ( empty($_GET['step']) )
47 $step = absint($_GET['step']);
57 check_admin_referer('import-btt');
58 $this->check_post_keyword( true );
61 check_admin_referer('import-btt');
62 $this->check_post_keyword( false );
73 function check_post_keyword($precheck = true) {
76 echo '<div class="narrow">';
77 echo '<p><h3>'.__('Reading Bunny’s Technorati Tags…').'</h3></p>';
79 // import Bunny's Keywords tags
80 $metakeys = $wpdb->get_results("SELECT post_id, meta_id, meta_key, meta_value FROM $wpdb->postmeta WHERE $wpdb->postmeta.meta_key = 'tags'");
81 if ( !is_array($metakeys)) {
82 echo '<p>' . __('No Tags Found!') . '</p>';
85 $count = count($metakeys);
86 echo '<p>' . sprintf( _n('Done! <strong>%s</strong> post with tags were read.', 'Done! <strong>%s</strong> posts with tags were read.', $count), $count ) . '<br /></p>';
88 foreach ( $metakeys as $post_meta ) {
89 if ( $post_meta->meta_value != '' ) {
90 $post_keys = explode(' ', $post_meta->meta_value);
91 foreach ( $post_keys as $keyword ) {
92 $keyword = addslashes(trim(str_replace('+',' ',$keyword)));
93 if ( '' != $keyword ) {
94 echo '<li>' . $post_meta->post_id . ' - ' . $keyword . '</li>';
96 wp_add_post_tags($post_meta->post_id, $keyword);
101 delete_post_meta($post_meta->post_id, 'tags');
106 echo '<form action="admin.php?import=btt&step='.($precheck? 2:3).'" method="post">';
107 wp_nonce_field('import-btt');
108 echo '<p class="submit"><input type="submit" name="submit" class="button" value="'.esc_attr__('Next').'" /></p>';
114 echo '<div class="narrow">';
115 echo '<p><h3>'.__('Import Complete!').'</h3></p>';
119 function BunnyTags_Import() {
124 // create the import object
125 $btt_import = new BunnyTags_Import();
127 // add it to the import page!
128 register_importer('btt', 'Bunny’s Technorati Tags', __('Import Bunny’s Technorati Tags into WordPress tags.'), array($btt_import, 'dispatch'));