Code Modernization: Remove a single trailing percent sign before calling sprintf() on the $default parameter in get_theme_mod().

This avoids a "Missing format specifier at end of string" fatal error on PHP 8, and maintains the current behaviour.

See #50913.

git-svn-id: https://develop.svn.wordpress.org/trunk@49068 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2020-09-29 10:01:05 +00:00
parent f070145fa9
commit bf945a81ec

View File

@ -1024,6 +1024,8 @@ function get_theme_mod( $name, $default = false ) {
if ( is_string( $default ) ) {
// Only run the replacement if an sprintf() string format pattern was found.
if ( preg_match( '#(?<!%)%(?:\d+\$?)?s#', $default ) ) {
// Remove a single trailing percent sign.
$default = preg_replace( '#(?<!%)%$#', '', $default );
$default = sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() );
}
}