I've written a custom theme which does some one-time setup chores after activation - things which I need to do every time I use it on a fresh copy of wordpress, like creating a nav menu and configuring discussion settings.
I've automated these things in my theme rather than a plugin because they are directly related to the theme and would have limited use elsewhere.
Anyway, what I'd like to do is after my theme is activated for the first time, show a popup box that will give the user a choice of whether or not to perform these actions. The code to do them is already working and written, but I don't have a mechanism for the user to start them off - my only real option here is to run them automatically by hooking into after_setup_theme
.
I've figured out how to tell if it's a first-time activation, using update_option
to store a boolean that I then check against - here's what I have:
function jp_theme_setup()
{
$installed = get_option('jp_installed');
if (!$installed)
{
update_option('jp_installed', true);
//set up my theme, do stuff involving things
//how can I ask the user whether or not to do certain actions?
}
}
add_action('after_setup_theme', 'jp_theme_setup');
How can I use a dialogue box to ask the user whether or not to perform these setup tasks?