[theme-reviewers] Tutorial: Incorporating the Settings API in WordPress Themes

Daniel Tara contact at onedesigns.com
Fri Feb 18 22:18:34 UTC 2011


Hey Chip,

 

I just took the time to read your tutorial. (Yes I tweeted about it without
reading)

 

This was one piece on enlightenment, especially the settings sections part,
which I didn't know they work like hooks.

 

If anyone complains about the length of the article they're lazy. If you're
interested you can fly through it.

 

Just a few minor observations:

 

1.       register_setting( 'theme_oenology_options',
'theme_oenology_options', 'oenology_options_validate' );

This needs to be hooked to admin_init or it will return a "Call to undefined
function" error. I would also put it somewhere at the beginning, where it
makes more sense, since the whole article revolves around this call. You're
putting it on page 4, after you defined all the default options, settings
sections and some settings page options.

2.       You said the argument in settings_fields must be the same as the
option defined in register_setting(). It must actually be the same as the
defined options group (you did call it $options_group). I would stress this
however, since if they're not the same it returns an "Options page not
found" error and many grasp at it without knowing where this error came
from.

3.       Your article pwnz

 

Daniel

 

From: theme-reviewers-bounces at lists.wordpress.org
[mailto:theme-reviewers-bounces at lists.wordpress.org] On Behalf Of Rahul
Bansal
Sent: Friday, February 18, 2011 3:34 PM
To: Chip Bennett
Cc: theme-reviewers at lists.wordpress.org
Subject: Re: [theme-reviewers] Tutorial: Incorporating the Settings API in
WordPress Themes

 

Heading anchors, if it would be helpful for linking?

 

That will be equally helpful!

You can use any "table of content" plugin to automate it.

There are many plugins, which parse h2/h3 tags to generate that.

 

We provide file-upload for favicon & logo as of now.

In a current theme (underdev) we used register settings for it but quality
of our code is yet to be "certified" from theme review team!

So we have decided to wait to publish articles about our methods till our
next theme goes live here. ;-)

 

--
Rahul Bansal | Founder & CEO | rtCamp Solutions Pvt. Ltd.
Skype: rahul286 | Twitter: @rahul286 | Web: http://rtcamp.com/




On Fri, Feb 18, 2011 at 6:56 PM, Chip Bennett <chip at chipbennett.net> wrote:

I'll probably cross the "file upload" issue down the road - though, likely,
*far* down the road (as my Theme currently has no need for any user-uploaded
files). Maybe I'll add a "custom favicon" option (though my personal
preference is for favicons to be Plugin territory, and not tied to a
particular Theme).

 

I love Justin Tadlock's Series Plugin; I've made some use of it in the past.
The problem here was that I found it difficult to break the content up
logically in a way that would facilitate separate Posts. So, I went with
simple pagination instead.

 

Now that it's done, perhaps I can go back and do some editorial work, and at
least provide some Heading anchors, if it would be helpful for linking?

 

And, I'm happy to take the time for something like this. I like to write
posts like these, especially when I can document something as I'm learning
how to do it - both for my own memory, and to pass on anything useful that I
may have learned. It probably cost me the equivalent time away from
performing some Theme reviews, but part of the mission of the Theme Review
Team is also to provide an educational resource for Theme developers. So
hopefully the review queue will forgive me. :)

 

Chip

 

On Fri, Feb 18, 2011 at 7:16 AM, Rahul Bansal <rahul.bansal at rtcamp.com>
wrote:

Length is worth the info. Didn't get time to read in detail till now.

 

For ease of navigation, you may break articles into entirely different
pages/posts and bind them using a series plugin.

Other reason for this suggestion is that article in series will have their
own URLs that will have advantages like:

*	We can refer people to particular subtopic by sharing a unique post
article
*	permalinks will contain keywords like "Register Settings and Define
Form Sections/Fields" etc. This wil give better search engine visibility. I
am less concerned about traffic gain that wil result, but my intention is to
indirectly help Google give better article so developers can avoid following
"wrong" article.

Series creation may require 1-2 hours of extra time from you!

 

On sidenote, after taking quick overview, I felt that the article missed
information about "file upload" box. (I searched "upload" keyword on "all"
article page to crosscheck". Many times I find developers complaining
register_settings has issues with file-uploads. 

 

Thanks again for taking so much time to write something like this. :-)


--
Rahul Bansal | Founder & CEO | rtCamp Solutions Pvt. Ltd.
Skype: rahul286 | Twitter: @rahul286 | Web: http://rtcamp.com/




On Fri, Feb 18, 2011 at 6:27 PM, Chip Bennett <chip at chipbennett.net> wrote:

Thanks!

 

I was worried about the length of the article, but it didn't seem to make
sense to split it into multiple posts.

 

Do you think it would be useful to do a more slimmed-down follow-up post,
that leaves out some of the advanced topics, like Settings page tabs,
contextual help, etc.?

 

Chip

 

On Fri, Feb 18, 2011 at 6:51 AM, Rahul Bansal <rahul.bansal at rtcamp.com>
wrote:

Great article... :-)

 

Added to - http://make.wordpress.org/themes/about/resources/ (comments
section)

 

Timing is good as well! 10 pages gives a lot to explore on weekend! ;-)


--
Rahul Bansal | Founder & CEO | rtCamp Solutions Pvt. Ltd.
Skype: rahul286 | Twitter: @rahul286 | Web: http://rtcamp.com/




On Fri, Feb 18, 2011 at 9:11 AM, Chip Bennett <chip at chipbennett.net> wrote:

All,

 

I have just published a tutorial: Incorporating the Settings API in
WordPress Themes <http://bit.ly/hHjo6n> :

While others such as
<http://ottopress.com/2009/wordpress-settings-api-tutorial/> Otto and
<http://planetozh.com/blog/2009/05/handling-plugins-options-in-wordpress-28-
with-register_setting/> Ozh have done yeomen's work in explaining how to
implement the Settings API, I have not yet come across anything that really
put everything together, and explained the process and implementation from
beginning to end, in a way that even the less-experienced Theme developers
(like me) could easily understand.

This tutorial will attempt to fill that gap, by providing examples of
current (as of the pending release of WordPress 3.1) best-practice
implementation, not merely of the Settings API, but of Theme Options
implementation as a whole, including:

.         Registering options in the database as a single options array

.         Initializing default options

.         Creating a single Theme Settings page (with tabs)

.         Defining settings page sections and fields

.         Validating and white-listing user-input form data

.         Adding Settings Page contextual help

.         Enqueueing custom CSS for the Settings page

.         Implementing settings in the Theme template files

.         Enqueueing front-end CSS

 

Please give it a read; I hope it is helpful. Also, any feedback, comments,
corrections, criticism, etc. is welcome, so please comment!

 

Chip

 

_______________________________________________
theme-reviewers mailing list
theme-reviewers at lists.wordpress.org
http://lists.wordpress.org/mailman/listinfo/theme-reviewers

 

 


_______________________________________________
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/20110219/3fa0f750/attachment-0001.htm>


More information about the theme-reviewers mailing list