function wf_theme_download_export()
{
    if (isset($_GET['wf_theme_download_export']) && $_GET['wf_theme_download_export'] == '1') {
        $data = wf_theme_export_options();
        header('Content-type: text/plain');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Content-Description: File Transfer');
        header('Content-Disposition: attachment; filename="' . sanitize_key(WF_THEME_NAME) . '-export-' . date('Y-m-d') . '.txt"');
        die($data);
    }
}
Example #2
0
function wf_theme_options_page()
{
    update_option('wf_theme_activated', false);
    wf_theme_process_demo_import();
    wf_theme_process_import();
    wf_theme_process_options_reset();
    settings_errors();
    echo '<div class="wrap">' . get_screen_icon('tools') . '<h2>' . WF_THEME_NAME . ' Tools</h2>';
    echo '<h3 class="title">Import Demo Data</h3>';
    echo '<p>Importing demo data (post, pages, images, theme settings, ...) is the easiest way to setup your theme. It will
  allow you to quickly edit everything instead of creating content from scratch. When you import the data following things will happen:</p>';
    echo '<ul class="bullets">
  <li>no existing posts, pages, categories, images, custom post types or any other data will be deleted or modified</li>
  <li>no WordPress settings will be modified except the site title and front page type</li>
  <li>about 10 posts, a few pages, 10+ images, some widgets and one menu will get imported</li>
  <li>images will be downloaded from our server; these images are copyrighted and watermarked by Envato\'s PhotoDune and are for demo use only</li>
  <li>please click import only once and wait, it can take a couple of minutes</li>
  </ul>';
    echo '<form method="post" action="' . admin_url('themes.php?page=wf_theme_options') . '">';
    echo get_submit_button('Import Demo Data', 'primary', 'wf-theme-import-demo-data');
    echo '</form>';
    echo '<hr /><h3 class="title">Theme Options</h3>';
    echo '<p>All theme options are configured using the built-in <a href="' . admin_url('customize.php') . '" title="Open Theme Customizer">Theme Customizer</a>.</p>';
    echo '<hr /><h3 class="title">Export Options</h3>';
    echo '<p>Please note: the export data contains <b>only</b> theme options. It doesn\'t contain any general WordPress
        settings found under the <i>Settings</i> menu, posts, pages, images or anything other besides settings found under <i>Theme - Customize</i>.</p>';
    echo '<textarea rows="3" cols="100" id="wf-theme-export-options">' . wf_theme_export_options() . '</textarea>';
    echo get_submit_button('Download Options Export', 'secondary', 'wf-theme-download-export');
    echo '<hr /><h3 class="title">Import Options</h3>';
    echo '<form method="post" enctype="multipart/form-data" action="' . admin_url('themes.php?page=wf_theme_options') . '">';
    echo '<p>Use only options exported from another site using the same version of ' . WF_THEME_NAME . ' theme.<br />
  Copy/paste the data into the textarea or choose a file with export data.</p>';
    echo '<textarea rows="3" cols="100" id="wf-theme-import-options" name="wf-theme-import-options"></textarea><br />';
    echo '<input type="file" name="wf-theme-import-options-file" />';
    echo get_submit_button('Import Options', 'secondary', 'wf-theme-process-import');
    echo '</form>';
    echo '<hr /><h3 class="title">Reset Options</h3>';
    echo '<form method="post" action="' . admin_url('themes.php?page=wf_theme_options') . '">';
    echo '<p>This will reset <b>only</b> the theme options to default values. No WordPress related options will be modified.<br />
  There is no undo! Export Options before resetting if you want to make a backup copy.</p>';
    echo get_submit_button('Reset Options', 'secondary', 'wf-theme-reset-options');
    echo '</form>';
    echo '</div>';
    // wrap
}