Пример #1
0
 /**
  * Save ajax handler for main panel data
  *
  * @since    1.0.0
  */
 public function save_panel_ajax()
 {
     header("Content-Type: application/json");
     // verify nonce
     if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], "msp_panel")) {
         echo json_encode(array('success' => false, 'message' => __("Authorization failed!", 'master-slider')));
         exit;
     }
     // ignore the request if the current user doesn't have sufficient permissions
     if (!current_user_can('publish_masterslider')) {
         echo json_encode(array('success' => false, 'message' => apply_filters('masterslider_insufficient_permissions_to_publish_message', __("Sorry, You don't have enough permission to publish slider!", 'master-slider'))));
         exit;
     }
     /////////////////////////////////////////////////////////////////////////////////////////
     // Get the slider id
     $slider_id = isset($_REQUEST['slider_id']) ? $_REQUEST['slider_id'] : '';
     if (empty($slider_id)) {
         echo json_encode(array('success' => false, 'type' => 'save', 'message' => __("Slider id is not defined.", 'master-slider')));
         exit;
     }
     // get the slider type
     $slider_type = isset($_REQUEST['slider_type']) ? $_REQUEST['slider_type'] : 'custom';
     // get panel data
     $msp_data = isset($_REQUEST['msp_data']) ? $_REQUEST['msp_data'] : NULL;
     // get parse and database tools
     global $mspdb;
     // load and get parser and start parsing data
     $parser = msp_get_parser();
     $parser->set_data($msp_data, $slider_id);
     // get required parsed data
     $slider_setting = $parser->get_slider_setting();
     $slides = $parser->get_slides();
     $slider_custom_styles = $parser->get_styles();
     $fields = array('title' => $slider_setting['title'], 'type' => $slider_setting['slider_type'], 'slides_num' => count($slides), 'params' => $msp_data, 'custom_styles' => $slider_custom_styles, 'custom_fonts' => $slider_setting['gfonts'], 'status' => 'published');
     // store slider data in database
     $is_saved = $mspdb->update_slider($slider_id, $fields);
     msp_save_custom_styles();
     // flush slider cache if slider cache is enabled
     msp_flush_slider_cache($slider_id);
     // create and output the response
     if (isset($is_saved)) {
         $response = json_encode(array('success' => true, 'type' => 'save', 'message' => __("Saved Successfully.", 'master-slider')));
     } else {
         $response = json_encode(array('success' => true, 'type' => 'save', 'message' => __("No Data Recieved.", 'master-slider')));
     }
     echo $response;
     exit;
     // IMPORTANT
 }
 /**
  * Regenerate and cache custom css codes for all slider after plugin update
  * 
  * @return bool  TRUE on success, FALSE otherwise
  */
 public function after_plugin_update()
 {
     if (get_option('masterslider_plugin_version', '0') == MSWP_AVERTA_VERSION) {
         return false;
     }
     msp_save_custom_styles();
     update_option('masterslider_plugin_version', MSWP_AVERTA_VERSION);
     do_action('masterslider_after_plugin_updated');
     return true;
 }
