WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#19809 closed defect (bug) (invalid)

can't pass an array(class, method) as a callback in add_settings_field()

Reported by: mati1000 Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.3.1
Component: General Keywords: close
Focuses: Cc:

Description

I want to pass an array(class, method) as a callback for a settings field:

add_settings_field($field, $label, array(&$this, $method) , $slug, $section, $field);

But 'do_settings_sections' don't do a check like 'add_filter()' and it's used as string with 'call_user_func' in wp-admin/includes/template.php:1103

Change History (5)

comment:1 @mati10004 years ago

The PHP error is:
Warning: call_user_func() [function.call-user-func]: First argument is expected to be a valid callback in /wp-admin/includes/template.php on line 1102

comment:2 @nacin4 years ago

call_user_func can handle callbacks including array(class, method). There's no requirement that the callback is a string. Your issue is likely that whatever you are passing does not calculate to be a valid callback.

comment:3 @mati10004 years ago

You are right, it's handle it and it work for me, but I get the php error...

comment:4 @solarissmoke4 years ago

  • Keywords close added

comment:5 @SergeyBiryukov4 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Feel free to reopen with more exact steps to reproduce if there's still a problem.

Note: See TracTickets for help on using tickets.