当前位置: 首页>>代码示例>>PHP>>正文


PHP WP_Import::import方法代码示例

本文整理汇总了PHP中WP_Import::import方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Import::import方法的具体用法?PHP WP_Import::import怎么用?PHP WP_Import::import使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WP_Import的用法示例。


在下文中一共展示了WP_Import::import方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: set_demo_data

 public function set_demo_data($file)
 {
     if (!defined('WP_LOAD_IMPORTERS')) {
         define('WP_LOAD_IMPORTERS', true);
     }
     require_once ABSPATH . 'wp-admin/includes/import.php';
     $importer_error = false;
     if (!class_exists('WP_Importer')) {
         $class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
         if (file_exists($class_wp_importer)) {
             require_once $class_wp_importer;
         } else {
             $importer_error = true;
         }
     }
     if (!class_exists('WP_Import')) {
         $class_wp_import = dirname(__FILE__) . '/wordpress-importer.php';
         if (file_exists($class_wp_import)) {
             require_once $class_wp_import;
         } else {
             $importer_error = true;
         }
     }
     if ($importer_error) {
         die("Error on import");
     } else {
         if (!is_file($file)) {
             echo "The XML file containing the dummy content is not available or could not be read .. You might want to try to set the file permission to chmod 755.<br/>If this doesn't work please use the Wordpress importer and import the XML file (should be located in your download .zip: Sample Content folder) manually ";
         } else {
             $wp_import = new WP_Import();
             $wp_import->fetch_attachments = true;
             $wp_import->import($file);
         }
     }
 }
开发者ID:ckirk,项目名称:Beatific,代码行数:35,代码来源:radium-importer.php

示例2: cmo_import_xml

function cmo_import_xml($demo_xml_file)
{
    if (function_exists('check_ajax_referer')) {
        check_ajax_referer(DEMO_IMPORTER_NONCE, 'security');
    }
    header('Content-type: text/html; charset=utf-8');
    define('WP_LOAD_IMPORTERS', true);
    require_once ABSPATH . 'wp-admin/includes/import.php';
    $import_error = false;
    if (!class_exists('WP_Importer')) {
        $wp_importer_file = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
        if (file_exists($wp_importer_file)) {
            require_once $wp_importer_file;
        } else {
            $import_error = true;
        }
    }
    if (!class_exists('WP_Import')) {
        require_once 'wordpress-importer/wordpress-importer.php';
    }
    if ($import_error || !class_exists('WP_Import')) {
        ajax_finish(false, __('Failed to load importer php files. Use WordPress Importer plugin to manually load demo content xml file.', 'cumulo'));
    }
    if (!is_file($demo_xml_file)) {
        ajax_finish(true, "done");
    }
    $wp_import = new WP_Import();
    $wp_import->fetch_attachments = true;
    set_time_limit(0);
    ob_start();
    $wp_import->import($demo_xml_file);
    ob_get_clean();
    ajax_finish(true, "done");
}
开发者ID:supahseppe,项目名称:ashley-travel,代码行数:34,代码来源:demo-importer-ajax.php

示例3: isset

 function kt_importer_content_callback()
 {
     $this->demoid = sanitize_title($_POST['demo']);
     $count = isset($_POST['count']) ? intval($_POST['count']) : 0;
     if ($count) {
         if (!defined('WP_LOAD_IMPORTERS')) {
             define('WP_LOAD_IMPORTERS', true);
         }
         require_once ABSPATH . 'wp-admin/includes/import.php';
         if (!class_exists('WP_Importer')) {
             $class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
             require_once $class_wp_importer;
         }
         if (!class_exists('WP_Import')) {
             $class_wp_import = dirname(__FILE__) . '/includes/wordpress-importer.php';
             require_once $class_wp_import;
         }
         $this->content_file_name = $this->kt_importer_dir . $this->demoid . '/content_' . $count . '.xml';
         if (!is_file($this->content_file_name)) {
             echo "The XML file containing the dummy content is not available or could not be read .. You might want to try to set the file permission to chmod 755.<br/>If this doesn't work please use the Wordpress importer and import the XML file (should be located in your download .zip: Sample Content folder) manually ";
         } else {
             $wp_import = new WP_Import();
             $wp_import->fetch_attachments = true;
             $returned_value = $wp_import->import($this->content_file_name);
             if (is_wp_error($returned_value)) {
                 echo "An Error Occurred During Import";
             }
         }
     } else {
         //Content imported successfully
         do_action('kt_importer_after_content_import', $this->demoid);
     }
     wp_die();
     // this is required to terminate immediately and return a proper response
 }
