[wp-trac] [WordPress Trac] #53807: Add function or filter to send all customizer setting default values to the database upon theme installation

WordPress Trac noreply at wordpress.org
Sun Aug 1 22:47:14 UTC 2021


#53807: Add function or filter to send all customizer setting default values to the
database upon theme installation
-----------------------------+-----------------------------
 Reporter:  curtiskessler    |       Owner:  (none)
     Type:  feature request  |      Status:  new
 Priority:  normal           |   Milestone:  Future Release
Component:  Customize        |     Version:
 Severity:  normal           |  Resolution:
 Keywords:  2nd-opinion      |     Focuses:
-----------------------------+-----------------------------

Comment (by curtiskessler):

 I decided to explicitly declare every default value in each instance of
 get_theme_mod() across my theme.

 This worked fine, although it was tedious. And if I ever decide to change
 the default values, the development process will require changing it in
 two locations instead of one.

 Declaring a default value in two locations seems needlessly redundant, and
 should probably be avoided if possible.

 I've just had an idea for how to solve this problem in the future. Perhaps
 the function get_theme_mod() could have an option for the default value
 argument, which instructs get_theme_mod() to fetch its default value from
 its customizer setting at the time the function is run.

 This would mean that if a theme developer sets up an instance of
 get_theme_mod() with the "fetch customizer value as default value" option
 enabled, during the rest of the development process, the developer can
 change the default values that display in both the customizer view and the
 front end view by only changing it in one location.

 Does this sound reasonable and feasible? I believe it would reduce the
 development work load while creating themes with high quantities of
 customizer settings and instances of get_theme_mod(), such as mine.

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


More information about the wp-trac mailing list