3 class BunnyTags_Import {
6 echo '<div class="wrap">';
7 echo '<h2>'.__('Import Bunny’s Technorati Tags').'</h2>';
8 echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'<br /><br /></p>';
16 echo '<div class="narrow">';
17 echo '<p>'.__('Howdy! This imports tags from an existing Bunny’s Technorati Tags installation into this blog using the new WordPress native tagging structure.').'</p>';
18 echo '<p>'.__('This is suitable for Bunny’s Technorati Tags version 0.6.').'</p>';
19 echo '<p><strong>'.__('All existing Bunny’s Technorati Tags will be removed after import.').'</strong></p>';
20 echo '<p><strong>'.__('Don’t be stupid - backup your database before proceeding!').'</strong></p>';
21 echo '<form action="admin.php?import=btt&step=1" method="post">';
22 wp_nonce_field('import-btt');
23 echo '<p class="submit"><input type="submit" name="submit" value="'.__('Import Tags »').'" /></p>';
29 if ( empty($_GET['step']) )
32 $step = abs(intval($_GET['step']));
42 check_admin_referer('import-btt');
43 $this->check_post_keyword( true );
46 check_admin_referer('import-btt');
47 $this->check_post_keyword( false );
58 function check_post_keyword($precheck = true) {
61 echo '<div class="narrow">';
62 echo '<p><h3>'.__('Reading Bunny’s Technorati Tags…').'</h3></p>';
64 // import Bunny's Keywords tags
65 $metakeys = $wpdb->get_results("SELECT post_id, meta_id, meta_key, meta_value FROM $wpdb->postmeta WHERE $wpdb->postmeta.meta_key = 'tags'");
66 if ( !is_array($metakeys)) {
67 echo '<p>' . __('No Tags Found!') . '</p>';
70 $count = count($metakeys);
71 echo '<p>' . sprintf( __('Done! <strong>%s</strong> posts with tags were read.'), $count ) . '<br /></p>';
73 foreach ( $metakeys as $post_meta ) {
74 if ( $post_meta->meta_value != '' ) {
75 $post_keys = explode(' ', $post_meta->meta_value);
76 foreach ( $post_keys as $keyword ) {
77 $keyword = addslashes(trim(str_replace('+',' ',$keyword)));
78 if ( '' != $keyword ) {
79 echo '<li>' . $post_meta->post_id . ' - ' . $keyword . '</li>';
81 wp_add_post_tags($post_meta->post_id, $keyword);
86 delete_post_meta($post_meta->post_id, 'tags');
91 echo '<form action="admin.php?import=btt&step='.($precheck? 2:3).'" method="post">';
92 wp_nonce_field('import-btt');
93 echo '<p class="submit"><input type="submit" name="submit" value="'.__('Next »').'" /></p>';
99 echo '<div class="narrow">';
100 echo '<p><h3>'.__('Import Complete!').'</h3></p>';
104 function BunnyTags_Import() {
109 // create the import object
110 $btt_import = new BunnyTags_Import();
112 // add it to the import page!
113 register_importer('btt', 'Bunny’s Technorati Tags', __('Import Bunny’s Technorati Tags into the new native tagging structure.'), array($btt_import, 'dispatch'));