Make WordPress Core

Changeset 61457


Ignore:
Timestamp:
01/09/2026 04:26:02 AM (4 weeks ago)
Author:
westonruter
Message:

Code Modernization: Use null coalescing operator instead of isset() ternaries in remaining core files.

Developed as a subset of https://github.com/WordPress/wordpress-develop/pull/10654
Initially developed in https://github.com/WordPress/wordpress-develop/pull/4886

Follow-up to [61456], [61455], [61454], [61453], [61445], [61444], [61443], [61442], [61436], [61435], [61434], [61403], [61433], [61432], [61431], [61430], [61429], [61424], [61404], [61403].

Props costdev, westonruter, jrf, SergeyBiryukov, swissspidy, hellofromTonya, marybaum, oglekler, dmsnell, chaion07, noisysocks, mukesh27.
See #63430.
Fixes #58874.

Location:
trunk/src/wp-includes
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/IXR/class-IXR-client.php

    r48238 r61457  
    3232            $bits = parse_url($server);
    3333            $this->server = $bits['host'];
    34             $this->port = isset($bits['port']) ? $bits['port'] : 80;
    35             $this->path = isset($bits['path']) ? $bits['path'] : '/';
     34            $this->port = $bits['port'] ?? 80;
     35            $this->path = $bits['path'] ?? '/';
    3636
    3737            // Make absolutely sure we have a path
  • trunk/src/wp-includes/class-wp-duotone.php

    r61299 r61457  
    210210        );
    211211
    212         $factor = isset( $angle_units[ $unit ] ) ? $angle_units[ $unit ] : 1;
     212        $factor = $angle_units[ $unit ] ?? 1;
    213213
    214214        return (float) $value * $factor;
     
    973973         * treated as a selector and requires scoping.
    974974         */
    975         $experimental_duotone = isset( $block_type->supports['color']['__experimentalDuotone'] )
    976             ? $block_type->supports['color']['__experimentalDuotone']
    977             : false;
     975        $experimental_duotone = $block_type->supports['color']['__experimentalDuotone'] ?? false;
    978976        if ( $experimental_duotone ) {
    979977            $root_selector = wp_get_block_css_selector( $block_type );
     
    10041002        // Get the per block settings from the theme.json.
    10051003        $tree              = wp_get_global_settings();
    1006         $presets_by_origin = isset( $tree['color']['duotone'] ) ? $tree['color']['duotone'] : array();
     1004        $presets_by_origin = $tree['color']['duotone'] ?? array();
    10071005
    10081006        self::$global_styles_presets = array();
     
    13051303     */
    13061304    public static function migrate_experimental_duotone_support_flag( $settings, $metadata ) {
    1307         $duotone_support = isset( $metadata['supports']['color']['__experimentalDuotone'] )
    1308             ? $metadata['supports']['color']['__experimentalDuotone']
    1309             : null;
     1305        $duotone_support = $metadata['supports']['color']['__experimentalDuotone'] ?? null;
    13101306
    13111307        if ( ! isset( $settings['supports']['filter']['duotone'] ) && null !== $duotone_support ) {
  • trunk/src/wp-includes/class-wp-hook.php

    r61118 r61457  
    493493    #[ReturnTypeWillChange]
    494494    public function offsetGet( $offset ) {
    495         return isset( $this->callbacks[ $offset ] ) ? $this->callbacks[ $offset ] : null;
     495        return $this->callbacks[ $offset ] ?? null;
    496496    }
    497497
  • trunk/src/wp-includes/class-wp-theme.php

    r61299 r61457  
    516516            }
    517517            // Set the parent. Pass the current instance so we can do the checks above and assess errors.
    518             $this->parent = new WP_Theme( $this->template, isset( $theme_root_template ) ? $theme_root_template : $this->theme_root, $this );
     518            $this->parent = new WP_Theme( $this->template, $theme_root_template ?? $this->theme_root, $this );
    519519        }
    520520
     
    777777     */
    778778    public function parent() {
    779         return isset( $this->parent ) ? $this->parent : false;
     779        return $this->parent ?? false;
    780780    }
    781781
     
    13981398
    13991399        $post_templates = $this->get_post_templates();
    1400         $post_templates = isset( $post_templates[ $post_type ] ) ? $post_templates[ $post_type ] : array();
     1400        $post_templates = $post_templates[ $post_type ] ?? array();
    14011401
    14021402        /**
  • trunk/src/wp-includes/deprecated.php

    r61411 r61457  
    42654265    _deprecated_function( __FUNCTION__, '6.0.0', 'wp_should_skip_block_supports_serialization()' );
    42664266
    4267     $border_support = isset( $block_type->supports['__experimentalBorder'] )
    4268         ? $block_type->supports['__experimentalBorder']
    4269         : false;
     4267    $border_support = $block_type->supports['__experimentalBorder'] ?? false;
    42704268
    42714269    return is_array( $border_support ) &&
     
    42894287    _deprecated_function( __FUNCTION__, '6.0.0', 'wp_should_skip_block_supports_serialization()' );
    42904288
    4291     $dimensions_support = isset( $block_type->supports['__experimentalDimensions'] )
    4292         ? $block_type->supports['__experimentalDimensions']
    4293         : false;
     4289    $dimensions_support = $block_type->supports['__experimentalDimensions'] ?? false;
    42944290
    42954291    return is_array( $dimensions_support ) &&
     
    43134309    _deprecated_function( __FUNCTION__, '6.0.0', 'wp_should_skip_block_supports_serialization()' );
    43144310
    4315     $spacing_support = isset( $block_type->supports['spacing'] )
    4316         ? $block_type->supports['spacing']
    4317         : false;
     4311    $spacing_support = $block_type->supports['spacing'] ?? false;
    43184312
    43194313    return is_array( $spacing_support ) &&
  • trunk/src/wp-includes/pluggable.php

    r61387 r61457  
    17231723         * @param string   $host  The host name of the redirect destination; empty string if not set.
    17241724         */
    1725         $allowed_hosts = (array) apply_filters( 'allowed_redirect_hosts', array( $wpp['host'] ), isset( $lp['host'] ) ? $lp['host'] : '' );
     1725        $allowed_hosts = (array) apply_filters( 'allowed_redirect_hosts', array( $wpp['host'] ), $lp['host'] ?? '' );
    17261726
    17271727        if ( isset( $lp['host'] ) && ( ! in_array( $lp['host'], $allowed_hosts, true ) && strtolower( $wpp['host'] ) !== $lp['host'] ) ) {
  • trunk/src/wp-includes/theme.php

    r61440 r61457  
    11051105function set_theme_mod( $name, $value ) {
    11061106    $mods      = get_theme_mods();
    1107     $old_value = isset( $mods[ $name ] ) ? $mods[ $name ] : false;
     1107    $old_value = $mods[ $name ] ?? false;
    11081108
    11091109    /**
     
    34293429    }
    34303430
    3431     return isset( $_wp_registered_theme_features[ $feature ] ) ? $_wp_registered_theme_features[ $feature ] : null;
     3431    return $_wp_registered_theme_features[ $feature ] ?? null;
    34323432}
    34333433
Note: See TracChangeset for help on using the changeset viewer.