[theme-reviewers] Theme Activation Hook

Chip Bennett chip at chipbennett.net
Thu Oct 24 11:49:00 UTC 2013


There is a much better way; in fact, if the Theme is saving default option
settings to the database, it is inherently _doing_it_wrong().

Try this, instead:

wp_parse_args( get_option( 'theme_themeslug_options', array() ),
$option_default_values );


(Side note: "theme_options" is not an appropriately namespaced option name.)

This is but one of a few ways to handle the use of (as Otto would say) sane
defaults. I've been considering proposing a change to the Guidelines that
would prohibit Themes from saving default options to the database. The only
way option settings should ever get saved to the database is when the
*user* does so.


On Thu, Oct 24, 2013 at 4:30 AM, Towfiq I. <tislam100 at gmail.com> wrote:

> Are we allowed to use:
>
> *if (is_admin() && isset($_GET['activated'] ) && $pagenow == "themes.php"
> ) {**}*
> *
> *
> *
> *
> *example:*
> *---------------------
> *if (is_admin() && isset($_GET['activated'] ) && $pagenow == "themes.php"
> ) {
>   $option_default_values = array(
> "block1_text_id" => "Lorem Ipsum",
> "block1_textarea_id" => "Lorem Ipsum blah blah blah");
>
> update_option('theme_options', $option_default_values);
> }
> --------------------------
>
> if we are not, what should we use instead?
> after_setup_theme doesnt work btw.
>
> or should we use after_switch_theme?
>
> Thanks
> --
> Towfiq I.
>
> _______________________________________________
> theme-reviewers mailing list
> theme-reviewers at lists.wordpress.org
> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wordpress.org/pipermail/theme-reviewers/attachments/20131024/f1583afe/attachment.html>


More information about the theme-reviewers mailing list