Make WordPress Core

Changeset 61444


Ignore:
Timestamp:
01/06/2026 05:55:33 AM (9 months ago)
Author:
westonruter
Message:

Code Modernization: Site Health, Permalinks, I18N, Users, Multisite: Use null coalescing operator instead of isset() ternaries.

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 [61443], [61442], [61436], [61435], [61434], [61403], [61433], [61432], [61431], [61430], [61429], [61424], [61404], [61403].

Props costdev, westonruter.
See #58874, #63430.

Location:
trunk/src
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-debug-data.php

    r61359 r61444  
    374374                $fields['httpd_software']      = array(
    375375                        'label' => __( 'Web server' ),
    376                         'value' => ( isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : __( 'Unable to determine what web server software is used' ) ),
    377                         'debug' => ( isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : 'unknown' ),
     376                        'value' => $_SERVER['SERVER_SOFTWARE'] ?? __( 'Unable to determine what web server software is used' ),
     377                        'debug' => $_SERVER['SERVER_SOFTWARE'] ?? 'unknown',
    378378                );
    379379                $fields['php_version']         = array(
  • trunk/src/wp-admin/includes/class-wp-ms-sites-list-table.php

    r61371 r61444  
    4545                        array(
    4646                                'plural' => 'sites',
    47                                 'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
     47                                'screen' => $args['screen'] ?? null,
    4848                        )
    4949                );
    … …  
    136136                }
    137137
    138                 $order_by = isset( $_REQUEST['orderby'] ) ? $_REQUEST['orderby'] : '';
     138                $order_by = $_REQUEST['orderby'] ?? '';
    139139                if ( 'registered' === $order_by ) {
    140140                        // 'registered' is a valid field name.
  • trunk/src/wp-admin/includes/class-wp-ms-themes-list-table.php

    r59960 r61444  
    4949                        array(
    5050                                'plural' => 'themes',
    51                                 'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
     51                                'screen' => $args['screen'] ?? null,
    5252                        )
    5353                );
    5454
    55                 $status = isset( $_REQUEST['theme_status'] ) ? $_REQUEST['theme_status'] : 'all';
     55                $status = $_REQUEST['theme_status'] ?? 'all';
    5656                if ( ! in_array( $status, array( 'all', 'enabled', 'disabled', 'upgrade', 'search', 'broken', 'auto-update-enabled', 'auto-update-disabled' ), true ) ) {
    5757                        $status = 'all';
    … …  
    154154
    155155                        $theme_data = array(
    156                                 'update_supported' => isset( $theme->update_supported ) ? $theme->update_supported : true,
     156                                'update_supported' => $theme->update_supported ?? true,
    157157                        );
    158158
  • trunk/src/wp-admin/includes/class-wp-ms-users-list-table.php

    r59878 r61444  
    4242                $users_per_page = $this->get_items_per_page( 'users_network_per_page' );
    4343
    44                 $role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : '';
     44                $role = $_REQUEST['role'] ?? '';
    4545
    4646                $paged = $this->get_pagenum();
  • trunk/src/wp-admin/includes/class-wp-site-health.php

    r61355 r61444  
    151151                                        $health_check_js_variables['site_status']['async'][] = array(
    152152                                                'test'      => $test['test'],
    153                                                 'has_rest'  => ( isset( $test['has_rest'] ) ? $test['has_rest'] : false ),
     153                                                'has_rest'  => $test['has_rest'] ?? false,
    154154                                                'completed' => false,
    155                                                 'headers'   => isset( $test['headers'] ) ? $test['headers'] : array(),
     155                                                'headers'   => $test['headers'] ?? array(),
    156156                                        );
    157157                                }
    … …  
    10531053
    10541054                foreach ( $modules as $library => $module ) {
    1055                         $extension_name = ( isset( $module['extension'] ) ? $module['extension'] : null );
    1056                         $function_name  = ( isset( $module['function'] ) ? $module['function'] : null );
    1057                         $constant_name  = ( isset( $module['constant'] ) ? $module['constant'] : null );
    1058                         $class_name     = ( isset( $module['class'] ) ? $module['class'] : null );
     1055                        $extension_name = $module['extension'] ?? null;
     1056                        $function_name  = $module['function'] ?? null;
     1057                        $constant_name  = $module['constant'] ?? null;
     1058                        $class_name     = $module['class'] ?? null;
    10591059
    10601060                        // If this module is a fallback for another function, check if that other function passed.
    … …  
    30243024                                                'args'     => $data['args'],
    30253025                                                'schedule' => $data['schedule'],
    3026                                                 'interval' => isset( $data['interval'] ) ? $data['interval'] : null,
     3026                                                'interval' => $data['interval'] ?? null,
    30273027                                        );
    30283028
  • trunk/src/wp-admin/includes/class-wp-users-list-table.php

    r57263 r61444  
    4747                                'singular' => 'user',
    4848                                'plural'   => 'users',
    49                                 'screen'   => isset( $args['screen'] ) ? $args['screen'] : null,
     49                                'screen'   => $args['screen'] ?? null,
    5050                        )
    5151                );
    … …  
    8686                $usersearch = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : '';
    8787
    88                 $role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : '';
     88                $role = $_REQUEST['role'] ?? '';
    8989
    9090                $per_page       = ( $this->is_site_users ) ? 'site_users_network_per_page' : 'users_per_page';
  • trunk/src/wp-admin/includes/user.php

    r61270 r61444  
    6363                }
    6464
    65                 $potential_role = isset( $wp_roles->role_objects[ $new_role ] ) ? $wp_roles->role_objects[ $new_role ] : false;
     65                $potential_role = $wp_roles->role_objects[ $new_role ] ?? false;
    6666
    6767                /*
  • trunk/src/wp-admin/my-sites.php

    r56515 r61444  
    1818}
    1919
    20 $action = isset( $_POST['action'] ) ? $_POST['action'] : 'splash';
     20$action = $_POST['action'] ?? 'splash';
    2121
    2222$blogs = get_blogs_of_user( $current_user->ID );
  • trunk/src/wp-admin/network/site-themes.php

    r58975 r61444  
    3030$action = $wp_list_table->current_action();
    3131
    32 $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
     32$s = $_REQUEST['s'] ?? '';
    3333
    3434// Clean up request URI from temporary args for screen options/paging uri's to work as expected.
  • trunk/src/wp-admin/network/themes.php

    r59784 r61444  
    2020$action = $wp_list_table->current_action();
    2121
    22 $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
     22$s = $_REQUEST['s'] ?? '';
    2323
    2424// Clean up request URI from temporary args for screen options/paging uri's to work as expected.
  • trunk/src/wp-admin/network/upgrade.php

    r61440 r61444  
    4848echo '<h1>' . __( 'Upgrade Network' ) . '</h1>';
    4949
    50 $action = isset( $_GET['action'] ) ? $_GET['action'] : 'show';
     50$action = $_GET['action'] ?? 'show';
    5151
    5252switch ( $action ) {
  • trunk/src/wp-admin/site-health.php

    r60609 r61444  
    3737);
    3838
    39 $current_tab = ( isset( $_GET['tab'] ) ? $_GET['tab'] : '' );
     39$current_tab = $_GET['tab'] ?? '';
    4040
    4141$title = sprintf(
  • trunk/src/wp-admin/users.php

    r60976 r61444  
    630630                                case 'add':
    631631                                        $message = __( 'New user created.' );
    632                                         $user_id = isset( $_GET['id'] ) ? $_GET['id'] : false;
     632                                        $user_id = $_GET['id'] ?? false;
    633633                                        if ( $user_id && current_user_can( 'edit_user', $user_id ) ) {
    634634                                                $message .= sprintf(
  • trunk/src/wp-includes/capabilities.php

    r61354 r61444  
    472472                        $caps = map_meta_cap( "edit_{$object_type}", $user_id, $object_id );
    473473
    474                         $meta_key = isset( $args[1] ) ? $args[1] : false;
     474                        $meta_key = $args[1] ?? false;
    475475
    476476                        if ( $meta_key ) {
  • trunk/src/wp-includes/pomo/po.php

    r57356 r61444  
    167167                                        } else {
    168168                                                $previous_is_backslash = false;
    169                                                 $unpoified            .= isset( $escapes[ $char ] ) ? $escapes[ $char ] : $char;
     169                                                $unpoified            .= $escapes[ $char ] ?? $char;
    170170                                        }
    171171                                }
  • trunk/src/wp-includes/pomo/translations.php

    r57734 r61444  
    120120                 */
    121121                public function get_header( $header ) {
    122                         return isset( $this->headers[ $header ] ) ? $this->headers[ $header ] : false;
     122                        return $this->headers[ $header ] ?? false;
    123123                }
    124124
    … …  
    133133                public function translate_entry( &$entry ) {
    134134                        $key = $entry->key();
    135                         return isset( $this->entries[ $key ] ) ? $this->entries[ $key ] : false;
     135                        return $this->entries[ $key ] ?? false;
    136136                }
    137137
  • trunk/src/wp-includes/rewrite.php

    r60447 r61444  
    578578                // Chop off /path/to/blog.
    579579                $home_path = parse_url( home_url( '/' ) );
    580                 $home_path = isset( $home_path['path'] ) ? $home_path['path'] : '';
     580                $home_path = $home_path['path'] ?? '';
    581581                $url       = preg_replace( sprintf( '#^%s#', preg_quote( $home_path ) ), '', trailingslashit( $url ) );
    582582        }
  • trunk/src/wp-includes/user.php

    r61387 r61444  
    24652465        $meta['show_admin_bar_front'] = empty( $userdata['show_admin_bar_front'] ) ? 'true' : $userdata['show_admin_bar_front'];
    24662466
    2467         $meta['locale'] = isset( $userdata['locale'] ) ? $userdata['locale'] : '';
     2467        $meta['locale'] = $userdata['locale'] ?? '';
    24682468
    24692469        $compacted = compact( 'user_pass', 'user_nicename', 'user_email', 'user_url', 'user_registered', 'user_activation_key', 'display_name' );
  • trunk/src/wp-signup.php

    r61411 r61444  
    977977        printf( __( 'You must first <a href="%s">log in</a>, and then you can create a new site.' ), $login_url );
    978978} else {
    979         $stage = isset( $_POST['stage'] ) ? $_POST['stage'] : 'default';
     979        $stage = $_POST['stage'] ?? 'default';
    980980        switch ( $stage ) {
    981981                case 'validate-user-signup':
    … …  
    10011001                case 'default':
    10021002                default:
    1003                         $user_email = isset( $_POST['user_email'] ) ? $_POST['user_email'] : '';
     1003                        $user_email = $_POST['user_email'] ?? '';
    10041004                        /**
    10051005                         * Fires when the site sign-up form is sent.
Note: See TracChangeset for help on using the changeset viewer.