[wp-trac] [WordPress Trac] #21488: Add Default Callback Functions for add_settings_field()

WordPress Trac wp-trac at lists.automattic.com
Tue Aug 28 20:06:44 UTC 2012


#21488: Add Default Callback Functions for add_settings_field()
-------------------------+------------------------------
 Reporter:  mordauk      |       Owner:
     Type:  enhancement  |      Status:  reopened
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  General      |     Version:
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |
-------------------------+------------------------------

Comment (by mordauk):

 Replying to [comment:23 nacin]:
 > Rather than overloading add_settings_field()'s $callback argument with a
 type-like name (as scribu points out), why not just name the actual
 function there?
 > {{{
 > add_settings_field( 'upload_path', __( 'Upload path' ),
 'do_settings_text',
 >     'media', 'uploads',
 >     array(
 >          'id' => 'upload_path', // defaults to first argument,
 >          'name' => 'upload_path', // defaults to first argument, then
 ['id']
 >          'class' => 'regular-text code',
 >          'description' => __( 'Default is <code>wp-
 content/uploads</code>' ),
 > );
 > }}}

 I prefer overloading it instead because that allows the user to just pass
 "text" or "textarea" as the callback, which makes it simpler. If the
 callback isn't overloaded and just the function name is passed, then I
 think the default callback functions should be named something more
 intuitive, perhaps just "text_field", "textarea_field", etc.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/21488#comment:24>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list