diff options
| author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2007-10-12 16:21:15 +0000 |
|---|---|---|
| committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2007-10-12 16:21:15 +0000 |
| commit | 3a4570b0fc8b3d6339bef71d17d7701554e0bbf7 (patch) | |
| tree | 2a06e5261263c68d8afd95a6328879dc289cb909 /wp-admin/import/btt.php | |
| parent | b83c34a7010faee0223f6037025c350da12e05e6 (diff) | |
| download | wordpress-mu-3a4570b0fc8b3d6339bef71d17d7701554e0bbf7.tar.gz wordpress-mu-3a4570b0fc8b3d6339bef71d17d7701554e0bbf7.tar.xz wordpress-mu-3a4570b0fc8b3d6339bef71d17d7701554e0bbf7.zip | |
Merge with WP 2.3 - testing use only!
Move pluggable functions out of wpmu-functions and into pluggable.php, fixes #439
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1069 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-admin/import/btt.php')
| -rw-r--r-- | wp-admin/import/btt.php | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/wp-admin/import/btt.php b/wp-admin/import/btt.php new file mode 100644 index 0000000..76a02c3 --- /dev/null +++ b/wp-admin/import/btt.php @@ -0,0 +1,115 @@ +<?php + +class BunnyTags_Import { + + function header() { + echo '<div class="wrap">'; + echo '<h2>'.__('Import Bunny’s Technorati Tags').'</h2>'; + echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'<br /><br /></p>'; + } + + function footer() { + echo '</div>'; + } + + function greet() { + echo '<div class="narrow">'; + 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>'; + echo '<p>'.__('This is suitable for Bunny’s Technorati Tags version 0.6.').'</p>'; + echo '<p><strong>'.__('All existing Bunny’s Technorati Tags will be removed after import.').'</strong></p>'; + echo '<p><strong>'.__('Don’t be stupid - backup your database before proceeding!').'</strong></p>'; + echo '<form action="admin.php?import=btt&step=1" method="post">'; + wp_nonce_field('import-btt'); + echo '<p class="submit"><input type="submit" name="submit" value="'.__('Import Tags »').'" /></p>'; + echo '</form>'; + echo '</div>'; + } + + function dispatch() { + if ( empty($_GET['step']) ) + $step = 0; + else + $step = abs(intval($_GET['step'])); + + // load the header + $this->header(); + + switch ( $step ) { + case 0 : + $this->greet(); + break; + case 1 : + check_admin_referer('import-btt'); + $this->check_post_keyword( true ); + break; + case 2 : + check_admin_referer('import-btt'); + $this->check_post_keyword( false ); + break; + case 3: + $this->done(); + break; + } + + // load the footer + $this->footer(); + } + + function check_post_keyword($precheck = true) { + global $wpdb; + + echo '<div class="narrow">'; + echo '<p><h3>'.__('Reading Bunny’s Technorati Tags…').'</h3></p>'; + + // import Bunny's Keywords tags + $metakeys = $wpdb->get_results("SELECT post_id, meta_id, meta_key, meta_value FROM $wpdb->postmeta WHERE $wpdb->postmeta.meta_key = 'tags'"); + if ( !is_array($metakeys)) { + echo '<p>' . __('No Tags Found!') . '</p>'; + return false; + } else { + $count = count($metakeys); + echo '<p>' . sprintf( __('Done! <strong>%s</strong> posts with tags were read.'), $count ) . '<br /></p>'; + echo '<ul>'; + foreach ( $metakeys as $post_meta ) { + if ( $post_meta->meta_value != '' ) { + $post_keys = explode(' ', $post_meta->meta_value); + foreach ( $post_keys as $keyword ) { + $keyword = addslashes(trim(str_replace('+',' ',$keyword))); + if ( '' != $keyword ) { + echo '<li>' . $post_meta->post_id . ' - ' . $keyword . '</li>'; + if ( !$precheck ) + wp_add_post_tags($post_meta->post_id, $keyword); + } + } + } + if ( !$precheck ) + delete_post_meta($post_meta->post_id, 'tags'); + } + echo '</ul>'; + } + + echo '<form action="admin.php?import=btt&step='.($precheck? 2:3).'" method="post">'; + wp_nonce_field('import-btt'); + echo '<p class="submit"><input type="submit" name="submit" value="'.__('Next »').'" /></p>'; + echo '</form>'; + echo '</div>'; + } + + function done() { + echo '<div class="narrow">'; + echo '<p><h3>'.__('Import Complete!').'</h3></p>'; + echo '</div>'; + } + + function BunnyTags_Import() { + } + +} + +// create the import object +$btt_import = new BunnyTags_Import(); + +// add it to the import page! +register_importer('btt', 'Bunny’s Technorati Tags', __('Import Bunny’s Technorati Tags into the new native tagging structure.'), array($btt_import, 'dispatch')); + +?> |
