I totally agree with the namespacing thing. I wish core would practice what it preaches just a bit better with these kinds of functions.<div><br></div><div>But, my example was intentionally complex. Basic examples are pretty straightforward:</div>
<div><br></div><div><?php submit_button( $button_text, $button_type, $name, $wrapper ); ?></div><div><br></div><div>$button_text: button text</div><div>$button_type: 'primary' or 'secondary' (actually, quite useful, as it helps ensure button style fits WP UI)</div>
<div>$name: name attribute</div><div>$wrapper: (boolean) whether or not to wrap button in <p> tags.</div><div><br></div><div>So:</div><div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">
<div><?php submit_button( "Save Settings", 'primary', 'submit' ); ?></div><div><?php submit_button( "Reset Defaults", 'secondary', 'reset' ); ?></div></blockquote>
<div><br></div><div>Is all you really need.</div><div><br></div><div>And in the first case, you can even get away with:</div><div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">
<div><?php submit_button(); ?></div></blockquote><div><br></div><div>No need to pass any arguments whatsoever.</div><div><br></div><div>If I had to guess, I would guess that the objective here is to abstract away as much of the settings form markup as absolutely possible - which is an objective that I would actually agree with. By abstracting the form markup, it becomes MUCH easier to make UI changes in the future, in a way that will ensure forward-compatibility for existing code.</div>
<div><br></div><div>Chip</div><div><br><div class="gmail_quote">On Mon, Jul 25, 2011 at 9:39 PM, Doug Stewart <span dir="ltr"><<a href="mailto:zamoose@gmail.com">zamoose@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Okay, need to get this off my chest:<br>
This particular example + the checked()/selected() stuff has been<br>
driving me batty. They're examples of over-complication on WordPress'<br>
part when perfectly viable pure PHP/HTML solutions are tried, true,<br>
tested and far more approachable.<br>
<br>
I mean, seriously, look at Chip's code (and not to single him out,<br>
it's just the only code to point to here): it's complicated and<br>
unusable/unapproachable without an XRef for the possible arguments. At<br>
least in the past, a person with PHP experience had a chance to read a<br>
simple ternary statment (in the case of checked()/selected()) or a<br>
person with HTML savvy can read the plain meaning of the Submit<br>
buttons. It's cleverness at the expense of readability/approachability<br>
and I think it's a mistake.<br>
<br>
Plus they're not even namespaced.<br>
<br>
Gah.<br>
<br>
Just my $.02.<br>
<div><div></div><div class="h5"><br>
On Mon, Jul 25, 2011 at 12:58 PM, Chip Bennett <<a href="mailto:chip@chipbennett.net">chip@chipbennett.net</a>> wrote:<br>
> The submit_button() function is flexible enough to handle resetting to<br>
> defaults. :)<br>
> For example, here's my old code from Oenology (note that I pass a "tab" name<br>
> to the button name attribute):<br>
><br>
> <input name="theme_oenology_options[submit-<?php echo $tab; ?>]"<br>
> type="submit" class="button-primary" value="Save Settings" /><br>
> <input name="theme_oenology_options[reset-<?php echo $tab; ?>]"<br>
> type="submit" class="button-secondary" value="Reset Defaults" /><br>
><br>
> And here's the replacement code:<br>
><br>
> <?php submit_button( __( 'Save Settings', 'oenology' ), 'primary',<br>
> 'theme_oenology_options[submit-' . $tab . ']', false ); ?><br>
> <?php submit_button( __( 'Reset Defaults', 'oenology' ), 'secondary',<br>
> 'theme_oenology_options[reset-' . $tab . ']', false ); ?><br>
><br>
> The rendered output is exactly the same in both cases.<br>
> Assuming that your "reset defaults" functionality looks at the NAME<br>
> attribute as part of the $_POST data passed to $input, then you're good to<br>
> go.<br>
> Chip<br>
><br>
> On Mon, Jul 25, 2011 at 11:44 AM, George Mamadashvili<br>
> <<a href="mailto:georgemamadashvili@gmail.com">georgemamadashvili@gmail.com</a>> wrote:<br>
>><br>
>> Hello Chip.<br>
>> I noticed that function too and liked it, but if theme author what to<br>
>> provide "Reset to Default" button, does it still need to be hard-coded? I<br>
>> had no to dig in this function, can we this function for reset button too?<br>
>> Best<br>
>> George<br>
>><br>
>> On Mon, Jul 25, 2011 at 8:25 PM, Chip Bennett <<a href="mailto:chip@chipbennett.net">chip@chipbennett.net</a>><br>
>> wrote:<br>
>>><br>
>>> Good morning developers/reviewers!<br>
>>> Just a note, from something that I noticed being used in Twenty Eleven:<br>
>>> the submit_button() function, which replaces hard-coded form submit buttons.<br>
>>> I would strongly recommend making use of it in Theme Settings Page forms;<br>
>>> as with other "doing things the core-supported way" criteria, I would expect<br>
>>> this one to show up in the Guidelines at some point in the future.<br>
>>> Chip<br>
>>> _______________________________________________<br>
>>> theme-reviewers mailing list<br>
>>> <a href="mailto:theme-reviewers@lists.wordpress.org">theme-reviewers@lists.wordpress.org</a><br>
>>> <a href="http://lists.wordpress.org/mailman/listinfo/theme-reviewers" target="_blank">http://lists.wordpress.org/mailman/listinfo/theme-reviewers</a><br>
>>><br>
>><br>
>><br>
>> _______________________________________________<br>
>> theme-reviewers mailing list<br>
>> <a href="mailto:theme-reviewers@lists.wordpress.org">theme-reviewers@lists.wordpress.org</a><br>
>> <a href="http://lists.wordpress.org/mailman/listinfo/theme-reviewers" target="_blank">http://lists.wordpress.org/mailman/listinfo/theme-reviewers</a><br>
>><br>
><br>
><br>
> _______________________________________________<br>
> theme-reviewers mailing list<br>
> <a href="mailto:theme-reviewers@lists.wordpress.org">theme-reviewers@lists.wordpress.org</a><br>
> <a href="http://lists.wordpress.org/mailman/listinfo/theme-reviewers" target="_blank">http://lists.wordpress.org/mailman/listinfo/theme-reviewers</a><br>
><br>
><br>
<br>
<br>
<br>
</div></div>--<br>
<font color="#888888">-Doug<br>
</font><div><div></div><div class="h5">_______________________________________________<br>
theme-reviewers mailing list<br>
<a href="mailto:theme-reviewers@lists.wordpress.org">theme-reviewers@lists.wordpress.org</a><br>
<a href="http://lists.wordpress.org/mailman/listinfo/theme-reviewers" target="_blank">http://lists.wordpress.org/mailman/listinfo/theme-reviewers</a><br>
</div></div></blockquote></div><br></div>