开发者ID:websideas,项目名称:aquila,代码行数:35,代码来源:kt_importer.php

示例4: define

 function us_dataImport()
 {
     if (!defined('WP_LOAD_IMPORTERS')) {
         define('WP_LOAD_IMPORTERS', true);
     }
     require_once get_template_directory() . '/vendor/wordpress-importer/wordpress-importer.php';
     if (!is_file(get_template_directory() . '/xml/demo_data.xml')) {
         echo "Automatic import failed. Please use the wordpress importer and import the XML file (Astra/xml/demo_data.xml) manually.";
     } else {
         $wp_import = new WP_Import();
         $wp_import->fetch_attachments = true;
         $wp_import->import(get_template_directory() . '/xml/demo_data.xml');
         // Set menu
         $locations = get_theme_mod('nav_menu_locations');
         $menus = wp_get_nav_menus();
         if (!empty($menus)) {
             foreach ($menus as $menu) {
                 if (is_object($menu) && $menu->name == 'Astra Main Menu') {
                     $locations['astra_main_menu'] = $menu->term_id;
                 }
                 if (is_object($menu) && $menu->name == 'Astra Footer Menu') {
                     $locations['astra_footer_menu'] = $menu->term_id;
                 }
             }
         }
         set_theme_mod('nav_menu_locations', $locations);
     }
     die;
 }
开发者ID:syncopetwice,项目名称:STG,代码行数:29,代码来源:ajax_import.php

示例5: vibe_import

/**
 * 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");
    }
}
开发者ID:nikitansk,项目名称:devschool,代码行数:40,代码来源:vibeimport.php

示例6: thb_import_data

function thb_import_data()
{
    // Load Importer API
    require_once ABSPATH . 'wp-admin/includes/import.php';
    $importerError = false;
    $file = get_template_directory() . "/inc/democontent/demo-content.xml";
    if (!class_exists('WP_Importer')) {
        $class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
        if (file_exists($class_wp_importer)) {
            require_once $class_wp_importer;
        } else {
            $importerError = true;
        }
    }
    if ($importerError !== false) {
        echo "The Auto importing script could not be loaded. Please use the wordpress importer and import the XML file that is located in your themes folder manually.";
    } else {
        if (class_exists('WP_Importer')) {
            try {
                $importer = new WP_Import();
                $importer->fetch_attachments = true;
                $importer->import($file);
                thb_update_options();
                thb_update_menus('Main Menu', 'nav-menu');
                thb_import_theme_options();
                // thb_update_widgets();
                die('Success!');
            } catch (Exception $e) {
                echo "Error while importing";
            }
        }
    }
    die;
}
开发者ID:adampdarcy,项目名称:paola,代码行数:34,代码来源:import.php

示例7: _import_wp

 /**
  * Import a WXR file.
  *
  * The $users parameter provides information on how users specified in the import
  * file should be imported. Each key is a user login name and indicates if the user
  * should be mapped to an existing user, created as a new user with a particular login
  * or imported with the information held in the WXR file. An example of this:
  *
  * <code>
  * $users = array(
  *   'alice' => 1, // alice will be mapped to user ID 1
  *   'bob' => 'john', // bob will be transformed into john
  *   'eve' => false // eve will be imported as is
  * );</code>
  *
  * @param string $filename Full path of the file to import
  * @param array $users User import settings
  * @param bool $fetch_files Whether or not do download remote attachments
  */
 protected function _import_wp($filename, $users = array(), $fetch_files = true)
 {
     $importer = new WP_Import();
     $file = realpath($filename);
     assert('!empty($file)');
     assert('is_file($file)');
     $authors = $mapping = $new = array();
     $i = 0;
     // each user is either mapped to a given ID, mapped to a new user
     // with given login or imported using details in WXR file
     foreach ($users as $user => $map) {
         $authors[$i] = $user;
         if (is_int($map)) {
             $mapping[$i] = $map;
         } else {
             if (is_string($map)) {
                 $new[$i] = $map;
             }
         }
         $i++;
     }
     $_POST = array('imported_authors' => $authors, 'user_map' => $mapping, 'user_new' => $new);
     ob_start();
     $importer->fetch_attachments = $fetch_files;
     $importer->import($file);
     ob_end_clean();
     $_POST = array();
 }
