[theme-reviewers] Function submit_button()
Doug Stewart
zamoose at gmail.com
Tue Jul 26 02:39:55 UTC 2011
Okay, need to get this off my chest:
This particular example + the checked()/selected() stuff has been
driving me batty. They're examples of over-complication on WordPress'
part when perfectly viable pure PHP/HTML solutions are tried, true,
tested and far more approachable.
I mean, seriously, look at Chip's code (and not to single him out,
it's just the only code to point to here): it's complicated and
unusable/unapproachable without an XRef for the possible arguments. At
least in the past, a person with PHP experience had a chance to read a
simple ternary statment (in the case of checked()/selected()) or a
person with HTML savvy can read the plain meaning of the Submit
buttons. It's cleverness at the expense of readability/approachability
and I think it's a mistake.
Plus they're not even namespaced.
Gah.
Just my $.02.
On Mon, Jul 25, 2011 at 12:58 PM, Chip Bennett <chip at chipbennett.net> wrote:
> The submit_button() function is flexible enough to handle resetting to
> defaults. :)
> For example, here's my old code from Oenology (note that I pass a "tab" name
> to the button name attribute):
>
> <input name="theme_oenology_options[submit-<?php echo $tab; ?>]"
> type="submit" class="button-primary" value="Save Settings" />
> <input name="theme_oenology_options[reset-<?php echo $tab; ?>]"
> type="submit" class="button-secondary" value="Reset Defaults" />
>
> And here's the replacement code:
>
> <?php submit_button( __( 'Save Settings', 'oenology' ), 'primary',
> 'theme_oenology_options[submit-' . $tab . ']', false ); ?>
> <?php submit_button( __( 'Reset Defaults', 'oenology' ), 'secondary',
> 'theme_oenology_options[reset-' . $tab . ']', false ); ?>
>
> The rendered output is exactly the same in both cases.
> Assuming that your "reset defaults" functionality looks at the NAME
> attribute as part of the $_POST data passed to $input, then you're good to
> go.
> Chip
>
> On Mon, Jul 25, 2011 at 11:44 AM, George Mamadashvili
> <georgemamadashvili at gmail.com> wrote:
>>
>> Hello Chip.
>> I noticed that function too and liked it, but if theme author what to
>> provide "Reset to Default" button, does it still need to be hard-coded? I
>> had no to dig in this function, can we this function for reset button too?
>> Best
>> George
>>
>> On Mon, Jul 25, 2011 at 8:25 PM, Chip Bennett <chip at chipbennett.net>
>> wrote:
>>>
>>> Good morning developers/reviewers!
>>> Just a note, from something that I noticed being used in Twenty Eleven:
>>> the submit_button() function, which replaces hard-coded form submit buttons.
>>> I would strongly recommend making use of it in Theme Settings Page forms;
>>> as with other "doing things the core-supported way" criteria, I would expect
>>> this one to show up in the Guidelines at some point in the future.
>>> 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
>>
>
>
> _______________________________________________
> theme-reviewers mailing list
> theme-reviewers at lists.wordpress.org
> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>
>
--
-Doug
More information about the theme-reviewers
mailing list