allow_fetch_attachments() public method

Default is true, can be filtered via import_allow_fetch_attachments. The choice made at the import options screen must also be true, false here hides that checkbox.
public allow_fetch_attachments ( ) : boolean
return boolean True if downloading attachments is allowed
/**
 * FILE: vibeimport.php 
 * Author: Mr.Vibe 
 * Credits: www.VibeThemes.com
 * Project: WPLMS
 */
function vibe_import($file)
{
    require_once ABSPATH . 'wp-admin/includes/import.php';
    $file_path = apply_filters('wplms_setup_import_file_path', VIBE_PATH . "/setup/data/{$file}.xml", $file);
    if (!class_exists('WP_Import')) {
        require_once 'wordpress-importer.php';
    }
    if (class_exists('WP_Import')) {
        if (file_exists($file_path)) {
            do_action('wplms_before_sample_data_import', $file);
            $WP_Import = new WP_Import();
            if (!function_exists('wp_insert_category')) {
                include ABSPATH . 'wp-admin/includes/taxonomy.php';
            }
            if (!function_exists('post_exists')) {
                include ABSPATH . 'wp-admin/includes/post.php';
            }
            if (!function_exists('comment_exists')) {
                include ABSPATH . 'wp-admin/includes/comment.php';
            }
            $WP_Import->fetch_attachments = true;
            $WP_Import->allow_fetch_attachments();
            $WP_Import->import($file_path);
            do_action('wplms_after_sample_data_import', $file);
            _e('Import Complete !', 'vibe');
        } else {
            echo __("Unable to locate Sample Data file.", 'vibe');
        }
    } else {
        echo __("Couldn't install the test demo data as we were unable to use the WP_Import class.", "vibe");
    }
}
Example #2
0
/**
 * FILE: vibeimport.php 
 * Author: Mr.Vibe 
 * Credits: www.VibeThemes.com
 * Project: WPLMS
 */
function vibe_import($file)
{
    require_once ABSPATH . 'wp-admin/includes/import.php';
    $file_path = apply_filters('wplms_setup_import_file_path', VIBE_PATH . "/setup/data/{$file}.xml", $file);
    if (!class_exists('WP_Import')) {
        require_once 'wordpress-importer.php';
    }
    if (class_exists('WP_Import')) {
        if (file_exists($file_path)) {
            do_action('wplms_before_sample_data_import', $file);
            $WP_Import = new WP_Import();
            if (!function_exists('wp_insert_category')) {
                include ABSPATH . 'wp-admin/includes/taxonomy.php';
            }
            if (!function_exists('post_exists')) {
                include ABSPATH . 'wp-admin/includes/post.php';
            }
            if (!function_exists('comment_exists')) {
                include ABSPATH . 'wp-admin/includes/comment.php';
            }
            $WP_Import->fetch_attachments = true;
            $WP_Import->allow_fetch_attachments();
            $WP_Import->import($file_path);
            _e('Import Complete !', 'vibe');
            echo '<a href="' . admin_url('options-permalink.php') . '" target="_blank" class="button button-primary" style="margin-top:15px;">' . __('Save Permalinks', 'vibe') . '</a><br />';
            echo '<a href="' . admin_url('options-general.php?page=bp-components') . '" target="_blank" class="button button-primary" style="margin-top:15px;">' . __('Save Components', 'vibe') . '</a>';
            do_action('wplms_after_sample_data_import', $file);
        } else {
            echo __("Unable to locate Sample Data file.", 'vibe');
        }
    } else {
        echo __("Couldn't install the test demo data as we were unable to use the WP_Import class.", "vibe");
    }
}
 function vwdemo_start_import()
 {
     define('WP_LOAD_IMPORTERS', true);
     // Load all importer functions
     require VW_DEMO_IMPORT_PATH . '/wordpress-importer/wordpress-importer.php';
     add_action('import_start', 'vwdemo_import_custom_sidebars', 91);
     add_action('import_start', 'vwdemo_import_widgets', 92);
     add_action('import_end', 'vwdemo_setup_menu');
     add_action('import_end', 'vwdemo_setup_homepage');
     add_action('import_end', 'vwdemo_setup_finish');
     add_filter('http_request_args', 'vwdemo_disable_reject_unsafe_urls', 11, 2);
     $wp_import = new WP_Import();
     $wp_import->fetch_attachments = $wp_import->allow_fetch_attachments();
     // Import
     $file_path = VW_DEMO_IMPORT_PATH . '/demo-content/demo-content.xml';
     if (file_exists($file_path)) {
         $wp_import->import($file_path);
     }
     die;
 }
Example #4
0
 function vwdemo_start_import()
 {
     define('WP_LOAD_IMPORTERS', true);
     error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT);
     if (!class_exists('WP_Import')) {
         require_once get_template_directory() . '/framework/demo-importer/wordpress-importer/wordpress-importer.php';
     }
     add_action('import_start', 'vwdemo_import_custom_sidebars', 91);
     add_action('import_start', 'vwdemo_import_widgets', 92);
     add_action('import_end', 'vwdemo_setup_menu');
     add_action('import_end', 'vwdemo_setup_homepage');
     add_filter('http_request_args', 'vwdemo_disable_reject_unsafe_urls', 11, 2);
     $wp_import = new WP_Import();
     $wp_import->fetch_attachments = $wp_import->allow_fetch_attachments();
     // Import
     $file_path = VW_DEMO_IMPORT_PATH . '/demo-content.xml';
     if (file_exists($file_path)) {
         $wp_import->import($file_path);
     }
     die;
 }