I’ve been writing WordPress themes for these past two years. Some of them are very simple and some others are quite complex. These themes need a settings panel so the user (or the site admin) can configure their site comfortably. There are many methods around the interwebs on how you can create such a settings panel for your theme/plugin. I tried to adapt some of them into my themes, but there was always something wishpering in my ear telling me to write my own settings panel with my own way :) .
The closest thing I found was the method used by Hybrid, Justin Tadlock‘s very powerful theme framework. However, it lacks some features I need, and it’s not too comfortable to work with. I like the way it uses the metaboxes to present the options though, it’s very WordPress :)
So I began playing with Hybrid’s code and altered the way it handles the options, but keep the presentation intact. I got it working the way I wanted it to, until I need to add another feature (other option type and validation). I came across Otto’s article about WordPress’ Setting API and it inspired to rewrite the code.
After a few fun days, I finally got it right and made it as a plugin so everyone can use it in their project. It still lacks some features (like file upload), but (I think) the base code is easy enough to modify so it won’t take long before I add them :)
For you WordPress lovers out there, here I present my very first public plugin, KC Settings.
Update:
This plugin is now hosted at WordPress plugins directory.
I’ve included a readme.html file so you should read it before using the plugin. The documentation is not complete yet, but should be enough to get you started. Any questions, bug reports, please feel free to contact me.
Love this plugin – it made my life much much easier. One thing I’d also like to see added, though, if you are taking requests is the option to enter a “date” using some other plugin (jquery ui, for example). Thanks for a great plugin!
Thanks for trying out the plugin Joshua and I’m glad that you find it useful. I’m still adding new option types and will try to implement your great idea.
Great plugin, i love it!
i’m triyng to do something similar to multi-input but referred to the whole meta box.
do you have any ideas for that?
thanks
Thanks for using the plugin, Luigi.
Could you explain more about the whole metabox? The current multiinput type has a javascript bug in it (just discovered it a few days ago) and I will make the fix. It’d be lovely if I could integrate your idea/need into the fix.
sure!
i create, for example, a metabox for posts named “meta-1″. inside i put a multi-input field.
using the script to add/remove multi-input fields, i’m trying to add (or remove) meta boxes.
for the example i’d like to add a “meta-2″ box with another multi-input field.
i hope you uderstand what i’m triyng to do… :)
Excellent plug-in!
However, I recently realized a potential limitation concerning the treatment of custom callback functions.
Particularly, I had to add metadata to custom taxonomy terms, introducing the featured post dropdown list. For every term a user can select at most one post as a featured post for that term. In order to populate the dropdown list, I had to write a custom callback function, but I couldn’t find a way to acquire a reference to the term object itself. I then modified the kc_settings_field function inside form.php so that it passes $object_id and $db_value when calling the callback function. Although $db_value is not necessary, I found it practical not to query the database twice.
If you think that there is a more elegant solution for acquiring the term object, I would be very happy to hear it. If not, this could be a handy addition for the next version of this great plugin.
Thank you for using the plugin and giving a very valuable feedback Tan!
My idea is to pass two arguments to the callback function:
$args, and$db_value. You will then be able to get all field data from$args, including the$object_id. The old'args'key will not be passed directly to the callback function but you’ll still be able to get it from the$argsarray, so you may need to modify your callback function when I push the update (in a day or two hopefully).Hi this is a really great plugin, thanks :)
Excuse if this is a silly question but I have been looking through the documentation and cannot find how to output the values of the fields into the template files. I have image urls and links. Im used to working with custom fields but in this case Im using plugin / theme settings.
A bit of feedback from my experience, not sure how hard this would be to address or if its worth it but when you make lots of sections and fields (in theme and plugin settings) all the blocks build up quite a lot. It would be great if you could minimise the sections you aren’t working on.
Hi Steve, thank you for using the plugin.
getting the value of theme/plugin options is quite simple:
You can also ommit the field ID to get the value of a section, or ommit the section ID to get all values of the plugin/theme setting.
By minimizing, did you mean expand/collapse like the metaboxes? I will try to implement this in the next update. Thanks for the suggestion! :)