Commit 8d4a9e15e9 for wordpress.org

commit 8d4a9e15e9c0721dd211ff637f832dd5f42c9764
Author: SergeyBiryukov <sergeybiryukov@git.wordpress.org>
Date:   Tue Sep 8 19:36:44 2026 +0000

    Code Modernization: Use the null coalescing assignment operator for registration argument defaults.

    Replaces the “assign a default only if not already set” guard blocks in `WP_Post_Type::set_props()` and `WP_Taxonomy::set_props()` with the null coalescing assignment operator (`??=`).

    Both classes normalize their registration arguments with the same idiom, so the two methods now read identically.

    **Scope**

    This covers `WP_Post_Type::set_props()` and `WP_Taxonomy::set_props()` completely: every guard in those two methods that `??=` can express is converted, so the two methods are internally consistent rather than half-modernized. The same pattern exists elsewhere in core; that is left for separate follow-ups on the same ticket so each one stays reviewable.

    Developed in https://github.com/WordPress/wordpress-develop/pull/13418.

    Follow-up to r63443, r63501, r63509.

    Props Soean, westonruter.
    See #65823.
    Built from https://develop.svn.wordpress.org/trunk@63541


    git-svn-id: http://core.svn.wordpress.org/trunk@62717 1a063a9b-81f0-0310-95a4-ce76da25c4cd