开发者ID:boonebgorges,项目名称:develop.wordpress,代码行数:47,代码来源:base.php

示例8: etheme_import_data

function etheme_import_data()
{
    // Load Importer API
    require_once ABSPATH . 'wp-admin/includes/import.php';
    $importerError = false;
    $file = get_template_directory() . "/code/dummy/Dummy.xml";
    //check if wp_importer, the base importer class is available, otherwise include it
    if (!class_exists('WP_Importer')) {
        $class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
        if (file_exists($class_wp_importer)) {
            require_once $class_wp_importer;
        } else {
            $importerError = true;
        }
    }
    if ($importerError !== false) {
        echo "The Auto importing script could not be loaded. Please use the wordpress importer and import the XML file that is located in your themes folder manually.";
    } else {
        if (class_exists('WP_Importer')) {
            try {
                $importer = new WP_Import();
                $importer->fetch_attachments = true;
                $importer->import($file);
                etheme_update_options();
                etheme_update_widgets();
                etheme_update_menus();
            } catch (Exception $e) {
                echo "Error while importing";
            }
        }
    }
    die;
}
开发者ID:donpapa26,项目名称:bakancslistad,代码行数:33,代码来源:import.php

示例9: vibe_import

/**
 * 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");
    }
}
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:38,代码来源:vibeimport.php

示例10:

 function import_content($folder = '', $file = 'content.xml.gz')
 {
     $import = new WP_Import();
     $xml = get_template_directory() . '/library/import/files/' . $folder . '/' . $file;
     $import->fetch_attachments = $_POST && key_exists('attachments', $_POST) && $_POST['attachments'] ? true : false;
     ob_start();
     $import->import($xml);
     ob_end_clean();
 }
开发者ID:love4code,项目名称:originalContracting,代码行数:9,代码来源:import.php

示例11:

 /** ---------------------------------------------------------------------------
  * Import | Content
  * ---------------------------------------------------------------------------- */
 function import_content($file = 'all.xml.gz')
 {
     $import = new WP_Import();
     $xml = LIBS_DIR . '/importer/demo/' . $file;
     // 		print_r($xml);
     $import->fetch_attachments = $_POST && key_exists('attachments', $_POST) && $_POST['attachments'] ? true : false;
     ob_start();
     $import->import($xml);
     ob_end_clean();
 }
开发者ID:JohnPaganella,项目名称:trinkbier,代码行数:13,代码来源:import.php

示例12: mtc_importer

