Make WordPress Core

Opened 15 years ago

Closed 14 years ago

#14149 closed enhancement (wontfix)

Introduce register_settings()

Reported by: nacin's profile nacin Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Administration Keywords: has-patch
Focuses: Cc:

Description

Introduce register_settings() as a wrapper for register_setting().

Currently, you need to loop on register_setting(), or some try to use the add_option_whitelist function or filters (which was originally introduced partially as a private helper and partially for bulk adds -- http://mu.wordpress.org/forums/topic/7415, #11730). It's ugly. We can make it better.

Untested patch. It takes either array( option, option, option ) or array( option => callback, option => callback ).

Attachments (2)

14149.diff (1.3 KB) - added by nacin 15 years ago.
141419-2.diff (964 bytes) - added by blepoxp 15 years ago.
Takes a mixed array to allow some options have callbacks while others dont'

Download all attachments as: .zip

Change History (7)

@nacin
15 years ago

#1 follow-up: @blepoxp
15 years ago

I'll test this momentarily. If this is introduced we probably should introduce an unregister_settings function at the same time.

#2 in reply to: ↑ 1 @nacin
15 years ago

Replying to blepoxp:

I'll test this momentarily. If this is introduced we probably should introduce an unregister_settings function at the same time.

Yep. Didn't get that far.

#3 @blepoxp
15 years ago

What do you think about the attached .diff? It would allow for options array to be a mixed index / associative array where indexed == no callback and associative == callback. ie:

$options = array( 'option_one', 'option_two' => 'option_two_callback', 'option_three' );

@blepoxp
15 years ago

Takes a mixed array to allow some options have callbacks while others dont'

#4 @nacin
14 years ago

Tempted to wontfix. Bulk adds should be relatively rare as most people are going to use a single option and serialize it.

If someone wants to loop through using an array and foreach, that seems amenable and allows for customization.

Especially with the callback, register_settings() only looks unnecessarily complex. Better for someone to loop themselves.

#5 @nacin
14 years ago

  • Milestone 3.1 deleted
  • Resolution set to wontfix
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.