diff --git a/wp-includes/class-wp-post-type.php b/wp-includes/class-wp-post-type.php
index 88fecd08c8..f191906268 100644
--- a/wp-includes/class-wp-post-type.php
+++ b/wp-includes/class-wp-post-type.php
@@ -570,19 +570,13 @@ final class WP_Post_Type {
 		$args['name'] = $this->name;

 		// If not set, default to the setting for 'public'.
-		if ( null === $args['publicly_queryable'] ) {
-			$args['publicly_queryable'] = $args['public'];
-		}
+		$args['publicly_queryable'] ??= $args['public'];

 		// If not set, default to the setting for 'public'.
-		if ( null === $args['show_ui'] ) {
-			$args['show_ui'] = $args['public'];
-		}
+		$args['show_ui'] ??= $args['public'];

 		// If not set, default to the setting for 'public'.
-		if ( null === $args['embeddable'] ) {
-			$args['embeddable'] = $args['public'];
-		}
+		$args['embeddable'] ??= $args['public'];

 		// If not set, default rest_namespace to wp/v2 if show_in_rest is true.
 		if ( false === $args['rest_namespace'] && ! empty( $args['show_in_rest'] ) ) {
@@ -595,19 +589,13 @@ final class WP_Post_Type {
 		}

 		// If not set, default to the setting for 'show_in_menu'.
-		if ( null === $args['show_in_admin_bar'] ) {
-			$args['show_in_admin_bar'] = (bool) $args['show_in_menu'];
-		}
+		$args['show_in_admin_bar'] ??= (bool) $args['show_in_menu'];

 		// If not set, default to the setting for 'public'.
-		if ( null === $args['show_in_nav_menus'] ) {
-			$args['show_in_nav_menus'] = $args['public'];
-		}
+		$args['show_in_nav_menus'] ??= $args['public'];

 		// If not set, default to true if not public, false if public.
-		if ( null === $args['exclude_from_search'] ) {
-			$args['exclude_from_search'] = ! $args['public'];
-		}
+		$args['exclude_from_search'] ??= ! $args['public'];

 		// Back compat with quirky handling in version 3.0. #14122.
 		if ( empty( $args['capabilities'] )
@@ -617,9 +605,7 @@ final class WP_Post_Type {
 		}

 		// If not set, default to false.
-		if ( null === $args['map_meta_cap'] ) {
-			$args['map_meta_cap'] = false;
-		}
+		$args['map_meta_cap'] ??= false;

 		// If there's no specified edit link and no UI, remove the edit link.
 		if ( ! $args['show_ui'] && ! $has_edit_link ) {
@@ -645,21 +631,19 @@ final class WP_Post_Type {
 			if ( ! is_array( $args['rewrite'] ) ) {
 				$args['rewrite'] = array();
 			}
+
 			if ( empty( $args['rewrite']['slug'] ) ) {
 				$args['rewrite']['slug'] = $this->name;
 			}
-			if ( ! isset( $args['rewrite']['with_front'] ) ) {
-				$args['rewrite']['with_front'] = true;
-			}
-			if ( ! isset( $args['rewrite']['pages'] ) ) {
-				$args['rewrite']['pages'] = true;
-			}
+
+			$args['rewrite']['with_front'] ??= true;
+			$args['rewrite']['pages']      ??= true;
+
 			if ( ! isset( $args['rewrite']['feeds'] ) || ! $args['has_archive'] ) {
 				$args['rewrite']['feeds'] = (bool) $args['has_archive'];
 			}
-			if ( ! isset( $args['rewrite']['ep_mask'] ) ) {
-				$args['rewrite']['ep_mask'] = $args['permalink_epmask'] ?? EP_PERMALINK;
-			}
+
+			$args['rewrite']['ep_mask'] ??= $args['permalink_epmask'] ?? EP_PERMALINK;
 		}

 		foreach ( $args as $property_name => $property_value ) {
diff --git a/wp-includes/class-wp-taxonomy.php b/wp-includes/class-wp-taxonomy.php
index 0c7ffa8c7d..f44ce34a11 100644
--- a/wp-includes/class-wp-taxonomy.php
+++ b/wp-includes/class-wp-taxonomy.php
@@ -376,9 +376,7 @@ final class WP_Taxonomy {
 		$args = array_merge( $defaults, $args );

 		// If not set, default to the setting for 'public'.
-		if ( null === $args['publicly_queryable'] ) {
-			$args['publicly_queryable'] = $args['public'];
-		}
+		$args['publicly_queryable'] ??= $args['public'];

 		if ( false !== $args['query_var'] && ( is_admin() || false !== $args['publicly_queryable'] ) ) {
 			if ( true === $args['query_var'] ) {
@@ -407,9 +405,7 @@ final class WP_Taxonomy {
 		}

 		// If not set, default to the setting for 'public'.
-		if ( null === $args['show_ui'] ) {
-			$args['show_ui'] = $args['public'];
-		}
+		$args['show_ui'] ??= $args['public'];

 		// If not set, default to the setting for 'show_ui'.
 		if ( null === $args['show_in_menu'] || ! $args['show_ui'] ) {
@@ -417,19 +413,13 @@ final class WP_Taxonomy {
 		}

 		// If not set, default to the setting for 'public'.
-		if ( null === $args['show_in_nav_menus'] ) {
-			$args['show_in_nav_menus'] = $args['public'];
-		}
+		$args['show_in_nav_menus'] ??= $args['public'];

 		// If not set, default to the setting for 'show_ui'.
-		if ( null === $args['show_tagcloud'] ) {
-			$args['show_tagcloud'] = $args['show_ui'];
-		}
+		$args['show_tagcloud'] ??= $args['show_ui'];

 		// If not set, default to the setting for 'show_ui'.
-		if ( null === $args['show_in_quick_edit'] ) {
-			$args['show_in_quick_edit'] = $args['show_ui'];
-		}
+		$args['show_in_quick_edit'] ??= $args['show_ui'];

 		// If not set, default rest_namespace to wp/v2 if show_in_rest is true.
 		if ( false === $args['rest_namespace'] && ! empty( $args['show_in_rest'] ) ) {
diff --git a/wp-includes/version.php b/wp-includes/version.php
index a7e360b33c..fd677c2e65 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
  *
  * @global string $wp_version
  */
-$wp_version = '7.2-alpha-63540';
+$wp_version = '7.2-alpha-63541';

 /**
  * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.