PATH:
home
/
letacommog
/
pymreception1
/
wp-content
/
themes
/
legenda
/
framework
<?php // **********************************************************************// // ! Etheme Import Class // **********************************************************************// class Etheme_Import{ var $args = array(); var $response = ''; function __construct(){ add_action( 'wp_ajax_etheme_import_ajax', array( $this, 'etheme_import_data' ) ); } public function etheme_import_data(){ $this->check(); $this->args = $_POST; if ( ! defined( 'WP_LOAD_IMPORTERS' ) ) { define( 'WP_LOAD_IMPORTERS', true ); } if ( ! class_exists( 'WP_Import' ) ){ require_once( trailingslashit(ETHEME_CODE_DIR) . 'wordpress-importer/wordpress-importer.php' ); } // Load Importer API require_once ABSPATH . 'wp-admin/includes/import.php'; $demo_data_installed = get_option( 'demo_data_installed' ); // 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 { $this->error( esc_html__( '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.', 'legenda' ) ); } } if( class_exists( 'WP_Importer' ) ){ try{ if ( $this->args['version'] != 'ecommerce' ) { $this->args['folder'] = 'http://8theme.com/import/' . ETHEME_DOMAIN . '_versions/' . $this->args['version']; $this->create_dir(); $this->create_file(); $this->import_slider(); $this->import_options(); $file = PARENT_DIR . '/framework/tmp/version_data.xml'; } elseif ( $demo_data_installed != 'yes' && $this->args['version'] == 'ecommerce' ) { $this->import_slider(); $this->import_widgets(); $file = get_template_directory() . '/framework/dummy/Dummy.xml'; } // ! Show the response of import_slider, import_options functions echo $this->response; if ( isset( $file ) && ! empty( $file ) ) { $importer = new WP_Import(); $importer->fetch_attachments = true; $importer->import( $file ); } $this->update_pages(); $this->update_menus(); } catch ( Exception $e ) { $this->error( esc_html__( "Error while importing", 'legenda' ) ); } die(); } } public function check(){ if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'et_nonce' ) ) { $this->error( esc_html__( '"nonce" check was failed', 'legenda' ) ); } foreach ( $_POST as $key => $value ) { if ( ! in_array( $key, array( 'action', 'version', 'id', 'nonce' ) ) ) { $this->error( 'wrong actions' ); } elseif( ! $value || $value == 'false' ){ $this->error( $key . esc_html__( ' was not set!', 'legenda' ) ); } } if ( ! function_exists( 'file_put_contents' ) && function_exists( 'wp_remote_get' ) ) { $this->error( 'file_put_contents and wp_remote_get' . esc_html__( ' functions must be activated', 'legenda' ) ); } elseif ( ! function_exists( 'file_put_contents' ) ) { $this->error( 'file_put_contents' . esc_html__( ' function must be activated', 'legenda' ) ); } elseif ( ! function_exists( 'wp_remote_get' ) ) { $this->error( 'wp_remote_get' . esc_html__( ' function must be activated', 'legenda' ) ); } } public function create_dir(){ $folder = PARENT_DIR . '/framework/tmp'; if ( ! file_exists( $folder ) ) { if ( ! wp_mkdir_p( $folder ) ) $this->error( 'can not craete ' . '"' . $folder . '" - folder' ); if ( ! is_writable( PARENT_DIR . '/framework/tmp' ) ) $this->error( '"' . $folder . '" - folder must be writable"' ); } } public function create_file(){ $xml = $this->args['folder'] .'/version_data.xml'; $content = $this->et_get_remote_content( $xml ); if( $content ) { $tmpxml = PARENT_DIR . '/framework/tmp/version_data.xml'; file_put_contents( $tmpxml, $content ); if ( false === file_put_contents( $tmpxml, $content ) ) { $this->error( $tmpxml . esc_html__( 'file is not writable', 'legenda' ) ); } } } public function et_get_remote_content($url){ $response = wp_remote_get( $url ); if( is_array( $response ) && isset( $response['headers'] ) && isset( $response['headers']['content-length'] ) && $response['headers']['content-length'] > 1000 ){ return $response['body']; } return false; } public function import_slider(){ if ( ! class_exists( 'RevSlider' ) ) { $this->response .= esc_html__( 'Please install or activate Revolution slider plugin', 'legenda' ) . '<br>'; return; } $sliders = array(); if ( $this->args['version'] == 'ecommerce' ) { $sliders['ecommerce'] = true; } else { $sliders[] = $this->et_get_remote_content( $this->args['folder'] . '/slider.zip' ); $sliders[] = $this->et_get_remote_content( $this->args['folder'] . '/slider2.zip' ); } foreach ( $sliders as $key => $value ) { if ( $value ) { if ( $this->args['version'] == 'ecommerce' ) { $tmpZip = PARENT_DIR . '/framework/dummy/tempSliderZip.zip'; } else { $tmpZip = PARENT_DIR . '/framework/tmp/tempSliderZip.zip'; file_put_contents( $tmpZip, $value ); } $revapi = new RevSlider(); ob_start(); $slider_result = $revapi->importSliderFromPost( true, true, $tmpZip ); ob_end_clean(); if ( $slider_result['success'] ) { $this->response .= esc_html__( 'Revolution slider installed successfully!', 'legenda' ) . '<br>'; } else { $this->response .= esc_html__( 'Revolution slider was not installed!', 'legenda' ) . '<br>'; } } } } public function import_options() { $options = $this->args['folder'] . '/options.txt'; $new_options = $this->et_get_remote_content( $options ); if( $new_options ) { $new_options = json_decode( base64_decode( $new_options ), true ); update_option( 'option_tree', $new_options ); $this->response .= esc_html__( 'Theme Options updated!', 'legenda' ) . '<br>'; } } public function import_widgets(){ $widgets = require apply_filters('et_file_url', PARENT_DIR . '/framework/widgets-import.php'); $active_widgets = get_option( 'sidebars_widgets' ); $widgets_counter = 1; $version = $this->args['version']; foreach ( $widgets[$version] as $area => $params ) { if ( ! empty( $active_widgets[$area] ) && $params['flush'] ) { unset( $active_widgets[ $area ] ); } foreach ($params['widgets'] as $widget => $args ) { $active_widgets[ $area ][] = $widget . '-' . $widgets_counter; $widget_content = get_option( 'widget_' . $widget ); $widget_content[ $widgets_counter ] = $args; update_option( 'widget_' . $widget, $widget_content ); $widgets_counter ++; } } update_option( 'sidebars_widgets', $active_widgets ); } public function update_pages(){ if ( $this->args['version'] == 'ecommerce' ) { global $options_presets; $theme_version = et_get_versions_option(); $Content_theme_version = $theme_version['ecommerce']['content']; //Update Theme Optinos $new_options = json_decode(base64_decode($Content_theme_version),true); update_option( 'option_tree', $new_options ); $home_id = get_page_by_title('Home Page'); $blog_id = get_page_by_title('Blog'); update_option( 'show_on_front', 'page' ); update_option( 'page_on_front', $home_id->ID ); update_option( 'page_for_posts', $blog_id->ID ); add_option( 'demo_data_installed', 'yes' ); } else { update_option( 'show_on_front', 'page' ); update_option( 'page_on_front', $this->args['id'] ); } } public function update_menus(){ global $wpdb; $menuname = 'Main Menu'; $bpmenulocation = 'main-menu'; $mobilemenulocation = 'mobile-menu'; $tablename = $wpdb->prefix.'terms'; $menu_ids = $wpdb->get_results( " SELECT term_id FROM ".$tablename." WHERE name= '".$menuname."' " ); foreach ( $menu_ids as $menu ) { $menu_id = $menu->term_id; } if( ! has_nav_menu( $bpmenulocation ) ){ $locations = get_theme_mod('nav_menu_locations'); if ( $menu_id ) { $locations[$bpmenulocation] = $menu_id; $locations[$mobilemenulocation] = $menu_id; } set_theme_mod( 'nav_menu_locations', $locations ); } } public function error( $msg = false ){ die( '<span class="et_error">' . $msg . '</span><br>' ); } } new Etheme_Import;
[+]
..
[+]
js
[-] options.php
[edit]
[-] import.php
[edit]
[+]
dummy
[-] vc.php
[edit]
[-] plugins.php
[edit]
[-] woo.php
[edit]
[-] version-check.php
[edit]
[+]
css
[-] portfolio.php
[edit]
[+]
wordpress-importer
[-] class-account-register-ajax.php
[edit]
[-] walkers.php
[edit]
[+]
tmp
[+]
twitteroauth
[-] widgets-import.php
[edit]
[+]
testimonials
[+]
thirdparty
[-] widgets.php
[edit]
[-] init.php
[edit]
[-] theme-options.php
[edit]
[-] theme-functions.php
[edit]
[+]
fonts-uploader
[+]
cache
[-] shortcodes.php
[edit]
[+]
plugins
[+]
inc