Overview
ThemePlus includes a built-in Import / Export system accessible from the options panel. It lets you export all saved theme options to a JSON file and import them back at any time — on the same site or a different one. Use it to back up settings before making major changes, migrate settings between staging and production environments, or share a configuration across multiple sites running the same theme.
The Import / Export panel is located in the last tab of the ThemePlus options panel, labeled Import / Export.
Exporting Settings
- Open the ThemePlus options panel — Appearance → Theme Options in the WordPress admin.
- Navigate to the Import / Export tab.
- Click Export Settings.
- A JSON file named
themeplus-export-{date}.jsonis downloaded to your computer.
The exported file contains all currently saved option values as a flat JSON object keyed by option ID.
Example export file structure
json
{
"primary_color": "#2271b1",
"secondary_color": "#646970",
"body_typography": {
"font-family": "Inter",
"font-weight": "400",
"font-size": "16px",
"line-height": "1.6",
"color": "#1e1e1e"
},
"enable_preloader": true,
"header_layout": "standard",
"social_links": {
"facebook": "https://facebook.com/yourpage",
"twitter": "",
"instagram": "https://instagram.com/yourhandle"
}
}
Importing Settings
- Open the ThemePlus options panel — Appearance → Theme Options.
- Navigate to the Import / Export tab.
- Click Choose File and select a previously exported
.jsonfile. - Click Import Settings.
- The panel reloads with the imported values applied and saved.
Important: Importing will overwrite all current settings. Export your current settings first if you want to keep them.
Programmatic Export
You can retrieve all saved options in PHP using the helper function:
php
$all_options = themeplus_get_option();
$json = wp_json_encode( $all_options, JSON_PRETTY_PRINT );
Triggering a download via a custom admin page
php
add_action( 'admin_post_mytheme_export_options', function() {
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( esc_html__( 'Unauthorized', 'your-textdomain' ) );
}
check_admin_referer( 'mytheme_export_options' );
$options = themeplus_get_option();
$filename = 'themeplus-export-' . gmdate( 'Y-m-d' ) . '.json';
header( 'Content-Type: application/json' );
header( 'Content-Disposition: attachment; filename="' . $filename . '"' );
header( 'Pragma: no-cache' );
echo wp_json_encode( $options, JSON_PRETTY_PRINT );
exit;
});
Programmatic Import
You can import settings in PHP by writing directly to the options table. ThemePlus stores all values under a single WordPress option keyed by your opt_name.
php
function mytheme_import_options( array $new_options ): bool {
$opt_name = 'mytheme_options'; // Your opt_name value
$current_options = get_option( $opt_name, [] );
// Merge new values over current — remove array_merge to replace entirely
$merged = array_merge( $current_options, $new_options );
return update_option( $opt_name, $merged );
}
Importing from an uploaded JSON file
php
add_action( 'admin_post_mytheme_import_options', function() {
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( esc_html__( 'Unauthorized', 'your-textdomain' ) );
}
check_admin_referer( 'mytheme_import_options' );
if ( empty( $_FILES['import_file']['tmp_name'] ) ) {
wp_safe_redirect( admin_url( 'themes.php?page=mytheme-options&tab=import_export&error=no_file' ) );
exit;
}
$file = $_FILES['import_file']['tmp_name'];
$content = file_get_contents( $file );
$options = json_decode( $content, true );
if ( ! is_array( $options ) ) {
wp_safe_redirect( admin_url( 'themes.php?page=mytheme-options&tab=import_export&error=invalid_json' ) );
exit;
}
$opt_name = 'mytheme_options';
update_option( $opt_name, $options );
wp_safe_redirect( admin_url( 'themes.php?page=mytheme-options&tab=import_export&imported=1' ) );
exit;
});
Resetting to Defaults
The Import / Export tab also includes a Reset to Defaults button. Clicking it clears all saved option values and restores the defaults defined in your field registrations.
This action cannot be undone. Always export your settings first if you may want to restore them.
Programmatic reset
php
function mytheme_reset_options(): bool {
$opt_name = 'mytheme_options'; // Your opt_name value
return delete_option( $opt_name );
}
After calling delete_option(), ThemePlus will use the default values defined in each field registration on the next panel load.
Use Cases
Before a major redesign — Export current settings, make changes, and restore the export if the new direction does not work out.
Staging to production migration — Configure and refine settings on a staging site, export, then import to production in one step.
Multi-site deployments — Set up one site, export, and import the same configuration across multiple sites running the same theme.
Onboarding a new client — Provide a pre-configured JSON export file alongside the theme so clients start with sensible defaults already in place.
Notes
- The export file contains option values only — it does not export media library attachments. Image fields store attachment IDs, which will be different across sites. After importing on a new site, re-upload images and re-select them in Image and Gallery fields.
- Always verify the imported JSON file came from the same theme with the same
opt_name— importing a file from a different theme or a differentopt_namemay produce unexpected results. - The Import / Export tab is only accessible to users with the
manage_optionscapability.