Example #1
0
function builder_import_theme_default_layouts_and_views($method = 'add', $layouts_method = 'add', $views_method = 'skip')
{
    if (!in_array($method, array('add', 'replace'))) {
        $method = 'add';
    }
    $theme_defaults_file = locate_template('defaults/layouts-and-views.zip');
    if (!file_exists($theme_defaults_file)) {
        $layouts = builder_get_builder_core_default_layouts();
        $storage = new ITStorage('layout_settings');
        $storage->save($layouts);
        return $layouts;
    }
    require_once dirname(dirname(__FILE__)) . '/import-export/class.builder-import-export.php';
    $import = new BuilderImportExport($theme_defaults_file);
    $data_sources = $import->get_data_sources();
    if (!isset($data_sources['layouts-views'])) {
        $import->cleanup();
        return false;
    }
    $settings = array('data_sources' => array('layouts-views' => array('method' => $method, 'layouts_method' => $layouts_method, 'views_method' => $views_method)));
    $db_data = array('layouts-views' => array());
    $results = $import->run_import($settings, false, true, $db_data);
    $import->cleanup();
    if (!isset($results['layouts-views']) || empty($results['layouts-views'])) {
        return false;
    }
    return $results['layouts-views'];
}
Example #2
0
 function run_import()
 {
     ITForm::check_nonce("import_run_guid_{$_REQUEST['guid']}");
     require_once dirname(__FILE__) . '/class.builder-import-export.php';
     $import = new BuilderImportExport($_REQUEST['guid']);
     $result = $import->run_import();
     $errors = '';
     if (is_array($result)) {
         $errors = '&errors=' . implode(',', $result);
     }
     $redirect = "{$this->_parent->_self_link}&imported={$_REQUEST['guid']}{$errors}";
     //			echo "<p>Redirect: $redirect</p>\n";
     wp_redirect($redirect);
     exit;
 }