';
echo '
' . __( 'Upgrade Network' ) . '
';
-$action = isset( $_GET['action'] ) ? $_GET['action'] : 'show';
+$action = $_GET['action'] ?? 'show';
switch ( $action ) {
case 'upgrade':
diff --git a/src/wp-admin/options-privacy.php b/src/wp-admin/options-privacy.php
index 33e59b4601175..4205967acb3a8 100644
--- a/src/wp-admin/options-privacy.php
+++ b/src/wp-admin/options-privacy.php
@@ -30,7 +30,7 @@ static function ( $body_class ) {
}
);
-$action = isset( $_POST['action'] ) ? $_POST['action'] : '';
+$action = $_POST['action'] ?? '';
get_current_screen()->add_help_tab(
array(
diff --git a/src/wp-admin/site-editor.php b/src/wp-admin/site-editor.php
index b0bb4e2bb1c10..628be6625369c 100644
--- a/src/wp-admin/site-editor.php
+++ b/src/wp-admin/site-editor.php
@@ -287,7 +287,7 @@ static function ( $classes ) {
wp_add_inline_script(
'wp-blocks',
- sprintf( 'wp.blocks.setCategories( %s );', wp_json_encode( isset( $editor_settings['blockCategories'] ) ? $editor_settings['blockCategories'] : array(), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) ),
+ sprintf( 'wp.blocks.setCategories( %s );', wp_json_encode( $editor_settings['blockCategories'] ?? array(), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) ),
'after'
);
diff --git a/src/wp-admin/site-health.php b/src/wp-admin/site-health.php
index 2117aa1a750b1..87d585c563bf6 100644
--- a/src/wp-admin/site-health.php
+++ b/src/wp-admin/site-health.php
@@ -36,7 +36,7 @@
'tab-count-' . count( $tabs ),
);
-$current_tab = ( isset( $_GET['tab'] ) ? $_GET['tab'] : '' );
+$current_tab = ( $_GET['tab'] ?? '' );
$title = sprintf(
// translators: %s: The currently displayed tab.
diff --git a/src/wp-admin/update-core.php b/src/wp-admin/update-core.php
index 308f7e661fb3e..3148dbb34d5fa 100644
--- a/src/wp-admin/update-core.php
+++ b/src/wp-admin/update-core.php
@@ -542,7 +542,7 @@ function list_plugin_updates() {
}
}
- $requires_php = isset( $plugin_data->update->requires_php ) ? $plugin_data->update->requires_php : null;
+ $requires_php = $plugin_data->update->requires_php ?? null;
$compatible_php = is_php_version_compatible( $requires_php );
if ( ! $compatible_php && current_user_can( 'update_php' ) ) {
@@ -687,8 +687,8 @@ function list_theme_updates() {
}
foreach ( $themes as $stylesheet => $theme ) {
- $requires_wp = isset( $theme->update['requires'] ) ? $theme->update['requires'] : null;
- $requires_php = isset( $theme->update['requires_php'] ) ? $theme->update['requires_php'] : null;
+ $requires_wp = $theme->update['requires'] ?? null;
+ $requires_php = $theme->update['requires_php'] ?? null;
$compatible_wp = is_wp_version_compatible( $requires_wp );
$compatible_php = is_php_version_compatible( $requires_php );
@@ -854,8 +854,8 @@ function do_core_upgrade( $reinstall = false ) {
}
$url = wp_nonce_url( $url, 'upgrade-core' );
- $version = isset( $_POST['version'] ) ? $_POST['version'] : false;
- $locale = isset( $_POST['locale'] ) ? $_POST['locale'] : 'en_US';
+ $version = $_POST['version'] ?? false;
+ $locale = $_POST['locale'] ?? 'en_US';
$update = find_core_update( $version, $locale );
if ( ! $update ) {
return;
@@ -947,8 +947,8 @@ function do_core_upgrade( $reinstall = false ) {
* @since 2.7.0
*/
function do_dismiss_core_update() {
- $version = isset( $_POST['version'] ) ? $_POST['version'] : false;
- $locale = isset( $_POST['locale'] ) ? $_POST['locale'] : 'en_US';
+ $version = $_POST['version'] ?? false;
+ $locale = $_POST['locale'] ?? 'en_US';
$update = find_core_update( $version, $locale );
if ( ! $update ) {
return;
@@ -964,8 +964,8 @@ function do_dismiss_core_update() {
* @since 2.7.0
*/
function do_undismiss_core_update() {
- $version = isset( $_POST['version'] ) ? $_POST['version'] : false;
- $locale = isset( $_POST['locale'] ) ? $_POST['locale'] : 'en_US';
+ $version = $_POST['version'] ?? false;
+ $locale = $_POST['locale'] ?? 'en_US';
$update = find_core_update( $version, $locale );
if ( ! $update ) {
return;
@@ -975,7 +975,7 @@ function do_undismiss_core_update() {
exit;
}
-$action = isset( $_GET['action'] ) ? $_GET['action'] : 'upgrade-core';
+$action = $_GET['action'] ?? 'upgrade-core';
$upgrade_error = false;
if ( ( 'do-theme-upgrade' === $action || ( 'do-plugin-upgrade' === $action && ! isset( $_GET['plugins'] ) ) )
diff --git a/src/wp-admin/update.php b/src/wp-admin/update.php
index 090c37cfc4dfe..a6c59ec06dab2 100644
--- a/src/wp-admin/update.php
+++ b/src/wp-admin/update.php
@@ -22,7 +22,7 @@
if ( isset( $_GET['action'] ) ) {
$plugin = isset( $_REQUEST['plugin'] ) ? trim( $_REQUEST['plugin'] ) : '';
$theme = isset( $_REQUEST['theme'] ) ? urldecode( $_REQUEST['theme'] ) : '';
- $action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
+ $action = $_REQUEST['action'] ?? '';
if ( 'update-selected' === $action ) {
if ( ! current_user_can( 'update_plugins' ) ) {
diff --git a/src/wp-admin/upload.php b/src/wp-admin/upload.php
index 7043dc279cf9c..1f42a287e4957 100644
--- a/src/wp-admin/upload.php
+++ b/src/wp-admin/upload.php
@@ -87,7 +87,7 @@
$message .= sprintf(
'
%2$s',
- esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids=' . ( isset( $_GET['ids'] ) ? $_GET['ids'] : '' ), 'bulk-media' ) ),
+ esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids=' . ( $_GET['ids'] ?? '' ), 'bulk-media' ) ),
__( 'Undo' )
);
@@ -117,7 +117,7 @@
$messages[3] = __( 'Error saving media file.' );
$messages[4] = __( 'Media file moved to the Trash.' ) . sprintf(
'
%2$s',
- esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids=' . ( isset( $_GET['ids'] ) ? $_GET['ids'] : '' ), 'bulk-media' ) ),
+ esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids=' . ( $_GET['ids'] ?? '' ), 'bulk-media' ) ),
__( 'Undo' )
);
$messages[5] = __( 'Media file restored from the Trash.' );
diff --git a/src/wp-admin/users.php b/src/wp-admin/users.php
index 60cf94b6ffdd2..6f41bacb8c6b8 100644
--- a/src/wp-admin/users.php
+++ b/src/wp-admin/users.php
@@ -629,7 +629,7 @@
break;
case 'add':
$message = __( 'New user created.' );
- $user_id = isset( $_GET['id'] ) ? $_GET['id'] : false;
+ $user_id = $_GET['id'] ?? false;
if ( $user_id && current_user_can( 'edit_user', $user_id ) ) {
$message .= sprintf(
'
%2$s',
diff --git a/src/wp-admin/widgets-form.php b/src/wp-admin/widgets-form.php
index cde09ca47c115..0f841d90434d6 100644
--- a/src/wp-admin/widgets-form.php
+++ b/src/wp-admin/widgets-form.php
@@ -139,7 +139,7 @@
$position = isset( $_POST[ $sidebar_id . '_position' ] ) ? (int) $_POST[ $sidebar_id . '_position' ] - 1 : 0;
$id_base = $_POST['id_base'];
- $sidebar = isset( $sidebars_widgets[ $sidebar_id ] ) ? $sidebars_widgets[ $sidebar_id ] : array();
+ $sidebar = $sidebars_widgets[ $sidebar_id ] ?? array();
// Delete.
if ( isset( $_POST['removewidget'] ) && $_POST['removewidget'] ) {
@@ -261,14 +261,14 @@
}
if ( ! isset( $sidebar ) ) {
- $sidebar = isset( $_GET['sidebar'] ) ? $_GET['sidebar'] : 'wp_inactive_widgets';
+ $sidebar = $_GET['sidebar'] ?? 'wp_inactive_widgets';
}
if ( ! isset( $multi_number ) ) {
- $multi_number = isset( $control['params'][0]['number'] ) ? $control['params'][0]['number'] : '';
+ $multi_number = $control['params'][0]['number'] ?? '';
}
- $id_base = isset( $control['id_base'] ) ? $control['id_base'] : $control['id'];
+ $id_base = $control['id_base'] ?? $control['id'];
// Show the widget form.
$width = ' style="width:' . max( $control['width'], 350 ) . 'px"';
diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php
index 56986c3d80a79..93b0ec541c97c 100644
--- a/src/wp-includes/script-loader.php
+++ b/src/wp-includes/script-loader.php
@@ -2027,7 +2027,7 @@ function wp_localize_community_events() {
$user_id = get_current_user_id();
$saved_location = get_user_option( 'community-events-location', $user_id );
- $saved_ip_address = isset( $saved_location['ip'] ) ? $saved_location['ip'] : false;
+ $saved_ip_address = $saved_location['ip'] ?? false;
$current_ip_address = WP_Community_Events::get_unsafe_client_ip();
/*
diff --git a/src/wp-signup.php b/src/wp-signup.php
index 0508d01c50df5..6daee76ae6c1b 100644
--- a/src/wp-signup.php
+++ b/src/wp-signup.php
@@ -976,7 +976,7 @@ function signup_get_available_languages() {
/* translators: %s: Login URL. */
printf( __( 'You must first
log in, and then you can create a new site.' ), $login_url );
} else {
- $stage = isset( $_POST['stage'] ) ? $_POST['stage'] : 'default';
+ $stage = $_POST['stage'] ?? 'default';
switch ( $stage ) {
case 'validate-user-signup':
if ( 'all' === $active_signup
@@ -1000,7 +1000,7 @@ function signup_get_available_languages() {
break;
case 'default':
default:
- $user_email = isset( $_POST['user_email'] ) ? $_POST['user_email'] : '';
+ $user_email = $_POST['user_email'] ?? '';
/**
* Fires when the site sign-up form is sent.
*
diff --git a/tests/phpunit/data/WPHTTP-testcase-redirection-script.php b/tests/phpunit/data/WPHTTP-testcase-redirection-script.php
index 94643d3de9c43..6b535a45c36bb 100644
--- a/tests/phpunit/data/WPHTTP-testcase-redirection-script.php
+++ b/tests/phpunit/data/WPHTTP-testcase-redirection-script.php
@@ -54,7 +54,7 @@ function is_ssl() {
if ( isset( $_GET['post-redirect-to-method'] ) ) {
$method = $_SERVER['REQUEST_METHOD'];
- $response_code = isset( $_GET['response_code'] ) ? $_GET['response_code'] : 301;
+ $response_code = $_GET['response_code'] ?? 301;
if ( 'POST' == $method && ! isset( $_GET['redirection-performed'] ) ) {
header( "Location: $url?post-redirect-to-method=1&redirection-performed=1", true, $response_code );
@@ -123,8 +123,8 @@ function is_ssl() {
}
-$rt = isset($_GET['rt']) ? $_GET['rt'] : 5;
-$r = isset($_GET['r']) ? $_GET['r'] : 0;
+$rt = $_GET['rt'] ?? 5;
+$r = $_GET['r'] ?? 0;
if ( $r < $rt ) {
$code = isset($_GET['code']) ? (int)$_GET['code'] : 302;
diff --git a/tests/phpunit/includes/abstract-testcase.php b/tests/phpunit/includes/abstract-testcase.php
index 5b080fc7ceb9f..35bf18f688feb 100644
--- a/tests/phpunit/includes/abstract-testcase.php
+++ b/tests/phpunit/includes/abstract-testcase.php
@@ -1313,7 +1313,7 @@ public function go_to( $url ) {
}
$parts = parse_url( $url );
if ( isset( $parts['scheme'] ) ) {
- $req = isset( $parts['path'] ) ? $parts['path'] : '';
+ $req = $parts['path'] ?? '';
if ( isset( $parts['query'] ) ) {
$req .= '?' . $parts['query'];
// Parse the URL query vars into $_GET.
diff --git a/tests/phpunit/includes/factory/class-wp-unittest-factory-for-term.php b/tests/phpunit/includes/factory/class-wp-unittest-factory-for-term.php
index ee082b3f97de1..6b2b7340df176 100644
--- a/tests/phpunit/includes/factory/class-wp-unittest-factory-for-term.php
+++ b/tests/phpunit/includes/factory/class-wp-unittest-factory-for-term.php
@@ -109,7 +109,7 @@ public function create_and_get( $args = array(), $generation_definitions = null
return $term_id;
}
- $taxonomy = isset( $args['taxonomy'] ) ? $args['taxonomy'] : $this->taxonomy;
+ $taxonomy = $args['taxonomy'] ?? $this->taxonomy;
return get_term( $term_id, $taxonomy );
}
diff --git a/tests/phpunit/includes/mock-fs.php b/tests/phpunit/includes/mock-fs.php
index 40705dc41141d..5a54e49039a21 100644
--- a/tests/phpunit/includes/mock-fs.php
+++ b/tests/phpunit/includes/mock-fs.php
@@ -46,7 +46,7 @@ public function init( $paths = '', $home_dir = '/' ) {
'/' => $this->fs,
);
$this->cache = array(); // Used by find_folder() and friends.
- $this->cwd = isset( $this->fs_map[ $home_dir ] ) ? $this->fs_map[ $home_dir ] : '/';
+ $this->cwd = $this->fs_map[ $home_dir ] ?? '/';
$this->setfs( $paths );
}
@@ -79,7 +79,7 @@ public function setfs( $paths ) {
* Locates a filesystem "node"
*/
private function locate_node( $path ) {
- return isset( $this->fs_map[ $path ] ) ? $this->fs_map[ $path ] : false;
+ return $this->fs_map[ $path ] ?? false;
}
/**
diff --git a/tests/phpunit/tests/abilities-api/wpRegisterAbility.php b/tests/phpunit/tests/abilities-api/wpRegisterAbility.php
index d07de062e12b2..61bf8f59dba53 100644
--- a/tests/phpunit/tests/abilities-api/wpRegisterAbility.php
+++ b/tests/phpunit/tests/abilities-api/wpRegisterAbility.php
@@ -154,7 +154,7 @@ public function test_register_ability_no_init_action(): void {
global $wp_actions;
// Store the original action count.
- $original_count = isset( $wp_actions['init'] ) ? $wp_actions['init'] : 0;
+ $original_count = $wp_actions['init'] ?? 0;
// Reset the action count to simulate it not being fired.
unset( $wp_actions['init'] );
@@ -450,7 +450,7 @@ public function test_unregister_ability_no_init_action(): void {
global $wp_actions;
// Store the original action count.
- $original_count = isset( $wp_actions['init'] ) ? $wp_actions['init'] : 0;
+ $original_count = $wp_actions['init'] ?? 0;
// Reset the action count to simulate it not being fired.
unset( $wp_actions['init'] );
@@ -496,7 +496,7 @@ public function test_get_ability_no_init_action(): void {
global $wp_actions;
// Store the original action count.
- $original_count = isset( $wp_actions['init'] ) ? $wp_actions['init'] : 0;
+ $original_count = $wp_actions['init'] ?? 0;
// Reset the action count to simulate it not being fired.
unset( $wp_actions['init'] );
@@ -559,7 +559,7 @@ public function test_has_ability_no_init_action(): void {
global $wp_actions;
// Store the original action count.
- $original_count = isset( $wp_actions['init'] ) ? $wp_actions['init'] : 0;
+ $original_count = $wp_actions['init'] ?? 0;
// Reset the action count to simulate it not being fired.
unset( $wp_actions['init'] );
@@ -615,7 +615,7 @@ public function test_get_abilities_no_init_action(): void {
global $wp_actions;
// Store the original action count.
- $original_count = isset( $wp_actions['init'] ) ? $wp_actions['init'] : 0;
+ $original_count = $wp_actions['init'] ?? 0;
// Reset the action count to simulate it not being fired.
unset( $wp_actions['init'] );
diff --git a/tests/phpunit/tests/abilities-api/wpRegisterAbilityCategory.php b/tests/phpunit/tests/abilities-api/wpRegisterAbilityCategory.php
index 169ea287d5e80..5a59b1050bf25 100644
--- a/tests/phpunit/tests/abilities-api/wpRegisterAbilityCategory.php
+++ b/tests/phpunit/tests/abilities-api/wpRegisterAbilityCategory.php
@@ -82,7 +82,7 @@ public function test_register_ability_category_no_init_action(): void {
global $wp_actions;
// Store the original action count.
- $original_count = isset( $wp_actions['init'] ) ? $wp_actions['init'] : 0;
+ $original_count = $wp_actions['init'] ?? 0;
// Reset the action count to simulate it not being fired.
unset( $wp_actions['init'] );
@@ -132,7 +132,7 @@ public function test_unregister_ability_category_no_init_action(): void {
global $wp_actions;
// Store the original action count.
- $original_count = isset( $wp_actions['init'] ) ? $wp_actions['init'] : 0;
+ $original_count = $wp_actions['init'] ?? 0;
// Reset the action count to simulate it not being fired.
unset( $wp_actions['init'] );
@@ -194,7 +194,7 @@ public function test_has_ability_category_no_init_action(): void {
global $wp_actions;
// Store the original action count.
- $original_count = isset( $wp_actions['init'] ) ? $wp_actions['init'] : 0;
+ $original_count = $wp_actions['init'] ?? 0;
// Reset the action count to simulate it not being fired.
unset( $wp_actions['init'] );
@@ -255,7 +255,7 @@ public function test_get_ability_category_no_init_action(): void {
global $wp_actions;
// Store the original action count.
- $original_count = isset( $wp_actions['init'] ) ? $wp_actions['init'] : 0;
+ $original_count = $wp_actions['init'] ?? 0;
// Reset the action count to simulate it not being fired.
unset( $wp_actions['init'] );
@@ -328,7 +328,7 @@ public function test_get_ability_categories_no_init_action(): void {
global $wp_actions;
// Store the original action count.
- $original_count = isset( $wp_actions['init'] ) ? $wp_actions['init'] : 0;
+ $original_count = $wp_actions['init'] ?? 0;
// Reset the action count to simulate it not being fired.
unset( $wp_actions['init'] );
diff --git a/tests/phpunit/tests/admin/wpPluginsListTable.php b/tests/phpunit/tests/admin/wpPluginsListTable.php
index e75a473e2ba82..daa54750fdf9e 100644
--- a/tests/phpunit/tests/admin/wpPluginsListTable.php
+++ b/tests/phpunit/tests/admin/wpPluginsListTable.php
@@ -137,7 +137,7 @@ public function test_get_views_should_return_views_by_default() {
* @param string $status The value for $_REQUEST['plugin_status'].
*/
public function test_construct_should_not_set_show_autoupdates_to_false_for_mustuse_and_dropins( $status ) {
- $original_status = isset( $_REQUEST['plugin_status'] ) ? $_REQUEST['plugin_status'] : null;
+ $original_status = $_REQUEST['plugin_status'] ?? null;
$_REQUEST['plugin_status'] = $status;
// Enable plugin auto-updates.
diff --git a/tests/phpunit/tests/block-bindings/postMetaSource.php b/tests/phpunit/tests/block-bindings/postMetaSource.php
index 0a305314b7869..927d290f80557 100644
--- a/tests/phpunit/tests/block-bindings/postMetaSource.php
+++ b/tests/phpunit/tests/block-bindings/postMetaSource.php
@@ -28,7 +28,7 @@ private function get_modified_post_content( $content ) {
*/
public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
self::$post = $factory->post->create_and_get();
- self::$wp_meta_keys_saved = isset( $GLOBALS['wp_meta_keys'] ) ? $GLOBALS['wp_meta_keys'] : array();
+ self::$wp_meta_keys_saved = $GLOBALS['wp_meta_keys'] ?? array();
}
/**
diff --git a/tests/phpunit/tests/cron.php b/tests/phpunit/tests/cron.php
index f79772074fc83..7abaf5c92095e 100644
--- a/tests/phpunit/tests/cron.php
+++ b/tests/phpunit/tests/cron.php
@@ -460,7 +460,7 @@ public function filter_pre_schedule_event_filter( $result, $event ) {
$this->preflight_cron_array[ $event->timestamp ][ $event->hook ][ $key ] = array(
'schedule' => $event->schedule,
- 'interval' => isset( $event->interval ) ? $event->interval : 0,
+ 'interval' => $event->interval ?? 0,
'args' => $event->args,
);
uksort( $this->preflight_cron_array, 'strnatcasecmp' );
diff --git a/tests/phpunit/tests/dependencies/scripts.php b/tests/phpunit/tests/dependencies/scripts.php
index 5975149a6e675..a444c3c5d584c 100644
--- a/tests/phpunit/tests/dependencies/scripts.php
+++ b/tests/phpunit/tests/dependencies/scripts.php
@@ -37,9 +37,9 @@ class Tests_Dependencies_Scripts extends WP_UnitTestCase {
public function set_up() {
parent::set_up();
- $this->old_wp_scripts = isset( $GLOBALS['wp_scripts'] ) ? $GLOBALS['wp_scripts'] : null;
- $this->old_wp_styles = isset( $GLOBALS['wp_styles'] ) ? $GLOBALS['wp_styles'] : null;
- $this->old_concatenate_scripts = isset( $GLOBALS['concatenate_scripts'] ) ? $GLOBALS['concatenate_scripts'] : null;
+ $this->old_wp_scripts = $GLOBALS['wp_scripts'] ?? null;
+ $this->old_wp_styles = $GLOBALS['wp_styles'] ?? null;
+ $this->old_concatenate_scripts = $GLOBALS['concatenate_scripts'] ?? null;
remove_action( 'wp_default_scripts', 'wp_default_scripts' );
remove_action( 'wp_default_scripts', 'wp_default_packages' );
$GLOBALS['wp_scripts'] = new WP_Scripts();
diff --git a/tests/phpunit/tests/filesystem/wpFilesystemDirect/base.php b/tests/phpunit/tests/filesystem/wpFilesystemDirect/base.php
index 97165de5c88df..96b449dd0306a 100644
--- a/tests/phpunit/tests/filesystem/wpFilesystemDirect/base.php
+++ b/tests/phpunit/tests/filesystem/wpFilesystemDirect/base.php
@@ -90,7 +90,7 @@ public function set_up() {
} elseif ( 'f' === $entry['type'] ) {
$this->create_file_if_needed(
$entry['path'],
- isset( $entry['contents'] ) ? $entry['contents'] : ''
+ $entry['contents'] ?? ''
);
}
}
diff --git a/tests/phpunit/tests/fonts/font-library/wpRestFontFamiliesController.php b/tests/phpunit/tests/fonts/font-library/wpRestFontFamiliesController.php
index ef1ced421c25e..9b845cba68e1d 100644
--- a/tests/phpunit/tests/fonts/font-library/wpRestFontFamiliesController.php
+++ b/tests/phpunit/tests/fonts/font-library/wpRestFontFamiliesController.php
@@ -1048,9 +1048,8 @@ protected function check_font_family_data( $data, $post_id, $links ) {
$expected = rest_url( 'wp/v2/font-families/' . $post->ID . '/font-faces/' . $font_face_ids[ $index ] );
$this->assertSame( $expected, $link['href'], 'The links for a font faces URL from the response data should match the REST endpoint.' );
- $embeddable = isset( $link['attributes']['embeddable'] )
- ? $link['attributes']['embeddable']
- : $link['embeddable'];
+ $embeddable = $link['attributes']['embeddable']
+ ?? $link['embeddable'];
$this->assertTrue( $embeddable, 'The embeddable should be true.' );
}
}
diff --git a/tests/phpunit/tests/general/wpResourceHints.php b/tests/phpunit/tests/general/wpResourceHints.php
index d0ece5d9ac874..3b546dc6e254e 100644
--- a/tests/phpunit/tests/general/wpResourceHints.php
+++ b/tests/phpunit/tests/general/wpResourceHints.php
@@ -12,8 +12,8 @@ class Tests_General_wpResourceHints extends WP_UnitTestCase {
public function set_up() {
parent::set_up();
- $this->old_wp_scripts = isset( $GLOBALS['wp_scripts'] ) ? $GLOBALS['wp_scripts'] : null;
- $this->old_wp_styles = isset( $GLOBALS['wp_styles'] ) ? $GLOBALS['wp_styles'] : null;
+ $this->old_wp_scripts = $GLOBALS['wp_scripts'] ?? null;
+ $this->old_wp_styles = $GLOBALS['wp_styles'] ?? null;
remove_action( 'wp_default_scripts', 'wp_default_scripts' );
remove_action( 'wp_default_styles', 'wp_default_styles' );
diff --git a/tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-router-region.php b/tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-router-region.php
index d6deab48ab141..f5e5e3a62d37c 100644
--- a/tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-router-region.php
+++ b/tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-router-region.php
@@ -45,7 +45,7 @@ public function set_up() {
$wp_filter['wp_footer'] = new WP_Hook();
// Removes all registered styles.
- $this->original_wp_styles = isset( $GLOBALS['wp_styles'] ) ? $GLOBALS['wp_styles'] : null;
+ $this->original_wp_styles = $GLOBALS['wp_styles'] ?? null;
$GLOBALS['wp_styles'] = new WP_Styles();
remove_action( 'wp_default_styles', 'wp_default_styles' );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
diff --git a/tests/phpunit/tests/l10n/loadScriptTextdomain.php b/tests/phpunit/tests/l10n/loadScriptTextdomain.php
index bc028fbfa5e4d..7aedd92cc666c 100644
--- a/tests/phpunit/tests/l10n/loadScriptTextdomain.php
+++ b/tests/phpunit/tests/l10n/loadScriptTextdomain.php
@@ -20,7 +20,7 @@ class Tests_L10n_LoadScriptTextdomain extends WP_UnitTestCase {
*/
public function test_resolve_relative_path( $translation_path, $handle, $src, $textdomain, $filter = array() ) {
if ( ! empty( $filter ) ) {
- add_filter( $filter[0], $filter[1], 10, isset( $filter[2] ) ? $filter[2] : 1 );
+ add_filter( $filter[0], $filter[1], 10, $filter[2] ?? 1 );
}
wp_enqueue_script( $handle, $src, array(), null );
diff --git a/tests/phpunit/tests/link/getAdjacentPost.php b/tests/phpunit/tests/link/getAdjacentPost.php
index 4d68493bfe8de..7fdd06ec75ead 100644
--- a/tests/phpunit/tests/link/getAdjacentPost.php
+++ b/tests/phpunit/tests/link/getAdjacentPost.php
@@ -192,7 +192,7 @@ public function test_get_adjacent_post_excluded_terms() {
wp_set_post_terms( $p2, array( $t ), 'wptests_tax' );
// Fake current page.
- $_post = isset( $GLOBALS['post'] ) ? $GLOBALS['post'] : null;
+ $_post = $GLOBALS['post'] ?? null;
$GLOBALS['post'] = get_post( $p1 );
$found = get_adjacent_post( false, array( $t ), true, 'wptests_tax' );
@@ -229,7 +229,7 @@ public function test_get_adjacent_post_excluded_terms_should_not_require_posts_t
wp_delete_object_term_relationships( $p3, 'category' );
// Fake current page.
- $_post = isset( $GLOBALS['post'] ) ? $GLOBALS['post'] : null;
+ $_post = $GLOBALS['post'] ?? null;
$GLOBALS['post'] = get_post( $p1 );
$found = get_adjacent_post( false, array( $t ), true, 'wptests_tax' );
diff --git a/tests/phpunit/tests/oembed/controller.php b/tests/phpunit/tests/oembed/controller.php
index aa0275c4c87ee..c8d9f00af05e7 100644
--- a/tests/phpunit/tests/oembed/controller.php
+++ b/tests/phpunit/tests/oembed/controller.php
@@ -93,7 +93,7 @@ public function mock_embed_request( $response, $parsed_args, $url ) {
unset( $response, $parsed_args );
$parsed_url = wp_parse_url( $url );
- $query = isset( $parsed_url['query'] ) ? $parsed_url['query'] : '';
+ $query = $parsed_url['query'] ?? '';
parse_str( $query, $query_params );
$this->request_count += 1;
diff --git a/tests/phpunit/tests/post/thumbnails.php b/tests/phpunit/tests/post/thumbnails.php
index 8f596cbe7f679..4c4885b00b23e 100644
--- a/tests/phpunit/tests/post/thumbnails.php
+++ b/tests/phpunit/tests/post/thumbnails.php
@@ -287,7 +287,7 @@ public function test_the_post_thumbnail_url() {
* @ticket 12922
*/
public function test__wp_preview_post_thumbnail_filter() {
- $old_post = isset( $GLOBALS['post'] ) ? $GLOBALS['post'] : null;
+ $old_post = $GLOBALS['post'] ?? null;
$GLOBALS['post'] = self::$post;
$_REQUEST['_thumbnail_id'] = self::$attachment_id;
@@ -307,7 +307,7 @@ public function test__wp_preview_post_thumbnail_filter() {
* @ticket 37697
*/
public function test__wp_preview_post_thumbnail_filter_secondary_post() {
- $old_post = isset( $GLOBALS['post'] ) ? $GLOBALS['post'] : null;
+ $old_post = $GLOBALS['post'] ?? null;
$secondary_post = self::factory()->post->create(
array(
diff --git a/tests/phpunit/tests/rest-api/application-passwords.php b/tests/phpunit/tests/rest-api/application-passwords.php
index 3dd76c0f94d61..65e3bf222d85f 100644
--- a/tests/phpunit/tests/rest-api/application-passwords.php
+++ b/tests/phpunit/tests/rest-api/application-passwords.php
@@ -154,7 +154,7 @@ public function test_update_application_password( array $update, array $existing
// Check updated only given values.
$updated_item = WP_Application_Passwords::get_user_application_password( self::$user_id, $uuid );
foreach ( $updated_item as $key => $update_value ) {
- $expected_value = isset( $update[ $key ] ) ? $update[ $key ] : $original_item[ $key ];
+ $expected_value = $update[ $key ] ?? $original_item[ $key ];
$this->assertSame( $expected_value, $update_value );
}
}
diff --git a/tests/phpunit/tests/rest-api/rest-pattern-directory-controller.php b/tests/phpunit/tests/rest-api/rest-pattern-directory-controller.php
index 038994cdd1183..6f84306dad61f 100644
--- a/tests/phpunit/tests/rest-api/rest-pattern-directory-controller.php
+++ b/tests/phpunit/tests/rest-api/rest-pattern-directory-controller.php
@@ -82,7 +82,7 @@ public function tear_down() {
*/
public function assertPatternMatchesSchema( $pattern ) {
$schema = static::$controller->get_item_schema();
- $pattern_id = isset( $pattern->id ) ? $pattern->id : '{pattern ID is missing}';
+ $pattern_id = $pattern->id ?? '{pattern ID is missing}';
$this->assertTrue(
rest_validate_value_from_schema( $pattern, $schema ),
diff --git a/tests/phpunit/tests/rest-api/rest-post-meta-fields.php b/tests/phpunit/tests/rest-api/rest-post-meta-fields.php
index 47eada094d0ee..5ce72a57fa55f 100644
--- a/tests/phpunit/tests/rest-api/rest-post-meta-fields.php
+++ b/tests/phpunit/tests/rest-api/rest-post-meta-fields.php
@@ -21,7 +21,7 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
)
);
- self::$wp_meta_keys_saved = isset( $GLOBALS['wp_meta_keys'] ) ? $GLOBALS['wp_meta_keys'] : array();
+ self::$wp_meta_keys_saved = $GLOBALS['wp_meta_keys'] ?? array();
self::$post_id = $factory->post->create();
self::$cpt_post_id = $factory->post->create( array( 'post_type' => 'cpt' ) );
}
diff --git a/tests/phpunit/tests/rest-api/rest-term-meta-fields.php b/tests/phpunit/tests/rest-api/rest-term-meta-fields.php
index 8d4ba295f87a5..737fa90d84633 100644
--- a/tests/phpunit/tests/rest-api/rest-term-meta-fields.php
+++ b/tests/phpunit/tests/rest-api/rest-term-meta-fields.php
@@ -21,7 +21,7 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
)
);
- self::$wp_meta_keys_saved = isset( $GLOBALS['wp_meta_keys'] ) ? $GLOBALS['wp_meta_keys'] : array();
+ self::$wp_meta_keys_saved = $GLOBALS['wp_meta_keys'] ?? array();
self::$category_id = $factory->category->create();
self::$customtax_term_id = $factory->term->create( array( 'taxonomy' => 'customtax' ) );
}
diff --git a/tests/phpunit/tests/shortcode.php b/tests/phpunit/tests/shortcode.php
index 269da2b05e34d..7467d1ed7e6a3 100644
--- a/tests/phpunit/tests/shortcode.php
+++ b/tests/phpunit/tests/shortcode.php
@@ -48,7 +48,7 @@ public function shortcode_test_shortcode_tag( $atts, $content = null, $tagname =
// [footag foo="bar"]
public function shortcode_footag( $atts ) {
- $foo = isset( $atts['foo'] ) ? $atts['foo'] : '';
+ $foo = $atts['foo'] ?? '';
return "foo = $foo";
}