Code Modernization: Use `str_starts_with()` in `WP_Theme_JSON` class methods.

This aims to make the code more readable and consistent, as the function is already used extensively in core files.

WordPress core includes a polyfill for `str_starts_with()` on PHP < 8.0 as of WordPress 5.9.

Follow-up to [55703], [55959].

Props spacedmonkey.
Fixes #58012.
Built from https://develop.svn.wordpress.org/trunk@55987


git-svn-id: http://core.svn.wordpress.org/trunk@55499 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2023-06-22 14:14:25 +00:00
parent f3ea3c57cb
commit b916b71dde
2 changed files with 3 additions and 3 deletions

View File

@ -3495,7 +3495,7 @@ class WP_Theme_JSON {
$prefix_len = strlen( $prefix );
$token_in = '|';
$token_out = '--';
if ( 0 === strpos( $value, $prefix ) ) {
if ( str_starts_with( $value, $prefix ) ) {
$unwrapped_name = str_replace(
$token_in,
$token_out,
@ -3519,7 +3519,7 @@ class WP_Theme_JSON {
$prefix = 'var:';
foreach ( $tree as $key => $data ) {
if ( is_string( $data ) && 0 === strpos( $data, $prefix ) ) {
if ( is_string( $data ) && str_starts_with( $data, $prefix ) ) {
$tree[ $key ] = self::convert_custom_properties( $data );
} elseif ( is_array( $data ) ) {
$tree[ $key ] = self::resolve_custom_css_format( $data );

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.3-alpha-55986';
$wp_version = '6.3-alpha-55987';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.