-
+ 157A7579D966B8160AF5D42FB504ACB4E959D2529A5F8B2A9187D5139B35109C0F3E0ACA21AC88A82221C63627BDAB15F04849FBFEBF0FAA8AD314E9A4098545
mp-wp/wp-admin/import/btt.php
(0 . 0)(1 . 130)
17599 <?php
17600 /**
17601 * BunnyTags Plugin Tag Importer
17602 *
17603 * @package WordPress
17604 * @subpackage Importer
17605 */
17606
17607 /**
17608 * BunnyTags Plugin tag converter
17609 *
17610 * This will process the BunnyTags plugin tags and convert them to the WordPress
17611 * 2.3 taxonomy.
17612 *
17613 * @since unknown
17614 */
17615 class BunnyTags_Import {
17616
17617 function header() {
17618 echo '<div class="wrap">';
17619 screen_icon();
17620 echo '<h2>'.__('Import Bunny’s Technorati Tags').'</h2>';
17621 echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'<br /><br /></p>';
17622 }
17623
17624 function footer() {
17625 echo '</div>';
17626 }
17627
17628 function greet() {
17629 echo '<div class="narrow">';
17630 echo '<p>'.__('Howdy! This imports tags from Bunny’s Technorati Tags into WordPress tags.').'</p>';
17631 echo '<p>'.__('This is suitable for Bunny’s Technorati Tags version 0.6.').'</p>';
17632 echo '<p><strong>'.__('All existing Bunny’s Technorati Tags will be removed after import.').'</strong></p>';
17633 echo '<p><strong>'.__('Don’t be stupid - backup your database before proceeding!').'</strong></p>';
17634 echo '<form action="admin.php?import=btt&step=1" method="post">';
17635 wp_nonce_field('import-btt');
17636 echo '<p class="submit"><input type="submit" name="submit" class="button" value="'.__('Import Tags').'" /></p>';
17637 echo '</form>';
17638 echo '</div>';
17639 }
17640
17641 function dispatch() {
17642 if ( empty($_GET['step']) )
17643 $step = 0;
17644 else
17645 $step = absint($_GET['step']);
17646
17647 // load the header
17648 $this->header();
17649
17650 switch ( $step ) {
17651 case 0 :
17652 $this->greet();
17653 break;
17654 case 1 :
17655 check_admin_referer('import-btt');
17656 $this->check_post_keyword( true );
17657 break;
17658 case 2 :
17659 check_admin_referer('import-btt');
17660 $this->check_post_keyword( false );
17661 break;
17662 case 3:
17663 $this->done();
17664 break;
17665 }
17666
17667 // load the footer
17668 $this->footer();
17669 }
17670
17671 function check_post_keyword($precheck = true) {
17672 global $wpdb;
17673
17674 echo '<div class="narrow">';
17675 echo '<p><h3>'.__('Reading Bunny’s Technorati Tags…').'</h3></p>';
17676
17677 // import Bunny's Keywords tags
17678 $metakeys = $wpdb->get_results("SELECT post_id, meta_id, meta_key, meta_value FROM $wpdb->postmeta WHERE $wpdb->postmeta.meta_key = 'tags'");
17679 if ( !is_array($metakeys)) {
17680 echo '<p>' . __('No Tags Found!') . '</p>';
17681 return false;
17682 } else {
17683 $count = count($metakeys);
17684 echo '<p>' . sprintf( __ngettext('Done! <strong>%s</strong> post with tags were read.', 'Done! <strong>%s</strong> posts with tags were read.', $count), $count ) . '<br /></p>';
17685 echo '<ul>';
17686 foreach ( $metakeys as $post_meta ) {
17687 if ( $post_meta->meta_value != '' ) {
17688 $post_keys = explode(' ', $post_meta->meta_value);
17689 foreach ( $post_keys as $keyword ) {
17690 $keyword = addslashes(trim(str_replace('+',' ',$keyword)));
17691 if ( '' != $keyword ) {
17692 echo '<li>' . $post_meta->post_id . ' - ' . $keyword . '</li>';
17693 if ( !$precheck )
17694 wp_add_post_tags($post_meta->post_id, $keyword);
17695 }
17696 }
17697 }
17698 if ( !$precheck )
17699 delete_post_meta($post_meta->post_id, 'tags');
17700 }
17701 echo '</ul>';
17702 }
17703
17704 echo '<form action="admin.php?import=btt&step='.($precheck? 2:3).'" method="post">';
17705 wp_nonce_field('import-btt');
17706 echo '<p class="submit"><input type="submit" name="submit" class="button" value="'.__('Next').'" /></p>';
17707 echo '</form>';
17708 echo '</div>';
17709 }
17710
17711 function done() {
17712 echo '<div class="narrow">';
17713 echo '<p><h3>'.__('Import Complete!').'</h3></p>';
17714 echo '</div>';
17715 }
17716
17717 function BunnyTags_Import() {
17718 }
17719
17720 }
17721
17722 // create the import object
17723 $btt_import = new BunnyTags_Import();
17724
17725 // add it to the import page!
17726 register_importer('btt', 'Bunny’s Technorati Tags', __('Import Bunny’s Technorati Tags into WordPress tags.'), array($btt_import, 'dispatch'));
17727
17728 ?>