Add 'default' to register_setting
|Reported by:||rmccue||Owned by:||joehoyle|
|Component:||Options, Meta APIs||Keywords:||has-patch dev-feedback needs-dev-note needs-refresh|
Imagine a future where you don't need to pass your default settings every time you call get_option. Instead, you simply pass into register_setting once.
Attached patch does this. Also moves the register_setting group of functions from wp-admin to wp-includes/option.php to allow usage everywhere, rather than just in the admin. This is probably a Good Idea with the changes made in #37885, as register_setting is now also useful for the REST API, not just the admin.
This does do some funky meta-programming that sucks a bit: if you call get_option( 'option_name' ) without a default parameter, it uses the registered default. If you call get_option( 'option_name', false ), it uses the value you passed in (false) even though this is the default parameter value. This isn't great, but allows us to do this nicely with backwards compatibility and is somewhat less surprising.