/**
  * When in Polylang on WPML we're using "all" languages,
  * saved options should be copied to ALL languages.
  *
  * @access public
  * @since 4.0.2
  */
 public function save_all_languages()
 {
     // Get the current language.
     $is_all = Avada::get_language_is_all();
     // If not "all", then early exit.
     if (!$is_all) {
         return;
     }
     // Get the options.
     $option_name = Avada::get_option_name();
     $original_option_name = Avada::get_original_option_name();
     $options = get_option($option_name);
     // Get available languages.
     $all_languages = Avada_Multilingual::get_available_languages();
     // Get default language
     $default_language = Avada_Multilingual::get_default_language();
     if ('en' !== $default_language) {
         update_option($original_option_name . '_' . $default_language, $options);
         update_option($original_option_name, $options);
     }
     foreach ($all_languages as $language) {
         // Skip English.
         if ('' === $language || 'en' === $language) {
             continue;
         }
         // Skip the main language if something other than English.
         // We've already handled that above.
         if ('en' !== $default_language && $default_language === $language) {
             continue;
         }
         // Copy options to the new language.
         update_option($original_option_name . '_' . $language, $options);
     }
 }
Esempio n. 2
0
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;
        }
    }
}
 public function __construct()
 {
     // Only run on the dashboard
     if (!is_admin()) {
         return;
     }
     // Set the version
     $this->version = '400';
     // Set the language
     if ($_GET && isset($_GET['lang'])) {
         $this->lang = $_GET['lang'];
     }
     if (!empty($this->lang) && !Avada::$lang_applied) {
         Avada_Multilingual::set_active_language($this->lang);
     }
     $default_old_options = get_option('Avada_options', array());
     // for multilingual sites, set the language for the options
     if (!in_array($this->lang, array('', 'en', 'all', null))) {
         $old_options = get_option('Avada_options_' . Avada_Multilingual::get_active_language(), array());
     } else {
         $old_options = $default_old_options;
     }
     $new_options = get_option(Avada::get_option_name(), array());
     // If clean install, set builder and encoding active
     if (empty($old_options) && empty($new_options)) {
         update_option('avada_disable_builder', 1);
         update_option('avada_disable_encoding', 1);
     }
     // No need to proceed if there's no data at all to migrate
     if (empty($default_old_options)) {
         return;
     }
     // Add migration steps for previous versions of Avada
     parent::update_installation(true);
     parent::migrate();
     // No need to proceed if the old options are empty
     if (empty($old_options) && !Avada_Multilingual::get_available_languages()) {
         return;
     }
     // Redirect to the migration script if needed
     $trigger_migration = false;
     if (!$_GET || !isset($_GET['avada_update']) || '1' != $_GET['avada_update']) {
         if (!empty($old_options)) {
             if (empty($new_options)) {
                 $trigger_migration = true;
             } else {
                 // Get a record of already run migrations
                 // and determine if we should continue or not
                 $migration_run = get_option('avada_migrations', array());
                 if (isset($migration_run[$this->version])) {
                     if (is_array($migration_run[$this->version])) {
                         if (isset($migration_run[$this->version]['finished']) && true !== $migration_run[$this->version]['finished']) {
                             $trigger_migration = true;
                         }
                         if (isset($migration_run[$this->version]['started']) && true !== $migration_run[$this->version]['started']) {
                             $trigger_migration = true;
                         }
                     } else {
                         $trigger_migration = true;
                     }
                 } else {
                     $trigger_migration = true;
                 }
             }
         }
     }
     if ($trigger_migration) {
         wp_redirect(trailingslashit(admin_url()) . 'index.php?avada_update=1&ver=400&step=0&new=1');
         exit;
     }
     // Define the migration steps
     $this->steps = array(array('callback' => '__return_true', 'description' => esc_html__('Preparing to run Upgrade', 'Avada')), array('callback' => array($this, 'migrate_sliders'), 'description' => esc_html__('Slider controls', 'Avada')), array('callback' => array($this, 'migrate_checkboxes'), 'description' => esc_html__('Checkbox & Switch controls', 'Avada')), array('callback' => array($this, 'dimension'), 'description' => esc_html__('Dimension controls', 'Avada')), array('callback' => array($this, 'social'), 'description' => esc_html__('Social Networks', 'Avada')), array('callback' => array($this, 'color_alpha'), 'description' => esc_html__('HEX to RGBA colors conversion', 'Avada')), array('callback' => array($this, 'color_hex'), 'description' => esc_html__('HEX colors', 'Avada')), array('callback' => array($this, 'media_files'), 'description' => esc_html__('Media Files', 'Avada')), array('callback' => array($this, 'spacing_1'), 'description' => esc_html__('Spacing Options', 'Avada')), array('callback' => array($this, 'custom_fonts'), 'description' => esc_html__('Custom Fonts', 'Avada')), array('callback' => array($this, 'typography_1'), 'description' => sprintf(esc_html__('Typography Options (step %s of %s)', 'Avada'), '1', '2')), array('callback' => array($this, 'typography_2'), 'description' => sprintf(esc_html__('Typography Options (step %s of %s)', 'Avada'), '2', '2')), array('callback' => array($this, 'other_options'), 'description' => esc_html__('Other Options', 'Avada')));
     // Run the parent class constructor
     parent::__construct();
     // Copy the old options to the new options for new migrations
     if ($_GET && isset($_GET['new']) && 1 == $_GET['new']) {
         $migration_run = get_option('avada_migrations', array());
         $migration_run[$this->version]['started'] = true;
         $migration_run[$this->version]['finished'] = false;
         if (!isset($migration_run['copied'])) {
             $migration_run['copied'] = false;
         }
         // Copy default options
         $old_options = get_option('Avada_options', array());
         $original_option_name = Avada::get_original_option_name();
         if (false == $migration_run['copied']) {
             update_option($original_option_name, $old_options);
         }
         // Check multilingual installations
         if (Avada_Multilingual::get_available_languages() && false == $migration_run['copied']) {
             // Loop languages
             foreach (Avada_Multilingual::get_available_languages() as $language) {
                 // Process secondary languages.
                 // 'en' & 'all' have already been handled before we check for multilingual.
                 if (!in_array($language, array('', 'en', 'all', null))) {
                     // Get the old language options
                     $old_language_options = get_option('Avada_options_' . $language, array());
                     // If the old language options are empty, use the standard options instead.
                     if (empty($old_language_options)) {
                         $old_language_options = $old_options;
                     }
                     // Update the new language options with the old ones
                     update_option($original_option_name . '_' . $language, $old_language_options);
                 }
             }
             $migration_run['copied'] = true;
         }
         update_option('avada_migrations', $migration_run);
     }
 }