[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
Tue Jul 27 23:41:15 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:  Awaiting Review
Component:  Customize        |    Version:
 Severity:  normal           |   Keywords:
  Focuses:                   |
-----------------------------+-----------------------------
 I am learning theme development and developing my first WordPress theme
 from scratch.

 My new theme contains ''many'' customizer settings, most of which include
 default values.

 I discovered recently that upon theme installation, these customizer
 default values only appear in the customizer view, but are not entered
 into the database and are not shown on the front end.

 To insert the customizer default values into the database so that they
 display on the front end upon theme installation, I believe (?) each theme
 mod must be manually entered into the database by using set_theme_mod().

 This requires duplication of every default value twice within the theme
 code, and the addition of many lines of code for themes that create many
 new customizer settings.

 I recommend creating a function or filter that theme developers can
 activate within functions.php to send all default customizer values to the
 database upon theme installation.

 This will avoid having to duplicate default values in both add_setting()
 and set_theme_mod() and reduce lines of code in themes.

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


More information about the wp-trac mailing list