Themes: In `get_theme_mod()`, only run the `sprintf()` replacement on the default value if there's a string format pattern found in the value.

This prevents standalone percent symbols from being stripped out, e.g. in a default value like `100%`.

Props aristath, kuus, moonomo, westonruter, davetgreen, daviedR, katielgc, noisysocks, SergeyBiryukov.
Fixes #34290.
Built from https://develop.svn.wordpress.org/trunk@46395


git-svn-id: http://core.svn.wordpress.org/trunk@46194 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2019-10-05 00:54:58 +00:00
parent 5fd25a6944
commit 83edc24762
2 changed files with 5 additions and 2 deletions

View File

@ -934,7 +934,10 @@ function get_theme_mod( $name, $default = false ) {
}
if ( is_string( $default ) ) {
$default = sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() );
// Only run the replacement if an sprintf() string format pattern was found.
if ( preg_match( '#(?<!%)%(?:\d+\$?)?s#', $default ) ) {
$default = sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() );
}
}
/** This filter is documented in wp-includes/theme.php */

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.3-beta2-46394';
$wp_version = '5.3-beta2-46395';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.