WP_Import::import_end PHP Method

import_end() public method

Performs post-import cleanup of files and the cache
public import_end ( )
        function import_end()
        {
            wp_import_cleanup($this->id);
            wp_cache_flush();
            foreach (get_taxonomies() as $tax) {
                delete_option("{$tax}_children");
                _get_term_hierarchy($tax);
            }
            wp_defer_term_counting(false);
            wp_defer_comment_counting(false);
            echo '<p>' . __('All done.', 'wordpress-importer') . ' <a href="' . admin_url() . '">' . __('Have fun!', 'wordpress-importer') . '</a>' . '</p>';
            echo '<p>' . __('Remember to update the passwords and roles of imported users.', 'wordpress-importer') . '</p>';
            do_action('import_end');
        }

Usage Example

 public function wpImportAttachments($file, $import_limit = 10)
 {
     $wp_import = new WP_Import();
     $wp_import->fetch_attachments = true;
     // load data from saved option
     $wp_import->post_orphans = get_option('_cri_post_orphans', array());
     $wp_import->processed_posts = get_option('_cri_processed_posts', array());
     $wp_import->url_remap = get_option('_cri_url_remap', array());
     add_filter('import_post_meta_key', array($wp_import, 'is_valid_meta_key'));
     add_filter('http_request_timeout', array(&$wp_import, 'bump_request_timeout'));
     // start buffer
     ob_start();
     // parse file and gather data
     $wp_import->import_start($file);
     // map author
     $wp_import->get_author_mapping();
     // attachment to be imported
     $attachments = array();
     foreach ($wp_import->posts as $post) {
         // only import attachment
         if ($post['post_type'] == 'attachment') {
             // if attachment has been imported already
             if (isset($wp_import->processed_posts[$post['post_id']]) && !empty($post['post_id'])) {
                 continue;
             }
             // if limit exceed, kill the loop
             if ($import_limit < 1) {
                 break;
             } else {
                 $import_limit--;
             }
             $attachments[] = $post;
         }
     }
     // if attachments reach to zero, we are done
     if (empty($attachments)) {
         return true;
     }
     // set importable posts to attachments
     $wp_import->posts = $attachments;
     // this process the attachments, turn off/on cache
     wp_suspend_cache_invalidation(true);
     $wp_import->process_posts();
     wp_suspend_cache_invalidation(false);
     // end has output, so buffer it out
     $wp_import->import_end();
     ob_end_clean();
     // save all post_orphans, processed_posts & url_remap to be used on the next run. also this will run on post import
     update_option('_cri_post_orphans', $wp_import->post_orphans);
     update_option('_cri_processed_posts', $wp_import->processed_posts);
     update_option('_cri_url_remap', $wp_import->url_remap);
     // false means we are going to continue
     return false;
 }
All Usage Examples Of WP_Import::import_end