From 7834c09236deaf6f84218677364d0912e89ce7df Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Thu, 2 Oct 2025 10:55:00 +0530 Subject: [PATCH 1/4] Use null coalescing operator --- src/wp-includes/class-wp-theme-json.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/class-wp-theme-json.php b/src/wp-includes/class-wp-theme-json.php index 0458a2be11b7b..adec7468bbe7c 100644 --- a/src/wp-includes/class-wp-theme-json.php +++ b/src/wp-includes/class-wp-theme-json.php @@ -1539,8 +1539,8 @@ public function get_custom_templates() { foreach ( $this->theme_json['customTemplates'] as $item ) { if ( isset( $item['name'] ) ) { $custom_templates[ $item['name'] ] = array( - 'title' => isset( $item['title'] ) ? $item['title'] : '', - 'postTypes' => isset( $item['postTypes'] ) ? $item['postTypes'] : array( 'page' ), + 'title' => $item['title'] ?? : '', + 'postTypes' => $item['postTypes'] ?? array( 'page' ), ); } } From 928d562ab7e2028e0aa359a14ae8fd30be53b5e8 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Thu, 2 Oct 2025 11:00:48 +0530 Subject: [PATCH 2/4] Fix syntax error in custom template title assignment --- src/wp-includes/class-wp-theme-json.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/class-wp-theme-json.php b/src/wp-includes/class-wp-theme-json.php index adec7468bbe7c..aa36330543375 100644 --- a/src/wp-includes/class-wp-theme-json.php +++ b/src/wp-includes/class-wp-theme-json.php @@ -1539,7 +1539,7 @@ public function get_custom_templates() { foreach ( $this->theme_json['customTemplates'] as $item ) { if ( isset( $item['name'] ) ) { $custom_templates[ $item['name'] ] = array( - 'title' => $item['title'] ?? : '', + 'title' => $item['title'] ?? '', 'postTypes' => $item['postTypes'] ?? array( 'page' ), ); } From 79a72f852d2ae83a4164eaef3237831ff561c716 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Thu, 2 Oct 2025 11:18:28 +0530 Subject: [PATCH 3/4] Refactor template parts assignment with null coalescing --- src/wp-includes/class-wp-theme-json.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/class-wp-theme-json.php b/src/wp-includes/class-wp-theme-json.php index aa36330543375..06b2e554a55f6 100644 --- a/src/wp-includes/class-wp-theme-json.php +++ b/src/wp-includes/class-wp-theme-json.php @@ -1563,8 +1563,8 @@ public function get_template_parts() { foreach ( $this->theme_json['templateParts'] as $item ) { if ( isset( $item['name'] ) ) { $template_parts[ $item['name'] ] = array( - 'title' => isset( $item['title'] ) ? $item['title'] : '', - 'area' => isset( $item['area'] ) ? $item['area'] : '', + 'title' => $item['title'] ?? '', + 'area' => $item['area'] ?? '', ); } } From 9318f527d7632a28ff400d0d35295ce525d1923b Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Thu, 2 Oct 2025 11:36:38 +0530 Subject: [PATCH 4/4] Simplify get_settings method using null coalescing --- src/wp-includes/class-wp-theme-json.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/wp-includes/class-wp-theme-json.php b/src/wp-includes/class-wp-theme-json.php index 06b2e554a55f6..2a4e6c8f609f2 100644 --- a/src/wp-includes/class-wp-theme-json.php +++ b/src/wp-includes/class-wp-theme-json.php @@ -1297,11 +1297,7 @@ protected static function remove_keys_not_in_schema( $tree, $schema ) { * @return array Settings per block. */ public function get_settings() { - if ( ! isset( $this->theme_json['settings'] ) ) { - return array(); - } else { - return $this->theme_json['settings']; - } + return $this->theme_json['settings'] ?? array(); } /**