Exemplo n.º 1
0
 function avia_import_config_file()
 {
     global $avia;
     //check if referer is ok
     if (function_exists('check_ajax_referer')) {
         check_ajax_referer('avia_nonce_save_backend');
     }
     //check if capability is ok
     $cap = apply_filters('avf_file_upload_capability', 'update_plugins');
     if (!current_user_can($cap)) {
         exit("Using this feature is reserved for Super Admins. You unfortunately don't have the necessary permissions.");
     }
     $attachment = $_POST['values'];
     $path = realpath(get_attached_file($attachment['id']));
     $options = @file_get_contents($path);
     if ($options) {
         if (!class_exists('WP_Import')) {
             if (!defined('WP_LOAD_IMPORTERS')) {
                 define('WP_LOAD_IMPORTERS', true);
             }
             $class_wp_import = AVIA_PHP . 'wordpress-importer/wordpress-importer.php';
             if (file_exists($class_wp_import)) {
                 require_once $class_wp_import;
             }
         }
         if (class_exists('WP_Import')) {
             $class_avia_import = AVIA_PHP . 'wordpress-importer/avia-import-class.php';
             if (file_exists($class_avia_import)) {
                 require_once $class_avia_import;
                 $avia_import = new avia_wp_import();
             }
             $options = unserialize(base64_decode($options));
             if (is_array($options)) {
                 foreach ($avia->option_pages as $page) {
                     $database_option[$page['parent']] = $avia_import->extract_default_values($options[$page['parent']], $page, $avia->subpages);
                 }
                 if (!empty($database_option)) {
                     update_option($avia->option_prefix, $database_option);
                 }
             }
             // currently no deletion. seems counter intuitive atm. also since the file upload button will only show txt files user can switch between settings easily
             // wp_delete_attachment($attachment['id'], true);
         }
     }
     exit('avia_config_file_imported');
 }
Exemplo n.º 2
0
//make sure to exclude the init function at the end of the file in kriesi_importer
if (!class_exists('WP_Import')) {
    $class_wp_import = IAMD_IMPORTER_URL . 'wordpress-importer.php';
    if (file_exists($class_wp_import)) {
        require_once $class_wp_import;
    } else {
        $avia_importerError = true;
    }
}
if ($avia_importerError !== false) {
    echo "The Auto importing script could not be loaded. please use the wordpress importer and import the XML file that is located in your themes folder manually.";
} else {
    if (class_exists('WP_Import')) {
        get_template_part('framework/wordpress-importer/my-import-class');
    }
    if (!is_file($import_filepath . '.xml')) {
        echo "The XML file containing the dummy content is not available or could not be read in <span>" . IAMD_IMPORTER_URL . "dummy/</span> You might want to try to set the file permission to chmod 777.<br/>If this doesn't work please use the wordpress importer and import the XML file (should be located in your themes folder: dummy.xml) manually <a href='/wp-admin/import.php'>here.</a>";
    } else {
        if (!isset($custom_export)) {
            #do_action('avia_import_hook');
            $wp_import = new avia_wp_import();
            $wp_import->fetch_attachments = true;
            $wp_import->import($import_filepath . '.xml');
            #$wp_import->saveOptions($import_filepath.'.php');
            $wp_import->set_menus();
        } else {
            $import = new avia_wp_import();
            #$import->saveOptions($import_filepath.'.php', $custom_export);
        }
    }
}
Exemplo n.º 3
0
    }
}
if ($avia_importerError !== false) {
    echo "The Auto importing script could not be loaded. please use the wordpress importer and import the XML file that is located in your themes folder manually.";
} else {
    if (class_exists('WP_Import')) {
        include_once 'wordpress-importer/avia-import-class.php';
    }
    if (!is_file($import_filepath . '.xml')) {
        echo "The XML file containing the dummy content is not available or could not be read in <pre>" . get_template_directory() . "</pre><br/> You might want to try to set the file permission to chmod 777.<br/>If this doesn't work please use the wordpress importer and import the XML file (should be located in your themes folder: dummy.xml) manually <a href='/wp-admin/import.php'>here.</a>";
    } else {
        if (!isset($custom_export)) {
            do_action('avia_import_hook');
            $wp_import = new avia_wp_import();
            $wp_import->rename_existing_menus();
            $wp_import->fetch_attachments = true;
            $wp_import->import($import_filepath . '.xml');
            $wp_import->saveOptions($import_filepath . '.php');
            $wp_import->set_menus();
            do_action('avia_after_import_hook');
            // todo: rename. make sure to update hook name of our woocommerce import script
        } else {
            $import = new avia_wp_import();
            $import->saveOptions($import_filepath . '.php', $custom_export);
            do_action('avia_after_custom_import_hook');
        }
        //generic hook. example use: after demo setting import we want to regen cached stylesheet
        do_action('ava_after_import_demo_settings');
        update_option('av_demo_content_imported', true);
    }
}