WordPress.org

Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#11143 closed defect (bug) (fixed)

do_settings_fields() is not calling on additional arguments from add_settings_field()

Reported by: hanilovesme Owned by:
Milestone: 2.9 Priority: normal
Severity: normal Version: 2.8.5
Component: Administration Keywords: has-patch
Focuses: Cc:

Description

According to the codex, the function add_settings_field() accepts a callback function, and additional arguments, as two of its parameters. It then passes this date to do_settings_field().

However, do_settings_field() calls the callback function, but ignores the additional arguments:

call_user_func($field[ 'callback' ]); <--- wouldn't $field[ 'args' ] be called as the second argument here?

Attachments (2)

do_settings_fields.diff (449 bytes) - added by scribu 9 years ago.
do_settings_fields.2.diff (443 bytes) - added by scribu 9 years ago.

Download all attachments as: .zip

Change History (7)

#1 @hanilovesme
9 years ago

  • Summary changed from additional arguments from add_settings_field do not get called on do_settings_fields to do_settings_fields() is not calling on additional arguments from add_settings_field()

#2 @scribu
9 years ago

  • Component changed from General to Administration
  • Keywords has-patch added
  • Milestone changed from Unassigned to 2.9

#3 follow-up: @ryan
9 years ago

call_user_func_array() will result in all of the array keys being lost. We should probably use call_user_func() and pass the whole args array in tact as one argument.

#4 in reply to: ↑ 3 @scribu
9 years ago

Replying to ryan:

call_user_func_array() will result in all of the array keys being lost. We should probably use call_user_func() and pass the whole args array in tact as one argument.

You're right; forgot about that. Patch updated.

#5 @automattor
9 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [12220]) Pass args to settings field callback. Props hanilovesme, scribu. fixes #11143

Note: See TracTickets for help on using tickets.