[wp-trac] [WordPress Trac] #39441: Improve the Settings API for accessibility and ease of use.

WordPress Trac noreply at wordpress.org
Mon Jan 2 22:11:41 UTC 2017


#39441: Improve the Settings API for accessibility and ease of use.
-------------------------------------+-------------------------------------
 Reporter:  flixos90                 |       Owner:
     Type:  enhancement              |      Status:  new
 Priority:  normal                   |   Milestone:  Future Release
Component:  Plugins                  |     Version:
 Severity:  normal                   |  Resolution:
 Keywords:  settings-api has-patch   |     Focuses:  accessibility,
  2nd-opinion                        |  administration
-------------------------------------+-------------------------------------
Changes (by flixos90):

 * keywords:  needs-patch settings-api => settings-api has-patch 2nd-opinion


Comment:

 [attachment:39441.diff] is an initial take on the technical part of the
 improvements from the ticket description (except implementing the single
 array parameter support of `add_settings_field()`). What the patch does:
 * Support passing one out of a few predefined strings as the `$callback`
 parameter in `add_settings_field()`, which then refer to core callback
 functions (happens in `do_settings_fields()`): What these strings and
 core-supported field types are needs to be discussed, I just added a few
 very basic ones that I think we should support. Four of the five callbacks
 are actually not yet implemented and only exist for demonstration
 purposes.
 * Enhance the `$args` parameter in `add_settings_field()`. It now supports
 more arguments and does some sanitization by filling defaults in. The only
 complex new argument is probably the `value_callback` one: It will be used
 to fetch the current value for the field. It usually does not need to be
 used, as most developers are probably using a regular `get_option()` call
 here. The default value for this argument is a new function
 `get_settings_field_option()` which retrieves the option based on the
 field's `input_name` argument. The function also supports fetching option
 values for multidimensional names, similar how it happens currently in the
 Customizer.

 I also created a small plugin [attachment:settings-api-tests.php] that can
 be used to test this functionality. Note that some fields there won't have
 any output yet, simply because I didn't implement their functions yet, as
 I mentioned above.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39441#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list