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 fusion_importer() { global $wpdb; if (current_user_can('manage_options')) { 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 if (!isset($_POST['demo_type']) || trim($_POST['demo_type']) == '') { $demo_type = 'classic'; } else { $demo_type = $_POST['demo_type']; } switch ($demo_type) { case 'agency': $shop_demo = false; $theme_xml_file = get_template_directory() . '/framework/plugins/importer/agency_demo/avada.xml'; $theme_options_file = get_template_directory() . '/framework/plugins/importer/agency_demo/theme_options.txt'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/framework/plugins/importer/agency_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/framework/plugins/importer/agency_demo/fusion_slider.zip'; break; case 'app': $shop_demo = false; $theme_xml_file = get_template_directory() . '/framework/plugins/importer/app_demo/avada.xml'; $theme_options_file = get_template_directory() . '/framework/plugins/importer/app_demo/theme_options.txt'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/framework/plugins/importer/app_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/framework/plugins/importer/app_demo/fusion_slider.zip'; break; case 'travel': $shop_demo = false; $theme_xml_file = get_template_directory() . '/framework/plugins/importer/travel_demo/avada.xml'; $theme_options_file = get_template_directory() . '/framework/plugins/importer/travel_demo/theme_options.txt'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/framework/plugins/importer/travel_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/framework/plugins/importer/travel_demo/fusion_slider.zip'; break; case 'cafe': $shop_demo = false; $theme_xml_file = get_template_directory() . '/framework/plugins/importer/cafe_demo/avada.xml'; $theme_options_file = get_template_directory() . '/framework/plugins/importer/cafe_demo/theme_options.txt'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/framework/plugins/importer/cafe_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/framework/plugins/importer/cafe_demo/fusion_slider.zip'; break; case 'fashion': $shop_demo = false; $theme_xml_file = get_template_directory() . '/framework/plugins/importer/fashion_demo/avada.xml'; $theme_options_file = get_template_directory() . '/framework/plugins/importer/fashion_demo/theme_options.txt'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/framework/plugins/importer/fashion_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/framework/plugins/importer/fashion_demo/fusion_slider.zip'; break; case 'architecture': $shop_demo = false; $theme_xml_file = get_template_directory() . '/framework/plugins/importer/architecture_demo/avada.xml'; $theme_options_file = get_template_directory() . '/framework/plugins/importer/architecture_demo/theme_options.txt'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/framework/plugins/importer/architecture_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/framework/plugins/importer/architecture_demo/fusion_slider.zip'; break; case 'hosting': $shop_demo = false; $theme_xml_file = get_template_directory() . '/framework/plugins/importer/hosting_demo/avada.xml'; $theme_options_file = get_template_directory() . '/framework/plugins/importer/hosting_demo/theme_options.txt'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/framework/plugins/importer/hosting_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/framework/plugins/importer/hosting_demo/fusion_slider.zip'; break; case 'hotel': $shop_demo = false; $theme_xml_file = get_template_directory() . '/framework/plugins/importer/hotel_demo/avada.xml'; $theme_options_file = get_template_directory() . '/framework/plugins/importer/hotel_demo/theme_options.txt'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/framework/plugins/importer/hotel_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/framework/plugins/importer/hotel_demo/fusion_slider.zip'; break; case 'law': $shop_demo = false; $theme_xml_file = get_template_directory() . '/framework/plugins/importer/law_demo/avada.xml'; $theme_options_file = get_template_directory() . '/framework/plugins/importer/law_demo/theme_options.txt'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/framework/plugins/importer/law_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/framework/plugins/importer/law_demo/fusion_slider.zip'; break; case 'lifestyle': $shop_demo = false; $theme_xml_file = get_template_directory() . '/framework/plugins/importer/lifestyle_demo/avada.xml'; $theme_options_file = get_template_directory() . '/framework/plugins/importer/lifestyle_demo/theme_options.txt'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/framework/plugins/importer/lifestyle_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/framework/plugins/importer/lifestyle_demo/fusion_slider.zip'; break; default: $shop_demo = true; $woo_xml = get_template_directory() . '/framework/plugins/importer/classic_demo/avada.xml'; $theme_xml_file = get_template_directory() . '/framework/plugins/importer/classic_demo/avada.xml'; $theme_options_file = get_template_directory() . '/framework/plugins/importer/classic_demo/theme_options.txt'; // Register Custom Sidebars $sidebar_exists = true; $sidebars = array('ContactSidebar' => 'Contact Sidebar', 'FAQ' => 'FAQ', 'HomepageSidebar' => 'Home Page Sidebar', 'Portfolio' => 'Portfolio', 'Megamenu1' => 'Megamenu1', 'Megamenu2' => 'Megamenu2'); // Sidebar Widgets File $widgets_file = get_template_directory() . '/framework/plugins/importer/classic_demo/widget_data.json'; $layerslider_exists = true; $layer_directory = get_template_directory() . '/framework/plugins/importer/classic_demo/layersliders/'; $revslider_exists = true; $rev_directory = get_template_directory() . '/framework/plugins/importer/classic_demo/revsliders/'; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/framework/plugins/importer/classic_demo/fusion_slider.zip'; } add_filter('intermediate_image_sizes_advanced', 'avada_filter_image_sizes'); /* Import Woocommerce if WooCommerce Exists */ if (class_exists('WooCommerce') && $shop_demo == true) { $importer = new WP_Import(); $theme_xml = $woo_xml; $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 (isset($woopage) && $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(); } else { $importer = new WP_Import(); /* Import Posts, Pages, Portfolio Content, FAQ, Images, Menus */ $theme_xml = $theme_xml_file; $importer->fetch_attachments = true; ob_start(); $importer->import($theme_xml); ob_end_clean(); 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) { if ($demo_type == 'classic') { $opmenu = get_page_by_title('One Page'); } foreach ($menus as $menu) { // assign menus to theme locations if ($demo_type == 'classic') { 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; } } } // Assign One Page Menu if (isset($opmenu) && $opmenu->ID && $menu->name == 'One Page') { update_post_meta($opmenu->ID, 'pyre_displayed_menu', $menu->term_id); } } elseif ($demo_type == 'agency') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'app') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'travel') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'cafe') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'fashion') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'architecture') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'hosting') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'hotel') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'law') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'lifestyle') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } } } set_theme_mod('nav_menu_locations', $locations); // set menus to locations // Import Theme Options $theme_options_txt = $theme_options_file; // theme options data file $theme_options_txt = file_get_contents($theme_options_txt); $smof_data = unserialize(base64_decode($theme_options_txt)); update_option(OPTIONS, $smof_data); // update theme options // Add sidebar widget areas if ($sidebar_exists == true) { 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"><h4 class="widget-title">', 'after_title' => '</h4></div>')); } } // Add data to widgets if (isset($widgets_file) && $widgets_file) { $widgets_json = $widgets_file; // widgets data file $widgets_json = file_get_contents($widgets_json); $widget_data = $widgets_json; $import_widgets = fusion_import_widget_data($widget_data); } // Import Layerslider if (function_exists('layerslider_import_sample_slider') && $layerslider_exists == true) { // if layerslider is activated // Get importUtil include WP_PLUGIN_DIR . '/LayerSlider/classes/class.ls.importutil.php'; foreach (glob($layer_directory . '*.zip') as $filename) { // get all files from revsliders data dir $filename = basename($filename); $layer_files[] = $layer_directory . $filename; } foreach ($layer_files as $layer_file) { // finally import layer slider $import = new LS_ImportUtil($layer_file); } // 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 if ($demo_type == 'classic') { $lspage = get_page_by_title('Layer Slider'); if (isset($lspage) && $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') && $revslider_exists == true) { // if revslider is activated foreach (glob($rev_directory . '*.zip') as $filename) { // get all files from revsliders data dir $filename = basename($filename); $rev_files[] = $rev_directory . $filename; } foreach ($rev_files as $rev_file) { // finally import rev slider data files $filepath = $rev_file; //check if zip file or fallback to old, if zip, check if all files exist $zip = new ZipArchive(); $importZip = $zip->open($filepath, ZIPARCHIVE::CREATE); if ($importZip === true) { //true or integer. If integer, its not a correct zip file //check if files all exist in zip $slider_export = $zip->getStream('slider_export.txt'); $custom_animations = $zip->getStream('custom_animations.txt'); $dynamic_captions = $zip->getStream('dynamic-captions.css'); $static_captions = $zip->getStream('static-captions.css'); $content = ''; $animations = ''; $dynamic = ''; $static = ''; while (!feof($slider_export)) { $content .= fread($slider_export, 1024); } if ($custom_animations) { while (!feof($custom_animations)) { $animations .= fread($custom_animations, 1024); } } if ($dynamic_captions) { while (!feof($dynamic_captions)) { $dynamic .= fread($dynamic_captions, 1024); } } if ($static_captions) { while (!feof($static_captions)) { $static .= fread($static_captions, 1024); } } fclose($slider_export); if ($custom_animations) { fclose($custom_animations); } if ($dynamic_captions) { fclose($dynamic_captions); } if ($static_captions) { fclose($static_captions); } //check for images! } else { //check if fallback //get content array $content = @file_get_contents($filepath); } if ($importZip === true) { //we have a zip $db = new UniteDBRev(); //update/insert custom animations $animations = @unserialize($animations); if (!empty($animations)) { foreach ($animations as $key => $animation) { //$animation['id'], $animation['handle'], $animation['params'] $exist = $db->fetch(GlobalsRevSlider::$table_layer_anims, "handle = '" . $animation['handle'] . "'"); if (!empty($exist)) { //update the animation, get the ID if ($updateAnim == "true") { //overwrite animation if exists $arrUpdate = array(); $arrUpdate['params'] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $db->update(GlobalsRevSlider::$table_layer_anims, $arrUpdate, array('handle' => $animation['handle'])); $id = $exist['0']['id']; } else { //insert with new handle $arrInsert = array(); $arrInsert["handle"] = 'copy_' . $animation['handle']; $arrInsert["params"] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $id = $db->insert(GlobalsRevSlider::$table_layer_anims, $arrInsert); } } else { //insert the animation, get the ID $arrInsert = array(); $arrInsert["handle"] = $animation['handle']; $arrInsert["params"] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $id = $db->insert(GlobalsRevSlider::$table_layer_anims, $arrInsert); } //and set the current customin-oldID and customout-oldID in slider params to new ID from $id $content = str_replace(array('customin-' . $animation['id'], 'customout-' . $animation['id']), array('customin-' . $id, 'customout-' . $id), $content); } } else { } //overwrite/append static-captions.css if (!empty($static)) { if (isset($updateStatic) && $updateStatic == "true") { //overwrite file RevOperations::updateStaticCss($static); } else { //append $static_cur = RevOperations::getStaticCss(); $static = $static_cur . "\n" . $static; RevOperations::updateStaticCss($static); } } //overwrite/create dynamic-captions.css //parse css to classes $dynamicCss = UniteCssParserRev::parseCssToArray($dynamic); if (is_array($dynamicCss) && $dynamicCss !== false && count($dynamicCss) > 0) { foreach ($dynamicCss as $class => $styles) { //check if static style or dynamic style $class = trim($class); if (strpos($class, ':hover') === false && strpos($class, ':') !== false || strpos($class, " ") !== false || strpos($class, ".tp-caption") === false || (strpos($class, ".") === false || strpos($class, "#") !== false) || strpos($class, ">") !== false) { //.tp-caption>.imageclass or .tp-caption.imageclass>img or .tp-caption.imageclass .img continue; } //is a dynamic style if (strpos($class, ':hover') !== false) { $class = trim(str_replace(':hover', '', $class)); $arrInsert = array(); $arrInsert["hover"] = json_encode($styles); $arrInsert["settings"] = json_encode(array('hover' => 'true')); } else { $arrInsert = array(); $arrInsert["params"] = json_encode($styles); } //check if class exists $result = $db->fetch(GlobalsRevSlider::$table_css, "handle = '" . $class . "'"); if (!empty($result)) { //update $db->update(GlobalsRevSlider::$table_css, $arrInsert, array('handle' => $class)); } else { //insert $arrInsert["handle"] = $class; $db->insert(GlobalsRevSlider::$table_css, $arrInsert); } } } else { } } $content = preg_replace('!s:(\\d+):"(.*?)";!e', "'s:'.strlen('\$2').':\"\$2\";'", $content); //clear errors in string $arrSlider = @unserialize($content); $sliderParams = $arrSlider["params"]; if (isset($sliderParams["background_image"])) { $sliderParams["background_image"] = UniteFunctionsWPRev::getImageUrlFromPath($sliderParams["background_image"]); } $json_params = json_encode($sliderParams); //new slider $arrInsert = array(); $arrInsert["params"] = $json_params; $arrInsert["title"] = UniteFunctionsRev::getVal($sliderParams, "title", "Slider1"); $arrInsert["alias"] = UniteFunctionsRev::getVal($sliderParams, "alias", "slider1"); $sliderID = $wpdb->insert(GlobalsRevSlider::$table_sliders, $arrInsert); $sliderID = $wpdb->insert_id; //-------- Slides Handle ----------- //create all slides $arrSlides = $arrSlider["slides"]; $alreadyImported = array(); foreach ($arrSlides as $slide) { $params = $slide["params"]; $layers = $slide["layers"]; //convert params images: if (isset($params["image"])) { //import if exists in zip folder if (trim($params["image"]) !== '') { if ($importZip === true) { //we have a zip, check if exists $image = $zip->getStream('images/' . $params["image"]); if (!$image) { echo $params["image"] . ' not found!<br>'; } else { if (!isset($alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]])) { $importImage = UniteFunctionsWPRev::import_media('zip://' . $filepath . "#" . 'images/' . $params["image"], $sliderParams["alias"] . '/'); if ($importImage !== false) { $alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]] = $importImage['path']; $params["image"] = $importImage['path']; } } else { $params["image"] = $alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]]; } } } } $params["image"] = UniteFunctionsWPRev::getImageUrlFromPath($params["image"]); } //convert layers images: foreach ($layers as $key => $layer) { if (isset($layer["image_url"])) { //import if exists in zip folder if (trim($layer["image_url"]) !== '') { if ($importZip === true) { //we have a zip, check if exists $image_url = $zip->getStream('images/' . $layer["image_url"]); if (!$image_url) { echo $layer["image_url"] . ' not found!<br>'; } else { if (!isset($alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]])) { $importImage = UniteFunctionsWPRev::import_media('zip://' . $filepath . "#" . 'images/' . $layer["image_url"], $sliderParams["alias"] . '/'); if ($importImage !== false) { $alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]] = $importImage['path']; $layer["image_url"] = $importImage['path']; } } else { $layer["image_url"] = $alreadyImported['zip://' . $filepath . "#" . 'images/' . $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($homepage_title); if (isset($homepage) && $homepage->ID) { update_option('show_on_front', 'page'); update_option('page_on_front', $homepage->ID); // Front Page } // Fusion Sliders Import if ($fs_exists == true) { @avada_import_fsliders($fs_url); } echo 'imported'; exit; } } }
function fusion_importer() { global $wpdb; if (current_user_can('manage_options')) { 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() . '/includes/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 if (!isset($_POST['demo_type']) || trim($_POST['demo_type']) == '') { $demo_type = 'classic'; } else { $demo_type = $_POST['demo_type']; } switch ($demo_type) { case 'agency': $shop_demo = false; $theme_xml_file = get_template_directory() . '/includes/plugins/importer/agency_demo/avada.xml'; $theme_options_file = get_template_directory() . '/includes/plugins/importer/agency_demo/theme_options.json'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/includes/plugins/importer/agency_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/includes/plugins/importer/agency_demo/fusion_slider.zip'; break; case 'app': $shop_demo = false; $theme_xml_file = get_template_directory() . '/includes/plugins/importer/app_demo/avada.xml'; $theme_options_file = get_template_directory() . '/includes/plugins/importer/app_demo/theme_options.json'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/includes/plugins/importer/app_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/includes/plugins/importer/app_demo/fusion_slider.zip'; break; case 'travel': $shop_demo = false; $theme_xml_file = get_template_directory() . '/includes/plugins/importer/travel_demo/avada.xml'; $theme_options_file = get_template_directory() . '/includes/plugins/importer/travel_demo/theme_options.json'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/includes/plugins/importer/travel_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/includes/plugins/importer/travel_demo/fusion_slider.zip'; break; case 'cafe': $shop_demo = false; $theme_xml_file = get_template_directory() . '/includes/plugins/importer/cafe_demo/avada.xml'; $theme_options_file = get_template_directory() . '/includes/plugins/importer/cafe_demo/theme_options.json'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/includes/plugins/importer/cafe_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/includes/plugins/importer/cafe_demo/fusion_slider.zip'; break; case 'fashion': $shop_demo = false; $theme_xml_file = get_template_directory() . '/includes/plugins/importer/fashion_demo/avada.xml'; $theme_options_file = get_template_directory() . '/includes/plugins/importer/fashion_demo/theme_options.json'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/includes/plugins/importer/fashion_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/includes/plugins/importer/fashion_demo/fusion_slider.zip'; break; case 'architecture': $shop_demo = false; $theme_xml_file = get_template_directory() . '/includes/plugins/importer/architecture_demo/avada.xml'; $theme_options_file = get_template_directory() . '/includes/plugins/importer/architecture_demo/theme_options.json'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/includes/plugins/importer/architecture_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/includes/plugins/importer/architecture_demo/fusion_slider.zip'; break; case 'hosting': $shop_demo = false; $theme_xml_file = get_template_directory() . '/includes/plugins/importer/hosting_demo/avada.xml'; $theme_options_file = get_template_directory() . '/includes/plugins/importer/hosting_demo/theme_options.json'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/includes/plugins/importer/hosting_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/includes/plugins/importer/hosting_demo/fusion_slider.zip'; break; case 'hotel': $shop_demo = false; $theme_xml_file = get_template_directory() . '/includes/plugins/importer/hotel_demo/avada.xml'; $theme_options_file = get_template_directory() . '/includes/plugins/importer/hotel_demo/theme_options.json'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/includes/plugins/importer/hotel_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/includes/plugins/importer/hotel_demo/fusion_slider.zip'; break; case 'law': $shop_demo = false; $theme_xml_file = get_template_directory() . '/includes/plugins/importer/law_demo/avada.xml'; $theme_options_file = get_template_directory() . '/includes/plugins/importer/law_demo/theme_options.json'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/includes/plugins/importer/law_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/includes/plugins/importer/law_demo/fusion_slider.zip'; break; case 'lifestyle': $shop_demo = false; $theme_xml_file = get_template_directory() . '/includes/plugins/importer/lifestyle_demo/avada.xml'; $theme_options_file = get_template_directory() . '/includes/plugins/importer/lifestyle_demo/theme_options.json'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/includes/plugins/importer/lifestyle_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/includes/plugins/importer/lifestyle_demo/fusion_slider.zip'; break; case 'church': $shop_demo = false; $theme_xml_file = get_template_directory() . '/includes/plugins/importer/church_demo/avada.xml'; $theme_options_file = get_template_directory() . '/includes/plugins/importer/church_demo/theme_options.json'; // Register Custom Sidebars $sidebar_exists = true; $sidebars = array('PageSidebar' => 'Page Sidebar'); // Sidebar Widgets File $widgets_file = get_template_directory() . '/includes/plugins/importer/church_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/includes/plugins/importer/church_demo/fusion_slider.zip'; break; case 'gym': $shop_demo = false; $theme_xml_file = get_template_directory() . '/includes/plugins/importer/gym_demo/avada.xml'; $theme_options_file = get_template_directory() . '/includes/plugins/importer/gym_demo/theme_options.json'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/includes/plugins/importer/gym_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/includes/plugins/importer/gym_demo/fusion_slider.zip'; break; case 'photography': $shop_demo = false; $theme_xml_file = get_template_directory() . '/includes/plugins/importer/photography_demo/avada.xml'; $theme_options_file = get_template_directory() . '/includes/plugins/importer/photography_demo/theme_options.json'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/includes/plugins/importer/photography_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/includes/plugins/importer/photography_demo/fusion_slider.zip'; break; case 'modern_shop': // is a shop demo? $shop_demo = true; // Set pages $woopages = array('woocommerce_shop_page_id' => 'Full Shop With Sidebar', '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'); $woo_xml = get_template_directory() . '/includes/plugins/importer/modern_shop_demo/avada.xml'; $theme_xml_file = get_template_directory() . '/includes/plugins/importer/modern_shop_demo/avada.xml'; $theme_options_file = get_template_directory() . '/includes/plugins/importer/modern_shop_demo/theme_options.json'; // Register Custom Sidebars $sidebar_exists = true; $sidebars = array('Shop' => 'Shop'); // Sidebar Widgets File $widgets_file = get_template_directory() . '/includes/plugins/importer/modern_shop_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/includes/plugins/importer/modern_shop_demo/fusion_slider.zip'; break; case 'classic_shop': // is a shop demo? $shop_demo = true; // Set pages $woopages = array('woocommerce_shop_page_id' => 'Shop Full Width', 'woocommerce_cart_page_id' => 'Shopping 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'); $woo_xml = get_template_directory() . '/includes/plugins/importer/classic_shop_demo/avada.xml'; $theme_xml_file = get_template_directory() . '/includes/plugins/importer/classic_shop_demo/avada.xml'; $theme_options_file = get_template_directory() . '/includes/plugins/importer/classic_shop_demo/theme_options.json'; // Register Custom Sidebars $sidebar_exists = true; $sidebars = array('Men' => 'Men', 'Women' => 'Women', 'Accessories' => 'Accessories', 'Products Sidebar' => 'ProductsSidebar', 'Content Widget 1' => 'ContentWidget1', 'Content Widget 2' => 'ContentWidget2', 'Content Widget 3' => 'ContentWidget3', 'Content Widget 4' => 'ContentWidget4', 'Promotion' => 'Promotion'); $sidebars = array_flip($sidebars); // lazy code // Sidebar Widgets File $widgets_file = get_template_directory() . '/includes/plugins/importer/classic_shop_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = true; $rev_directory = get_template_directory() . '/includes/plugins/importer/classic_shop_demo/revsliders/'; // reading settings $homepage_title = 'Home 1'; $fs_exists = true; $fs_url = get_template_directory() . '/includes/plugins/importer/classic_shop_demo/fusion_slider.zip'; break; case 'landing_product': // is a shop demo? $shop_demo = true; // 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'); $woo_xml = get_template_directory() . '/includes/plugins/importer/landing_product_demo/avada.xml'; $theme_xml_file = get_template_directory() . '/includes/plugins/importer/landing_product_demo/avada.xml'; $theme_options_file = get_template_directory() . '/includes/plugins/importer/landing_product_demo/theme_options.json'; // Register Custom Sidebars $sidebar_exists = false; // Sidebar Widgets File $widgets_file = get_template_directory() . '/includes/plugins/importer/landing_product_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = true; $rev_directory = get_template_directory() . '/includes/plugins/importer/landing_product_demo/revsliders/'; // reading settings $homepage_title = 'Homepage'; $fs_exists = false; break; case 'forum': $shop_demo = false; $theme_xml_file = get_template_directory() . '/includes/plugins/importer/forum_demo/avada.xml'; $theme_options_file = get_template_directory() . '/includes/plugins/importer/forum_demo/theme_options.json'; // Register Custom Sidebars $sidebar_exists = true; $sidebars = array('News Sidebar' => 'NewsSidebar', 'Forum Sidebar' => 'ForumSidebar', 'Apple Sidebar' => 'AppleSidebar', 'Android Sidebar' => 'AndroidSidebar', 'Microsoft Sidebar' => 'MicrosoftSidebar'); $sidebars = array_flip($sidebars); // lazy code // Sidebar Widgets File $widgets_file = get_template_directory() . '/includes/plugins/importer/forum_demo/widget_data.json'; $layerslider_exists = false; $revslider_exists = false; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/includes/plugins/importer/forum_demo/fusion_slider.zip'; break; default: // is a shop demo? $shop_demo = true; // 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'); $woo_xml = get_template_directory() . '/includes/plugins/importer/classic_demo/avada.xml'; $theme_xml_file = get_template_directory() . '/includes/plugins/importer/classic_demo/avada.xml'; $theme_options_file = get_template_directory() . '/includes/plugins/importer/classic_demo/theme_options.json'; // Register Custom Sidebars $sidebar_exists = true; $sidebars = array('ContactSidebar' => 'Contact Sidebar', 'FAQ' => 'FAQ', 'HomepageSidebar' => 'Home Page Sidebar', 'Portfolio' => 'Portfolio', 'Megamenu1' => 'Megamenu1', 'Megamenu2' => 'Megamenu2', 'Twitter' => 'Twitter', 'PageWidget1' => 'Page Widget 1', 'PageWidget2' => 'Page Widget 2'); // Sidebar Widgets File $widgets_file = get_template_directory() . '/includes/plugins/importer/classic_demo/widget_data.json'; $layerslider_exists = true; $layer_directory = get_template_directory() . '/includes/plugins/importer/classic_demo/layersliders/'; $revslider_exists = true; $rev_directory = get_template_directory() . '/includes/plugins/importer/classic_demo/revsliders/'; // reading settings $homepage_title = 'Home'; $fs_exists = true; $fs_url = get_template_directory() . '/includes/plugins/importer/classic_demo/fusion_slider.zip'; } add_filter('intermediate_image_sizes_advanced', 'avada_filter_image_sizes'); /* Import Woocommerce if WooCommerce Exists */ if (class_exists('WooCommerce') && $shop_demo == true) { $importer = new WP_Import(); $theme_xml = $woo_xml; $importer->fetch_attachments = true; ob_start(); $importer->import($theme_xml); ob_end_clean(); foreach ($woopages as $woo_page_name => $woo_page_title) { $woopage = get_page_by_title($woo_page_title); if (isset($woopage) && $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(); } else { $importer = new WP_Import(); /* Import Posts, Pages, Portfolio Content, FAQ, Images, Menus */ $theme_xml = $theme_xml_file; $importer->fetch_attachments = true; //ob_start(); $importer->import($theme_xml); //ob_end_clean(); 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) { if ($demo_type == 'classic') { $opmenu = get_page_by_title('One Page'); } else { if ($demo_type == 'landing_product') { $opmenu = get_page_by_title('Homepage'); } } foreach ($menus as $menu) { // assign menus to theme locations if ($demo_type == 'classic') { 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; } } } // Assign One Page Menu if (isset($opmenu) && $opmenu->ID && $menu->name == 'One Page') { update_post_meta($opmenu->ID, 'pyre_displayed_menu', $menu->term_id); } } elseif ($demo_type == 'agency') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'app') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'travel') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'cafe') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'fashion') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'architecture') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'hosting') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'hotel') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'law') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'lifestyle') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'church') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'gym') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'photography') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'modern_shop') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'classic_shop') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } else { if ($menu->name == 'Top Secondary Menu') { $locations['top_navigation'] = $menu->term_id; } } } elseif ($demo_type == 'landing_product') { // Assign One Page Menu if (isset($opmenu) && $opmenu->ID && $menu->name == 'Landing Page Menu') { update_post_meta($opmenu->ID, 'pyre_displayed_menu', $menu->term_id); } if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } elseif ($demo_type == 'forum') { if ($menu->name == 'Main Menu') { $locations['main_navigation'] = $menu->term_id; } } } } set_theme_mod('nav_menu_locations', $locations); // set menus to locations // Import Theme Options $theme_options_json = file_get_contents($theme_options_file); $theme_options = json_decode($theme_options_json, true); $theme_options['logo_retina'] = ''; $theme_options_db_name = Avada::get_original_option_name(); update_option($theme_options_db_name, $theme_options); // Add sidebar widget areas if ($sidebar_exists == true) { 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"><h4 class="widget-title">', 'after_title' => '</h4></div>')); } } // Add data to widgets if (isset($widgets_file) && $widgets_file) { $widgets_json = $widgets_file; // widgets data file $widgets_json = file_get_contents($widgets_json); $widget_data = $widgets_json; $import_widgets = fusion_import_widget_data($widget_data); } // Import Layerslider if (function_exists('layerslider_import_sample_slider') && $layerslider_exists == true) { // if layerslider is activated // Get importUtil include WP_PLUGIN_DIR . '/LayerSlider/classes/class.ls.importutil.php'; $layer_files = fusion_get_import_files($layer_directory, 'zip'); foreach ($layer_files as $layer_file) { // finally import layer slider $import = new LS_ImportUtil($layer_file); } // 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 if ($demo_type == 'classic') { $lspage = get_page_by_title('Layer Slider'); if (isset($lspage) && $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') && $revslider_exists == true) { // if revslider is activated $rev_files = fusion_get_import_files($rev_directory, 'zip'); $slider = new RevSlider(); foreach ($rev_files as $rev_file) { // finally import rev slider data files $filepath = $rev_file; ob_start(); $slider->importSliderFromPost(true, false, $filepath); ob_clean(); ob_end_clean(); } } // Set reading options $homepage = get_page_by_title($homepage_title); if (isset($homepage) && $homepage->ID) { update_option('show_on_front', 'page'); update_option('page_on_front', $homepage->ID); // Front Page } // Fusion Sliders Import if ($fs_exists == true) { @avada_import_fsliders($fs_url); } update_option('avada_imported_demo', 'true'); echo 'imported'; exit; } } }
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 WHERE flag_hidden = '0' AND flag_deleted = '0' ORDER BY date_c ASC" ); if(!empty($sliders)): foreach($sliders as $key => $item): $slides[$item->id] = $item->name; endforeach; endif; 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 . '*.zip' ) as $filename ) { // get all files from revsliders data dir $filename = basename($filename); $rev_files[] = get_template_directory() . '/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);*/ $filepath = $rev_file; //if(file_exists($filepath) == false) //UniteFunctionsRev::throwError("Import file not found!!!"); //check if zip file or fallback to old, if zip, check if all files exist $zip = new ZipArchive; $importZip = $zip->open($filepath, ZIPARCHIVE::CREATE); if($importZip === true){ //true or integer. If integer, its not a correct zip file //check if files all exist in zip $slider_export = $zip->getStream('slider_export.txt'); $custom_animations = $zip->getStream('custom_animations.txt'); $dynamic_captions = $zip->getStream('dynamic-captions.css'); $static_captions = $zip->getStream('static-captions.css'); //if(!$slider_export) UniteFunctionsRev::throwError("slider_export.txt does not exist!"); //if(!$custom_animations) UniteFunctionsRev::throwError("custom_animations.txt does not exist!"); //if(!$dynamic_captions) UniteFunctionsRev::throwError("dynamic-captions.css does not exist!"); //if(!$static_captions) UniteFunctionsRev::throwError("static-captions.css does not exist!"); $content = ''; $animations = ''; $dynamic = ''; $static = ''; while (!feof($slider_export)) $content .= fread($slider_export, 1024); if($custom_animations){ while (!feof($custom_animations)) $animations .= fread($custom_animations, 1024); } if($dynamic_captions){ while (!feof($dynamic_captions)) $dynamic .= fread($dynamic_captions, 1024); } if($static_captions){ while (!feof($static_captions)) $static .= fread($static_captions, 1024); } fclose($slider_export); if($custom_animations){ fclose($custom_animations); } if($dynamic_captions){ fclose($dynamic_captions); } if($static_captions){ fclose($static_captions); } //check for images! }else{ //check if fallback //get content array $content = @file_get_contents($filepath); } if($importZip === true){ //we have a zip $db = new UniteDBRev(); //update/insert custom animations $animations = @unserialize($animations); if(!empty($animations)){ foreach($animations as $key => $animation){ //$animation['id'], $animation['handle'], $animation['params'] $exist = $db->fetch(GlobalsRevSlider::$table_layer_anims, "handle = '".$animation['handle']."'"); if(!empty($exist)){ //update the animation, get the ID if($updateAnim == "true"){ //overwrite animation if exists $arrUpdate = array(); $arrUpdate['params'] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $db->update(GlobalsRevSlider::$table_layer_anims, $arrUpdate, array('handle' => $animation['handle'])); $id = $exist['0']['id']; }else{ //insert with new handle $arrInsert = array(); $arrInsert["handle"] = 'copy_'.$animation['handle']; $arrInsert["params"] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $id = $db->insert(GlobalsRevSlider::$table_layer_anims, $arrInsert); } }else{ //insert the animation, get the ID $arrInsert = array(); $arrInsert["handle"] = $animation['handle']; $arrInsert["params"] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $id = $db->insert(GlobalsRevSlider::$table_layer_anims, $arrInsert); } //and set the current customin-oldID and customout-oldID in slider params to new ID from $id $content = str_replace(array('customin-'.$animation['id'], 'customout-'.$animation['id']), array('customin-'.$id, 'customout-'.$id), $content); } //dmp(__("animations imported!",REVSLIDER_TEXTDOMAIN)); }else{ //dmp(__("no custom animations found, if slider uses custom animations, the provided export may be broken...",REVSLIDER_TEXTDOMAIN)); } //overwrite/append static-captions.css if(!empty($static)){ if($updateStatic == "true"){ //overwrite file RevOperations::updateStaticCss($static); }else{ //append $static_cur = RevOperations::getStaticCss(); $static = $static_cur."\n".$static; RevOperations::updateStaticCss($static); } } //overwrite/create dynamic-captions.css //parse css to classes $dynamicCss = UniteCssParserRev::parseCssToArray($dynamic); if(is_array($dynamicCss) && $dynamicCss !== false && count($dynamicCss) > 0){ foreach($dynamicCss as $class => $styles){ //check if static style or dynamic style $class = trim($class); if((strpos($class, ':hover') === false && strpos($class, ':') !== false) || //before, after strpos($class," ") !== false || // .tp-caption.imageclass img or .tp-caption .imageclass or .tp-caption.imageclass .img strpos($class,".tp-caption") === false || // everything that is not tp-caption (strpos($class,".") === false || strpos($class,"#") !== false) || // no class -> #ID or img strpos($class,">") !== false){ //.tp-caption>.imageclass or .tp-caption.imageclass>img or .tp-caption.imageclass .img continue; } //is a dynamic style if(strpos($class, ':hover') !== false){ $class = trim(str_replace(':hover', '', $class)); $arrInsert = array(); $arrInsert["hover"] = json_encode($styles); $arrInsert["settings"] = json_encode(array('hover' => 'true')); }else{ $arrInsert = array(); $arrInsert["params"] = json_encode($styles); } //check if class exists $result = $db->fetch(GlobalsRevSlider::$table_css, "handle = '".$class."'"); if(!empty($result)){ //update $db->update(GlobalsRevSlider::$table_css, $arrInsert, array('handle' => $class)); }else{ //insert $arrInsert["handle"] = $class; $db->insert(GlobalsRevSlider::$table_css, $arrInsert); } } //dmp(__("dynamic styles imported!",REVSLIDER_TEXTDOMAIN)); }else{ //dmp(__("no dynamic styles found, if slider uses dynamic styles, the provided export may be broken...",REVSLIDER_TEXTDOMAIN)); } } $content = preg_replace('!s:(\d+):"(.*?)";!e', "'s:'.strlen('$2').':\"$2\";'", $content); //clear errors in string $arrSlider = @unserialize($content); $sliderParams = $arrSlider["params"]; if(isset($sliderParams["background_image"])) $sliderParams["background_image"] = UniteFunctionsWPRev::getImageUrlFromPath($sliderParams["background_image"]); $json_params = json_encode($sliderParams); //new slider $arrInsert = array(); $arrInsert["params"] = $json_params; $arrInsert["title"] = UniteFunctionsRev::getVal($sliderParams, "title","Slider1"); $arrInsert["alias"] = UniteFunctionsRev::getVal($sliderParams, "alias","slider1"); $sliderID = $wpdb->insert(GlobalsRevSlider::$table_sliders,$arrInsert); $sliderID = $wpdb->insert_id; //-------- Slides Handle ----------- //create all slides $arrSlides = $arrSlider["slides"]; $alreadyImported = array(); foreach($arrSlides as $slide){ $params = $slide["params"]; $layers = $slide["layers"]; //convert params images: if(isset($params["image"])){ //import if exists in zip folder if(trim($params["image"]) !== ''){ if($importZip === true){ //we have a zip, check if exists $image = $zip->getStream('images/'.$params["image"]); if(!$image){ echo $params["image"].' not found!<br>'; }else{ if(!isset($alreadyImported['zip://'.$filepath."#".'images/'.$params["image"]])){ $importImage = UniteFunctionsWPRev::import_media('zip://'.$filepath."#".'images/'.$params["image"], $sliderParams["alias"].'/'); if($importImage !== false){ $alreadyImported['zip://'.$filepath."#".'images/'.$params["image"]] = $importImage['path']; $params["image"] = $importImage['path']; } }else{ $params["image"] = $alreadyImported['zip://'.$filepath."#".'images/'.$params["image"]]; } } } } $params["image"] = UniteFunctionsWPRev::getImageUrlFromPath($params["image"]); } //convert layers images: foreach($layers as $key=>$layer){ if(isset($layer["image_url"])){ //import if exists in zip folder if(trim($layer["image_url"]) !== ''){ if($importZip === true){ //we have a zip, check if exists $image_url = $zip->getStream('images/'.$layer["image_url"]); if(!$image_url){ echo $layer["image_url"].' not found!<br>'; }else{ if(!isset($alreadyImported['zip://'.$filepath."#".'images/'.$layer["image_url"]])){ $importImage = UniteFunctionsWPRev::import_media('zip://'.$filepath."#".'images/'.$layer["image_url"], $sliderParams["alias"].'/'); if($importImage !== false){ $alreadyImported['zip://'.$filepath."#".'images/'.$layer["image_url"]] = $importImage['path']; $layer["image_url"] = $importImage['path']; } }else{ $layer["image_url"] = $alreadyImported['zip://'.$filepath."#".'images/'.$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' ) ); } } }