function mtc_importer()
{
    global $wpdb;
    if (current_user_can('manage_options') && isset($_GET['import_data_content'])) {
        if (!defined('WP_LOAD_IMPORTERS')) {
            define('WP_LOAD_IMPORTERS', true);
        }
        // we are loading importers
        if (!class_exists('WP_Importer')) {
            // if main importer class doesn't exist
            $wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
            include $wp_importer;
        }
        if (!class_exists('WP_Import')) {
            // if WP importer doesn't exist
            $wp_import = get_template_directory() . '/admin/library/plugins/importer/wordpress-importer.php';
            include $wp_import;
        }
        if (class_exists('WP_Importer') && class_exists('WP_Import')) {
            // check for main import class and wp import class
            $importer = new WP_Import();
            $import_message = array();
            /* First Import Posts, Pages, Portfolio Content, FAQ, Images, Menus */
            $import_message[] = 'First Import Posts, Pages, Portfolio Content, FAQ, Images, Menus';
            $theme_xml = get_template_directory() . '/admin/library/plugins/importer/data/bzine.xml.gz';
            $importer->fetch_attachments = true;
            ob_start();
            $importer->import($theme_xml);
            ob_end_clean();
            /* Import Theme Options */
            $import_message[] = 'Import Theme Options';
            $theme_options_txt = get_template_directory_uri() . '/admin/library/plugins/importer/data/theme_options.txt';
            // theme options data file
            $theme_options_txt = wp_remote_get($theme_options_txt);
            $data = unserialize(base64_decode($theme_options_txt['body']));
            update_option(OPTIONS, $data);
            // update theme options
            /* Add data to widgets */
            $import_message[] = 'Add data to widgets';
            $widgets_json = get_template_directory_uri() . '/admin/library/plugins/importer/data/bzine_widget.json';
            // widgets data file
            $widgets_json = wp_remote_get($widgets_json);
            $widget_data = $widgets_json['body'];
            $widget_data = json_decode($widget_data, true);
            update_option('sidebars_widgets', $widget_data['setting']);
            foreach ($widget_data['data'] as $key => $widget) {
                $dada = serialize($widget);
                update_option($key, $widget);
            }
            // finally redirect to success page
            wp_redirect(admin_url('themes.php?page=optionsframework&imported=success#of-option-generaloptions'));
        }
    }
}
开发者ID:afftt,项目名称:infos-ping,代码行数:54,代码来源:importer.php

示例13:

 function import_xml()
 {
     $xml_file = get_template_directory() . '/framework/importer/data/sample-data.xml.gz';
     if (file_exists($xml_file)) {
         $importer = new WP_Import();
         $importer->fetch_attachments = true;
         ob_start();
         $importer->import($xml_file);
         ob_end_clean();
     }
 }
开发者ID:mynein,项目名称:myne,代码行数:11,代码来源:importer.php

示例14: etheme_import_data

function etheme_import_data()
{
    //delete_option('demo_data_installed');die();
    if (!isset($_POST['version'])) {
        $style = 'e-commerce';
    } else {
        $style = $_POST['version'];
    }
    // Load Importer API
    require_once ABSPATH . 'wp-admin/includes/import.php';
    $importerError = false;
    $demo_data_installed = get_option('demo_data_installed');
    switch ($style) {
        case 'e-commerce':
            $file = get_template_directory() . "/framework/dummy/Dummy.xml";
            break;
        case 'corporate':
            $file = get_template_directory() . "/framework/dummy/Dummy_corpo.xml";
            break;
        default:
            $file = get_template_directory() . "/framework/dummy/Dummy_corpo.xml";
    }
    //check if wp_importer, the base importer class is available, otherwise include it
    if (!class_exists('WP_Importer')) {
        $class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
        if (file_exists($class_wp_importer)) {
            require_once $class_wp_importer;
        } else {
            $importerError = true;
        }
    }
    if ($importerError !== false) {
        echo "The Auto importing script could not be loaded. Please use the wordpress importer and import the XML file that is located in your themes folder manually.";
    } else {
        if (class_exists('WP_Importer')) {
            try {
                if ($demo_data_installed != 'yes') {
                    $importer = new WP_Import();
                    $importer->fetch_attachments = true;
                    $importer->import($file);
                }
                etheme_update_options($style);
                etheme_update_menus();
                die('Success!');
            } catch (Exception $e) {
                echo "Error while importing";
            }
        }
    }
    die;
}
开发者ID:MrMuzik,项目名称:ar4tupgrade,代码行数:51,代码来源:import.php

示例15: define

 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;
 }
开发者ID:wilxsv,项目名称:prevensionPublicLibrary,代码行数:20,代码来源:demo-importer.php


注:本文中的WP_Import::import方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。