'; screen_icon(); echo '
'.__('Howdy! Upload your WordPress eXtended RSS (WXR) file and we’ll import the posts, pages, comments, custom fields, categories, and tags into this blog.').'
'; echo ''.__('Choose a WordPress WXR file to upload, then click Upload file and import.').'
'; wp_import_upload_form("admin.php?import=wordpress&step=1"); echo 'admins entries.'); ?>
allow_create_users() ) { echo ''.__('If a new user is created by WordPress, a password will be randomly generated. Manually change the user’s details if necessary.')."
\n"; } $authors = $this->get_wp_authors(); echo ''; } function users_form($n, $author) { if ( $this->allow_create_users() ) { printf(''.__('Please upload a valid WXR (WordPress eXtended RSS) export file.').'
'; } } // fetch the user ID for a given author name, respecting the mapping preferences function checkauthor($author) { global $current_user; if ( !empty($this->author_ids[$author]) ) return $this->author_ids[$author]; // failsafe: map to the current user return $current_user->ID; } function process_categories() { global $wpdb; $cat_names = (array) get_terms('category', 'fields=names'); while ( $c = array_shift($this->categories) ) { $cat_name = trim($this->get_tag( $c, 'wp:cat_name' )); // If the category exists we leave it alone if ( in_array($cat_name, $cat_names) ) continue; $category_nicename = $this->get_tag( $c, 'wp:category_nicename' ); $category_description = $this->get_tag( $c, 'wp:category_description' ); $posts_private = (int) $this->get_tag( $c, 'wp:posts_private' ); $links_private = (int) $this->get_tag( $c, 'wp:links_private' ); $parent = $this->get_tag( $c, 'wp:category_parent' ); if ( empty($parent) ) $category_parent = '0'; else $category_parent = category_exists($parent); $catarr = compact('category_nicename', 'category_parent', 'posts_private', 'links_private', 'posts_private', 'cat_name', 'category_description'); $cat_ID = wp_insert_category($catarr); } } function process_tags() { global $wpdb; $tag_names = (array) get_terms('post_tag', 'fields=names'); while ( $c = array_shift($this->tags) ) { $tag_name = trim($this->get_tag( $c, 'wp:tag_name' )); // If the category exists we leave it alone if ( in_array($tag_name, $tag_names) ) continue; $slug = $this->get_tag( $c, 'wp:tag_slug' ); $description = $this->get_tag( $c, 'wp:tag_description' ); $tagarr = compact('slug', 'description'); $tag_ID = wp_insert_term($tag_name, 'post_tag', $tagarr); } } function process_terms() { global $wpdb, $wp_taxonomies; $custom_taxonomies = $wp_taxonomies; // get rid of the standard taxonomies unset( $custom_taxonomies['category'] ); unset( $custom_taxonomies['post_tag'] ); unset( $custom_taxonomies['link_category'] ); $custom_taxonomies = array_keys( $custom_taxonomies ); $current_terms = (array) get_terms( $custom_taxonomies, 'get=all' ); $taxonomies = array(); foreach ( $current_terms as $term ) { if ( isset( $_terms[$term->taxonomy] ) ) { $taxonomies[$term->taxonomy] = array_merge( $taxonomies[$term->taxonomy], array($term->name) ); } else { $taxonomies[$term->taxonomy] = array($term->name); } } while ( $c = array_shift($this->terms) ) { $term_name = trim($this->get_tag( $c, 'wp:term_name' )); $term_taxonomy = trim($this->get_tag( $c, 'wp:term_taxonomy' )); // If the term exists in the taxonomy we leave it alone if ( isset($taxonomies[$term_taxonomy] ) && in_array( $term_name, $taxonomies[$term_taxonomy] ) ) continue; $slug = $this->get_tag( $c, 'wp:term_slug' ); $description = $this->get_tag( $c, 'wp:term_description' ); $termarr = compact('slug', 'description'); $term_ID = wp_insert_term($term_name, $this->get_tag( $c, 'wp:term_taxonomy' ), $termarr); } } function process_author($post) { $author = $this->get_tag( $post, 'dc:creator' ); if ($author) $this->allauthornames[] = $author; } function process_posts() { echo ''.__('Sorry, there has been an error.').'
'; echo '' . $file['error'] . '
'; return false; } $this->file = $file['file']; $this->id = (int) $file['id']; return true; } function dispatch() { if (empty ($_GET['step'])) $step = 0; else $step = (int) $_GET['step']; $this->header(); switch ($step) { case 0 : $this->greet(); break; case 1 : check_admin_referer('import-upload'); if ( $this->handle_upload() ) $this->select_authors(); break; case 2: check_admin_referer('import-wordpress'); $result = $this->import( $_GET['id'], $_POST['attachments'] ); if ( is_wp_error( $result ) ) echo $result->get_error_message(); break; } $this->footer(); } function WP_Import() { // Nothing. } } /** * Register WordPress Importer * * @since unknown * @var WP_Import * @name $wp_import */ $wp_import = new WP_Import(); register_importer('wordpress', 'WordPress', __('Import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.'), array ($wp_import, 'dispatch')); ?>