[wp-trac] [WordPress Trac] #26817: WP_Customize_Setting default value set to empty string by default

WordPress Trac noreply at wordpress.org
Mon Feb 3 19:13:05 UTC 2014


#26817: WP_Customize_Setting default value set to empty string by default
-------------------------+------------------------------
 Reporter:  bassjobsen   |       Owner:
     Type:  enhancement  |      Status:  closed
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Appearance   |     Version:  3.8
 Severity:  normal       |  Resolution:  invalid
 Keywords:               |     Focuses:
-------------------------+------------------------------

Comment (by obenland):

 Replying to [comment:3 bassjobsen]:
 > So in add_setting() the second paramter $args is required and has a
 required key (default).

 `add_setting()` is defined
 [https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class-wp-
 customize-manager.php#L520 here]. The first argument is `$id`, which is
 required (nothing assigned to it), the second argument, `$args`, is set to
 be an empty array if nothing gets passed. So no, `$args` is not required.

 Since the default here is an empty array, we can ''assume'' that it
 doesn't have a required key either.
 [https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class-wp-
 customize-setting.php#L25 Looking at the constructor] in
 `WP_Customize_Setting`, we see that it gets all default properties of that
 class and loops through the `$args` array on the hunt for new values.
 Since all properties have a defined value (including `$default`, which is
 an empty string), we now ''know'' that there is no required key necessary.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/26817#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list