0,'message'=>esc_html__('You do not have permission to do this','bigc')));die; } self::load_lib(); //Check Importer Plugins was installed if ( !class_exists( 'WP_Importer' ) or ! class_exists( 'WP_Import' ) ){ echo json_encode(array('status'=>0,'message'=>esc_html__('Importer Class Was Not Installed','bigc')));die; } global $config; $st_import_config = $config['import_config']; // $import_option = $config['import_option']; extract($st_import_config); $step =isset($_REQUEST['step'])? $_REQUEST['step']:1; $data_dir=self::$_import_path; $data_url=self::$_import_url; // var_dump($data_dir); // var_dump($data_url); $package=self::$_package; if($step==1) { //Update theme_options $data_json = $data_url . '/theme-options.json'; $data_res = wp_remote_get($data_json); if(!is_wp_error($data_res)) { $data_body = $data_res['body']; $options=unserialize(ot_decode($data_body)); // unserialize // var_dump(ot_options_id()); if(!empty($options)){ if(!function_exists('ot_options_id')) { echo json_encode( array( 'status' =>0, 'messenger'=>"Plugin: Option Tree must be installed first. Stop working!", 'next_url' => '' ) ); die; } // var_dump($options); update_option( ot_options_id(), $options ); // and overwrite the current theme-options echo json_encode( array( 'status' =>"ok", 'messenger'=>"Importing the demo theme options... DONE!
", 'next_url' => admin_url(self::$_import_page."&7up_do_import=1&package={$package}&step=" . ($step + 1)) // 'next_url' => '' ) ); }else{ echo json_encode( array( 'status' =>0, 'messenger'=>"File: theme-options.json contain NULL content. Stop working!", 'next_url' => '' ) ); } }else{ echo json_encode( array( 'status' =>0, 'messenger'=>sprintf("Can not read theme-options.json
File:%s
. Stop working!
",$data_json), 'next_url' => '' ) ); die; } } //Update Widgets if($step==2){ // Add data to widgets $json_file = $data_url .'/widget.json'; // widgets data file $widgets_json = wp_remote_get( $json_file ); $widget_data = $widgets_json['body']; $data_object=json_decode($widget_data); $import_widgets =self::wie_import_data( $data_object ); echo json_encode( array( 'status' =>1, 'messenger'=>"Importing the demo widgets... DONE!.
", 'next_url' => admin_url(self::$_import_page."&7up_do_import=1&package={$package}&step=" . ($step + 1)), ) ); } //Import XML if($step==3){ $stt_file=isset($_REQUEST['file_number'])?$_REQUEST['file_number']:0; $ds_file=array_filter(glob($data_dir.'/data/*'),'is_file'); $file_name=isset($ds_file[$stt_file])?$ds_file[$stt_file]:false; if(!$file_name){ echo json_encode( array( 'status' =>0, 'messenger'=>"File Not Found. Stop working!", 'next_url' => '' ) ); die; } $nexturl=admin_url(self::$_import_page."&7up_do_import=1&package={$package}&step=" . ($step).'&file_number='.($stt_file+1)); if($stt_file>=count($ds_file)-1){ $nexturl=admin_url(self::$_import_page."&7up_do_import=1&package={$package}&step=" . ($step+1)); } ob_start(); $importer = new WP_Import(); $theme_xml = $file_name; $importer->fetch_attachments = true; $importer->import($theme_xml); @ob_clean(); echo json_encode( array( 'status' =>1, 'messenger'=>sprintf("Importing data: %s %d of %d ... DONE!
",basename($file_name),$stt_file+1, count($ds_file)-0), 'next_url' => $nexturl, 'file' => $ds_file, ) ); } // Set Up Menu Theme Location if($step==4) { // 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 (!empty($menu_locations)) foreach ($menu_locations as $key => $st_over_menu) { if ($menu->name == $key) { $locations[$st_over_menu] = $menu->term_id; } } } } set_theme_mod('nav_menu_locations', $locations); // set menus to locations $nexturl = admin_url(self::$_import_page . "&7up_do_import=1&package={$package}&step=" . ($step+1) ); echo json_encode(array( 'status' => 1, 'messenger' => "Importing menu settings ... DONE!
", 'next_url' => $nexturl, ) ); } // Set reading options if($step == '5'){ // Set reading options if(!$set_woocommerce_page) { $next_url = ''; $messenger = 'All Done! Have Fun'; } else { $next_url = admin_url(self::$_import_page . "&7up_do_import=1&package={$package}&step=" . ($step+1) ); $messenger = ''; } if($homepage_default != ""){ $homepage = get_page_by_title( $homepage_default ); if(is_object($homepage)) { update_option('show_on_front', 'page'); update_option('page_on_front', $homepage->ID); // Front Page } } if($blogpage_default != ""){ $homepage = get_page_by_title( $blogpage_default ); if(is_object($homepage)) { update_option('show_on_front', 'page'); update_option('page_for_posts', $homepage->ID); // Blog Page } } echo json_encode( array( 'status' =>"ok", 'messenger'=>"Setting reading options... DONE!
".$messenger, 'next_url' => $next_url, ) ); } if($step=='6') { //Setup Woocommerce page if(class_exists('Woocommerce') and class_exists('WC_Install')) { WC_Install::create_pages(); WC_Admin_Notices::remove_notice( 'install' ); } add_action('init', 'sv_set_catthumb_import'); if(!function_exists('sv_set_catthumb_import')){ function sv_set_catthumb_import(){ if(!get_option('term_cat_meta')){ global $config; $import_option = $config['import_option']; foreach ($import_option as $key => $value) { $term_slug = str_replace('taxonomy_', '', $key); $term = get_term_by('slug', $term_slug, 'product_cat'); if(!empty($value['thumb_cat'])) update_woocommerce_term_meta( $term->term_id, 'thumbnail_id', $value['thumb_cat'] ); } update_option( "term_cat_meta", $import_option ); } } } echo json_encode( array( 'status' =>"ok", 'messenger'=>"Setting Woocommerce options... DONE!
All Done! Have Fun", 'next_url' => '', ) ); } die; } } } SV_Importer::init(); }