function vwdemo_import_widgets()
 {
     echo '<p>Import widgets</p>';
     require VW_DEMO_IMPORT_PATH . '/widget-importer-exporter/widgets.php';
     require VW_DEMO_IMPORT_PATH . '/widget-importer-exporter/import.php';
     $file_path = VW_DEMO_IMPORT_PATH . '/demo-content/widgets.txt';
     if (file_exists($file_path) && function_exists('wie_process_import_file')) {
         wie_process_import_file($file_path);
     }
 }
예제 #2
0
 function vwdemo_import_widgets()
 {
     if (!function_exists('wie_process_import_file')) {
         require_once get_template_directory() . '/framework/demo-importer/widget-importer-exporter/widgets.php';
         require_once get_template_directory() . '/framework/demo-importer/widget-importer-exporter/import.php';
     }
     echo '<p>Import widgets</p>';
     $file_path = VW_DEMO_IMPORT_PATH . '/widgets.txt';
     if (file_exists($file_path)) {
         wie_process_import_file($file_path);
     }
 }
예제 #3
0
파일: import.php 프로젝트: dot2006/jobify
/**
 * Upload import file
 *
 * @since 0.3
 */
function wie_upload_import_file()
{
    // Check nonce for security since form was posted
    if (!empty($_POST) && !empty($_FILES['wie_import_file']) && check_admin_referer('wie_import', 'wie_import_nonce')) {
        // check_admin_referer prints fail page and dies
        // Uploaded file
        $uploaded_file = $_FILES['wie_import_file'];
        // Check file type
        // This will also fire if no file uploaded
        $wp_filetype = wp_check_filetype_and_ext($uploaded_file['tmp_name'], $uploaded_file['name'], false);
        if ('wie' != $wp_filetype['ext'] && !wp_match_mime_types('wie', $wp_filetype['type'])) {
            wp_die(__('You must upload a <b>.wie</b> file generated by this plugin.', 'widget-importer-exporter'), '', array('back_link' => true));
        }
        // Check and move file to uploads dir, get file data
        // Will show die with WP errors if necessary (file too large, quota exceeded, etc.)
        $overrides = array('test_form' => false);
        $file_data = wp_handle_upload($uploaded_file, $overrides);
        if (isset($file_data['error'])) {
            wp_die($file_data['error'], '', array('back_link' => true));
        }
        // Process import file
        wie_process_import_file($file_data['file']);
    }
}
function cmo_demo_widgets_import()
{
    if (!function_exists('wie_process_import_file')) {
        require_once 'widget-importer/widget-importer.php';
    }
    $widget_file = get_file_path('widgets.wie');
    if (!is_file($widget_file)) {
        ajax_finish(true, "done");
    }
    set_time_limit(0);
    ob_start();
    wie_process_import_file($widget_file);
    ob_get_clean();
    ajax_finish(true, "done");
}
function lab_1cl_demo_install_package_content()
{
    $resp = array('success' => false, 'errorMsg' => '');
    $pack_name = $_POST['pack'];
    $source_details = $_POST['contentSourceDetails'];
    $pack = lab_1cl_demo_installer_get_pack($pack_name);
    # Content Source Install by Type
    switch ($source_details['type']) {
        case "xml-wp-content":
        case "xml-products":
            # Run wordpress importer independently
            if (!defined("WP_LOAD_IMPORTERS")) {
                define("WP_LOAD_IMPORTERS", true);
                require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'wordpress-importer/wordpress-importer.php';
            }
            # Demo Content File (XML)
            if ($source_details['type'] == 'xml-products') {
                $xml_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . $pack['products'];
            } else {
                $xml_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . $pack['file'];
            }
            try {
                @set_time_limit(0);
                $wp_importer = new WP_Import();
                $wp_importer->fetch_attachments = isset($source_details['downloadMedia']) && $source_details['downloadMedia'];
                $wp_importer->id = sanitize_title($pack['name']);
                # Download Shop Attachments by Default
                if ($source_details['type'] == 'xml-products') {
                    $wp_importer->fetch_attachments = true;
                }
                ob_start();
                $wp_importer->import($xml_file);
                $content = ob_get_clean();
                $resp['imp'] = $wp_importer;
                $resp['success'] = true;
                # Small but important stuff to setup
                if ($source_details['type'] == 'xml-wp-content') {
                    # Set Frontpage and Posts page
                    if (isset($pack['frontpage']) || isset($pack['postspage'])) {
                        update_option('show_on_front', 'page');
                        if (isset($pack['frontpage'])) {
                            update_option('page_on_front', $pack['frontpage']);
                        }
                        if (isset($pack['postspage'])) {
                            update_option('page_for_posts', $pack['postspage']);
                        }
                    }
                    # Menus
                    if (isset($pack['menus']) && is_array($pack['menus'])) {
                        $nav_menus = wp_get_nav_menus();
                        foreach ($pack['menus'] as $menu_location => $menu_name) {
                            if (is_array($nav_menus)) {
                                foreach ($nav_menus as $term) {
                                    if (strtolower($menu_name) == strtolower($term->name)) {
                                        $nav_menu_locations = get_theme_mod('nav_menu_locations');
                                        if (!is_array($nav_menu_locations)) {
                                            $nav_menu_locations = array();
                                        }
                                        $nav_menu_locations[$menu_location] = $term->term_id;
                                        set_theme_mod('nav_menu_locations', $nav_menu_locations);
                                    }
                                }
                            }
                        }
                    }
                    # Flush rewrite rules
                    flush_rewrite_rules();
                }
            } catch (Exception $e) {
                $resp['errorMsg'] = $e;
            }
            break;
        case "theme-options":
            $theme_options = dirname(__FILE__) . DIRECTORY_SEPARATOR . $pack['options'];
            try {
                if ($theme_options = file_get_contents($theme_options)) {
                    $smof_data = unserialize(base64_decode($theme_options));
                    # Backup Nav Locations
                    $nav_menu_locations = get_theme_mod('nav_menu_locations');
                    # Save Theme Options
                    of_save_options(apply_filters('of_options_before_save', $smof_data));
                    # Restore Nav Locations
                    set_theme_mod('nav_menu_locations', $nav_menu_locations);
                    $resp['success'] = true;
                } else {
                    $resp['errorMsg'] = 'Invalid data serialization for Theme Options. Required format: Base64 Encoded';
                }
            } catch (Exception $e) {
                $resp['errorMsg'] = $e;
            }
            break;
        case "custom-css":
            $custom_css = $pack['custom_css'];
            if ($custom_css) {
                $custom_css = dirname(__FILE__) . DIRECTORY_SEPARATOR . $custom_css;
                try {
                    if ($custom_css = file_get_contents($custom_css)) {
                        $custom_css_options = json_decode(base64_decode($custom_css));
                        lab_1cl_demo_installer_custom_css_save($custom_css_options);
                        $resp['success'] = true;
                    }
                } catch (Exception $e) {
                    $resp['errorMsg'] = $e;
                }
            }
            break;
        case "widgets":
            $widgets = dirname(__FILE__) . DIRECTORY_SEPARATOR . $pack['widgets'];
            if (!class_exists('Widget_Importer_Exporter')) {
                require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'widget-importer-exporter/widget-importer-exporter.php';
            }
            try {
                wie_process_import_file($widgets);
                $resp['success'] = true;
            } catch (Exception $e) {
                $resp['errorMsg'] = $e;
            }
            break;
        case "revslider":
            try {
                # Import Revolution Slider
                if ($pack['revslider'] && class_exists('RevSlider')) {
                    $revslider = dirname(__FILE__) . DIRECTORY_SEPARATOR . $pack['revslider'];
                    $rev = new RevSlider();
                    ob_start();
                    $rev->importSliderFromPost(true, true, $revslider);
                    $content = ob_get_clean();
                    $resp['success'] = true;
                } else {
                    $resp['errorMsg'] = 'Revolution Slider is not installed/activated and thus this content source couldn\'t be imported!';
                }
            } catch (Exception $e) {
                $resp['errorMsg'] = $e;
            }
            break;
        case "layerslider":
            try {
                # Import Layer Slider
                if ($pack['layerslider'] && function_exists('ls_import_sliders')) {
                    $layerslider = dirname(__FILE__) . DIRECTORY_SEPARATOR . $pack['layerslider'];
                    include LS_ROOT_PATH . '/classes/class.ls.importutil.php';
                    $import = new LS_ImportUtil($layerslider, basename($layerslider));
                    $resp['success'] = true;
                } else {
                    $resp['errorMsg'] = 'Layer Slider is not installed/activated and thus this content source couldn\'t be imported!';
                }
            } catch (Exception $e) {
                $resp['errorMsg'] = $e;
            }
            break;
    }
    echo json_encode($resp);
    die;
}