Backup Options" to export/import theme settings Based on "Gantry Export and Import Options" by Hassan Derakhshandeh Modified to work with Child Themes by OCWS @ http://www.oldcastleweb.com/pws/backing-up-theme-options/ Usage: 1. Add entire backup/restore snippet to functions.php 2. For more information, check out https://digwp.com/2014/04/backup-restore-theme-options/ */ class backup_restore_theme_options { function backup_restore_theme_options() { add_action('admin_menu', array(&$this, 'admin_menu')); } function admin_menu() { // add_submenu_page($parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function); // $page = add_submenu_page('themes.php', 'Backup Options', 'Backup Options', 'manage_options', 'backup-options', array(&$this, 'options_page')); // add_theme_page($page_title, $menu_title, $capability, $menu_slug, $function); $page = add_theme_page('Backup Options', 'Backup Options', 'manage_options', 'backup-options', array(&$this, 'options_page')); add_action("load-{$page}", array(&$this, 'import_export')); } function import_export() { $ocwsqt_option_name = get_option( 'stylesheet' ); if (isset($_GET['action']) && ($_GET['action'] == 'download')) { header("Cache-Control: public, must-revalidate"); header("Pragma: hack"); header("Content-Type: text/plain"); header('Content-Disposition: attachment; filename="'.$ocwsqt_option_name.'-options-'.date("dMy").'.dat"'); echo serialize($this->_get_options()); die(); } if (isset($_POST['upload']) && check_admin_referer('shapeSpace_restoreOptions', 'shapeSpace_restoreOptions')) { if ($_FILES["file"]["error"] > 0) { // error } else { $options = unserialize(file_get_contents($_FILES["file"]["tmp_name"])); if ($options) { foreach ($options as $option) { update_option($option->option_name, unserialize($option->option_value)); } } } wp_redirect(admin_url('themes.php?page=backup-options')); exit; } } function options_page() { ?>

Backup/Restore Theme Options

Backup/Export

Here are the stored settings for the current theme:

Download as file

Restore/Import

_get_options()); } function _get_options() { global $wpdb; $ocwsqt_option_name = get_option('stylesheet'); return $wpdb->get_results("SELECT option_name, option_value FROM {$wpdb->options} WHERE option_name = '". $ocwsqt_option_name ."'"); } } new backup_restore_theme_options();