check_is_import_allowed() ){ $msg = esc_html__( 'The import has been stopped - there is no valid purchase/license Code', 'apollo13-framework-extensions' ); $result = array( 'log' => $msg, 'sublevel_name' => '', 'level_name' => $msg, 'is_it_end' => true ); //send AJAX response echo json_encode( sizeof( $result ) ? $result : false ); die(); //this is required to return a proper result } /** @noinspection PhpIncludeInspection */ $file_system_check = require_once A13FE_BASE_DIR . 'design_importer/actions.php'; //error on file system access if( ! $file_system_check ){ $result = array( 'level' => '', 'level_name' => esc_html__( 'Import failed', 'apollo13-framework-extensions' ), 'sublevel' => '', 'sublevel_name' => '', 'log' => esc_html__( 'Can not access the file system.', 'apollo13-framework-extensions' ), 'is_it_end' => true, 'alert' => true ); } else{ $level = isset( $_POST['level'] ) ? sanitize_text_field( wp_unslash( $_POST['level'] ) ) : ''; $sublevel = isset( $_POST['sublevel'] ) ? sanitize_text_field( wp_unslash( $_POST['sublevel'] ) ) : ''; $sublevel_name = ''; $log = ''; $array_index = 0; $alert = false; $chosen_options = isset( $_POST['import_options'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['import_options'] ) ) : array(); $levels = array( '_' => '', //empty to avoid bonus logic 'start' => esc_html__( 'Starting the import', 'apollo13-framework-extensions' ), 'download_files' => esc_html__( 'Downloading files', 'apollo13-framework-extensions' ), 'clear_content' => esc_html__( 'Deleting the current content', 'apollo13-framework-extensions' ), 'install_plugins' => esc_html__( 'Installing plugins', 'apollo13-framework-extensions' ), 'install_content' => esc_html__( 'Importing the content', 'apollo13-framework-extensions' ), 'install_revo_sliders' => esc_html__( 'Importing the sliders', 'apollo13-framework-extensions' ), 'setup_plugins_configs' => esc_html__( 'Setting up plugins settings', 'apollo13-framework-extensions' ), 'setup_wc' => esc_html__( 'Setting up WooCommerce settings', 'apollo13-framework-extensions' ), 'setup_fp' => esc_html__( 'Setting up the front page', 'apollo13-framework-extensions' ), 'setup_menus' => esc_html__( 'Setting up the menus', 'apollo13-framework-extensions' ), 'setup_widgets' => esc_html__( 'Setting up the widgets', 'apollo13-framework-extensions' ), 'setup_permalinks' => esc_html__( 'Setting up the permalinks', 'apollo13-framework-extensions' ), 'import_predefined_set' => esc_html__( 'Importing the theme settings', 'apollo13-framework-extensions' ), 'generate_custom_style' => esc_html__( 'Importing the theme settings', 'apollo13-framework-extensions' ), 'install_plugins_2' => esc_html__( 'Installing plugins', 'apollo13-framework-extensions' ), 'clean' => esc_html__( 'Cleaning', 'apollo13-framework-extensions' ), 'end' => esc_html__( 'Everything done.', 'apollo13-framework-extensions' ) . ' ' . '' . esc_html__( 'View your website!', 'apollo13-framework-extensions' ) .'', ); //check what options are selected if( ! isset( $chosen_options['download_files'] ) ){ unset( $levels['download_files'] ); } if( ! isset( $chosen_options['clear_content'] ) ){ unset( $levels['clear_content'] ); } if( ! isset( $chosen_options['install_plugins'] ) ){ unset( $levels['install_plugins'] ); unset( $levels['setup_plugins_configs'] ); unset( $levels['setup_wc'] ); unset( $levels['install_plugins_2'] ); } if( ! isset( $chosen_options['import_shop'] ) ){ unset( $levels['setup_wc'] ); unset( $levels['install_plugins_2'] ); } if( ! isset( $chosen_options['install_content'] ) ){ unset( $levels['install_content'] ); } if( ! isset( $chosen_options['install_revo_sliders'] ) ){ unset( $levels['install_revo_sliders'] ); } if( ! isset( $chosen_options['install_site_settings'] ) ){ unset( $levels['setup_fp'] ); unset( $levels['setup_menus'] ); unset( $levels['setup_widgets'] ); unset( $levels['setup_permalinks'] ); } if( ! isset( $chosen_options['install_theme_settings'] ) ){ unset( $levels['import_predefined_set'] ); unset( $levels['generate_custom_style'] ); } if( ! isset( $chosen_options['clean'] ) ){ unset( $levels['clean'] ); } //get current level key if( strlen( $level ) === 0 ){ //get first level to process $level = key( $levels ); } else{ //move array pointer to current importing level while( key( $levels ) !== $level ) { //and ask for next one next( $levels ); $array_index ++; } //save new current level $level = key( $levels ); } //Execute current level function $function = 'a13fe_demo_data_' . $level; if( function_exists( $function ) ){ //no notices or other "echos", we put it in $log ob_start(); $functions_with_1_param = array( 'a13fe_demo_data_import_predefined_set', 'a13fe_demo_data_start', 'a13fe_demo_data_clean', 'a13fe_demo_data_install_revo_sliders' ); $demo_id = isset( $_POST['demo_id'] ) ? sanitize_text_field( wp_unslash( $_POST['demo_id'] ) ) : ''; //how many params should function receive if( in_array( $function, $functions_with_1_param ) ){ $sublevel = $function( $demo_id ); } else{ $sublevel = $function( $sublevel, $sublevel_name, $demo_id, $chosen_options ); } //collect all produced output to log $log = ob_get_contents(); ob_end_clean(); //should we move to next level if( $sublevel === true ){ $sublevel = ''; //reset next( $levels ); $level = key( $levels ); } } //no function - move to next level. Some steps are just information without action else{ next( $levels ); $array_index ++; $level = key( $levels ); } //check if this is last element $is_it_end = false; end( $levels ); if( key( $levels ) === $level ){ $is_it_end = true; } //prepare progress info $progress = round( 100 * ( 1 + $array_index ) / count( $levels ) ); //special case - demo import files download failure $failure_codes = array( 620, // invalid purchase code 621, // trying to get paid demo // 1012, // no available servers 1013 // server directory no writable ); if( is_array( $sublevel ) && $sublevel['sublevel'] === false && in_array( $sublevel['response']['code'], $failure_codes ) ){ $log = $sublevel['response']['message']; $sublevel = false; $is_it_end = true; $alert = true; } $result = array( 'level' => $level, 'level_name' => $levels[ $level ], 'sublevel' => $sublevel, 'sublevel_name' => $sublevel_name, 'log' => $log, 'progress' => $progress, 'is_it_end' => $is_it_end, 'alert' => $alert ); } //send AJAX response echo json_encode( sizeof( $result ) ? $result : false ); die(); //this is required to return a proper result } /** * Retrieves list of Designs to import * * @since 1.4.0 * @return bool|array list of designs or false on error */ function a13fe_get_demo_list() { $demos_definition = array(); //try import by https $response = wp_remote_get( A13FRAMEWORK_IMPORT_SERVER . '/definitions/' . A13FRAMEWORK_TPL_SLUG . '_demos_definition.php', array('timeout' => 20) ); if( !is_wp_error( $response ) && wp_remote_retrieve_response_code( $response ) == 200 ){ $demos_definition = json_decode( wp_remote_retrieve_body( $response ), true ); } else{ // try http import $response = wp_remote_get( str_replace( 'https:', 'http:', A13FRAMEWORK_IMPORT_SERVER ) . '/definitions/' . A13FRAMEWORK_TPL_SLUG . '_demos_definition.php', array('timeout' => 20) ); if( !is_wp_error( $response ) && wp_remote_retrieve_response_code( $response ) == 200 ){ $demos_definition = json_decode( wp_remote_retrieve_body( $response ), true ); //inform the whole import process that this server has issues with SSL update_option( 'a13fe_import_by_http', 'on' ); } } if(!isset($demos_definition['demos'])){ return false; } return $demos_definition; } /** * Displays whole Designs import interface * * @since 1.4.0 */ function a13fe_get_demo_importer_content() { global $apollo13framework_a13; $demos_definition = a13fe_get_demo_list(); $demos = $demos_definition === false ? array() : $demos_definition['demos']; $demo_count = $demos_definition === false ? 0 : count( $demos ); $all_categories = array(); $available_demos = array(); $available_demos_number = 0; if($demos_definition !== false){ include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); foreach ( $demos as $demo ) { //check if demo is available for this configuration if( isset( $demo['must_have_plugins'] ) && is_array( $demo['must_have_plugins'] ) ){ $not_available = false; foreach( $demo['must_have_plugins'] as $plugin ) { if( ! is_plugin_active( $plugin ) ){ $not_available = true; } } if( $not_available ){ //skip this demo continue; } } //count this demo $available_demos_number++; $available_demos[] = $demo; //collect categories $all_categories = array_merge( $all_categories, $demo['categories'] ); } } ?>
'.esc_html__( 'There was a problem with getting a list of available Designs for import. This can happen for several reasons:', 'apollo13-framework-extensions' ).'
'. ''.A13FRAMEWORK_IMPORT_SERVER.''
).
'| In order to achieve the import results as close as possible to the original demo version, the importer will have to remove all current content. If you are using a fresh WordPress installation and want to get the best import results you should check this option. However, if you are just updating your existing website, stay away from this option. ', 'apollo13-framework-extensions' ) ); ?> |
||
| The theme settings are all the settings that you can later change on in the Customizer. If you wish to change only the look of your existing site to one from our demos, then mark only this option. ', 'apollo13-framework-extensions' ) ); ?> |
||