Commit 45d3acd275 for wordpress.org
commit 45d3acd2755deeff16e8961a0df8def091b7bf54
Author: wildworks <wildworks@git.wordpress.org>
Date: Fri Sep 11 11:06:51 2026 +0000
Code Modernization: Use null coalescing operator in `WP_Block_Parser`
Two methods used a ternary that treats a falsy value as not provided even though the parameters accept `0` as valid input, so this switches to the null coalescing operator, which tests only for `null`.
Developed in: https://github.com/WordPress/wordpress-develop/pull/13484
Props mukesh27, wildworks.
See #65818.
Built from https://develop.svn.wordpress.org/trunk@63601
git-svn-id: http://core.svn.wordpress.org/trunk@62777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/class-wp-block-parser.php b/wp-includes/class-wp-block-parser.php
index c7e087ece8..3b50c8e30c 100644
--- a/wp-includes/class-wp-block-parser.php
+++ b/wp-includes/class-wp-block-parser.php
@@ -324,7 +324,7 @@ class WP_Block_Parser {
* @param null|int $length How many bytes of document text to output.
*/
public function add_freeform( $length = null ) {
- $length = $length ? $length : strlen( $this->document ) - $this->offset;
+ $length = $length ?? strlen( $this->document ) - $this->offset;
if ( 0 === $length ) {
return;
@@ -356,7 +356,7 @@ class WP_Block_Parser {
}
$parent->block->innerContent[] = null;
- $parent->prev_offset = $last_offset ? $last_offset : $token_start + $token_length;
+ $parent->prev_offset = $last_offset ?? $token_start + $token_length;
}
/**
diff --git a/wp-includes/version.php b/wp-includes/version.php
index a21aa5afb2..6c982a77d6 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.2-alpha-63600';
+$wp_version = '7.2-alpha-63601';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.