[wp-trac] [WordPress Trac] #36633: Customizer Doesn't Save Defaults in The Database for a Theme

WordPress Trac noreply at wordpress.org
Fri Apr 22 13:09:42 UTC 2016


#36633: Customizer Doesn't Save Defaults in The Database for a Theme
--------------------------------+------------------------------
 Reporter:  mrahmadawais        |       Owner:
     Type:  enhancement         |      Status:  closed
 Priority:  normal              |   Milestone:  Awaiting Review
Component:  Customize           |     Version:  trunk
 Severity:  normal              |  Resolution:  wontfix
 Keywords:  dev-feedback close  |     Focuses:
--------------------------------+------------------------------

Comment (by mrahmadawais):

 Replying to [comment:2 kuus]:
 > Hello, for what I understood from your comment this is not a bug and
 does not have anything to do with the customizer. Default values are not
 meant to be stored in the database, in fact themes should use ''''sane
 defaults'''' (see article https://make.wordpress.org/themes/2014/07/09
 /using-sane-defaults-in-themes/).
 >
 > In your specific case I guess you should simply show the social box
 unless the value retrieved is true, for instance (pseudo code): `<?php if
 ( ! get_theme_mod('hide_box') ) { ?>box template<?php } ?>`
 >
 > feel free to reopen if I misunderstood your ticket

 Well, think about this. I have 10 social icons in this theme and I have
 enabled 5 of them by default while the rest of them are false by default.
 If Customizer default option is not meant to be saved in the database, it
 is kind of against DRY. I will have to keep defaults in the customizer as
 well as in the theme file where they are being used. One set of default
 options should be enough, what do you suggest in this case?

 BTW I didn't report a bug, it's tagged under `enhancement`. I know and
 have read sane defaults article before.

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


More information about the wp-trac mailing list