PHP Cross Reference of WordPress Subversion HEAD |
| [ Index ] [ Classes ] [ Functions ] [ Variables ] [ Constants ] |
[Summary view] [Print] [Text view]
1 <?php 2 3 class BunnyTags_Import { 4 5 function header() { 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>'; 9 } 10 11 function footer() { 12 echo '</div>'; 13 } 14 15 function greet() { 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>'; 24 echo '</form>'; 25 echo '</div>'; 26 } 27 28 function dispatch() { 29 if ( empty($_GET['step']) ) 30 $step = 0; 31 else 32 $step = abs(intval($_GET['step'])); 33 34 // load the header 35 $this->header(); 36 37 switch ( $step ) { 38 case 0 : 39 $this->greet(); 40 break; 41 case 1 : 42 check_admin_referer('import-btt'); 43 $this->check_post_keyword( true ); 44 break; 45 case 2 : 46 check_admin_referer('import-btt'); 47 $this->check_post_keyword( false ); 48 break; 49 case 3: 50 $this->done(); 51 break; 52 } 53 54 // load the footer 55 $this->footer(); 56 } 57 58 function check_post_keyword($precheck = true) { 59 global $wpdb; 60 61 echo '<div class="narrow">'; 62 echo '<p><h3>'.__('Reading Bunny’s Technorati Tags…').'</h3></p>'; 63 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>'; 68 return false; 69 } else { 70 $count = count($metakeys); 71 echo '<p>' . sprintf( __('Done! <strong>%s</strong> posts with tags were read.'), $count ) . '<br /></p>'; 72 echo '<ul>'; 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>'; 80 if ( !$precheck ) 81 wp_add_post_tags($post_meta->post_id, $keyword); 82 } 83 } 84 } 85 if ( !$precheck ) 86 delete_post_meta($post_meta->post_id, 'tags'); 87 } 88 echo '</ul>'; 89 } 90 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>'; 94 echo '</form>'; 95 echo '</div>'; 96 } 97 98 function done() { 99 echo '<div class="narrow">'; 100 echo '<p><h3>'.__('Import Complete!').'</h3></p>'; 101 echo '</div>'; 102 } 103 104 function BunnyTags_Import() { 105 } 106 107 } 108 109 // create the import object 110 $btt_import = new BunnyTags_Import(); 111 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')); 114 115 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated Thu Dec 6 06:47:08 2007 for RedAlt XRefs | Cross-referenced by PHPXref 0.6 and RedAlt |