PhotoDune

Settings API vs. Old School Theme Options

2000 posts
  • United States
  • Bought between 50 and 99 items
  • Has been a member for 3-4 years
  • Exclusive Author
ThemeOcean says
bitfade said
with settings API , you have to use php for everything.

Is that supposed to be a good thing?

960 posts
  • Sold between 100 and 1 000 dollars
  • Has been a member for 3-4 years
  • Bought between 10 and 49 items
  • Exclusive Author
  • Microlancer Beta Tester
  • United States
fillerspace says
landonw said
bitfade said
with settings API , you have to use php for everything.
Is that supposed to be a good thing?
i think he was saying that’s a bad thing…why go through the hassle of using php to generate your JavaScript and CSS when you could just write it directly?
589 posts
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Has been a member for 2-3 years
  • Europe
  • Exclusive Author
  • Referred between 10 and 49 users
  • Bought between 100 and 499 items
WPScientist says
fillerspace said
landonw said
bitfade said
with settings API , you have to use php for everything.
Is that supposed to be a good thing?
i think he was saying that’s a bad thing…why go through the hassle of using php to generate your JavaScript and CSS when you could just write it directly?

Two questions:

1) What do you mean you have to generate JS and CSS with PHP ? (sub-question: how does it generate it?)

2) What do you mean by writing JS and CSS directly?

JS and CSS are things completely unrelated to how you make the theme options panel. You create a CSS file and a JS file then using add_action() and WordPress enqueue functions insert them on the page.

1025 posts
  • Author had a File in an Envato Bundle
  • Bought between 50 and 99 items
  • Elite Author
  • Exclusive Author
  • Has been a member for 4-5 years
  • Referred between 500 and 999 users
  • Sold between 250 000 and 1 000 000 dollars
+1 more
ThemeBlvd says

I think that if you were creating a simple theme that’s not loaded with options, you can save yourself a lot of time by just using the Settings API . You don’t have to plan out any of your HTML markup, create any CSS or javascript, etc. Wam, Bam, finished, and the user has a simple interface they already know how to use. However, for me personally, I like to jazz everything up, so I’ll continue to stay away from the Settings API … and apparently people in the WordPress community will continue to dislike me, I suppose :-)

589 posts
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Has been a member for 2-3 years
  • Europe
  • Exclusive Author
  • Referred between 10 and 49 users
  • Bought between 100 and 499 items
WPScientist says
ThemeBlvd said
I think that if you were creating a simple theme that’s not loaded with options, you can save yourself a lot of time by just using the Settings API . You don’t have to plan out any of your HTML markup, create any CSS or javascript, etc. Wam, Bam, finished, and the user has a simple interface they already know how to use. However, for me personally, I like to jazz everything up, so I’ll continue to stay away from the Settings API … and apparently people in the WordPress community will continue to dislike me, I suppose :-)

Well from what i can see none of us is a fan of the Settings API :)

And you can build your own “framework” for the theme options panel and reuse it for every project. Much easier to just populate an array with options you need then to create it from scratch every time :)

1844 posts
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Author had a File in an Envato Bundle
  • Has been a member for 4-5 years
  • Author had a Free File of the Month
  • Won a Competition
  • Bought between 10 and 49 items
+4 more
bitfade says

using php to generate form markup can be ok if you don’t need complex layouts

but when you start using widgets like tabs, accordions, etc and/or need to alter layout/options values at runtime in response to user action, this approach is very limiting

no matter how much you extend your framework trying to deal with all possible situations, you’ll often find yourself in a point where you need more control

I rely on ajax/json to exchange data, using static html for the layout and javascript to handle runtime changes/dynamic data is a natural choice and gives me the control i need in all possible sitations.

589 posts
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Has been a member for 2-3 years
  • Europe
  • Exclusive Author
  • Referred between 10 and 49 users
  • Bought between 100 and 499 items
WPScientist says
bitfade said
using php to generate form markup can be ok if you don’t need complex layouts

but when you start using widgets like tabs, accordions, etc and/or need to alter layout/options values at runtime in response to user action, this approach is very limiting

no matter how much you extend your framework trying to deal with all possible situations, you’ll often find yourself in a point where you need more control

I rely on ajax/json to exchange data, using static html for the layout and javascript to handle runtime changes/dynamic data is a natural choice and gives me the control i need in all possible sitations.

I actually think for complex theme options panel using PHP to make it all dynamic (automatic) is the best way to go.

3256 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Exclusive Author
  • Interviewed on the Envato Notes blog
  • Beta Tester
  • Author had a File in an Envato Bundle
  • Author had a Free File of the Month
+4 more
ParkerAndKent says

I keep only the js and the css outside, obviously.

The html of my options is printed by php. I find this solution the only way to go. I set my options in multidimensional arrays, that I can use them to create forms for the theme options, for the metaboxes and for the shortcodes generator… each form element has a dedicated function for the ouput, simple or complex… so if I edit an element it has effect everywhere.

I don’t think you can do all this by using the settings api, that is dedicated only for the options. So if i have to use that for the options and my framework for shortcodes and metaboxes I would need useless additional work and code.

1844 posts
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Author had a File in an Envato Bundle
  • Has been a member for 4-5 years
  • Author had a Free File of the Month
  • Won a Competition
  • Bought between 10 and 49 items
+4 more
bitfade says
WPScientist said
I actually think for complex theme options panel using PHP to make it all dynamic (automatic) is the best way to go.
Opposite side of the coin here.

to store fields, rules, error messages, behaviours in object/arrays and add tons of server side code to generate all the possible form markup variations it may work for others but has always failed to me
589 posts
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Has been a member for 2-3 years
  • Europe
  • Exclusive Author
  • Referred between 10 and 49 users
  • Bought between 100 and 499 items
WPScientist says
bitfade said
WPScientist said
I actually think for complex theme options panel using PHP to make it all dynamic (automatic) is the best way to go.
Opposite side of the coin here.

to store fields, rules, error messages, behaviours in object/arrays and add tons of server side code to generate all the possible form markup variations it may work for others but has always failed to me

What variations, you need: input(text), textarea, select, checkbox, radio and upload. What else is there.

Adding a new option is like:

$options[] = array( 'title' => 'Field title',
                    'desc'  => 'Here goes the description for this field.',
                    'id'    => 'the_field_id',
                    'std'   => 'default value',
                    'type'  => 'text' );

The system takes care of everything else for this option.

by
by
by
by
by