Пример #3
0
function pvt_wordpress_content_importer()
{
    $theme_dir = get_template_directory();
    if (is_admin() && isset($_GET['importcontent'])) {
        if (!defined('WP_LOAD_IMPORTERS')) {
            define('WP_LOAD_IMPORTERS', true);
        }
        if (!class_exists('WP_Importer')) {
            $class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
            if (file_exists($class_wp_importer)) {
                include $class_wp_importer;
            }
        }
        if (!class_exists('pvt_WP_Import')) {
            $class_wp_import = $theme_dir . '/inc/importer/wordpress-importer.php';
            if (file_exists($class_wp_import)) {
                include $class_wp_import;
            }
        }
        if (class_exists('WP_Importer') && class_exists('pvt_WP_Import')) {
            $importer = new pvt_WP_Import();
            $files_to_import = array();
            // Live Composer has links to images hard-coded, so before importing
            // media we need to check that the Settings > Media >
            // 'Organize my uploads into month- and year-based folders' unchecked
            // as on demo server. After import is done we set back original state
            // of this setting.
            $setting_original_useyearmonthfolders = get_option('uploads_use_yearmonth_folders');
            update_option('uploads_use_yearmonth_folders', 0);
            if ($_GET['importcontent'] == 'basic-templates') {
                $import_path = $theme_dir . '/design/basic-config/';
                $files_to_import[] = $import_path . 'seowp-templates.xml.gz';
                $files_to_import[] = $import_path . 'seowp-themefooters.xml.gz';
                $files_to_import[] = $import_path . 'seowp-systempagetemplates.xml.gz';
                $files_to_import[] = $import_path . 'seowp-livecomposer-tutorials.xml.gz';
            }
            if ($_GET['importcontent'] == 'alldemocontent') {
                $import_path = $theme_dir . '/design/demo-content/';
                $files_array = array(array('seowp-homepages.xml.gz', 'seowp-predesignedpages-1.xml.gz'), array('seowp-predesignedpages-2.xml.gz', 'seowp-predesignedpages-3.xml.gz'), array('seowp-predesignedpages-4.xml.gz', 'seowp-predesignedpages-5.xml.gz'), array('seowp-predesignedpages-6.xml.gz', 'seowp-predesignedpages-7.xml.gz'), array('seowp-predesignedpages-8.xml.gz', 'seowp-predesignedpages-9.xml.gz'), array('seowp-predesignedpages-10.xml.gz', 'seowp-predesignedpages-11.xml.gz'), array('seowp-downloads.xml.gz', 'seowp-partners.xml.gz'), array('seowp-staff.xml.gz', 'seowp-testimonials.xml.gz'), array('seowp-posts.xml.gz', 'seowp-projects.xml.gz'), array('seowp-media-homepage.xml.gz'), array('seowp-media-menuimages.xml.gz'), array('seowp-media-sliderimages.xml.gz'), array('seowp-media-clientlogos.xml.gz'), array('seowp-media-blogpostthumbs.xml.gz'), array('seowp-media-footerimages.xml.gz'), array('seowp-media-staffavatars.xml.gz'), array('seowp-media-servicepage.xml.gz'), array('seowp-media-sectionbackgrounds.xml.gz'), array('seowp-media-ebookcovers.xml.gz'), array('seowp-media-projectthumbs.xml.gz'));
                if (isset($_GET['importcontent_part'])) {
                    foreach ($files_array[$_GET['importcontent_part']] as $file_name) {
                        $files_to_import[] = $import_path . $file_name;
                    }
                    if (isset($files_array[$_GET['importcontent_part'] + 1])) {
                        echo '<input type="hidden" name="importcontent_part" id="importcontent_part" value="' . ($_GET['importcontent_part'] + 1) . '" />';
                    }
                }
            }
            // Start Import
            if (file_exists($class_wp_importer)) {
                // Import included images
                $importer->fetch_attachments = true;
                foreach ($files_to_import as $import_file) {
                    if (is_file($import_file)) {
                        ob_start();
                        $importer->import($import_file);
                        $log = ob_get_contents();
                        ob_end_clean();
                        // output log in the hidden div
                        echo '<div class="ajax-log">';
                        echo $log;
                        echo '</div>';
                        if (stristr($log, 'error') || !stristr($log, 'All done.')) {
                            // Set marker div that will be fildered by ajax request
                            echo '<div class="ajax-request-error"></div>';
                            // output log in the div
                            echo '<div class="ajax-error-log">';
                            echo $log;
                            echo '</div>';
                        }
                    } else {
                        // Set marker div that will be fildered by ajax request
                        echo '<div class="ajax-request-error"></div>';
                        // output log in the div
                        echo '<div class="ajax-error-log">';
                        echo "Can't open file: " . $import_file . "</ br>";
                        echo '</div>';
                    }
                }
            } else {
                // Set marker div that will be fildered by ajax request
                echo '<div class="ajax-request-error"></div>';
                // output log in the div
                echo '<div class="ajax-error-log">';
                echo "Failed to load: " . $class_wp_import . "</ br>";
                echo '</div>';
            }
            // Set 'Organize my uploads into month- and year-based folders' setting
            // to its original state
            update_option('uploads_use_yearmonth_folders', $setting_original_useyearmonthfolders);
        }
        /**
         * ----------------------------------------------------------------------
         * Basic configuration:
         * Post import actions
         */
        if ($_GET['importcontent'] == 'basic-templates') {
            // 1. Import Menus
            // 2. Activate Mega Main Menu for menu locations
            // 3. Import Widgets
            // 4. Demo description for author
            // 5. Tutorial Pages for LiveComposer
            // 6. Newsletter Sign-Up Plugin Settings
            // 7. Rotating Tweets Default Options Setup
            // 8. Regenerate Custom CSS
            // Path to the folder with basic import files
            $import_path_basic_config = $theme_dir . '/design/basic-config/';
            // 1:
            // Import Top Bar menu
            // if no menu set for 'topbar' location
            if (!has_nav_menu('topbar')) {
                if (is_plugin_active('wpfw_menus_management/wpfw_menus_management.php')) {
                    wpfw_import_menu($import_path_basic_config . 'seowp-menu-topbar.txt', 'topbar');
                }
            }
            // Import Mega Main Menu menu
            // if no menu set for 'header-menu' location
            if (!has_nav_menu('header-menu')) {
                if (is_plugin_active('wpfw_menus_management/wpfw_menus_management.php')) {
                    wpfw_import_menu($import_path_basic_config . 'seowp-menu-megamainmenu.txt', 'header-menu');
                }
            }
            $locations = get_nav_menu_locations();
            set_theme_mod('nav_menu_locations', $locations);
            // Import Mobile Off-Canvas Menu
            if (is_plugin_active('wpfw_menus_management/wpfw_menus_management.php')) {
                wpfw_import_menu($import_path_basic_config . 'seowp-menu-mobile-offcanvas.txt');
            }
            // 2: Activate Mega Main Menu for 'topbar' and 'header-menu' locations
            // See /inc/plugins-integration/megamainmenu.php for function source
            if (is_plugin_active('mega_main_menu/mega_main_menu.php')) {
                lbmn_activate_mainmegamenu_locations();
            }
            // Predefine Custom Sidebars in LiveComposer
            // First set new sidebars in options table
            update_option('dslc_plugin_options_widgets_m', array('sidebars' => 'Sidebar,404 Page Widgets,Comment Form Area,'));
            // Define default Archive and Search options with System Templates
            // 404 Page Template
            $current_lc_archive_options = get_option('dslc_plugin_options_archives');
            $current_lc_archive_options['404_page'] = lbmn_get_page_by_title(LBMN_SYSTEMPAGE_404_DEFAULT, 'lbmn_archive');
            // Archive Page Template
            $new_archive_listing_id = lbmn_get_page_by_title(LBMN_SYSTEMPAGE_ARCHIVE_DEFAULT, 'lbmn_archive');
            $current_lc_archive_options['post'] = $new_archive_listing_id;
            $current_lc_archive_options['dslc_projects'] = $new_archive_listing_id;
            $current_lc_archive_options['dslc_galleries'] = $new_archive_listing_id;
            $current_lc_archive_options['dslc_downloads'] = $new_archive_listing_id;
            $current_lc_archive_options['dslc_staff'] = $new_archive_listing_id;
            $current_lc_archive_options['dslc_partners'] = $new_archive_listing_id;
            $current_lc_archive_options['author'] = $new_archive_listing_id;
            // Search Results
            $new_search_listing_id = lbmn_get_page_by_title(LBMN_SYSTEMPAGE_SEARCHRESULTS_DEFAULT, 'lbmn_archive');
            $current_lc_archive_options['search_results'] = $new_search_listing_id;
            update_option('dslc_plugin_options_archives', $current_lc_archive_options);
            // Then run LiveComposer function that creates sidebars dynamically
            dslc_sidebars();
            // 3: Import widgets
            $files_with_widgets_to_import = array();
            $files_with_widgets_to_import[] = $import_path_basic_config . 'seowp-widgets.wie';
            // Remove default widgets from 'mobile-offcanvas' widget area
            $sidebars_widgets = get_option('sidebars_widgets');
            if (is_array($sidebars_widgets['mobile-offcanvas'])) {
                $sidebars_widgets['mobile-offcanvas'] = NULL;
            }
            update_option('sidebars_widgets', $sidebars_widgets);
            // There are dynamic values in 'seowp-widgets.wie' that needs to be replaced
            // before import processing
            global $widget_strings_replace;
            $widget_strings_replace = array('TOREPLACE_OFFCANVAS_MENUID' => lbmn_get_menuid_by_menutitle('Mobile Off-canvas Menu'));
            foreach ($files_with_widgets_to_import as $file) {
                pvt_import_data($file);
            }
            // 4: Put some demo description into current user info field
            // that used in the blog user boxes
            $user_ID = get_current_user_id();
            $user_info = get_userdata($user_ID);
            if (!$user_info->description) {
                update_user_meta($user_ID, 'description', 'This is author biographical info, ' . 'that can be used to tell more about you, your iterests, ' . 'background and experience. ' . 'You can change it on <a href="/wp-admin/profile.php">Admin &gt; Users &gt; Your Profile &gt; Biographical Info</a> page."');
            }
            // 5: Predefine Tutorial Pages in LiveComposer
            update_option('dslc_plugin_options_tuts', array('lc_tut_chapter_one' => lbmn_get_page_by_slug('live-composer-tutorials/chapter-1'), 'lc_tut_chapter_two' => lbmn_get_page_by_slug('live-composer-tutorials/chapter-2'), 'lc_tut_chapter_three' => lbmn_get_page_by_slug('live-composer-tutorials/chapter-3'), 'lc_tut_chapter_four' => lbmn_get_page_by_slug('live-composer-tutorials/chapter-4')));
            // 6: Newsletter Sign-Up Plugin Form Elements
            update_option('nsu_form', array('email_label' => '', 'email_default_value' => 'Your email address...', 'email_label' => '', 'redirect_to' => get_site_url() . '/index.php?pagename=/lbmn_archive/thanks-for-signing-up/'));
            // Add custom Mega Main Menu options
            $mmm_options = get_option('mega_main_menu_options');
            // Add custom Additional Mega Menu styles
            $mmm_options['additional_styles_presets'] = array('1' => array('style_name' => "Call to action item", 'text_color' => "rgba(255,255,255,1)", 'font' => array("font_size" => "15", "font_weight" => "600"), 'icon' => array("font_size" => "16"), 'bg_gradient' => array("color1" => "#A1C627", "start" => "0", "color2" => "#A1C627", "end" => "100", "orientation" => "top"), "text_color_hover" => "rgba(255,255,255,1)", "bg_gradient_hover" => array("color1" => "#56AEE3", "start" => "0", "color2" => "#56AEE3", "end" => "100", "orientation" => "top")), '2' => array('style_name' => "Dropdown Heading", 'text_color' => "rgba(0,0,0,1)", 'font' => array("font_size" => "15", "font_weight" => "400"), 'icon' => array("font_size" => "15"), 'bg_gradient' => array("color1" => "", "start" => "0", "color2" => "", "end" => "100", "orientation" => "top"), "text_color_hover" => "rgba(0,0,0,1)", "bg_gradient_hover" => array("color1" => "", "start" => "0", "color2" => "", "end" => "100", "orientation" => "top")), '3' => array('style_name' => "Dropdown Menu Text", 'text_color' => "rgba(0,0,0,1)", 'icon' => array("font_size" => "21"), 'font' => array("font_size" => "21", "font_weight" => "300"), 'bg_gradient' => array("color1" => "", "start" => "0", "color2" => "", "end" => "100", "orientation" => "top"), "text_color_hover" => "rgba(0,0,0,1)", "bg_gradient_hover" => array("color1" => "", "start" => "0", "color2" => "", "end" => "100", "orientation" => "top")));
            // Add custom icons
            $mmm_options['set_of_custom_icons'] = array('1' => array('custom_icon' => esc_url_raw(get_template_directory_uri() . '/images/flag-spain.png')), '2' => array('custom_icon' => esc_url_raw(get_template_directory_uri() . '/images/flag-italy.png')), '3' => array('custom_icon' => esc_url_raw(get_template_directory_uri() . '/images/flag-france.png')), '4' => array('custom_icon' => esc_url_raw(get_template_directory_uri() . '/images/flag-uk.png')), '5' => array('custom_icon' => esc_url_raw(get_template_directory_uri() . '/images/flag-us.png')), '6' => array('custom_icon' => esc_url_raw(get_template_directory_uri() . '/images/flag-austria.png')), '7' => array('custom_icon' => esc_url_raw(get_template_directory_uri() . '/images/flag-belgium.png')), '8' => array('custom_icon' => esc_url_raw(get_template_directory_uri() . '/images/flag-germany.png')), '9' => array('custom_icon' => esc_url_raw(get_template_directory_uri() . '/images/flag-netherlands.png')), '10' => array('custom_icon' => esc_url_raw(get_template_directory_uri() . '/images/flag-poland.png')), '11' => array('custom_icon' => esc_url_raw(get_template_directory_uri() . '/images/flag-portugal.png')), '12' => array('custom_icon' => esc_url_raw(get_template_directory_uri() . '/images/flag-romania.png')), '13' => array('custom_icon' => esc_url_raw(get_template_directory_uri() . '/images/flag-russia.png')), '14' => array('custom_icon' => esc_url_raw(get_template_directory_uri() . '/images/flag-ukraine.png')));
            // Put Mega Main Menu options back
            update_option('mega_main_menu_options', $mmm_options);
            // 8: Regenerate Custom CSS
            lbmn_customized_css_cache_reset(false);
            // refresh custom css without printig css (false)
            if (is_plugin_active('mega_main_menu/mega_main_menu.php')) {
                // call the function that normaly starts only in Theme Customizer
                lbmn_mainmegamenu_customizer_integration();
            }
        }
        // if $_GET['importcontent']
        /**
         * ----------------------------------------------------------------------
         * Demo Content: Full
         */
        if ($_GET['importcontent'] == 'alldemocontent' && $_GET['importcontent_part'] == 16) {
            $import_path_demo_content = $theme_dir . '/design/demo-content/';
            // Import Demo Ninja Forms
            lbmn_ninjaforms_import();
            lbmn_debug_console('Import Demo Mega Menu');
            // Import Demo Mega Menu menu
            if (is_plugin_active('wpfw_menus_management/wpfw_menus_management.php')) {
                wpfw_import_menu($import_path_demo_content . 'seowp-demomegamenu.txt', 'header-menu');
            }
            $locations = get_nav_menu_locations();
            set_theme_mod('nav_menu_locations', $locations);
            // Activate Mega Main Menu for 'header-menu' locations
            // See /inc/plugins-integration/megamainmenu.php for function source
            if (is_plugin_active('mega_main_menu/mega_main_menu.php')) {
                lbmn_activate_mainmegamenu_locations();
            }
            // Import pre-designed MasterSlider Slides
            // Check if MasterSlider is active
            // http://support.averta.net/envato/support/ticket/regenerate-custom-css-programatically/#post-16478
            if (defined('MSWP_AVERTA_VERSION')) {
                $current_sliders = get_masterslider_names('title-id');
                $slider_already_imported = false;
                foreach ($current_sliders as $slider => $slider_id) {
                    if (stristr($slider, 'Flat Design Style')) {
                        $slider_already_imported = true;
                    }
                }
                if (!$slider_already_imported) {
                    global $ms_importer;
                    if (is_null($ms_importer)) {
                        $ms_importer = new MSP_Importer();
                    }
                    // * @return bool   true on success and false on failure
                    $slider_import_state = $ms_importer->import_data(file_get_contents($import_path_demo_content . 'seowp-masterslider.json'));
                }
                // Force Master Slider Custom CSS regeneration
                include_once MSWP_AVERTA_ADMIN_DIR . '/includes/msp-admin-functions.php';
                if (function_exists('msp_save_custom_styles')) {
                    msp_update_preset_css();
                    // Presets re-generation
                    msp_save_custom_styles();
                    // Save sliders custom css
                }
            }
            // Use a static front page
            $home_page = get_page_by_title(LBMN_HOME_TITLE);
            update_option('page_on_front', $home_page->ID);
            update_option('show_on_front', 'page');
            // Set the blog page (not needed)
            // $blog = get_page_by_title( LBMN_BLOG_TITLE );
            // update_option( 'page_for_posts', $blog->ID );
            lbmn_debug_console('lbmn_customized_css_cache_reset');
            // Regenerate Custom CSS
            lbmn_customized_css_cache_reset(false);
            // refresh custom css without printig css (false)
            if (is_plugin_active('mega_main_menu/mega_main_menu.php')) {
                // call the function that normally starts only in Theme Customizer
                lbmn_mainmegamenu_customizer_integration();
            }
            // lbmn_debug_console( 'Search & Replace image URLS' );
            // Search & Replace image URLS
            // lbmn_lcsearchreplace(); not needed any more
        }
        // if $_GET['importcontent']
    }
    // is isset($_GET['importcontent'])
}
Пример #4
0
/**
 * Update custom_css, custom_fonts and slide num fields in sliders table
 * 
 * @param int $slider_id the slider id that is going to be updated             
 * @return int|false The number of rows updated, or false on error.
 */
