Enjoy our 5th post of our Advent Calendar: More and more WordPress themes, especially commercial themes, have an option page. The settings are stored in the database. Only few themes have an uninstall button to delete these settings in your database.
Here is a solution, which is easy to implement for every theme developer:
Now we have to add some code and the entries in your database are gone.
if (isset($_POST['your_preffix_uninstall'])) {
delete_option('your_theme_options');
update_option('template', 'default');
update_option('stylesheet', 'default');
delete_option('current_theme');
$theme = get_current_theme();
do_action('switch_theme', $theme);
$redirect = 'themes.php';
}
Everyone who is still saving every option seperately have to expand this line of code of course delete_option('your_theme_options')
. 😉 Therefore it is better to save the settings in an array or object. More details are available at Working With Options
Comments
3 responses to “5th Post Of Our Advent Calendar: Theme Uninstaller”
Great tip! i was looking for that, thanks! 🙂
[…] мотивам: wpengineer.com Подписатся на обновления блога:Подписаться по […]
Am implementing this in my Connections Reloaded theme. Have a new release scheduled for this week!