[theme-reviewers] Theme Activation Hook
Otto
otto at ottodestruct.com
Thu Oct 24 16:49:02 UTC 2013
Note that at some point in the nebulous future, if your theme saves
"default options" to the database and relies on that working, then it
will very likely be broken-as-heck in the theme previewer. My long
term plan there is to make a database for it, then make the whole
thing completely read-only. No saving of anything to the database,
period.
So make sure you're using defaults correctly. Default settings are the
one you use when there are *no* settings in the database or anywhere
else. You should not rely on being able to "write" to anywhere to have
the thing work properly.
-Otto
On Thu, Oct 24, 2013 at 3:35 AM, Konstantin Kovshenin
<kovshenin at gmail.com> wrote:
> Why are you trying to write the default options to the database? You can
> just use $options = get_option( 'your_theme_options', $defaults ); and
> update them only if they've changed on your options page. I would also
> suggest looking into theme mods and not options:
> https://codex.wordpress.org/Function_Reference/get_theme_mod
>
>
> On Thu, Oct 24, 2013 at 12:30 PM, 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
>>
>
>
>
> --
> Konstantin
>
> _______________________________________________
> theme-reviewers mailing list
> theme-reviewers at lists.wordpress.org
> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>
More information about the theme-reviewers
mailing list