function msp_update_slider_custom_css_and_fonts($slider_id)
{
    if (!isset($slider_id) || !is_numeric($slider_id)) {
        return false;
    }
    // get database tool
    global $mspdb;
    $slider_params = $mspdb->get_slider_field_val($slider_id, 'params');
    if (!$slider_params) {
        return false;
    }
    // load and get parser and start parsing data
    $parser = msp_get_parser();
    $parser->set_data($slider_params, $slider_id);
    // get required parsed data
    $slider_setting = $parser->get_slider_setting();
    $slides = $parser->get_slides();
    $slider_custom_styles = $parser->get_styles();
    $fields = array('slides_num' => count($slides), 'custom_styles' => $slider_custom_styles, 'custom_fonts' => $slider_setting['gfonts']);
    msp_save_custom_styles();
    $mspdb->update_slider($slider_id, $fields);
}
function lbmn_wordpress_content_importer()
{
    $theme_dir = get_template_directory();
    if (is_admin() && isset($_GET['importcontent'])) {
        if (!defined('WP_LOAD_IMPORTERS')) {
            define('WP_LOAD_IMPORTERS', true);
        }
        if (!class_exists('WP_Importer')) {
            $class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
            if (file_exists($class_wp_importer)) {
                include $class_wp_importer;
            }
        }
        if (!class_exists('lbmn_WP_Import')) {
            $class_wp_import = $theme_dir . '/inc/importer/wordpress-importer.php';
            if (file_exists($class_wp_import)) {
                include $class_wp_import;
            }
        }
        if (class_exists('WP_Importer') && class_exists('lbmn_WP_Import')) {
            $importer = new lbmn_WP_Import();
            $files_to_import = array();
            // Live Composer has links to images hard-coded, so before importing
            // media we need to check that the Settings > Media >
            // 'Organize my uploads into month- and year-based folders' unchecked
            // as on demo server. After import is done we set back original state
            // of this setting.
            $setting_original_useyearmonthfolders = get_option('uploads_use_yearmonth_folders');
            update_option('uploads_use_yearmonth_folders', 0);
            if ($_GET['importcontent'] == 'basic-templates') {
                $import_path = $theme_dir . '/design/basic-config/';
                $files_array = array('start' => array(), 'templates' => array('files' => array('seowp-templates.xml.gz'), 'description' => __('Importing: Post Templates...', 'lbmn')), 'templates-system' => array('files' => array('seowp-systempagetemplates.xml.gz'), 'description' => __('Importing: System Templates...', 'lbmn')), 'menu-topbar' => array('files' => array('seowp-topbar.xml.gz'), 'description' => __('Importing: Top Bar Menu...', 'lbmn')), 'menu-topbar-config' => array('description' => __('Configuring Top Bar...', 'lbmn')), 'menu-basic' => array('files' => array('seowp-basicmenu.xml.gz'), 'description' => __('Importing: Basic Main Menu...', 'lbmn')), 'menu-basic-config' => array('description' => __('Configuring Basic Menu...', 'lbmn')), 'footer-basic' => array('files' => array('seowp-footer-default.xml.gz'), 'description' => __('Importing: Basic Footer...', 'lbmn')), 'basic-config' => array('description' => __('Final touches...', 'lbmn')), 'finish-basic-templates' => array('description' => __('Finishing...', 'lbmn')));
                // $files_to_import[] = $import_path . 'seowp-livecomposer-tutorials.xml.gz';
            }
            if ($_GET['importcontent'] == 'alldemocontent') {
                $import_path = $theme_dir . '/design/demo-content/';
                $files_array = array('start' => array(), 'home' => array('files' => array('seowp-homepages.xml.gz', 'seowp-predesignedpages-1.xml.gz'), 'description' => __('Importing: Home Page...', 'lbmn')), 'predesigned-1' => array('files' => array('seowp-predesignedpages-2.xml.gz', 'seowp-predesignedpages-3.xml.gz'), 'description' => __('Importing: Inner Pages – part 1...', 'lbmn')), 'predesigned-2' => array('files' => array('seowp-predesignedpages-4.xml.gz', 'seowp-predesignedpages-5.xml.gz'), 'description' => __('Importing: Inner Pages – part 2...', 'lbmn')), 'predesigned-3' => array('files' => array('seowp-predesignedpages-6.xml.gz', 'seowp-predesignedpages-7.xml.gz'), 'description' => __('Importing: Inner Pages – part 3...', 'lbmn')), 'predesigned-4' => array('files' => array('seowp-predesignedpages-8.xml.gz', 'seowp-predesignedpages-9.xml.gz'), 'description' => __('Importing: Inner Pages – part 4...', 'lbmn')), 'predesigned-5' => array('files' => array('seowp-predesignedpages-10.xml.gz', 'seowp-predesignedpages-11.xml.gz'), 'description' => __('Importing: Inner Pages – part 5...', 'lbmn')), 'downloads' => array('files' => array('seowp-downloads.xml.gz', 'seowp-partners.xml.gz'), 'description' => __('Importing: Resources & Partners...', 'lbmn')), 'staff' => array('files' => array('seowp-staff.xml.gz', 'seowp-testimonials.xml.gz'), 'description' => __('Importing: Staff & Testimonials...', 'lbmn')), 'posts' => array('files' => array('seowp-posts.xml.gz', 'seowp-projects.xml.gz'), 'description' => __('Importing: Posts & Projects...', 'lbmn')), 'media-home' => array('files' => array('seowp-media-homepage.xml.gz'), 'description' => __('Importing: Home Page – Images...', 'lbmn')), 'media-menu' => array('files' => array('seowp-media-menuimages.xml.gz'), 'description' => __('Importing: Menu – Images...', 'lbmn')), 'media-slider' => array('files' => array('seowp-media-sliderimages.xml.gz'), 'description' => __('Importing: Slider - Images...', 'lbmn')), 'media-clinentlogos' => array('files' => array('seowp-media-clientlogos.xml.gz'), 'description' => __('Importing: ClientLogos – Images...', 'lbmn')), 'media-blogthumbs' => array('files' => array('seowp-media-blogpostthumbs.xml.gz'), 'description' => __('Importing: Posts – Images...', 'lbmn')), 'media-footer' => array('files' => array('seowp-media-footerimages.xml.gz'), 'description' => __('Importing: Footer – Images...', 'lbmn')), 'media-staff' => array('files' => array('seowp-media-staffavatars.xml.gz'), 'description' => __('Importing: Staff – Images...', 'lbmn')), 'media-servicepage' => array('files' => array('seowp-media-servicepage.xml.gz'), 'description' => __('Importing: Services – Images...', 'lbmn')), 'media-bg' => array('files' => array('seowp-media-sectionbackgrounds.xml.gz'), 'description' => __('Importing: Background Images...', 'lbmn')), 'media-ebooks' => array('files' => array('seowp-media-ebookcovers.xml.gz'), 'description' => __('Importing E-book Covers...', 'lbmn')), 'media-projectthumbs' => array('files' => array('seowp-media-projectthumbs.xml.gz'), 'description' => __('Importing: Project – Images...', 'lbmn')), 'mainmenu' => array('files' => array('seowp-mainmenu.xml.gz'), 'description' => __('Importing: Main Menu...', 'lbmn')), 'menu-config' => array('description' => __('Configuring: Menus...', 'lbmn')), 'ninjaforms' => array('description' => __('Importing: Ninja Forms...', 'lbmn')), 'masterslider' => array('description' => __('Importing: Master Slider...', 'lbmn')), 'footers' => array('files' => array('seowp-themefooters.xml.gz'), 'description' => __('Importing: Theme Footers...', 'lbmn')), 'finish-maincontent' => array('description' => __('Finishing...', 'lbmn')));
            }
            if (isset($_GET['importcontent_step_current_id'])) {
                $content_part_id = sanitize_key($_GET['importcontent_step_current_id']);
                if (!$content_part_id) {
                    $content_part_id = 'start';
                }
                lbmn_debug_console($content_part_id);
                // Get array internal pointer to the poistion needed
                reset($files_array);
                while (key($files_array) !== $content_part_id && key($files_array) !== null) {
                    next($files_array);
                }
                if (key($files_array) === null) {
                    end($files_array);
                }
                $files_current = current($files_array);
                $files_current_id = key($files_array);
                $files_current_pos = array_search($files_current_id, array_keys($files_array));
                if (isset($files_array[$files_current_id]['files'])) {
                    // Prepare array of the files to import during the current step
                    foreach ($files_array[$files_current_id]['files'] as $file_name) {
                        $files_to_import[] = $import_path . $file_name;
                    }
                }
                // Transmit to the JS number of the current step and how many steps in total
                // to make possible to update the progress bar
                echo '<input type="hidden" name="importcontent_steps_total" id="importcontent_steps_total" value="' . count($files_array) . '" />';
                echo '<input type="hidden" name="importcontent_step_current_no" id="importcontent_step_current_no" value="' . $files_current_pos . '" />';
                echo '<input type="hidden" name="importcontent_step_current_descr" id="importcontent_step_current_descr" value="' . $files_array[$files_current_id]['description'] . '" />';
                // Set internal array pointer to the next position
                $files_next = next($files_array);
                $files_next_id = key($files_array);
                if (key($files_array) !== null) {
                    echo '<input type="hidden" name="importcontent_step_next_id" id="importcontent_step_next_id" value="' . $files_next_id . '" />';
                }
            }
            // Start Import
            if (file_exists($class_wp_importer)) {
                // Import included images
                $importer->fetch_attachments = true;
                foreach ($files_to_import as $import_file) {
                    if (is_file($import_file)) {
                        ob_start();
                        $importer->import($import_file);
                        $log = ob_get_contents();
                        ob_end_clean();
                        // output log in the hidden div
                        echo '<div class="ajax-log">';
                        echo $log;
                        echo '</div>';
                        if (stristr($log, 'error') || !stristr($log, 'All done.')) {
                            // Set marker div that will be fildered by ajax request
                            echo '<div class="ajax-request-error"></div>';
                            // output log in the div
                            echo '<div class="ajax-error-log">';
                            echo $log;
                            echo '</div>';
                        }
                    } else {
                        // Set marker div that will be fildered by ajax request
                        echo '<div class="ajax-request-error"></div>';
                        // output log in the div
                        echo '<div class="ajax-error-log">';
                        echo "Can't open file: " . $import_file . "</ br>";
                        echo '</div>';
                    }
                }
            } else {
                // Set marker div that will be fildered by ajax request
                echo '<div class="ajax-request-error"></div>';
                // output log in the div
                echo '<div class="ajax-error-log">';
                echo "Failed to load: " . $class_wp_import . "</ br>";
                echo '</div>';
            }
            // Set 'Organize my uploads into month- and year-based folders' setting
            // to its original state
            update_option('uploads_use_yearmonth_folders', $setting_original_useyearmonthfolders);
        }
        if (isset($_GET['importcontent_step_current_id']) && $_GET['importcontent_step_current_id'] == 'menu-topbar-config') {
            // Asign 'Demo Mega Menu' to the 'Header Menu' location
            $menu_object = wp_get_nav_menu_object('top-bar-menu');
            $menu_object_id = $menu_object->term_id;
            $locations = get_nav_menu_locations();
            $locations['topbar'] = $menu_object_id;
            set_theme_mod('nav_menu_locations', $locations);
            // Activate Mega Main Menu functionality for the 'header-menu' locations
            // See /inc/plugins-integration/megamainmenu.php for function source
            if (is_plugin_active('mega_main_menu/mega_main_menu.php')) {
                lbmn_activate_mainmegamenu_locations();
            }
        }
        if (isset($_GET['importcontent_step_current_id']) && $_GET['importcontent_step_current_id'] == 'menu-basic-config') {
            // Asign 'Demo Mega Menu' to the 'Header Menu' location
            $menu_object = wp_get_nav_menu_object('basic-main-menu');
            $menu_object_id = $menu_object->term_id;
            $locations = get_nav_menu_locations();
            $locations['header-menu'] = $menu_object_id;
            set_theme_mod('nav_menu_locations', $locations);
        }
        if (isset($_GET['importcontent_step_current_id']) && $_GET['importcontent_step_current_id'] == 'menu-config') {
            // Asign 'Demo Mega Menu' to the 'Header Menu' location
            $menu_object = wp_get_nav_menu_object('mega-main-menu');
            $menu_object_id = $menu_object->term_id;
            $locations = get_nav_menu_locations();
            $locations['header-menu'] = $menu_object_id;
            set_theme_mod('nav_menu_locations', $locations);
            // Activate Mega Main Menu functionality for the 'header-menu' locations
            // See /inc/plugins-integration/megamainmenu.php for function source
            if (is_plugin_active('mega_main_menu/mega_main_menu.php')) {
                lbmn_activate_mainmegamenu_locations();
            }
        }
        if (isset($_GET['importcontent_step_current_id']) && $_GET['importcontent_step_current_id'] == 'ninjaforms') {
            // Import Demo Ninja Forms
            lbmn_ninjaforms_import();
        }
        if (isset($_GET['importcontent_step_current_id']) && $_GET['importcontent_step_current_id'] == 'masterslider') {
            $import_path_demo_content = $theme_dir . '/design/demo-content/';
            // Import pre-designed MasterSlider Slides
            // Check if MasterSlider is active
            // http://support.averta.net/envato/support/ticket/regenerate-custom-css-programatically/#post-16478
            if (defined('MSWP_AVERTA_VERSION')) {
                $current_sliders = get_masterslider_names('title-id');
                $slider_already_imported = false;
                foreach ($current_sliders as $slider => $slider_id) {
                    if (stristr($slider, 'Flat Design Style')) {
                        $slider_already_imported = true;
                    }
                }
                if (!$slider_already_imported) {
                    global $ms_importer;
                    if (is_null($ms_importer)) {
                        $ms_importer = new MSP_Importer();
                    }
                    // * @return bool   true on success and false on failure
                    $slider_import_state = $ms_importer->import_data(file_get_contents($import_path_demo_content . 'seowp-masterslider.json'));
                }
                // Force Master Slider Custom CSS regeneration
                include_once MSWP_AVERTA_ADMIN_DIR . '/includes/msp-admin-functions.php';
                if (function_exists('msp_save_custom_styles')) {
                    msp_update_preset_css();
                    // Presets re-generation
                    msp_save_custom_styles();
                    // Save sliders custom css
                }
            }
        }
        if (isset($_GET['importcontent_step_current_id']) && $_GET['importcontent_step_current_id'] == 'finish-maincontent') {
            // Use a static front page
            $home_page = get_page_by_title(LBMN_HOME_TITLE);
            update_option('page_on_front', $home_page->ID);
            update_option('show_on_front', 'page');
            // Set the blog page (not needed)
            // $blog = get_page_by_title( LBMN_BLOG_TITLE );
            // update_option( 'page_for_posts', $blog->ID );
            lbmn_debug_console('lbmn_customized_css_cache_reset');
            // Regenerate Custom CSS
            lbmn_customized_css_cache_reset(false);
            // refresh custom css without printig css (false)
            if (is_plugin_active('mega_main_menu/mega_main_menu.php')) {
                // call the function that normally starts only in Theme Customizer
                lbmn_mainmegamenu_customizer_integration();
            }
        }
        /**
         * ----------------------------------------------------------------------
         * Basic configuration:
         * Post import actions
         */
        if (isset($_GET['importcontent_step_current_id']) && $_GET['importcontent_step_current_id'] == 'basic-config') {
            // 1. Import Menus
            // 2. Activate Mega Main Menu for menu locations
            // 3. Import Widgets
            // 4. Demo description for author
            // 5. Tutorial Pages for LiveComposer
            // 6. Newsletter Sign-Up Plugin Settings
            // 7. Rotating Tweets Default Options Setup
            // 8. Regenerate Custom CSS
            // Path to the folder with basic import files
            $import_path_basic_config = $theme_dir . '/design/basic-config/';
            // $locations = get_nav_menu_locations();
            // set_theme_mod('nav_menu_locations', $locations);
            // 2: Activate Mega Main Menu for 'topbar' and 'header-menu' locations
            // See /inc/plugins-integration/megamainmenu.php for function source
            if (is_plugin_active('mega_main_menu/mega_main_menu.php')) {
                lbmn_activate_mainmegamenu_locations();
            }
            // Predefine Custom Sidebars in LiveComposer
            // First set new sidebars in options table
            update_option('dslc_plugin_options_widgets_m', array('sidebars' => 'Sidebar,404 Page Widgets,Comment Form Area,'));
            // Define default Archive and Search options with System Templates
            // 404 Page Template
            $current_lc_archive_options = get_option('dslc_plugin_options_archives');
            $current_lc_archive_options['404_page'] = lbmn_get_page_by_title(LBMN_SYSTEMPAGE_404_DEFAULT, 'lbmn_archive');
            // Archive Page Template
            $new_archive_listing_id = lbmn_get_page_by_title(LBMN_SYSTEMPAGE_ARCHIVE_DEFAULT, 'lbmn_archive');
            $current_lc_archive_options['post'] = $new_archive_listing_id;
            $current_lc_archive_options['dslc_projects'] = $new_archive_listing_id;
            $current_lc_archive_options['dslc_galleries'] = $new_archive_listing_id;
            $current_lc_archive_options['dslc_downloads'] = $new_archive_listing_id;
            $current_lc_archive_options['dslc_staff'] = $new_archive_listing_id;
            $current_lc_archive_options['dslc_partners'] = $new_archive_listing_id;
            $current_lc_archive_options['author'] = $new_archive_listing_id;
            // Search Results
            $new_search_listing_id = lbmn_get_page_by_title(LBMN_SYSTEMPAGE_SEARCHRESULTS_DEFAULT, 'lbmn_archive');
            $current_lc_archive_options['search_results'] = $new_search_listing_id;
            update_option('dslc_plugin_options_archives', $current_lc_archive_options);
            // Then run LiveComposer function that creates sidebars dynamically
            dslc_sidebars();
            // 3: Import widgets
            $files_with_widgets_to_import = array();
            $files_with_widgets_to_import[] = $import_path_basic_config . 'seowp-widgets.wie';
            // Remove default widgets from 'mobile-offcanvas' widget area
            $sidebars_widgets = get_option('sidebars_widgets');
            if (is_array($sidebars_widgets['mobile-offcanvas'])) {
                $sidebars_widgets['mobile-offcanvas'] = NULL;
            }
            update_option('sidebars_widgets', $sidebars_widgets);
            // There are dynamic values in 'seowp-widgets.wie' that needs to be replaced
            // before import processing
            global $widget_strings_replace;
            $widget_strings_replace = array('TOREPLACE_OFFCANVAS_MENUID' => lbmn_get_menuid_by_menutitle('Basic Main Menu'));
            foreach ($files_with_widgets_to_import as $file) {
                lbmn_import_data($file);
            }
            // 4: Put some demo description into current user info field
            // that used in the blog user boxes
            $user_ID = get_current_user_id();
            $user_info = get_userdata($user_ID);
            if (!$user_info->description) {
                update_user_meta($user_ID, 'description', 'This is author biographical info, ' . 'that can be used to tell more about you, your iterests, ' . 'background and experience. ' . 'You can change it on <a href="/wp-admin/profile.php">Admin &gt; Users &gt; Your Profile &gt; Biographical Info</a> page."');
            }
            // Add custom Mega Main Menu options
            $mmm_options = get_option('mega_main_menu_options');
            // Add custom Additional Mega Menu styles
            $mmm_options['additional_styles_presets'] = array('1' => array('style_name' => "Call to action item", 'text_color' => "rgba(255,255,255,1)", 'font' => array("font_size" => "15", "font_weight" => "600"), 'icon' => array("font_size" => "16"), 'bg_gradient' => array("color1" => "#A1C627", "start" => "0", "color2" => "#A1C627", "end" => "100", "orientation" => "top"), "text_color_hover" => "rgba(255,255,255,1)", "bg_gradient_hover" => array("color1" => "#56AEE3", "start" => "0", "color2" => "#56AEE3", "end" => "100", "orientation" => "top")), '2' => array('style_name' => "Dropdown Heading", 'text_color' => "rgba(0,0,0,1)", 'font' => array("font_size" => "15", "font_weight" => "400"), 'icon' => array("font_size" => "15"), 'bg_gradient' => array("color1" => "", "start" => "0", "color2" => "", "end" => "100", "orientation" => "top"), "text_color_hover" => "rgba(0,0,0,1)", "bg_gradient_hover" => array("color1" => "", "start" => "0", "color2" => "", "end" => "100", "orientation" => "top")), '3' => array('style_name' => "Dropdown Menu Text", 'text_color' => "rgba(0,0,0,1)", 'icon' => array("font_size" => "21"), 'font' => array("font_size" => "21", "font_weight" => "300"), 'bg_gradient' => array("color1" => "", "start" => "0", "color2" => "", "end" => "100", "orientation" => "top"), "text_color_hover" => "rgba(0,0,0,1)", "bg_gradient_hover" => array("color1" => "", "start" => "0", "color2" => "", "end" => "100", "orientation" => "top")));
            // Add custom icons
            $mmm_options['set_of_custom_icons'] = array('1' => array('custom_icon' => esc_url_raw(get_template_directory_uri() . '/images/flag-spain.png')), '2' => array('custom_icon' => esc_url_raw(get_template_directory_uri() . '/images/flag-italy.png')), '3' => array('custom_icon' => esc_url_raw(get_template_directory_uri() . '/images/flag-france.png')), '4' => array('custom_icon' => esc_url_raw(get_template_directory_uri() . '/images/flag-uk.png')), '5' => array('custom_icon' => esc_url_raw(get_template_directory_uri() . '/images/flag-us.png')), '6' => array('custom_icon' => esc_url_raw(get_template_directory_uri() . '/images/flag-austria.png')), '7' => array('custom_icon' => esc_url_raw(get_template_directory_uri() . '/images/flag-belgium.png')), '8' => array('custom_icon' => esc_url_raw(get_template_directory_uri() . '/images/flag-germany.png')), '9' => array('custom_icon' => esc_url_raw(get_template_directory_uri() . '/images/flag-netherlands.png')), '10' => array('custom_icon' => esc_url_raw(get_template_directory_uri() . '/images/flag-poland.png')), '11' => array('custom_icon' => esc_url_raw(get_template_directory_uri() . '/images/flag-portugal.png')), '12' => array('custom_icon' => esc_url_raw(get_template_directory_uri() . '/images/flag-romania.png')), '13' => array('custom_icon' => esc_url_raw(get_template_directory_uri() . '/images/flag-russia.png')), '14' => array('custom_icon' => esc_url_raw(get_template_directory_uri() . '/images/flag-ukraine.png')));
            // Put Mega Main Menu options back
            update_option('mega_main_menu_options', $mmm_options);
            // 8: Regenerate Custom CSS
            lbmn_customized_css_cache_reset(false);
            // refresh custom css without printig css (false)
            if (is_plugin_active('mega_main_menu/mega_main_menu.php')) {
                // call the function that normaly starts only in Theme Customizer
                lbmn_mainmegamenu_customizer_integration();
            }
        }
        // if $_GET['importcontent']
        // Update theme option '_basic_config_done'
        if (isset($_GET['importcontent_step_current_id']) && $_GET['importcontent_step_current_id'] == 'finish-basic-templates') {
            update_option(LBMN_THEME_NAME . '_basic_config_done', true);
            define('LBMN_THEME_CONFUGRATED', true);
        }
        // Update theme option '_basic_config_done'
        if (isset($_GET['importcontent_step_current_id']) && $_GET['importcontent_step_current_id'] == 'finish-maincontent') {
            update_option(LBMN_THEME_NAME . '_democontent_imported', true);
        }
    }
    // is isset($_GET['importcontent'])
}