Changeset 6162
- Timestamp:
- 09/24/07 01:57:55 (1 year ago)
- Files:
-
- trunk/wp-admin/import/stp.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/wp-admin/import/stp.php
r6118 r6162 1 1 <?php 2 3 2 class STP_Import { 4 5 3 function header() { 6 4 echo '<div class="wrap">'; … … 20 18 echo '<p><strong>'.__('Don’t be stupid - backup your database before proceeding!').'</strong></p>'; 21 19 echo '<form action="admin.php?import=stp&step=1" method="post">'; 22 wp_nonce_field('import- utw');20 wp_nonce_field('import-stp'); 23 21 echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 1 »').'" /></p>'; 24 22 echo '</form>'; 25 23 echo '</div>'; 26 24 } 27 28 25 29 26 function dispatch () { … … 33 30 $step = (int) $_GET['step']; 34 31 } 35 36 32 // load the header 37 33 $this->header(); 38 39 34 switch ( $step ) { 40 35 case 0 : … … 42 37 break; 43 38 case 1 : 44 check_admin_referer('import- utw');39 check_admin_referer('import-stp'); 45 40 $this->import_posts(); 46 41 break; 47 42 case 2: 48 check_admin_referer('import- utw');43 check_admin_referer('import-stp'); 49 44 $this->import_t2p(); 50 45 break; 51 46 case 3: 52 check_admin_referer('import- utw');47 check_admin_referer('import-stp'); 53 48 $this->cleanup_import(); 54 49 break; 55 50 } 56 57 51 // load the footer 58 52 $this->footer(); … … 73 67 } 74 68 else { 75 76 69 // if there's an existing entry, delete it 77 70 if ( get_option('stpimp_posts') ) { 78 71 delete_option('stpimp_posts'); 79 72 } 80 73 81 74 add_option('stpimp_posts', $posts); 82 83 84 75 $count = count($posts); 85 86 76 echo '<p>' . sprintf( __('Done! <strong>%s</strong> tag to post relationships were read.'), $count ) . '<br /></p>'; 87 88 77 } 89 78 90 79 echo '<form action="admin.php?import=stp&step=2" method="post">'; 91 wp_nonce_field('import- utw');80 wp_nonce_field('import-stp'); 92 81 echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 2 »').'" /></p>'; 93 82 echo '</form>'; 94 83 echo '</div>'; 95 96 84 } 97 85 98 86 99 87 function import_t2p ( ) { 100 101 88 echo '<div class="narrow">'; 102 89 echo '<p><h3>'.__('Adding Tags to Posts…').'</h3></p>'; 103 90 104 91 // run that funky magic! 105 92 $tags_added = $this->tag2post(); 106 93 107 94 echo '<p>' . sprintf( __('Done! <strong>%s</strong> tags where added!'), $tags_added ) . '<br /></p>'; 108 109 95 echo '<form action="admin.php?import=stp&step=3" method="post">'; 110 wp_nonce_field('import- utw');96 wp_nonce_field('import-stp'); 111 97 echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 3 »').'" /></p>'; 112 98 echo '</form>'; 113 99 echo '</div>'; 114 115 100 } 116 101 117 118 102 function get_stp_posts ( ) { 119 120 103 global $wpdb; 121 122 104 // read in all the posts from the STP post->tag table: should be wp_post2tag 123 105 $posts_query = "SELECT post_id, tag_name FROM " . $wpdb->prefix . "stp_tags"; 124 125 106 $posts = $wpdb->get_results($posts_query); 126 127 107 return $posts; 128 129 108 } 130 131 109 132 110 function tag2post ( ) { … … 143 121 $the_post = (int) $this_post->post_id; 144 122 $the_tag = $wpdb->escape($this_post->tag_name); 145 146 123 // try to add the tag 147 124 wp_add_post_tags($the_post, $the_tag); 148 149 125 $tags_added++; 150 151 126 } 152 127 153 128 // that's it, all posts should be linked to their tags properly, pending any errors we just spit out! 154 129 return $tags_added; 155 156 157 130 } 158 131 159 160 132 function cleanup_import ( ) { 161 162 133 delete_option('stpimp_posts'); 163 164 134 $this->done(); 165 166 135 } 167 136 168 169 137 function done ( ) { 170 171 138 echo '<div class="narrow">'; 172 139 echo '<p><h3>'.__('Import Complete!').'</h3></p>'; 173 174 140 echo '<p>' . __('OK, so we lied about this being a 4-step program! You’re done!') . '</p>'; 175 176 141 echo '<p>' . __('Now wasn’t that easy?') . '</p>'; 177 178 142 echo '</div>'; 179 180 143 } 181 144 182 183 145 function STP_Import ( ) { 184 185 146 // Nothing. 186 187 147 } 188 189 148 } 190 191 149 192 150 // create the import object … … 195 153 // add it to the import page! 196 154 register_importer('stp', 'Simple Tagging', __('Import Simple Tagging tags into the new native tagging structure.'), array($stp_import, 'dispatch')); 197 198 155 ?>
