wordpress-settings-api-class icon indicating copy to clipboard operation
wordpress-settings-api-class copied to clipboard

register_setting 3rd argument is array since 4.7.0

Open achchu93 opened this issue 5 years ago • 3 comments

Since WP 4.7.0 register_setting's 3rd parameter is an array. Please update it in the code...

achchu93 avatar Sep 14 '20 05:09 achchu93

it's already passed as array line 153 register_setting( $section['id'], $section['id'], array( $this, 'sanitize_options' ) );

maybe you should be more specific.

roidayan avatar Sep 15 '20 06:09 roidayan

@roidayan I think you should read the question correctly. See, on that line 153 the 3rd parameter is a callback. But as per the wordpress doc it should be an array. Within that array only you should have a key as 'sanitize_callback'. if you just send the callback function as third parameter we cant have type and other keys of array.

https://developer.wordpress.org/reference/functions/register_setting/

achchu93 avatar Sep 15 '20 07:09 achchu93

I see what you mean. Not sure it's important at all. It is backward compatible to allow passing only a callback. And then it will be treated as an array with a sanitize_callback key only. Do you hit any issue?

roidayan avatar Sep 19 '20 15:09 roidayan