X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/312084b5d95c21feb519ff03decf948420e1f6fa..4f9d63e13cd8c6e275797c75b401b074b82937bc:/wp-admin/import/utw.php diff --git a/wp-admin/import/utw.php b/wp-admin/import/utw.php deleted file mode 100644 index 3add5b63..00000000 --- a/wp-admin/import/utw.php +++ /dev/null @@ -1,290 +0,0 @@ -'; - screen_icon(); - echo '

'.__('Import Ultimate Tag Warrior').'

'; - echo '

'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'

'; - } - - function footer() { - echo ''; - } - - function greet() { - echo '
'; - echo '

'.__('Howdy! This imports tags from Ultimate Tag Warrior 3 into WordPress tags.').'

'; - echo '

'.__('This has not been tested on any other versions of Ultimate Tag Warrior. Mileage may vary.').'

'; - echo '

'.__('To accommodate larger databases for those tag-crazy authors out there, we have made this into an easy 5-step program to help you kick that nasty UTW habit. Just keep clicking along and we will let you know when you are in the clear!').'

'; - echo '

'.__('Don’t be stupid - backup your database before proceeding!').'

'; - echo '
'; - echo '

'; - echo '
'; - echo '
'; - } - - - function dispatch () { - if ( empty( $_GET['step'] ) ) { - $step = 0; - } else { - $step = (int) $_GET['step']; - } - - if ( $step > 1 ) - check_admin_referer('import-utw'); - - // load the header - $this->header(); - - switch ( $step ) { - case 0 : - $this->greet(); - break; - case 1 : - $this->import_tags(); - break; - case 2 : - $this->import_posts(); - break; - case 3: - $this->import_t2p(); - break; - case 4: - $this->cleanup_import(); - break; - } - - // load the footer - $this->footer(); - } - - - function import_tags ( ) { - echo '
'; - echo '

'.__('Reading UTW Tags…').'

'; - - $tags = $this->get_utw_tags(); - - // if we didn't get any tags back, that's all there is folks! - if ( !is_array($tags) ) { - echo '

' . __('No Tags Found!') . '

'; - return false; - } - else { - - // if there's an existing entry, delete it - if ( get_option('utwimp_tags') ) { - delete_option('utwimp_tags'); - } - - add_option('utwimp_tags', $tags); - - - $count = count($tags); - - echo '

' . sprintf( _n('Done! %s tag were read.', 'Done! %s tags were read.', $count), $count ) . '

'; - echo '

' . __('The following tags were found:') . '

'; - - echo ''; - - echo '
'; - - echo '

' . __('If you don’t want to import any of these tags, you should delete them from the UTW tag management page and then re-run this import.') . '

'; - - - } - - echo '
'; - wp_nonce_field('import-utw'); - echo '

'; - echo '
'; - echo '
'; - } - - - function import_posts ( ) { - echo '
'; - echo '

'.__('Reading UTW Post Tags…').'

'; - - // read in all the UTW tag -> post settings - $posts = $this->get_utw_posts(); - - // if we didn't get any tags back, that's all there is folks! - if ( !is_array($posts) ) { - echo '

' . __('No posts were found to have tags!') . '

'; - return false; - } - else { - - // if there's an existing entry, delete it - if ( get_option('utwimp_posts') ) { - delete_option('utwimp_posts'); - } - - add_option('utwimp_posts', $posts); - - - $count = count($posts); - - echo '

' . sprintf( _n('Done! %s tag to post relationships were read.', 'Done! %s tags to post relationships were read.', $count), $count ) . '

'; - - } - - echo '
'; - wp_nonce_field('import-utw'); - echo '

'; - echo '
'; - echo '
'; - - } - - - function import_t2p ( ) { - - echo '
'; - echo '

'.__('Adding Tags to Posts…').'

'; - - // run that funky magic! - $tags_added = $this->tag2post(); - - echo '

' . sprintf( _n( 'Done! %s tag were added!', 'Done! %s tags were added!', $tags_added ), $tags_added ) . '

'; - - echo '
'; - wp_nonce_field('import-utw'); - echo '

'; - echo '
'; - echo '
'; - - } - - - function get_utw_tags ( ) { - - global $wpdb; - - // read in all the tags from the UTW tags table: should be wp_tags - $tags_query = "SELECT tag_id, tag FROM " . $wpdb->prefix . "tags"; - - $tags = $wpdb->get_results($tags_query); - - // rearrange these tags into something we can actually use - foreach ( $tags as $tag ) { - - $new_tags[$tag->tag_id] = $tag->tag; - - } - - return $new_tags; - - } - - function get_utw_posts ( ) { - - global $wpdb; - - // read in all the posts from the UTW post->tag table: should be wp_post2tag - $posts_query = "SELECT tag_id, post_id FROM " . $wpdb->prefix . "post2tag"; - - $posts = $wpdb->get_results($posts_query); - - return $posts; - - } - - - function tag2post ( ) { - - // get the tags and posts we imported in the last 2 steps - $tags = get_option('utwimp_tags'); - $posts = get_option('utwimp_posts'); - - // null out our results - $tags_added = 0; - - // loop through each post and add its tags to the db - foreach ( $posts as $this_post ) { - - $the_post = (int) $this_post->post_id; - $the_tag = (int) $this_post->tag_id; - - // what's the tag name for that id? - $the_tag = $tags[$the_tag]; - - // screw it, just try to add the tag - wp_add_post_tags($the_post, $the_tag); - - $tags_added++; - - } - - // that's it, all posts should be linked to their tags properly, pending any errors we just spit out! - return $tags_added; - - - } - - - function cleanup_import ( ) { - - delete_option('utwimp_tags'); - delete_option('utwimp_posts'); - - $this->done(); - - } - - - function done ( ) { - - echo '
'; - echo '

'.__('Import Complete!').'

'; - - echo '

' . __('OK, so we lied about this being a 5-step program! You’re done!') . '

'; - - echo '

' . __('Now wasn’t that easy?') . '

'; - - echo '
'; - - } - - - function UTW_Import ( ) { - - // Nothing. - - } - -} - - -// create the import object -$utw_import = new UTW_Import(); - -// add it to the import page! -register_importer('utw', 'Ultimate Tag Warrior', __('Import Ultimate Tag Warrior tags into WordPress tags.'), array($utw_import, 'dispatch')); - -?>