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); } } }
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"); }
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 }
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; }
/** * 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 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; }
/** * 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(); }
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; }
/** * 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"); } }
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(); }
/** --------------------------------------------------------------------------- * 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(); }
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')); } } }
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(); } }
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; }
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; }
function handle_wp_import($data) { if (!class_exists('WP_Import')) { $wp_importer = get_template_directory() . '/lib/vendor/wordpress-importer/wordpress-importer.php'; if (is_readable($wp_importer)) { require $wp_importer; } else { return new WP_Error('wp_importer_missing', esc_html__('The WordPress importer class can\'t be found.', 'youxi')); } } $data = wp_parse_args($data, array('xml' => '', 'attachments_baseurl' => '', 'attachments_dir' => '')); // Import the content $wp_import = new WP_Import(); $wp_import->attachments_baseurl = $data['attachments_baseurl']; $wp_import->attachments_dir = $data['attachments_dir']; $wp_import->fetch_attachments = true; ob_start(); set_time_limit(0); $wp_import->import($data['xml']); return ob_get_clean(); }
function import_content($file = 'content.xml') { $xml = AZEXO_THEME_DIR . '/azexo/importer/data/' . $file; if (file_exists($xml)) { $import = new WP_Import(); $import->fetch_attachments = $_POST && key_exists('attachments', $_POST) && $_POST['attachments'] ? true : false; ob_start(); $import->import($xml); ob_end_clean(); // set home & blog page $home = get_page_by_title('Home'); $blog = get_page_by_title('Journal'); if ($home->ID && $blog->ID) { update_option('show_on_front', 'page'); update_option('page_on_front', $home->ID); // Front Page update_option('page_for_posts', $blog->ID); // Blog Page } } }
public function import_content($file) { if (!class_exists('WP_Importer')) { ob_start(); $class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php'; require_once $class_wp_importer; require_once get_template_directory() . '/includes/import/class.wordpress-importer.php'; $qode_import = new WP_Import(); set_time_limit(0); $path = get_template_directory() . '/includes/import/files/' . $file; $qode_import->fetch_attachments = $this->attachments; $returned_value = $qode_import->import($path); if (is_wp_error($returned_value)) { $this->message = __("An Error Occurred During Import", "qode"); } else { $this->message = __("Content imported successfully", "qode"); } ob_get_clean(); } else { $this->message = __("Error loading files", "qode"); } }
static function beginInstall() { global $easy_metadata, $config_suboption; EASYFInstallerHelper::createImages(); if (!defined('WP_LOAD_IMPORTERS')) { define('WP_LOAD_IMPORTERS', true); } if (!class_exists('WP_Import')) { $class_wp_import = EASY_F_PLUGIN_PATH . '/admin/importer/wordpress-importer.php'; if (file_exists($class_wp_import)) { require_once $class_wp_import; } } $import_file = EASY_F_PLUGIN_PATH . '/demo_data_here/dummy' . $config_suboption . '.xml'; if (is_file($import_file)) { $wp_import = new WP_Import(); $wp_import->fetch_attachments = false; if (isset($easy_metadata['data']->allow_attachment) && $easy_metadata['data']->allow_attachment == "yes") { $wp_import->fetch_attachments = true; } $wp_import->import($import_file); } }
public function import_demo_content($data_file) { try { if (!defined('WP_LOAD_IMPORTERS')) { define('WP_LOAD_IMPORTERS', true); } if (!class_exists('WP_Import')) { include dirname(__FILE__) . "/wordpress-importer.php"; } $xml_filepath = $data_file; if (!file_exists($xml_filepath)) { return false; } $importer = new WP_Import(); $importer->fetch_attachments = true; ob_start(); $importer->import($xml_filepath); ob_end_clean(); return true; } catch (Exception $e) { throw $e; } }
public function import_vc_templates($file) { if (!class_exists('WP_Importer')) { ob_start(); require_once 'class.wordpress-importer.php'; $thememove_import = new WP_Import(); set_time_limit(0); $path = get_template_directory() . '/inc/import/files/' . $file; $thememove_import->fetch_attachments = $this->attachments; $returned_value = $thememove_import->import($path); echo $returned_value; die; if (is_wp_error($returned_value)) { $this->message = __("An Error Occurred During Import", "thememove"); } else { $this->message = __("Content imported successfully", "thememove"); } ob_get_clean(); } else { $this->message = __("Error loading files", "thememove"); } }
function us_demo_import_content() { set_time_limit(0); if (!defined('WP_LOAD_IMPORTERS')) { define('WP_LOAD_IMPORTERS', true); } require_once get_template_directory() . '/vendor/wordpress-importer/wordpress-importer.php'; //select which files to import // $aviable_demos = array ('demo1', 'demo2', ); // $demo_version = 'demo1'; // if (in_array($_POST['demo'], $aviable_demos)) { // $demo_version = $_POST['demo']; // } $wp_import = new WP_Import(); $wp_import->fetch_attachments = true; ob_start(); $wp_import->import(get_template_directory() . '/xml/demo_data.xml'); ob_end_clean(); // 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 == 'Impreza Header Menu') { $locations['impeza_main_menu'] = $menu->term_id; } } } set_theme_mod('nav_menu_locations', $locations); //Set Front Page $front_page = get_page_by_title('Home'); if (isset($front_page->ID)) { update_option('show_on_front', 'page'); update_option('page_on_front', $front_page->ID); } echo 'ok'; die; }
function tbDummyData() { /* init */ global $wp_filesystem; if (empty($wp_filesystem)) { require_once ABSPATH . '/wp-admin/includes/file.php'; WP_Filesystem(); } define('WP_LOAD_IMPORTERS', true); /* init importer */ 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 = TB_INCLUDES . 'wordpress-importer/wordpress-importer.php'; if (file_exists($class_wp_import)) { require_once $class_wp_import; } else { $importer_error = true; } } if ($importer_error) { die("Import error! Please unninstall WP importer plugin and try again"); } $wp_import = new WP_Import(); /* attachments */ $wp_import->fetch_attachments = true; /* init post query */ $theme = isset($_POST['theme']) ? $_POST['theme'] : 'tbtheme'; $current_data = isset($_POST['current_data']) ? $_POST['current_data'] : ''; /* tb used theme */ update_option('tb-theme-primary', $theme); ob_start(); /* import slider, ess grid and widget setting */ switch ($current_data) { case 'options': $options_json = get_template_directory_uri() . '/inc/dummy/' . $theme . '/options.json'; $options = $wp_filesystem->get_contents($options_json); if ($options) { tbImportThemeOptions($options); } else { die('<br />Your server don\'t have permission read options file. Theme options isn\'t imported<br />'); } break; case 'slider': if (!tbImportRevSlider($theme)) { $msg = '<br />You haven\'t install Rev Slider plugin. Slider isn\'t imported<br />'; } die($msg); break; case 'grid': if (!tbImportEssGrid($theme)) { $msg = '<br />You haven\'t install Ess Grid plugin. Ess data isn\'t imported<br />'; } die($msg); break; case 'widget': $widgets_json = get_template_directory_uri() . '/inc/dummy/' . $theme . '/widget_data.json'; $widgets = $wp_filesystem->get_contents($widgets_json); if ($widgets) { $msg = ''; tbImportWidgetSetting($widgets); } else { $msg = '<br />Your server don\'t have permission read widgets setting file. Widgets setting isn\'t imported<br />'; } die($msg); break; default: if ($current_data == 15) { if (function_exists('cptui_create_custom_post_types')) { if (file_exists(get_template_directory() . '/inc/dummy/' . $theme . '/posttypes/post.json')) { $posttypes = $wp_filesystem->get_contents(get_template_directory_uri() . '/inc/dummy/' . $theme . '/posttypes/post.json'); update_option('cptui_post_types', json_decode($posttypes, true)); } if (file_exists(get_template_directory() . '/inc/dummy/' . $theme . '/posttypes/tax.json')) { $tax = $wp_filesystem->get_contents(get_template_directory_uri() . '/inc/dummy/' . $theme . '/posttypes/tax.json'); update_option('cptui_taxonomies', json_decode($tax, true)); } flush_rewrite_rules(); } } if ($current_data == 16) { /*delete old menu and import new.*/ foreach (get_terms('nav_menu') as $nav) { wp_delete_nav_menu($nav->slug); } } if (file_exists(get_template_directory() . '/inc/dummy/' . $theme . '/data/sample' . $current_data . '.xml')) { $wp_import->import(get_template_directory() . '/inc/dummy/' . $theme . '/data/sample' . $current_data . '.xml'); } break; } ob_end_clean(); /* Done */ if ($current_data == 16) { die('<br />Import is finished.'); } }
function pp_import_demo_content() { if (is_admin() && isset($_POST['demo']) && !empty($_POST['demo'])) { if (!defined('WP_LOAD_IMPORTERS')) { define('WP_LOAD_IMPORTERS', true); } // Load Importer API require_once ABSPATH . 'wp-admin/includes/import.php'; if (!class_exists('WP_Importer')) { $class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php'; if (file_exists($class_wp_importer)) { require $class_wp_importer; } } if (!class_exists('WP_Import')) { $class_wp_importer = get_template_directory() . "/modules/import/wordpress-importer.php"; if (file_exists($class_wp_importer)) { require $class_wp_importer; } } $import_files = array(); //Check import selected demo if (class_exists('WP_Import')) { switch ($_POST['demo']) { case 1: default: //Check if install Woocommerce if (!class_exists('Woocommerce')) { $import_filepath = get_template_directory() . "/cache/demos/1.xml"; } else { $import_filepath = get_template_directory() . "/cache/demos/1_woo.xml"; } $page_on_front = 3602; //Demo 1 Homepage ID $oldurl = 'http://themes.themegoods2.com/photome/demo'; break; } //Run and download demo contents $wp_import = new WP_Import(); $wp_import->fetch_attachments = true; $wp_import->import($import_filepath); } //Setup default front page settings. update_option('show_on_front', 'page'); update_option('page_on_front', $page_on_front); //Set default custom menu settings $locations = get_theme_mod('nav_menu_locations'); $locations['primary-menu'] = 21; $locations['top-menu'] = 24; $locations['side-menu'] = 23; set_theme_mod('nav_menu_locations', $locations); //Change all URLs from demo URL to localhost $update_options = array(0 => 'content', 1 => 'excerpts', 2 => 'links', 3 => 'attachments', 4 => 'custom', 5 => 'guids'); $newurl = esc_url(site_url()); VB_update_urls($update_options, $oldurl, $newurl); exit; } }
function us_demo_import_content() { global $us_template_directory; $config = us_config('demo-import'); set_time_limit(0); if (!defined('WP_LOAD_IMPORTERS')) { define('WP_LOAD_IMPORTERS', TRUE); } require_once $us_template_directory . '/framework/vendor/wordpress-importer/wordpress-importer.php'; //select which files to import $aviable_demos = array_keys($config); $demo_version = $aviable_demos[0]; if (in_array($_POST['demo'], $aviable_demos)) { $demo_version = $_POST['demo']; } $wp_import = new WP_Import(); $wp_import->fetch_attachments = TRUE; ob_start(); $wp_import->import($us_template_directory . '/demo-import/' . $demo_version . '-data.xml'); ob_end_clean(); // Set menu if (isset($config[$demo_version]['nav_menu_locations'])) { $locations = get_theme_mod('nav_menu_locations'); $menus = wp_get_nav_menus(); if (!empty($menus)) { foreach ($menus as $menu) { if (is_object($menu) and isset($config[$demo_version]['nav_menu_locations'][$menu->name])) { $nav_location_key = $config[$demo_version]['nav_menu_locations'][$menu->name]; $locations[$nav_location_key] = $menu->term_id; } } } set_theme_mod('nav_menu_locations', $locations); } // Set Front Page if (isset($config[$demo_version]['front_page'])) { $front_page = get_page_by_title($config[$demo_version]['front_page']); if (isset($front_page->ID)) { update_option('show_on_front', 'page'); update_option('page_on_front', $front_page->ID); } } wp_send_json_success(); }
function tie_demo_installer() { ?> <div id="icon-tools" class="icon32"><br></div> <h2><?php _e('Import Demo Data', 'tie'); ?> </h2> <div style="background-color: #F5FAFD; margin:10px 0;padding: 10px;color: #0C518F;border: 3px solid #CAE0F3; claer:both; width:90%; line-height:18px;"> <p class="tie_message_hint"><?php _e('Importing demo data (post, pages, images, theme settings, ...) is the easiest way to setup your theme. It will allow you to quickly edit everything instead of creating content from scratch. When you import the data following things will happen:', 'tie'); ?> </p> <ul style="padding-left: 20px;list-style-position: inside;list-style-type: square;}"> <li><?php _e('No existing posts, pages, categories, images, custom post types or any other data will be deleted or modified.', 'tie'); ?> </li> <li><?php _e('About 10 posts, a few pages, 10+ images, some widgets and two menus will get imported.', 'tie'); ?> </li> <li><?php _e('Images will be downloaded from our server, these images are copyrighted and are for demo use only.', 'tie'); ?> </li> <li><?php _e('Please click import only once and wait, it can take a couple of minutes.', 'tie'); ?> </li> </ul> </div> <form method="post"> <input type="hidden" name="demononce" value="<?php echo wp_create_nonce('tie-demo-code'); ?> " /> <input name="reset" class="button" type="submit" value="<?php _e('Import Demo Data', 'tie'); ?> " /> <input type="hidden" name="action" value="demo-data" /> </form> <br /> <br /> <?php if (isset($_REQUEST['action']) && 'demo-data' == $_REQUEST['action'] && check_admin_referer('tie-demo-code', 'demononce')) { 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 = get_template_directory() . '/framework/admin/inc/importer/wordpress-importer.php'; if (file_exists($class_wp_import)) { require_once $class_wp_import; } else { $importerError = true; } } if ($importer_error) { die("Error in import :("); } else { if (!is_file(get_template_directory() . '/framework/admin/inc/importer/sample.xml')) { _e("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", "tie"); } else { $wp_import = new WP_Import(); $wp_import->fetch_attachments = true; $wp_import->import(get_template_directory() . '/framework/admin/inc/importer/sample.xml'); } } tie_set_demo_data(); } }
function ac_demo_data_import() { global $wpdb; // Let WP know we are importing if (!defined('WP_LOAD_IMPORTERS')) { define('WP_LOAD_IMPORTERS', true); } // Import plugin may already be active if (!is_plugin_active('wordpress-importer/wordpress-importer.php')) { // We need to include WP data import plugin if (!class_exists('WP_Import')) { require_once AC_INCLUDES_PATH . '/wordpress-importer/wordpress-importer.php'; } // We need to include WP data importer if (!class_exists('WP_Importer')) { require_once ABSPATH . 'wp-admin/includes/class-wp-importer.php'; } } // Check we have our Importer if (class_exists('WP_Importer') && class_exists('WP_Import')) { // Create the importer $importer = new WP_Import(); // -- CONTENT -- // Import WP exported content (posts, pages, menu items, etc). $importer->fetch_attachments = true; ob_start(); $importer->import(AC_DD_THEME_XML_PATH); ob_end_clean(); // -- MENU ITEMS -- // Assign the menu to our location $locations = get_theme_mod('nav_menu_locations'); // Get the menus $menus = wp_get_nav_menus(); // Assign the menu if ($menus) { foreach ($menus as $menu) { // If it's the main menu assign to the Main Menu if ($menu->slug == 'one-page-menu') { $locations['primary_navigation'] = $menu->term_id; } } } // Store the locations set_theme_mod('nav_menu_locations', $locations); // -- THEME OPTIONS -- $ac_dd_theme_options_txt_path = wp_remote_get(AC_DD_THEME_OPTIONS_TXT_URI); $ac_dd_theme_options_txt_path = unserialize(base64_decode($ac_dd_theme_options_txt_path['body'])); update_option(AC_THEME_NAME . '_options', $ac_dd_theme_options_txt_path); // -- WIDGETS -- ac_data_importer_import_widgets(AC_DD_WIDGETS_PATH); // -- REV SLIDER -- /* $rev_directory = AC_INCLUDES_PATH . '/demo-data/rev_sliders/'; ac_import_rev_sliders( $rev_directory ); */ // -- AC Gallery -- // Remove duplicate Homepage, New Gallery and Trash galleries /* $post = get_page_by_path( 'homepage', OBJECT, 'ac_gallery' ); wp_delete_post( $post->ID, true ); $post = get_page_by_path( 'New Gallery', OBJECT, 'ac_gallery' ); wp_delete_post( $post->ID, true ); $post = get_page_by_path( 'trash', OBJECT, 'ac_gallery' ); wp_delete_post( $post->ID, true ); */ // Set reading options $homepage = get_page_by_title('Home'); if ($homepage->ID) { update_option('show_on_front', 'page'); update_option('page_on_front', $homepage->ID); } /* $posts_page = get_page_by_title( 'Blog' ); if($posts_page->ID) { update_option('show_on_front', 'page'); update_option('page_for_posts', $posts_page->ID); } */ // Hide Hello World! post $my_post = array('ID' => 1, 'post_status' => 'draft'); wp_update_post($my_post); // Store that the import has been run update_option('ac_demo_data_imported', '1'); // Hookup message to user add_action('admin_notices', 'ac_demo_data_finished_msg'); } }
function fusion_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() . '/framework/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(); /* First Import Posts, Pages, Portfolio Content, FAQ, Images, Menus */ $theme_xml = get_template_directory() . '/framework/plugins/importer/data/avada.xml.gz'; $importer->fetch_attachments = true; ob_start(); $importer->import($theme_xml); ob_end_clean(); /* Import Woocommerce if WooCommerce Exists */ if (class_exists('Woocommerce')) { $importer = new WP_Import(); $theme_xml = get_template_directory() . '/framework/plugins/importer/data/wooproducts.xml.gz'; $importer->fetch_attachments = true; ob_start(); $importer->import($theme_xml); ob_end_clean(); // Set pages $woopages = array('woocommerce_shop_page_id' => 'Shop', 'woocommerce_cart_page_id' => 'Cart', 'woocommerce_checkout_page_id' => 'Checkout', 'woocommerce_pay_page_id' => 'Checkout → Pay', 'woocommerce_thanks_page_id' => 'Order Received', 'woocommerce_myaccount_page_id' => 'My Account', 'woocommerce_edit_address_page_id' => 'Edit My Address', 'woocommerce_view_order_page_id' => 'View Order', 'woocommerce_change_password_page_id' => 'Change Password', 'woocommerce_logout_page_id' => 'Logout', 'woocommerce_lost_password_page_id' => 'Lost Password'); foreach ($woopages as $woo_page_name => $woo_page_title) { $woopage = get_page_by_title($woo_page_title); if ($woopage->ID) { update_option($woo_page_name, $woopage->ID); // Front Page } } // We no longer need to install pages delete_option('_wc_needs_pages'); delete_transient('_wc_activation_redirect'); // Flush rules after install flush_rewrite_rules(); } // Set imported menus to registered theme locations $locations = get_theme_mod('nav_menu_locations'); // registered menu locations in theme $menus = wp_get_nav_menus(); // registered menus if ($menus) { foreach ($menus as $menu) { // assign menus to theme locations if ($menu->name == 'Main') { $locations['main_navigation'] = $menu->term_id; } else { if ($menu->name == '404') { $locations['404_pages'] = $menu->term_id; } else { if ($menu->name == 'Top') { $locations['top_navigation'] = $menu->term_id; } } } } } set_theme_mod('nav_menu_locations', $locations); // set menus to locations // Import Theme Options $theme_options_txt = get_template_directory_uri() . '/framework/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 sidebar widget areas $sidebars = array('ContactSidebar' => 'Contact Sidebar', 'FAQ' => 'FAQ', 'HomepageSidebar' => 'Home Page Sidebar', 'Portfolio' => 'Portfolio'); update_option('sbg_sidebars', $sidebars); foreach ($sidebars as $sidebar) { $sidebar_class = avada_name_to_class($sidebar); register_sidebar(array('name' => $sidebar, 'id' => 'avada-custom-sidebar-' . strtolower($sidebar_class), 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<div class="heading"><h3>', 'after_title' => '</h3></div>')); } // Add data to widgets $widgets_json = get_template_directory_uri() . '/framework/plugins/importer/data/widget_data.json'; // widgets data file $widgets_json = wp_remote_get($widgets_json); $widget_data = $widgets_json['body']; $import_widgets = fusion_import_widget_data($widget_data); // Import Layerslider if (function_exists('layerslider_import_sample_slider')) { // if layerslider is activated $ls_txt = get_template_directory_uri() . '/framework/plugins/importer/data/layerslider.txt'; // layerslider data file $ls_txt = wp_remote_get($ls_txt); $data = json_decode(base64_decode($ls_txt['body']), true); avada_import_sample_slider($data); // update theme options // Get all sliders // Table name $table_name = $wpdb->prefix . "layerslider"; // Get sliders $sliders = $wpdb->get_results("SELECT * FROM {$table_name}\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE flag_hidden = '0' AND flag_deleted = '0'\n\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY date_c ASC"); if (!empty($sliders)) { foreach ($sliders as $key => $item) { $slides[$item->id] = $item->name; } } if ($slides) { foreach ($slides as $key => $val) { $slides_array[$val] = $key; } } // Assign LayerSlider $lspage = get_page_by_title('Layer Slider'); if ($lspage->ID && $slides_array['Avada Full Width']) { update_post_meta($lspage->ID, 'pyre_slider', $slides_array['Avada Full Width']); } } // Import Revslider if (class_exists('UniteFunctionsRev')) { // if revslider is activated $rev_directory = get_template_directory() . '/framework/plugins/importer/data/revsliders/'; // layerslider data dir foreach (glob($rev_directory . '*.txt') as $filename) { // get all files from revsliders data dir $filename = basename($filename); $rev_files[] = get_template_directory_uri() . '/framework/plugins/importer/data/revsliders/' . $filename; } foreach ($rev_files as $rev_file) { // finally import rev slider data files $get_file = wp_remote_get($rev_file); $arrSlider = unserialize($get_file['body']); $sliderParams = $arrSlider["params"]; if (isset($sliderParams["background_image"])) { $sliderParams["background_image"] = UniteFunctionsWPRev::getImageUrlFromPath($sliderParams["background_image"]); } $json_params = json_encode($sliderParams); $arrInsert = array(); $arrInsert["params"] = $json_params; $arrInsert["title"] = UniteFunctionsRev::getVal($sliderParams, "title", "Slider1"); $arrInsert["alias"] = UniteFunctionsRev::getVal($sliderParams, "alias", "slider1"); $wpdb->insert(GlobalsRevSlider::$table_sliders, $arrInsert); $sliderID = mysql_insert_id(); //create all slides $arrSlides = $arrSlider["slides"]; foreach ($arrSlides as $slide) { $params = $slide["params"]; $layers = $slide["layers"]; //convert params images: if (isset($params["image"])) { $params["image"] = UniteFunctionsWPRev::getImageUrlFromPath($params["image"]); } //convert layers images: foreach ($layers as $key => $layer) { if (isset($layer["image_url"])) { $layer["image_url"] = UniteFunctionsWPRev::getImageUrlFromPath($layer["image_url"]); $layers[$key] = $layer; } } //create new slide $arrCreate = array(); $arrCreate["slider_id"] = $sliderID; $arrCreate["slide_order"] = $slide["slide_order"]; $arrCreate["layers"] = json_encode($layers); $arrCreate["params"] = json_encode($params); $wpdb->insert(GlobalsRevSlider::$table_slides, $arrCreate); } } } // Set reading options $homepage = get_page_by_title('Home Version 13'); $posts_page = get_page_by_title('Blog Large'); if ($homepage->ID && $posts_page->ID) { update_option('show_on_front', 'page'); update_option('page_on_front', $homepage->ID); // Front Page update_option('page_for_posts', $posts_page->ID); // Blog Page } // finally redirect to success page wp_redirect(admin_url('themes.php?page=optionsframework&imported=success#of-option-generaloptions')); } } }
function codeless_import_content($file, $attachments) { if (!class_exists('WP_Importer')) { ob_start(); $class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php'; require_once $class_wp_importer; require_once get_template_directory() . '/admin/inc/fields/codeless_import/class.wordpress-importer.php'; $wp_import = new WP_Import(); set_time_limit(0); $path = get_template_directory() . '/includes/dummy_data/' . $this->type . '/' . $file . '.xml'; $wp_import->fetch_attachments = $attachments; $value = $wp_import->import($path); ob_get_clean(); if (is_wp_error($value)) { $this->message .= __("Error during Import. Try Again", "redux-framework"); return 2; } else { $this->message .= __("Content has been imported successfully ", "redux-framework"); return 1; } } else { $this->message = __("Error loading importer. Try again or contact support", "redux-framework"); return 2; } }
function do_import() { $import_attachments = isset($_POST['webnus_importer_attachments']) && $_POST['webnus_importer_attachments'] == 'true' ? true : false; global $wpdb; if (!class_exists('WP_Import')) { include_once get_template_directory() . "/inc/plugins/wordpress-importer/wordpress-importer.php"; } $file_name = ''; if (isset($_POST['webnus_importer_filename'])) { $file_name = $_POST['webnus_importer_filename']; } $file_name = empty($file_name) ? 'dummy.xml' : $file_name; $myimporter = new WP_Import(); ob_start(); $myimporter->fetch_attachments = false; //$import_attachments; $myimporter->import(get_template_directory() . '/inc/dummy-data/' . $file_name); ob_end_clean(); echo 'Done! Demo data imported.'; die; }