[wp-trac] [WordPress Trac] #49421: Cannot use conversion specifications in `theme mod` default values

WordPress Trac noreply at wordpress.org
Wed Feb 12 17:50:26 UTC 2020

#49421: Cannot use conversion specifications in `theme mod` default values
 Reporter:  jqz           |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Customize     |    Version:  5.3.2
 Severity:  normal        |   Keywords:
  Focuses:                |
 This is a follow-up to #34290.

 With the fix [46395] it is no longer possible to have a `theme_mod` which
 is itself a format string and has a default value which includes a
 conversion specification, e.g.

   \get_theme_mod('site_copyright', 'Copyright %%1$s; all rights
   \get_bloginfo('name', 'display')

 With a double `%%`, the default string is now unchanged, but with a single
 `%` it is replaced with the ‘template directory’ URL.  It is now no longer
 possible to achieve the desired `%1$s` in the default string.

 Also, where the default is something like `100%`, the code supplying the
 default value to `get_theme_mod` now needs to test the WordPress version
 to know whether it should pass `100%` or `100%%`.

 A fix might be for the `sprintf` code path also to be followed if the
 string contains a double `%%`.  Or revert the change (so that the
 behaviour of `get_theme_mod` is more clearly defined as it was before -
 i.e. the default value is a format string and literal `%` signs need
 escaping as `%%`) and find another solution to the initial problem.

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

More information about the wp-trac mailing list