[theme-reviewers] Themes are required to save options in a single array
sayontan at gmail.com
Mon Feb 6 21:39:10 UTC 2012
I have done this in my theme, where all options pages write to the same
array using the Settings API. However it is not a piece of code that I
would want to write from scratch again - it is just not worth the trouble.
You can take a look at Chip's tutorial on this topic. That does a very good
job of handling a fairly complex scenario. I have a comment on that post
that says how you can handle multiple options pages:
The problem is this: you have 2 forms and you are, at any point of time
submitting only one of them. So "Form 2" fields will be missing when you
are submitting "Form 1" and vice versa, which blanks out the options
pertaining to the form that is not being submitted. To tackle this, I made
use of the fact that I already know what my fields are in the back-end. If
I am getting the input for Form 1, I simply populate the registered setting
with all the option values corresponding to the fields in Form 2. That way
the array I am trying to save is always complete.
On Mon, Feb 6, 2012 at 1:26 PM, Bruce Wampler <weavertheme at gmail.com> wrote:
> Using SAPI and more than one db option:
> This is a difficult question. In my own theme, I have found there are
> really serious issues with the Settings API when trying to track two sets
> of settings with more than a single HTML form - it tends to reset values
> back to false in a way I've never been able to figure out. I ended up
> settings groups, but wrapping all the settings in what is essentially is a
> single <form>, so all the settings are in one db entry. It was not easy to
> From recent discussions on this group, it looks like it would be
> worthwhile investigating using *_theme_mod functions to keep theme settings
> instead of the general settings. There was a link to an article by Otto on
> how to use the SAPI validation function differently to keep the SAPI
> features while using theme_mod instead.
> I haven't tried this yet, but think that perhaps the only one data base
> entry rules should eventually be replaced with use theme_mod instead - if
> it really can be compatible with SAPI.
> It should be fairly easy to add a check in the theme to provide an
> automatic conversion from the general settings to theme_mod.
> But this is not an easy thing - especially for themes with lots of
> Bruce Wampler
> Weaver II theme
> theme-reviewers mailing list
> theme-reviewers at lists.wordpress.org
http://mynethome.net | http://mynethome.net/blog
Beating Australia in Cricket is like killing a celebrity. The death gets
more coverage than the crime.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the theme-reviewers