function stepped_import_do()
{
    if (!defined('WP_LOAD_IMPORTERS')) {
        define('WP_LOAD_IMPORTERS', true);
    }
    include_once STEPPED_IMPORTER_PATH . 'wordpress-importer/wordpress-importer.php';
    include_once STEPPED_IMPORTER_PATH . 'wordpress-importer/import-class.php';
    $import_filepath = STEPPED_IMPORTER_PATH . 'data/content.xml';
    ob_start();
    $wp_import = new wpGrade_import();
    $wp_import->fetch_attachments = true;
    $wp_import->import_posts_pages($import_filepath, $_POST['step_number'], $_POST['number_of_steps']);
    echo ob_get_contents();
    ob_end_clean();
}
Пример #2
0
}
//check if the wp import class is available, this class handles the wordpress XML files. If not, include it
if (!class_exists('WPGrade_WP_Import')) {
    $class_wp_import = wpgrade::themefilepath('inc/import/wordpress-importer/wordpress-importer.php');
    if (file_exists($class_wp_import)) {
        require_once $class_wp_import;
    } else {
        $wpGrade_importerError = true;
    }
}
if ($wpGrade_importerError !== false) {
    $response['id'] = new WP_Error('import_posts_pages_noscript', 'The Auto importing script could not be loaded. Please use the <a href="' . admin_url('import.php') . '">WordPress default import</a> and import the .XML file provided in the archive you\'ve received on purchase manually.');
} else {
    if (class_exists('WPGrade_WP_Import')) {
        include_once 'wordpress-importer/wpgrade-import-class.php';
    }
    if (!is_file($import_filepath . '.xml')) {
        $response['id'] = new WP_Error('import_posts_pages_nofile', 'The XML file containing the demo data could not be found or could not be read in <pre>' . wpgrade::themefilepath('inc/import/demo-data') . '</pre><br/> You might want to try to set the file permission to 777.<br/>If this doesn\'t work please use the <a href="' . admin_url('import.php') . '">WordPress default import</a> and import the .XML file provided in the archive you\'ve received on purchase manually.');
    } else {
        ob_start();
        $wp_import = new wpGrade_import();
        $wp_import->fetch_attachments = true;
        $response['id'] = $wp_import->import_posts_pages($import_filepath . '.xml', $response['supplemental']['stepNumber'], $response['supplemental']['numberOfSteps']);
        //after the last step we assign the menus to the proper locations
        if ($response['supplemental']['stepNumber'] == $response['supplemental']['numberOfSteps']) {
            $wp_import->set_menus();
        }
        $response['data'] = ob_get_contents();
        ob_end_clean();
    }
}