[theme-reviewers] Theme-Check plugin and textdomain

Otto otto at ottodestruct.com
Wed Jan 19 18:42:22 UTC 2011


Note, to use this with the settings API is easy. Just modify your
validation function slightly. Instead of validating and returning the
newly validated values, you validate, then call set_theme_mod on them
independently to set them in the database. Then you have the
validation function return false or something.

-Otto



On Wed, Jan 19, 2011 at 12:36 PM, Otto <otto at ottodestruct.com> wrote:
> On Wed, Jan 19, 2011 at 12:30 PM, Muhammad Khairul Syahir Abdul Hakim
> <khairulsyahir at gmail.com> wrote:
>> I'm actually using the settings api to store the theme's settings as a
>> single array in the db.
>
> That is one way to do it, but the theme mod system does that too, and
> was made specifically for themes. So you might consider it as an
> alternate approach.
>
> It is very simple, actually. To set an option, you do this:
>
> set_theme_mod('option_name',$value);
>
> To get that option back, you do this:
>
> $value = get_theme_mod('option_name', $default);
>
> That will return the stored value or the $default if there isn't one.
> Removing an option can be done with:
>
> remove_theme_mod('option_name');
>
> The options are stored specific to your theme, and in one big
> serialized array, although really that is abstracted out for you.
>
> Other functions:
> get_theme_mods() will return the big array of your options if you want.
> remove_theme_mods() removes the array from the DB, thus clearing your settings.
>
> -Otto
>


More information about the theme-reviewers mailing list