requires_php ) ? $api->requires_php : null;
- $requires_wp = isset( $api->requires ) ? $api->requires : null;
+ $requires_php = $api->requires_php ?? null;
+ $requires_wp = $api->requires ?? null;
$compatible_php = is_php_version_compatible( $requires_php );
$compatible_wp = is_wp_version_compatible( $requires_wp );
diff --git a/src/wp-admin/includes/post.php b/src/wp-admin/includes/post.php
index ed73b8ff5fd14..d47f956c1ef94 100644
--- a/src/wp-admin/includes/post.php
+++ b/src/wp-admin/includes/post.php
@@ -421,7 +421,7 @@ function edit_post( $post_data = null ) {
}
}
- $attachment_data = isset( $post_data['attachments'][ $post_id ] ) ? $post_data['attachments'][ $post_id ] : array();
+ $attachment_data = $post_data['attachments'][ $post_id ] ?? array();
/** This filter is documented in wp-admin/includes/media.php */
$translated = apply_filters( 'attachment_fields_to_save', $translated, $attachment_data );
@@ -980,7 +980,7 @@ function add_meta( $post_id ) {
$metakeyselect = isset( $_POST['metakeyselect'] ) ? wp_unslash( trim( $_POST['metakeyselect'] ) ) : '';
$metakeyinput = isset( $_POST['metakeyinput'] ) ? wp_unslash( trim( $_POST['metakeyinput'] ) ) : '';
- $metavalue = isset( $_POST['metavalue'] ) ? $_POST['metavalue'] : '';
+ $metavalue = $_POST['metavalue'] ?? '';
if ( is_string( $metavalue ) ) {
$metavalue = trim( $metavalue );
}
@@ -1690,7 +1690,7 @@ function wp_check_post_lock( $post ) {
$lock = explode( ':', $lock );
$time = $lock[0];
- $user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true );
+ $user = $lock[1] ?? get_post_meta( $post->ID, '_edit_last', true );
if ( ! get_userdata( $user ) ) {
return false;
diff --git a/src/wp-admin/includes/theme.php b/src/wp-admin/includes/theme.php
index d98cb5de33dd3..698850f7bf4dc 100644
--- a/src/wp-admin/includes/theme.php
+++ b/src/wp-admin/includes/theme.php
@@ -728,8 +728,8 @@ function wp_prepare_themes_for_js( $themes = null ) {
$customize_action = esc_url( $customize_action );
}
- $update_requires_wp = isset( $updates[ $slug ]['requires'] ) ? $updates[ $slug ]['requires'] : null;
- $update_requires_php = isset( $updates[ $slug ]['requires_php'] ) ? $updates[ $slug ]['requires_php'] : null;
+ $update_requires_wp = $updates[ $slug ]['requires'] ?? null;
+ $update_requires_php = $updates[ $slug ]['requires_php'] ?? null;
$auto_update = in_array( $slug, $auto_updates, true );
$auto_update_action = $auto_update ? 'disable-auto-update' : 'enable-auto-update';
diff --git a/src/wp-admin/includes/update-core.php b/src/wp-admin/includes/update-core.php
index eb8e93f2c84cd..9a3bdc1c5e05b 100644
--- a/src/wp-admin/includes/update-core.php
+++ b/src/wp-admin/includes/update-core.php
@@ -1241,7 +1241,7 @@ function update_core( $from, $to ) {
// Find the local version of the working directory.
$working_dir_local = WP_CONTENT_DIR . '/upgrade/' . basename( $from ) . $distro;
- $checksums = get_core_checksums( $wp_version, isset( $wp_local_package ) ? $wp_local_package : 'en_US' );
+ $checksums = get_core_checksums( $wp_version, $wp_local_package ?? 'en_US' );
if ( is_array( $checksums ) && isset( $checksums[ $wp_version ] ) ) {
$checksums = $checksums[ $wp_version ]; // Compat code for 3.7-beta2.
diff --git a/src/wp-admin/includes/update.php b/src/wp-admin/includes/update.php
index 78ca061f2e072..a0916c43135cf 100644
--- a/src/wp-admin/includes/update.php
+++ b/src/wp-admin/includes/update.php
@@ -465,7 +465,7 @@ function wp_plugin_update_row( $file, $plugin_data ) {
);
$plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags );
- $plugin_slug = isset( $response->slug ) ? $response->slug : $response->id;
+ $plugin_slug = $response->slug ?? $response->id;
if ( isset( $response->slug ) ) {
$details_url = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_slug . '§ion=changelog' );
@@ -499,7 +499,7 @@ function wp_plugin_update_row( $file, $plugin_data ) {
$active_class = is_plugin_active( $file ) ? ' active' : '';
}
- $requires_php = isset( $response->requires_php ) ? $response->requires_php : null;
+ $requires_php = $response->requires_php ?? null;
$compatible_php = is_php_version_compatible( $requires_php );
$notice_type = $compatible_php ? 'notice-warning' : 'notice-error';
@@ -691,8 +691,8 @@ function wp_theme_update_row( $theme_key, $theme ) {
$active = $theme->is_allowed( 'network' ) ? ' active' : '';
- $requires_wp = isset( $response['requires'] ) ? $response['requires'] : null;
- $requires_php = isset( $response['requires_php'] ) ? $response['requires_php'] : null;
+ $requires_wp = $response['requires'] ?? null;
+ $requires_php = $response['requires_php'] ?? null;
$compatible_wp = is_wp_version_compatible( $requires_wp );
$compatible_php = is_php_version_compatible( $requires_php );
diff --git a/src/wp-admin/includes/user.php b/src/wp-admin/includes/user.php
index 1d2d919348c79..e3f3a409f7bc3 100644
--- a/src/wp-admin/includes/user.php
+++ b/src/wp-admin/includes/user.php
@@ -62,7 +62,7 @@ function edit_user( $user_id = 0 ) {
wp_die( __( 'Sorry, you are not allowed to give users that role.' ), 403 );
}
- $potential_role = isset( $wp_roles->role_objects[ $new_role ] ) ? $wp_roles->role_objects[ $new_role ] : false;
+ $potential_role = $wp_roles->role_objects[ $new_role ] ?? false;
/*
* Don't let anyone with 'promote_users' edit their own role to something without it.
diff --git a/src/wp-admin/includes/widgets.php b/src/wp-admin/includes/widgets.php
index 93979b6a25de5..7b57a229ad3c4 100644
--- a/src/wp-admin/includes/widgets.php
+++ b/src/wp-admin/includes/widgets.php
@@ -137,7 +137,7 @@ function wp_list_widget_controls_dynamic_sidebar( $params ) {
$i++;
$widget_id = $params[0]['widget_id'];
- $id = isset( $params[0]['_temp_id'] ) ? $params[0]['_temp_id'] : $widget_id;
+ $id = $params[0]['_temp_id'] ?? $widget_id;
$hidden = isset( $params[0]['_hide'] ) ? ' style="display:none;"' : '';
$params[0]['before_widget'] = "
";
@@ -191,23 +191,23 @@ function wp_widget_control( $sidebar_args ) {
global $wp_registered_widgets, $wp_registered_widget_controls, $sidebars_widgets;
$widget_id = $sidebar_args['widget_id'];
- $sidebar_id = isset( $sidebar_args['id'] ) ? $sidebar_args['id'] : false;
+ $sidebar_id = $sidebar_args['id'] ?? false;
$key = $sidebar_id ? array_search( $widget_id, $sidebars_widgets[ $sidebar_id ], true ) : '-1'; // Position of widget in sidebar.
- $control = isset( $wp_registered_widget_controls[ $widget_id ] ) ? $wp_registered_widget_controls[ $widget_id ] : array();
+ $control = $wp_registered_widget_controls[ $widget_id ] ?? array();
$widget = $wp_registered_widgets[ $widget_id ];
$id_format = $widget['id'];
- $widget_number = isset( $control['params'][0]['number'] ) ? $control['params'][0]['number'] : '';
- $id_base = isset( $control['id_base'] ) ? $control['id_base'] : $widget_id;
- $width = isset( $control['width'] ) ? $control['width'] : '';
- $height = isset( $control['height'] ) ? $control['height'] : '';
- $multi_number = isset( $sidebar_args['_multi_num'] ) ? $sidebar_args['_multi_num'] : '';
- $add_new = isset( $sidebar_args['_add'] ) ? $sidebar_args['_add'] : '';
-
- $before_form = isset( $sidebar_args['before_form'] ) ? $sidebar_args['before_form'] : '
';
- $before_widget_content = isset( $sidebar_args['before_widget_content'] ) ? $sidebar_args['before_widget_content'] : '
';
- $after_widget_content = isset( $sidebar_args['after_widget_content'] ) ? $sidebar_args['after_widget_content'] : '
';
+ $widget_number = $control['params'][0]['number'] ?? '';
+ $id_base = $control['id_base'] ?? $widget_id;
+ $width = $control['width'] ?? '';
+ $height = $control['height'] ?? '';
+ $multi_number = $sidebar_args['_multi_num'] ?? '';
+ $add_new = $sidebar_args['_add'] ?? '';
+
+ $before_form = $sidebar_args['before_form'] ?? '
';
+ $before_widget_content = $sidebar_args['before_widget_content'] ?? '
';
+ $after_widget_content = $sidebar_args['after_widget_content'] ?? '
';
$query_arg = array( 'editwidget' => $widget['id'] );
if ( $add_new ) {
diff --git a/src/wp-admin/link-parse-opml.php b/src/wp-admin/link-parse-opml.php
index c0f02bd92d3e6..4c2e3afeb009f 100644
--- a/src/wp-admin/link-parse-opml.php
+++ b/src/wp-admin/link-parse-opml.php
@@ -55,9 +55,9 @@ function startElement( $parser, $tag_name, $attrs ) { // phpcs:ignore WordPress.
// Save the data away.
$names[] = $name;
$urls[] = $url;
- $targets[] = isset( $attrs['TARGET'] ) ? $attrs['TARGET'] : '';
- $feeds[] = isset( $attrs['XMLURL'] ) ? $attrs['XMLURL'] : '';
- $descriptions[] = isset( $attrs['DESCRIPTION'] ) ? $attrs['DESCRIPTION'] : '';
+ $targets[] = $attrs['TARGET'] ?? '';
+ $feeds[] = $attrs['XMLURL'] ?? '';
+ $descriptions[] = $attrs['DESCRIPTION'] ?? '';
} // End if outline.
}
diff --git a/src/wp-admin/my-sites.php b/src/wp-admin/my-sites.php
index e395579ea2a89..5754acb967454 100644
--- a/src/wp-admin/my-sites.php
+++ b/src/wp-admin/my-sites.php
@@ -17,7 +17,7 @@
wp_die( __( 'Sorry, you are not allowed to access this page.' ) );
}
-$action = isset( $_POST['action'] ) ? $_POST['action'] : 'splash';
+$action = $_POST['action'] ?? 'splash';
$blogs = get_blogs_of_user( $current_user->ID );
diff --git a/src/wp-admin/nav-menus.php b/src/wp-admin/nav-menus.php
index 1758bfe221e1c..3ac33de322e25 100644
--- a/src/wp-admin/nav-menus.php
+++ b/src/wp-admin/nav-menus.php
@@ -52,7 +52,7 @@
$num_locations = count( array_keys( $locations ) );
// Allowed actions: add, update, delete.
-$action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'edit';
+$action = $_REQUEST['action'] ?? 'edit';
/*
* If a JSON blob of navigation menu data is found, expand it and inject it
diff --git a/src/wp-admin/network/edit.php b/src/wp-admin/network/edit.php
index f46896bd2b5be..f12251babeeb3 100644
--- a/src/wp-admin/network/edit.php
+++ b/src/wp-admin/network/edit.php
@@ -10,7 +10,7 @@
/** Load WordPress Administration Bootstrap */
require_once __DIR__ . '/admin.php';
-$action = ( isset( $_GET['action'] ) ) ? $_GET['action'] : '';
+$action = $_GET['action'] ?? '';
if ( empty( $action ) ) {
wp_redirect( network_admin_url() );
diff --git a/src/wp-admin/network/site-themes.php b/src/wp-admin/network/site-themes.php
index abca9f97209cc..3cdad8621afb7 100644
--- a/src/wp-admin/network/site-themes.php
+++ b/src/wp-admin/network/site-themes.php
@@ -29,7 +29,7 @@
$action = $wp_list_table->current_action();
-$s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
+$s = $_REQUEST['s'] ?? '';
// Clean up request URI from temporary args for screen options/paging uri's to work as expected.
$temp_args = array( 'enabled', 'disabled', 'error' );
diff --git a/src/wp-admin/network/themes.php b/src/wp-admin/network/themes.php
index 1ad21e97380cd..f2e96b502e1d4 100644
--- a/src/wp-admin/network/themes.php
+++ b/src/wp-admin/network/themes.php
@@ -19,7 +19,7 @@
$action = $wp_list_table->current_action();
-$s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
+$s = $_REQUEST['s'] ?? '';
// Clean up request URI from temporary args for screen options/paging uri's to work as expected.
$temp_args = array(
diff --git a/src/wp-admin/network/upgrade.php b/src/wp-admin/network/upgrade.php
index 55cbedd643c5a..665542d3ea05c 100644
--- a/src/wp-admin/network/upgrade.php
+++ b/src/wp-admin/network/upgrade.php
@@ -42,7 +42,7 @@
echo '
';
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 5c22d39d5df67..9898aaddf7e97 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 6c4efd2a50c2b..eca962e310e58 100644
--- a/src/wp-admin/site-editor.php
+++ b/src/wp-admin/site-editor.php
@@ -130,7 +130,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() ) ),
+ sprintf( 'wp.blocks.setCategories( %s );', wp_json_encode( $editor_settings['blockCategories'] ?? array() ) ),
'after'
);
diff --git a/src/wp-admin/site-health.php b/src/wp-admin/site-health.php
index dac787748daaa..772729eb5247e 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 8949f39e33d27..a510bf7ac2362 100644
--- a/src/wp-admin/update-core.php
+++ b/src/wp-admin/update-core.php
@@ -531,7 +531,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' ) ) {
@@ -676,8 +676,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 );
@@ -843,8 +843,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;
@@ -936,8 +936,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;
@@ -953,8 +953,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;
@@ -964,7 +964,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 29480c2840a57..e1901958f1107 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 29a8c4de8d193..7ab16e4378e4c 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 2c635c543a951..99d8d34912231 100644
--- a/src/wp-admin/users.php
+++ b/src/wp-admin/users.php
@@ -615,7 +615,7 @@
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 b77f23dbc3aea..971fa862c78c8 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'] ) {
@@ -259,14 +259,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/author-template.php b/src/wp-includes/author-template.php
index 184d7d0f38954..d8018337e4c0b 100644
--- a/src/wp-includes/author-template.php
+++ b/src/wp-includes/author-template.php
@@ -164,7 +164,7 @@ function get_the_author_meta( $field = '', $user_id = false ) {
if ( ! $user_id ) {
global $authordata;
- $user_id = isset( $authordata->ID ) ? $authordata->ID : 0;
+ $user_id = $authordata->ID ?? 0;
} else {
$authordata = get_userdata( $user_id );
}
@@ -173,7 +173,7 @@ function get_the_author_meta( $field = '', $user_id = false ) {
$field = 'user_' . $field;
}
- $value = isset( $authordata->$field ) ? $authordata->$field : '';
+ $value = $authordata->$field ?? '';
/**
* Filters the value of the requested user metadata.
@@ -497,7 +497,7 @@ function wp_list_authors( $args = '' ) {
}
foreach ( $authors as $author_id ) {
- $posts = isset( $post_counts[ $author_id ] ) ? $post_counts[ $author_id ] : 0;
+ $posts = $post_counts[ $author_id ] ?? 0;
if ( ! $posts && $parsed_args['hide_empty'] ) {
continue;
diff --git a/src/wp-includes/block-supports/dimensions.php b/src/wp-includes/block-supports/dimensions.php
index 7951f8d881a89..b0e460b662e5a 100644
--- a/src/wp-includes/block-supports/dimensions.php
+++ b/src/wp-includes/block-supports/dimensions.php
@@ -60,7 +60,7 @@ function wp_apply_dimensions_support( $block_type, $block_attributes ) { // phpc
// Width support to be added in near future.
$has_min_height_support = block_has_support( $block_type, array( 'dimensions', 'minHeight' ), false );
- $block_styles = isset( $block_attributes['style'] ) ? $block_attributes['style'] : null;
+ $block_styles = $block_attributes['style'] ?? null;
if ( ! $block_styles ) {
return $attributes;
diff --git a/src/wp-includes/block-supports/elements.php b/src/wp-includes/block-supports/elements.php
index fa2536908ca6e..4be5f14f3f2fd 100644
--- a/src/wp-includes/block-supports/elements.php
+++ b/src/wp-includes/block-supports/elements.php
@@ -88,7 +88,7 @@ function wp_render_elements_support( $block_content, $block ) {
*/
function wp_render_elements_support_styles( $pre_render, $block ) {
$block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] );
- $element_block_styles = isset( $block['attrs']['style']['elements'] ) ? $block['attrs']['style']['elements'] : null;
+ $element_block_styles = $block['attrs']['style']['elements'] ?? null;
/*
* For now we only care about link color.
@@ -99,7 +99,7 @@ function wp_render_elements_support_styles( $pre_render, $block ) {
return null;
}
$class_name = wp_get_elements_class_name( $block );
- $link_block_styles = isset( $element_block_styles['link'] ) ? $element_block_styles['link'] : null;
+ $link_block_styles = $element_block_styles['link'] ?? null;
wp_style_engine_get_styles(
$link_block_styles,
diff --git a/src/wp-includes/block-supports/layout.php b/src/wp-includes/block-supports/layout.php
index 1eb1d777152ad..e497bff4ad0a3 100644
--- a/src/wp-includes/block-supports/layout.php
+++ b/src/wp-includes/block-supports/layout.php
@@ -235,13 +235,13 @@ function wp_register_layout_support( $block_type ) {
* @return string CSS styles on success. Else, empty string.
*/
function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false, $gap_value = null, $should_skip_gap_serialization = false, $fallback_gap_value = '0.5em', $block_spacing = null ) {
- $layout_type = isset( $layout['type'] ) ? $layout['type'] : 'default';
+ $layout_type = $layout['type'] ?? 'default';
$layout_styles = array();
if ( 'default' === $layout_type ) {
if ( $has_block_gap_support ) {
if ( is_array( $gap_value ) ) {
- $gap_value = isset( $gap_value['top'] ) ? $gap_value['top'] : null;
+ $gap_value = $gap_value['top'] ?? null;
}
if ( null !== $gap_value && ! $should_skip_gap_serialization ) {
// Get spacing CSS variable from preset value if provided.
@@ -271,9 +271,9 @@ function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false
}
}
} elseif ( 'constrained' === $layout_type ) {
- $content_size = isset( $layout['contentSize'] ) ? $layout['contentSize'] : '';
- $wide_size = isset( $layout['wideSize'] ) ? $layout['wideSize'] : '';
- $justify_content = isset( $layout['justifyContent'] ) ? $layout['justifyContent'] : 'center';
+ $content_size = $layout['contentSize'] ?? '';
+ $wide_size = $layout['wideSize'] ?? '';
+ $justify_content = $layout['justifyContent'] ?? 'center';
$all_max_width_value = $content_size ? $content_size : $wide_size;
$wide_max_width_value = $wide_size ? $wide_size : $content_size;
@@ -350,7 +350,7 @@ function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false
if ( $has_block_gap_support ) {
if ( is_array( $gap_value ) ) {
- $gap_value = isset( $gap_value['top'] ) ? $gap_value['top'] : null;
+ $gap_value = $gap_value['top'] ?? null;
}
if ( null !== $gap_value && ! $should_skip_gap_serialization ) {
// Get spacing CSS variable from preset value if provided.
@@ -380,7 +380,7 @@ function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false
}
}
} elseif ( 'flex' === $layout_type ) {
- $layout_orientation = isset( $layout['orientation'] ) ? $layout['orientation'] : 'horizontal';
+ $layout_orientation = $layout['orientation'] ?? 'horizontal';
$justify_content_options = array(
'left' => 'flex-start',
@@ -599,7 +599,7 @@ function wp_render_layout_support_flag( $block_content, $block ) {
$global_settings = wp_get_global_settings();
$fallback_layout = ! empty( _wp_array_get( $block_type->supports, array( 'layout', 'default' ), array() ) ) ? _wp_array_get( $block_type->supports, array( 'layout', 'default' ), array() ) : _wp_array_get( $block_type->supports, array( '__experimentalLayout', 'default' ), array() );
- $used_layout = isset( $block['attrs']['layout'] ) ? $block['attrs']['layout'] : $fallback_layout;
+ $used_layout = $block['attrs']['layout'] ?? $fallback_layout;
$class_names = array();
$layout_definitions = wp_get_layout_definitions();
@@ -769,7 +769,7 @@ function wp_render_layout_support_flag( $block_content, $block ) {
* @return string Filtered block content.
*/
function wp_restore_group_inner_container( $block_content, $block ) {
- $tag_name = isset( $block['attrs']['tagName'] ) ? $block['attrs']['tagName'] : 'div';
+ $tag_name = $block['attrs']['tagName'] ?? 'div';
$group_with_inner_container_regex = sprintf(
'/(^\s*<%1$s\b[^>]*wp-block-group(\s|")[^>]*>)(\s*
]*wp-block-group__inner-container(\s|")[^>]*>)((.|\S|\s)*)/U',
preg_quote( $tag_name, '/' )
diff --git a/src/wp-includes/block-supports/shadow.php b/src/wp-includes/block-supports/shadow.php
index 7a710c5222d92..46faa95d656ee 100644
--- a/src/wp-includes/block-supports/shadow.php
+++ b/src/wp-includes/block-supports/shadow.php
@@ -59,7 +59,7 @@ function wp_apply_shadow_support( $block_type, $block_attributes ) {
$shadow_block_styles = array();
$preset_shadow = array_key_exists( 'shadow', $block_attributes ) ? "var:preset|shadow|{$block_attributes['shadow']}" : null;
- $custom_shadow = isset( $block_attributes['style']['shadow'] ) ? $block_attributes['style']['shadow'] : null;
+ $custom_shadow = $block_attributes['style']['shadow'] ?? null;
$shadow_block_styles['shadow'] = $preset_shadow ? $preset_shadow : $custom_shadow;
$attributes = array();
diff --git a/src/wp-includes/block-supports/spacing.php b/src/wp-includes/block-supports/spacing.php
index ea9b39822de1b..07ec1189692cd 100644
--- a/src/wp-includes/block-supports/spacing.php
+++ b/src/wp-includes/block-supports/spacing.php
@@ -52,7 +52,7 @@ function wp_apply_spacing_support( $block_type, $block_attributes ) {
$attributes = array();
$has_padding_support = block_has_support( $block_type, array( 'spacing', 'padding' ), false );
$has_margin_support = block_has_support( $block_type, array( 'spacing', 'margin' ), false );
- $block_styles = isset( $block_attributes['style'] ) ? $block_attributes['style'] : null;
+ $block_styles = $block_attributes['style'] ?? null;
if ( ! $block_styles ) {
return $attributes;
diff --git a/src/wp-includes/block-supports/typography.php b/src/wp-includes/block-supports/typography.php
index 78c8b0a2ffd0d..ec1c768d9420f 100644
--- a/src/wp-includes/block-supports/typography.php
+++ b/src/wp-includes/block-supports/typography.php
@@ -394,11 +394,11 @@ function wp_get_typography_value_and_unit( $raw_value, $options = array() ) {
* @return string|null A font-size value using clamp() on success, otherwise null.
*/
function wp_get_computed_fluid_typography_value( $args = array() ) {
- $maximum_viewport_width_raw = isset( $args['maximum_viewport_width'] ) ? $args['maximum_viewport_width'] : null;
- $minimum_viewport_width_raw = isset( $args['minimum_viewport_width'] ) ? $args['minimum_viewport_width'] : null;
- $maximum_font_size_raw = isset( $args['maximum_font_size'] ) ? $args['maximum_font_size'] : null;
- $minimum_font_size_raw = isset( $args['minimum_font_size'] ) ? $args['minimum_font_size'] : null;
- $scale_factor = isset( $args['scale_factor'] ) ? $args['scale_factor'] : null;
+ $maximum_viewport_width_raw = $args['maximum_viewport_width'] ?? null;
+ $minimum_viewport_width_raw = $args['minimum_viewport_width'] ?? null;
+ $maximum_font_size_raw = $args['maximum_font_size'] ?? null;
+ $minimum_font_size_raw = $args['minimum_font_size'] ?? null;
+ $scale_factor = $args['scale_factor'] ?? null;
// Normalizes the minimum font size in order to use the value for calculations.
$minimum_font_size = wp_get_typography_value_and_unit( $minimum_font_size_raw );
@@ -407,7 +407,7 @@ function wp_get_computed_fluid_typography_value( $args = array() ) {
* We get a 'preferred' unit to keep units consistent when calculating,
* otherwise the result will not be accurate.
*/
- $font_size_unit = isset( $minimum_font_size['unit'] ) ? $minimum_font_size['unit'] : 'rem';
+ $font_size_unit = $minimum_font_size['unit'] ?? 'rem';
// Normalizes the maximum font size in order to use the value for calculations.
$maximum_font_size = wp_get_typography_value_and_unit(
@@ -498,8 +498,8 @@ function wp_get_typography_font_size_value( $preset, $should_use_fluid_typograph
// Checks if fluid font sizes are activated.
$global_settings = wp_get_global_settings();
- $typography_settings = isset( $global_settings['typography'] ) ? $global_settings['typography'] : array();
- $layout_settings = isset( $global_settings['layout'] ) ? $global_settings['layout'] : array();
+ $typography_settings = $global_settings['typography'] ?? array();
+ $layout_settings = $global_settings['layout'] ?? array();
if (
isset( $typography_settings['fluid'] ) &&
@@ -517,7 +517,7 @@ function wp_get_typography_font_size_value( $preset, $should_use_fluid_typograph
: array();
// Defaults.
- $default_maximum_viewport_width = isset( $layout_settings['wideSize'] ) ? $layout_settings['wideSize'] : '1600px';
+ $default_maximum_viewport_width = $layout_settings['wideSize'] ?? '1600px';
$default_minimum_viewport_width = '320px';
$default_minimum_font_size_factor_max = 0.75;
$default_minimum_font_size_factor_min = 0.25;
@@ -527,7 +527,7 @@ function wp_get_typography_font_size_value( $preset, $should_use_fluid_typograph
$default_minimum_font_size_limit = $has_min_font_size ? $fluid_settings['minFontSize'] : '14px';
// Font sizes.
- $fluid_font_size_settings = isset( $preset['fluid'] ) ? $preset['fluid'] : null;
+ $fluid_font_size_settings = $preset['fluid'] ?? null;
// A font size has explicitly bypassed fluid calculations.
if ( false === $fluid_font_size_settings ) {
@@ -535,8 +535,8 @@ function wp_get_typography_font_size_value( $preset, $should_use_fluid_typograph
}
// Try to grab explicit min and max fluid font sizes.
- $minimum_font_size_raw = isset( $fluid_font_size_settings['min'] ) ? $fluid_font_size_settings['min'] : null;
- $maximum_font_size_raw = isset( $fluid_font_size_settings['max'] ) ? $fluid_font_size_settings['max'] : null;
+ $minimum_font_size_raw = $fluid_font_size_settings['min'] ?? null;
+ $maximum_font_size_raw = $fluid_font_size_settings['max'] ?? null;
// Font sizes.
$preferred_size = wp_get_typography_value_and_unit( $preset['size'] );
diff --git a/src/wp-includes/block-template-utils.php b/src/wp-includes/block-template-utils.php
index c00628fc1b257..d321bc884f5c0 100644
--- a/src/wp-includes/block-template-utils.php
+++ b/src/wp-includes/block-template-utils.php
@@ -322,10 +322,10 @@ function _get_block_templates_files( $template_type, $query = array() ) {
}
// Prepare metadata from $query.
- $slugs_to_include = isset( $query['slug__in'] ) ? $query['slug__in'] : array();
- $slugs_to_skip = isset( $query['slug__not_in'] ) ? $query['slug__not_in'] : array();
- $area = isset( $query['area'] ) ? $query['area'] : null;
- $post_type = isset( $query['post_type'] ) ? $query['post_type'] : '';
+ $slugs_to_include = $query['slug__in'] ?? array();
+ $slugs_to_skip = $query['slug__not_in'] ?? array();
+ $area = $query['area'] ?? null;
+ $post_type = $query['post_type'] ?? '';
$stylesheet = get_stylesheet();
$template = get_template();
@@ -954,7 +954,7 @@ function get_block_templates( $query = array(), $template_type = 'wp_template' )
return $templates;
}
- $post_type = isset( $query['post_type'] ) ? $query['post_type'] : '';
+ $post_type = $query['post_type'] ?? '';
$wp_query_args = array(
'post_status' => array( 'auto-draft', 'draft', 'publish' ),
'post_type' => $template_type,
diff --git a/src/wp-includes/block-template.php b/src/wp-includes/block-template.php
index 794aec91203aa..0fb216d55be45 100644
--- a/src/wp-includes/block-template.php
+++ b/src/wp-includes/block-template.php
@@ -308,10 +308,10 @@ function _resolve_template_for_new_post( $wp_query ) {
remove_filter( 'pre_get_posts', '_resolve_template_for_new_post' );
// Pages.
- $page_id = isset( $wp_query->query['page_id'] ) ? $wp_query->query['page_id'] : null;
+ $page_id = $wp_query->query['page_id'] ?? null;
// Posts, including custom post types.
- $p = isset( $wp_query->query['p'] ) ? $wp_query->query['p'] : null;
+ $p = $wp_query->query['p'] ?? null;
$post_id = $page_id ? $page_id : $p;
$post = get_post( $post_id );
diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php
index 347839f09a1e1..6b2a88c626b69 100644
--- a/src/wp-includes/blocks.php
+++ b/src/wp-includes/blocks.php
@@ -165,12 +165,12 @@ function register_block_script_handle( $metadata, $field_name, $index = 0 ) {
}
$script_asset = require $script_asset_path;
- $script_dependencies = isset( $script_asset['dependencies'] ) ? $script_asset['dependencies'] : array();
+ $script_dependencies = $script_asset['dependencies'] ?? array();
$result = wp_register_script(
$script_handle,
$script_uri,
$script_dependencies,
- isset( $script_asset['version'] ) ? $script_asset['version'] : false
+ $script_asset['version'] ?? false
);
if ( ! $result ) {
return false;
diff --git a/src/wp-includes/capabilities.php b/src/wp-includes/capabilities.php
index 26b150fe4b03a..5e76a487cbcb7 100644
--- a/src/wp-includes/capabilities.php
+++ b/src/wp-includes/capabilities.php
@@ -462,7 +462,7 @@ function map_meta_cap( $cap, $user_id, ...$args ) {
$caps = map_meta_cap( "edit_{$object_type}", $user_id, $object_id );
- $meta_key = isset( $args[1] ) ? $args[1] : false;
+ $meta_key = $args[1] ?? false;
if ( $meta_key ) {
$allowed = ! is_protected_meta( $meta_key, $object_type );
diff --git a/src/wp-includes/category-template.php b/src/wp-includes/category-template.php
index dcc32c417f864..5fc653bb19cda 100644
--- a/src/wp-includes/category-template.php
+++ b/src/wp-includes/category-template.php
@@ -963,7 +963,7 @@ function wp_generate_tag_cloud( $tags, $args = '' ) {
// Assemble the data that will be used to generate the tag cloud markup.
$tags_data = array();
foreach ( $tags as $key => $tag ) {
- $tag_id = isset( $tag->id ) ? $tag->id : $key;
+ $tag_id = $tag->id ?? $key;
$count = $counts[ $key ];
$real_count = $real_counts[ $key ];
diff --git a/src/wp-includes/class-wp-block-type.php b/src/wp-includes/class-wp-block-type.php
index 1fb8894164a7b..7d4932e6dbf19 100644
--- a/src/wp-includes/class-wp-block-type.php
+++ b/src/wp-includes/class-wp-block-type.php
@@ -322,7 +322,7 @@ public function __get( $name ) {
if ( count( $this->{$new_name} ) > 1 ) {
return $this->{$new_name};
}
- return isset( $this->{$new_name}[0] ) ? $this->{$new_name}[0] : null;
+ return $this->{$new_name}[0] ?? null;
}
/**
diff --git a/src/wp-includes/class-wp-comment-query.php b/src/wp-includes/class-wp-comment-query.php
index 40f283896653e..9654ba6bd58ae 100644
--- a/src/wp-includes/class-wp-comment-query.php
+++ b/src/wp-includes/class-wp-comment-query.php
@@ -932,12 +932,12 @@ protected function get_comment_ids() {
*/
$clauses = apply_filters_ref_array( 'comments_clauses', array( compact( $pieces ), &$this ) );
- $fields = isset( $clauses['fields'] ) ? $clauses['fields'] : '';
- $join = isset( $clauses['join'] ) ? $clauses['join'] : '';
- $where = isset( $clauses['where'] ) ? $clauses['where'] : '';
- $orderby = isset( $clauses['orderby'] ) ? $clauses['orderby'] : '';
- $limits = isset( $clauses['limits'] ) ? $clauses['limits'] : '';
- $groupby = isset( $clauses['groupby'] ) ? $clauses['groupby'] : '';
+ $fields = $clauses['fields'] ?? '';
+ $join = $clauses['join'] ?? '';
+ $where = $clauses['where'] ?? '';
+ $orderby = $clauses['orderby'] ?? '';
+ $limits = $clauses['limits'] ?? '';
+ $groupby = $clauses['groupby'] ?? '';
$this->filtered_where_clause = $where;
diff --git a/src/wp-includes/class-wp-customize-manager.php b/src/wp-includes/class-wp-customize-manager.php
index 4f8aae8fbdc65..440b5bc7e19bd 100644
--- a/src/wp-includes/class-wp-customize-manager.php
+++ b/src/wp-includes/class-wp-customize-manager.php
@@ -1219,9 +1219,9 @@ public function import_theme_starter_content( $starter_content = array() ) {
$sidebars_widgets = isset( $starter_content['widgets'] ) && ! empty( $this->widgets ) ? $starter_content['widgets'] : array();
$attachments = isset( $starter_content['attachments'] ) && ! empty( $this->nav_menus ) ? $starter_content['attachments'] : array();
$posts = isset( $starter_content['posts'] ) && ! empty( $this->nav_menus ) ? $starter_content['posts'] : array();
- $options = isset( $starter_content['options'] ) ? $starter_content['options'] : array();
$nav_menus = isset( $starter_content['nav_menus'] ) && ! empty( $this->nav_menus ) ? $starter_content['nav_menus'] : array();
- $theme_mods = isset( $starter_content['theme_mods'] ) ? $starter_content['theme_mods'] : array();
+ $options = $starter_content['options'] ?? array();
+ $theme_mods = $starter_content['theme_mods'] ?? array();
// Widgets.
$max_widget_numbers = array();
@@ -1488,7 +1488,7 @@ public function import_theme_starter_content( $starter_content = array() ) {
$this->set_post_value(
$nav_menu_setting_id,
array(
- 'name' => isset( $nav_menu['name'] ) ? $nav_menu['name'] : $nav_menu_location,
+ 'name' => $nav_menu['name'] ?? $nav_menu_location,
)
);
$this->pending_starter_content_settings_ids[] = $nav_menu_setting_id;
@@ -5227,10 +5227,10 @@ public function register_controls() {
'label' => __( 'Logo' ),
'section' => 'title_tagline',
'priority' => 8,
- 'height' => isset( $custom_logo_args[0]['height'] ) ? $custom_logo_args[0]['height'] : null,
- 'width' => isset( $custom_logo_args[0]['width'] ) ? $custom_logo_args[0]['width'] : null,
- 'flex_height' => isset( $custom_logo_args[0]['flex-height'] ) ? $custom_logo_args[0]['flex-height'] : null,
- 'flex_width' => isset( $custom_logo_args[0]['flex-width'] ) ? $custom_logo_args[0]['flex-width'] : null,
+ 'height' => $custom_logo_args[0]['height'] ?? null,
+ 'width' => $custom_logo_args[0]['width'] ?? null,
+ 'flex_height' => $custom_logo_args[0]['flex-height'] ?? null,
+ 'flex_width' => $custom_logo_args[0]['flex-width'] ?? null,
'button_labels' => array(
'select' => __( 'Select logo' ),
'change' => __( 'Change logo' ),
diff --git a/src/wp-includes/class-wp-customize-nav-menus.php b/src/wp-includes/class-wp-customize-nav-menus.php
index bbda8b51b3795..b3cb912ded071 100644
--- a/src/wp-includes/class-wp-customize-nav-menus.php
+++ b/src/wp-includes/class-wp-customize-nav-menus.php
@@ -1250,7 +1250,7 @@ protected function print_post_type_container( $available_item_type ) {
-
+
multidimensional( $root, $keys );
diff --git a/src/wp-includes/class-wp-customize-widgets.php b/src/wp-includes/class-wp-customize-widgets.php
index 41a57dc66bbe1..0d84c599ed5d9 100644
--- a/src/wp-includes/class-wp-customize-widgets.php
+++ b/src/wp-includes/class-wp-customize-widgets.php
@@ -1099,7 +1099,7 @@ public function get_available_widgets() {
$available_widget = array_merge(
$available_widget,
array(
- 'temp_id' => isset( $args['_temp_id'] ) ? $args['_temp_id'] : null,
+ 'temp_id' => $args['_temp_id'] ?? null,
'is_multi' => $is_multi_widget,
'control_tpl' => $control_tpl,
'multi_number' => ( 'multi' === $args['_add'] ) ? $args['_multi_num'] : false,
diff --git a/src/wp-includes/class-wp-hook.php b/src/wp-includes/class-wp-hook.php
index 0f7dc4b7a3be6..89e7994fc497d 100644
--- a/src/wp-includes/class-wp-hook.php
+++ b/src/wp-includes/class-wp-hook.php
@@ -461,7 +461,7 @@ public function offsetExists( $offset ) {
*/
#[ReturnTypeWillChange]
public function offsetGet( $offset ) {
- return isset( $this->callbacks[ $offset ] ) ? $this->callbacks[ $offset ] : null;
+ return $this->callbacks[ $offset ] ?? null;
}
/**
diff --git a/src/wp-includes/class-wp-http-cookie.php b/src/wp-includes/class-wp-http-cookie.php
index 8f55e4486cfda..cfdf4da1dd2c6 100644
--- a/src/wp-includes/class-wp-http-cookie.php
+++ b/src/wp-includes/class-wp-http-cookie.php
@@ -114,7 +114,7 @@ public function __construct( $data, $requested_url = '' ) {
if ( isset( $parsed_url['host'] ) ) {
$this->domain = $parsed_url['host'];
}
- $this->path = isset( $parsed_url['path'] ) ? $parsed_url['path'] : '/';
+ $this->path = $parsed_url['path'] ?? '/';
if ( ! str_ends_with( $this->path, '/' ) ) {
$this->path = dirname( $this->path ) . '/';
}
@@ -190,12 +190,12 @@ public function test( $url ) {
// Get details on the URL we're thinking about sending to.
$url = parse_url( $url );
- $url['port'] = isset( $url['port'] ) ? $url['port'] : ( 'https' === $url['scheme'] ? 443 : 80 );
- $url['path'] = isset( $url['path'] ) ? $url['path'] : '/';
+ $url['port'] = $url['port'] ?? ( 'https' === $url['scheme'] ? 443 : 80 );
+ $url['path'] = $url['path'] ?? '/';
// Values to use for comparison against the URL.
- $path = isset( $this->path ) ? $this->path : '/';
- $port = isset( $this->port ) ? $this->port : null;
+ $path = $this->path ?? '/';
+ $port = $this->port ?? null;
$domain = isset( $this->domain ) ? strtolower( $this->domain ) : strtolower( $url['host'] );
if ( false === stripos( $domain, '.' ) ) {
$domain .= '.local';
diff --git a/src/wp-includes/class-wp-http-ixr-client.php b/src/wp-includes/class-wp-http-ixr-client.php
index d45ca150eb2a6..41d31ca9d14ae 100644
--- a/src/wp-includes/class-wp-http-ixr-client.php
+++ b/src/wp-includes/class-wp-http-ixr-client.php
@@ -25,7 +25,7 @@ public function __construct( $server, $path = false, $port = false, $timeout = 1
$bits = parse_url( $server );
$this->scheme = $bits['scheme'];
$this->server = $bits['host'];
- $this->port = isset( $bits['port'] ) ? $bits['port'] : $port;
+ $this->port = $bits['port'] ?? $port;
$this->path = ! empty( $bits['path'] ) ? $bits['path'] : '/';
// Make absolutely sure we have a path.
diff --git a/src/wp-includes/class-wp-http-requests-response.php b/src/wp-includes/class-wp-http-requests-response.php
index 821077656c84b..943a208f60aab 100644
--- a/src/wp-includes/class-wp-http-requests-response.php
+++ b/src/wp-includes/class-wp-http-requests-response.php
@@ -164,10 +164,10 @@ public function get_cookies() {
array(
'name' => $cookie->name,
'value' => urldecode( $cookie->value ),
- 'expires' => isset( $cookie->attributes['expires'] ) ? $cookie->attributes['expires'] : null,
- 'path' => isset( $cookie->attributes['path'] ) ? $cookie->attributes['path'] : null,
- 'domain' => isset( $cookie->attributes['domain'] ) ? $cookie->attributes['domain'] : null,
- 'host_only' => isset( $cookie->flags['host-only'] ) ? $cookie->flags['host-only'] : null,
+ 'expires' => $cookie->attributes['expires'] ?? null,
+ 'path' => $cookie->attributes['path'] ?? null,
+ 'domain' => $cookie->attributes['domain'] ?? null,
+ 'host_only' => $cookie->flags['host-only'] ?? null,
)
);
}
diff --git a/src/wp-includes/class-wp-http.php b/src/wp-includes/class-wp-http.php
index e1d37878a140f..1ddc58f8c3664 100644
--- a/src/wp-includes/class-wp-http.php
+++ b/src/wp-includes/class-wp-http.php
@@ -670,7 +670,7 @@ public static function processResponse( $response ) { // phpcs:ignore WordPress.
return array(
'headers' => $response[0],
- 'body' => isset( $response[1] ) ? $response[1] : '',
+ 'body' => $response[1] ?? '',
);
}
diff --git a/src/wp-includes/class-wp-meta-query.php b/src/wp-includes/class-wp-meta-query.php
index 0c6867d84ee2a..50b4aba7074c8 100644
--- a/src/wp-includes/class-wp-meta-query.php
+++ b/src/wp-includes/class-wp-meta-query.php
@@ -619,7 +619,7 @@ public function get_sql_for_clause( &$clause, $parent_query, $clause_key = '' )
$clause['alias'] = $alias;
// Determine the data type.
- $_meta_type = isset( $clause['type'] ) ? $clause['type'] : '';
+ $_meta_type = $clause['type'] ?? '';
$meta_type = $this->get_cast_for_type( $_meta_type );
$clause['cast'] = $meta_type;
diff --git a/src/wp-includes/class-wp-network-query.php b/src/wp-includes/class-wp-network-query.php
index 7199ec03a1a15..6ef17816dbd86 100644
--- a/src/wp-includes/class-wp-network-query.php
+++ b/src/wp-includes/class-wp-network-query.php
@@ -451,12 +451,12 @@ protected function get_network_ids() {
*/
$clauses = apply_filters_ref_array( 'networks_clauses', array( compact( $pieces ), &$this ) );
- $fields = isset( $clauses['fields'] ) ? $clauses['fields'] : '';
- $join = isset( $clauses['join'] ) ? $clauses['join'] : '';
- $where = isset( $clauses['where'] ) ? $clauses['where'] : '';
- $orderby = isset( $clauses['orderby'] ) ? $clauses['orderby'] : '';
- $limits = isset( $clauses['limits'] ) ? $clauses['limits'] : '';
- $groupby = isset( $clauses['groupby'] ) ? $clauses['groupby'] : '';
+ $fields = $clauses['fields'] ?? '';
+ $join = $clauses['join'] ?? '';
+ $where = $clauses['where'] ?? '';
+ $orderby = $clauses['orderby'] ?? '';
+ $limits = $clauses['limits'] ?? '';
+ $groupby = $clauses['groupby'] ?? '';
if ( $where ) {
$where = 'WHERE ' . $where;
diff --git a/src/wp-includes/class-wp-paused-extensions-storage.php b/src/wp-includes/class-wp-paused-extensions-storage.php
index 4658277289e49..aea7fc1eb816b 100644
--- a/src/wp-includes/class-wp-paused-extensions-storage.php
+++ b/src/wp-includes/class-wp-paused-extensions-storage.php
@@ -161,7 +161,7 @@ public function get_all() {
$paused_extensions = (array) get_option( $option_name, array() );
- return isset( $paused_extensions[ $this->type ] ) ? $paused_extensions[ $this->type ] : array();
+ return $paused_extensions[ $this->type ] ?? array();
}
/**
diff --git a/src/wp-includes/class-wp-query.php b/src/wp-includes/class-wp-query.php
index 4e1ce2e425303..97b2d03cc781e 100644
--- a/src/wp-includes/class-wp-query.php
+++ b/src/wp-includes/class-wp-query.php
@@ -2950,13 +2950,13 @@ public function get_posts() {
*/
$clauses = (array) apply_filters_ref_array( 'posts_clauses', array( compact( $pieces ), &$this ) );
- $where = isset( $clauses['where'] ) ? $clauses['where'] : '';
- $groupby = isset( $clauses['groupby'] ) ? $clauses['groupby'] : '';
- $join = isset( $clauses['join'] ) ? $clauses['join'] : '';
- $orderby = isset( $clauses['orderby'] ) ? $clauses['orderby'] : '';
- $distinct = isset( $clauses['distinct'] ) ? $clauses['distinct'] : '';
- $fields = isset( $clauses['fields'] ) ? $clauses['fields'] : '';
- $limits = isset( $clauses['limits'] ) ? $clauses['limits'] : '';
+ $where = $clauses['where'] ?? '';
+ $groupby = $clauses['groupby'] ?? '';
+ $join = $clauses['join'] ?? '';
+ $orderby = $clauses['orderby'] ?? '';
+ $distinct = $clauses['distinct'] ?? '';
+ $fields = $clauses['fields'] ?? '';
+ $limits = $clauses['limits'] ?? '';
}
/**
@@ -3084,13 +3084,13 @@ public function get_posts() {
*/
$clauses = (array) apply_filters_ref_array( 'posts_clauses_request', array( compact( $pieces ), &$this ) );
- $where = isset( $clauses['where'] ) ? $clauses['where'] : '';
- $groupby = isset( $clauses['groupby'] ) ? $clauses['groupby'] : '';
- $join = isset( $clauses['join'] ) ? $clauses['join'] : '';
- $orderby = isset( $clauses['orderby'] ) ? $clauses['orderby'] : '';
- $distinct = isset( $clauses['distinct'] ) ? $clauses['distinct'] : '';
- $fields = isset( $clauses['fields'] ) ? $clauses['fields'] : '';
- $limits = isset( $clauses['limits'] ) ? $clauses['limits'] : '';
+ $where = $clauses['where'] ?? '';
+ $groupby = $clauses['groupby'] ?? '';
+ $join = $clauses['join'] ?? '';
+ $orderby = $clauses['orderby'] ?? '';
+ $distinct = $clauses['distinct'] ?? '';
+ $fields = $clauses['fields'] ?? '';
+ $limits = $clauses['limits'] ?? '';
}
if ( ! empty( $groupby ) ) {
diff --git a/src/wp-includes/class-wp-scripts.php b/src/wp-includes/class-wp-scripts.php
index cf0259c3c4d49..fc3e3ce9b0dbe 100644
--- a/src/wp-includes/class-wp-scripts.php
+++ b/src/wp-includes/class-wp-scripts.php
@@ -307,7 +307,7 @@ public function do_item( $handle, $group = false ) {
$intended_strategy = (string) $this->get_data( $handle, 'strategy' );
$cond_before = '';
$cond_after = '';
- $conditional = isset( $obj->extra['conditional'] ) ? $obj->extra['conditional'] : '';
+ $conditional = $obj->extra['conditional'] ?? '';
if ( ! $this->is_delayed_strategy( $intended_strategy ) ) {
$intended_strategy = '';
diff --git a/src/wp-includes/class-wp-site-query.php b/src/wp-includes/class-wp-site-query.php
index 6598866162445..e716be3e0dccb 100644
--- a/src/wp-includes/class-wp-site-query.php
+++ b/src/wp-includes/class-wp-site-query.php
@@ -665,12 +665,12 @@ protected function get_site_ids() {
*/
$clauses = apply_filters_ref_array( 'sites_clauses', array( compact( $pieces ), &$this ) );
- $fields = isset( $clauses['fields'] ) ? $clauses['fields'] : '';
- $join = isset( $clauses['join'] ) ? $clauses['join'] : '';
- $where = isset( $clauses['where'] ) ? $clauses['where'] : '';
- $orderby = isset( $clauses['orderby'] ) ? $clauses['orderby'] : '';
- $limits = isset( $clauses['limits'] ) ? $clauses['limits'] : '';
- $groupby = isset( $clauses['groupby'] ) ? $clauses['groupby'] : '';
+ $fields = $clauses['fields'] ?? '';
+ $join = $clauses['join'] ?? '';
+ $where = $clauses['where'] ?? '';
+ $orderby = $clauses['orderby'] ?? '';
+ $limits = $clauses['limits'] ?? '';
+ $groupby = $clauses['groupby'] ?? '';
if ( $where ) {
$where = 'WHERE ' . $where;
diff --git a/src/wp-includes/class-wp-styles.php b/src/wp-includes/class-wp-styles.php
index 76883b54ca98a..c4febc83483a4 100644
--- a/src/wp-includes/class-wp-styles.php
+++ b/src/wp-includes/class-wp-styles.php
@@ -168,7 +168,7 @@ public function do_item( $handle, $group = false ) {
$src = $obj->src;
$cond_before = '';
$cond_after = '';
- $conditional = isset( $obj->extra['conditional'] ) ? $obj->extra['conditional'] : '';
+ $conditional = $obj->extra['conditional'] ?? '';
if ( $conditional ) {
$cond_before = "';
// Check for paged content that exceeds the max number of pages.
diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php
index 604ede7c876a7..a6536a355ba8c 100644
--- a/src/wp-includes/comment.php
+++ b/src/wp-includes/comment.php
@@ -2109,7 +2109,7 @@ function wp_filter_comment( $commentdata ) {
*
* @param string $comment_agent The comment author's browser user agent.
*/
- $commentdata['comment_agent'] = apply_filters( 'pre_comment_user_agent', ( isset( $commentdata['comment_agent'] ) ? $commentdata['comment_agent'] : '' ) );
+ $commentdata['comment_agent'] = apply_filters( 'pre_comment_user_agent', ( $commentdata['comment_agent'] ?? '' ) );
/** This filter is documented in wp-includes/comment.php */
$commentdata['comment_author'] = apply_filters( 'pre_comment_author_name', $commentdata['comment_author'] );
/**
@@ -2227,7 +2227,7 @@ function wp_new_comment( $commentdata, $wp_error = false ) {
}
if ( ! isset( $commentdata['comment_agent'] ) ) {
- $commentdata['comment_agent'] = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : '';
+ $commentdata['comment_agent'] = $_SERVER['HTTP_USER_AGENT'] ?? '';
}
/**
@@ -2501,7 +2501,7 @@ function wp_update_comment( $commentarr, $wp_error = false ) {
$filter_comment = false;
if ( ! has_filter( 'pre_comment_content', 'wp_filter_kses' ) ) {
- $filter_comment = ! user_can( isset( $comment['user_id'] ) ? $comment['user_id'] : 0, 'unfiltered_html' );
+ $filter_comment = ! user_can( $comment['user_id'] ?? 0, 'unfiltered_html' );
}
if ( $filter_comment ) {
diff --git a/src/wp-includes/customize/class-wp-customize-header-image-setting.php b/src/wp-includes/customize/class-wp-customize-header-image-setting.php
index 80333a54128af..0834b378d3a6e 100644
--- a/src/wp-includes/customize/class-wp-customize-header-image-setting.php
+++ b/src/wp-includes/customize/class-wp-customize-header-image-setting.php
@@ -40,8 +40,8 @@ public function update( $value ) {
if ( empty( $custom_image_header ) ) {
require_once ABSPATH . 'wp-admin/includes/class-custom-image-header.php';
$args = get_theme_support( 'custom-header' );
- $admin_head_callback = isset( $args[0]['admin-head-callback'] ) ? $args[0]['admin-head-callback'] : null;
- $admin_preview_callback = isset( $args[0]['admin-preview-callback'] ) ? $args[0]['admin-preview-callback'] : null;
+ $admin_head_callback = $args[0]['admin-head-callback'] ?? null;
+ $admin_preview_callback = $args[0]['admin-preview-callback'] ?? null;
$custom_image_header = new Custom_Image_Header( $admin_head_callback, $admin_preview_callback );
}
diff --git a/src/wp-includes/embed.php b/src/wp-includes/embed.php
index d75939cce6b56..65cd3b8e1282e 100644
--- a/src/wp-includes/embed.php
+++ b/src/wp-includes/embed.php
@@ -674,7 +674,7 @@ function get_oembed_response_data_for_url( $url, $args ) {
return false;
}
- $width = isset( $args['width'] ) ? $args['width'] : 0;
+ $width = $args['width'] ?? 0;
$data = get_oembed_response_data( $post_id, $width );
diff --git a/src/wp-includes/error-protection.php b/src/wp-includes/error-protection.php
index 08c4159665862..b9cff7073df53 100644
--- a/src/wp-includes/error-protection.php
+++ b/src/wp-includes/error-protection.php
@@ -46,7 +46,7 @@ function wp_paused_themes() {
*/
function wp_get_extension_error_description( $error ) {
$constants = get_defined_constants( true );
- $constants = isset( $constants['Core'] ) ? $constants['Core'] : $constants['internal'];
+ $constants = $constants['Core'] ?? $constants['internal'];
$core_errors = array();
foreach ( $constants as $constant => $value ) {
diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php
index 9ce636edd5b1d..d73f235061fa9 100644
--- a/src/wp-includes/formatting.php
+++ b/src/wp-includes/formatting.php
@@ -961,7 +961,7 @@ function _wp_specialchars( $text, $quote_style = ENT_NOQUOTES, $charset = false,
static $_charset = null;
if ( ! isset( $_charset ) ) {
$alloptions = wp_load_alloptions();
- $_charset = isset( $alloptions['blog_charset'] ) ? $alloptions['blog_charset'] : '';
+ $_charset = $alloptions['blog_charset'] ?? '';
}
$charset = $_charset;
}
@@ -2632,8 +2632,8 @@ function force_balance_tags( $text ) {
$tag_name = $regex[2];
$tag = strtolower( $tag_name );
$is_single_tag = in_array( $tag, $single_tags, true );
- $pre_attribute_ws = isset( $regex[4] ) ? $regex[4] : '';
- $attributes = trim( isset( $regex[5] ) ? $regex[5] : $regex[3] );
+ $pre_attribute_ws = $regex[4] ?? '';
+ $attributes = trim( $regex[5] ?? $regex[3] );
$has_self_closer = str_ends_with( $attributes, '/' );
$newtext .= $tagqueue;
@@ -5256,10 +5256,10 @@ function wp_sprintf( $pattern, ...$args ) {
// Find numbered arguments or take the next one in order.
if ( preg_match( '/^%(\d+)\$/', $fragment, $matches ) ) {
$index = $matches[1] - 1; // 0-based array vs 1-based sprintf() arguments.
- $arg = isset( $args[ $index ] ) ? $args[ $index ] : '';
+ $arg = $args[ $index ] ?? '';
$fragment = str_replace( "%{$matches[1]}$", '%', $fragment );
} else {
- $arg = isset( $args[ $arg_index ] ) ? $args[ $arg_index ] : '';
+ $arg = $args[ $arg_index ] ?? '';
++$arg_index;
}
diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php
index adf8b86170f15..b2f1878868179 100644
--- a/src/wp-includes/functions.php
+++ b/src/wp-includes/functions.php
@@ -945,7 +945,7 @@ function do_enclose( $content, $post ) {
$headers = wp_get_http_headers( $url );
if ( $headers ) {
$len = isset( $headers['Content-Length'] ) ? (int) $headers['Content-Length'] : 0;
- $type = isset( $headers['Content-Type'] ) ? $headers['Content-Type'] : '';
+ $type = $headers['Content-Type'] ?? '';
$allowed_types = array( 'video', 'audio' );
// Check to see if we can figure out the mime type from the extension.
@@ -3297,7 +3297,7 @@ function wp_get_image_mime( $file ) {
$imagesize = @getimagesize( $file );
}
- $mime = ( isset( $imagesize['mime'] ) ) ? $imagesize['mime'] : false;
+ $mime = $imagesize['mime'] ?? false;
} else {
$mime = false;
}
@@ -3591,7 +3591,7 @@ function wp_nonce_ays( $action ) {
get_bloginfo( 'name' )
);
- $redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
+ $redirect_to = $_REQUEST['redirect_to'] ?? '';
$html = $title;
$html .= '
';
@@ -5935,8 +5935,8 @@ function _doing_it_wrong( $function_name, $message, $version ) {
* @return bool Whether the server is running lighttpd < 1.5.0.
*/
function is_lighttpd_before_150() {
- $server_parts = explode( '/', isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : '' );
- $server_parts[1] = isset( $server_parts[1] ) ? $server_parts[1] : '';
+ $server_parts = explode( '/', $_SERVER['SERVER_SOFTWARE'] ?? '' );
+ $server_parts[1] = $server_parts[1] ?? '';
return ( 'lighttpd' === $server_parts[0] && -1 == version_compare( $server_parts[1], '1.5.0' ) );
}
@@ -6902,9 +6902,9 @@ function wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override = ar
while (
$tortoise
&&
- ( $evanescent_hare = isset( $override[ $hare ] ) ? $override[ $hare ] : call_user_func_array( $callback, array_merge( array( $hare ), $callback_args ) ) )
+ ( $evanescent_hare = $override[ $hare ] ?? call_user_func_array( $callback, array_merge( array( $hare ), $callback_args ) ) )
&&
- ( $hare = isset( $override[ $evanescent_hare ] ) ? $override[ $evanescent_hare ] : call_user_func_array( $callback, array_merge( array( $evanescent_hare ), $callback_args ) ) )
+ ( $hare = $override[ $evanescent_hare ] ?? call_user_func_array( $callback, array_merge( array( $evanescent_hare ), $callback_args ) ) )
) {
if ( $_return_loop ) {
$return[ $tortoise ] = true;
@@ -6918,7 +6918,7 @@ function wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override = ar
}
// Increment tortoise by one step.
- $tortoise = isset( $override[ $tortoise ] ) ? $override[ $tortoise ] : call_user_func_array( $callback, array_merge( array( $tortoise ), $callback_args ) );
+ $tortoise = $override[ $tortoise ] ?? call_user_func_array( $callback, array_merge( array( $tortoise ), $callback_args ) );
}
return false;
@@ -7019,7 +7019,7 @@ function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pr
if ( in_array( $call['function'], array( 'do_action', 'apply_filters', 'do_action_ref_array', 'apply_filters_ref_array' ), true ) ) {
$caller[] = "{$call['function']}('{$call['args'][0]}')";
} elseif ( in_array( $call['function'], array( 'include', 'include_once', 'require', 'require_once' ), true ) ) {
- $filename = isset( $call['args'][0] ) ? $call['args'][0] : '';
+ $filename = $call['args'][0] ?? '';
$caller[] = $call['function'] . "('" . str_replace( $truncate_paths, '', wp_normalize_path( $filename ) ) . "')";
} else {
$caller[] = $call['function'];
diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php
index a2b10290649d0..96d30dd97eaee 100644
--- a/src/wp-includes/general-template.php
+++ b/src/wp-includes/general-template.php
@@ -4474,7 +4474,7 @@ function paginate_links( $args = '' ) {
$url_parts = explode( '?', $pagenum_link );
// Get max pages and current page out of the current query, if available.
- $total = isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1;
+ $total = $wp_query->max_num_pages ?? 1;
$current = get_query_var( 'paged' ) ? (int) get_query_var( 'paged' ) : 1;
// Append the format placeholder to the base URL.
@@ -4513,7 +4513,7 @@ function paginate_links( $args = '' ) {
if ( isset( $url_parts[1] ) ) {
// Find the format argument.
$format = explode( '?', str_replace( '%_%', $args['format'], $args['base'] ) );
- $format_query = isset( $format[1] ) ? $format[1] : '';
+ $format_query = $format[1] ?? '';
wp_parse_str( $format_query, $format_args );
// Find the query args of the requested URL.
diff --git a/src/wp-includes/kses.php b/src/wp-includes/kses.php
index 31bc2b5e7a921..75d425d8fadbc 100644
--- a/src/wp-includes/kses.php
+++ b/src/wp-includes/kses.php
@@ -2680,7 +2680,7 @@ function _wp_kses_allow_pdf_objects( $url ) {
// If the URL host matches the current site's media URL, it's safe.
$upload_info = wp_upload_dir( null, false );
$parsed_url = wp_parse_url( $upload_info['url'] );
- $upload_host = isset( $parsed_url['host'] ) ? $parsed_url['host'] : '';
+ $upload_host = $parsed_url['host'] ?? '';
$upload_port = isset( $parsed_url['port'] ) ? ':' . $parsed_url['port'] : '';
if ( str_starts_with( $url, "http://$upload_host$upload_port/" )
diff --git a/src/wp-includes/link-template.php b/src/wp-includes/link-template.php
index c0437f6de9ff1..a723e6bbff572 100644
--- a/src/wp-includes/link-template.php
+++ b/src/wp-includes/link-template.php
@@ -2413,7 +2413,7 @@ function get_pagenum_link( $pagenum = 1, $escape = true ) {
$request = remove_query_arg( 'paged' );
$home_root = parse_url( home_url() );
- $home_root = ( isset( $home_root['path'] ) ) ? $home_root['path'] : '';
+ $home_root = $home_root['path'] ?? '';
$home_root = preg_quote( $home_root, '|' );
$request = preg_replace( '|^' . $home_root . '|i', '', $request );
diff --git a/src/wp-includes/load.php b/src/wp-includes/load.php
index 9324eed562ff0..de31f79ba5f33 100644
--- a/src/wp-includes/load.php
+++ b/src/wp-includes/load.php
@@ -13,7 +13,7 @@
* @return string The HTTP protocol. Default: HTTP/1.0.
*/
function wp_get_server_protocol() {
- $protocol = isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : '';
+ $protocol = $_SERVER['SERVER_PROTOCOL'] ?? '';
if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0', 'HTTP/3' ), true ) ) {
$protocol = 'HTTP/1.0';
@@ -115,7 +115,7 @@ function wp_populate_basic_auth_from_authorization_header() {
}
// From our prior conditional, one of these must be set.
- $header = isset( $_SERVER['HTTP_AUTHORIZATION'] ) ? $_SERVER['HTTP_AUTHORIZATION'] : $_SERVER['REDIRECT_HTTP_AUTHORIZATION'];
+ $header = $_SERVER['HTTP_AUTHORIZATION'] ?? $_SERVER['REDIRECT_HTTP_AUTHORIZATION'];
// Test to make sure the pattern matches expected.
if ( ! preg_match( '%^Basic [a-z\d/+]*={0,2}$%i', $header ) ) {
diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php
index db5565e385678..d1b17a4558480 100644
--- a/src/wp-includes/media.php
+++ b/src/wp-includes/media.php
@@ -1166,7 +1166,7 @@ function wp_get_attachment_image( $attachment_id, $size = 'thumbnail', $icon = f
*/
function wp_get_attachment_image_url( $attachment_id, $size = 'thumbnail', $icon = false ) {
$image = wp_get_attachment_image_src( $attachment_id, $size, $icon );
- return isset( $image[0] ) ? $image[0] : false;
+ return $image[0] ?? false;
}
/**
@@ -1986,7 +1986,7 @@ function wp_img_tag_add_loading_optimization_attrs( $image, $context ) {
*/
$filtered_loading_attr = apply_filters(
'wp_img_tag_add_loading_attr',
- isset( $optimization_attrs['loading'] ) ? $optimization_attrs['loading'] : false,
+ $optimization_attrs['loading'] ?? false,
$image,
$context
);
@@ -2005,7 +2005,7 @@ function wp_img_tag_add_loading_optimization_attrs( $image, $context ) {
* is only intended for the specific scenario where the above filtered caused the problem.
*/
if ( isset( $optimization_attrs['fetchpriority'] ) && 'high' === $optimization_attrs['fetchpriority'] &&
- ( isset( $optimization_attrs['loading'] ) ? $optimization_attrs['loading'] : false ) !== $filtered_loading_attr &&
+ ( $optimization_attrs['loading'] ?? false ) !== $filtered_loading_attr &&
'lazy' === $filtered_loading_attr
) {
_doing_it_wrong(
@@ -2204,7 +2204,7 @@ function wp_iframe_tag_add_loading_attr( $iframe, $context ) {
return $iframe;
}
- $value = isset( $optimization_attrs['loading'] ) ? $optimization_attrs['loading'] : false;
+ $value = $optimization_attrs['loading'] ?? false;
/**
* Filters the `loading` attribute value to add to an iframe. Default `lazy`.
diff --git a/src/wp-includes/nav-menu.php b/src/wp-includes/nav-menu.php
index b43e45601cb81..6d91bab880b8e 100644
--- a/src/wp-includes/nav-menu.php
+++ b/src/wp-includes/nav-menu.php
@@ -319,8 +319,8 @@ function wp_update_nav_menu_object( $menu_id = 0, $menu_data = array() ) {
$_menu = wp_get_nav_menu_object( $menu_id );
$args = array(
- 'description' => ( isset( $menu_data['description'] ) ? $menu_data['description'] : '' ),
- 'name' => ( isset( $menu_data['menu-name'] ) ? $menu_data['menu-name'] : '' ),
+ 'description' => $menu_data['description'] ?? '',
+ 'name' => $menu_data['menu-name'] ?? '',
'parent' => ( isset( $menu_data['parent'] ) ? (int) $menu_data['parent'] : 0 ),
'slug' => null,
);
diff --git a/src/wp-includes/option.php b/src/wp-includes/option.php
index 5d7cbc0b154c1..0e1446e1da82b 100644
--- a/src/wp-includes/option.php
+++ b/src/wp-includes/option.php
@@ -1185,7 +1185,7 @@ function wp_user_settings() {
function get_user_setting( $name, $default_value = false ) {
$all_user_settings = get_all_user_settings();
- return isset( $all_user_settings[ $name ] ) ? $all_user_settings[ $name ] : $default_value;
+ return $all_user_settings[ $name ] ?? $default_value;
}
/**
diff --git a/src/wp-includes/pluggable.php b/src/wp-includes/pluggable.php
index ea422fce2f9e0..698cb828f8bc1 100644
--- a/src/wp-includes/pluggable.php
+++ b/src/wp-includes/pluggable.php
@@ -1622,7 +1622,7 @@ function wp_validate_redirect( $location, $fallback_url = '' ) {
* @param string[] $hosts An array of allowed host names.
* @param string $host The host name of the redirect destination; empty string if not set.
*/
- $allowed_hosts = (array) apply_filters( 'allowed_redirect_hosts', array( $wpp['host'] ), isset( $lp['host'] ) ? $lp['host'] : '' );
+ $allowed_hosts = (array) apply_filters( 'allowed_redirect_hosts', array( $wpp['host'] ), $lp['host'] ?? '' );
if ( isset( $lp['host'] ) && ( ! in_array( $lp['host'], $allowed_hosts, true ) && strtolower( $wpp['host'] ) !== $lp['host'] ) ) {
$location = $fallback_url;
diff --git a/src/wp-includes/pomo/po.php b/src/wp-includes/pomo/po.php
index 89d827c2550b9..b7bbd6eb7dfea 100644
--- a/src/wp-includes/pomo/po.php
+++ b/src/wp-includes/pomo/po.php
@@ -166,7 +166,7 @@ public static function unpoify( $input_string ) {
}
} else {
$previous_is_backslash = false;
- $unpoified .= isset( $escapes[ $char ] ) ? $escapes[ $char ] : $char;
+ $unpoified .= $escapes[ $char ] ?? $char;
}
}
}
diff --git a/src/wp-includes/pomo/translations.php b/src/wp-includes/pomo/translations.php
index d3a1d3cbd09a9..cdebeb443c837 100644
--- a/src/wp-includes/pomo/translations.php
+++ b/src/wp-includes/pomo/translations.php
@@ -81,7 +81,7 @@ public function set_headers( $headers ) {
* @param string $header
*/
public function get_header( $header ) {
- return isset( $this->headers[ $header ] ) ? $this->headers[ $header ] : false;
+ return $this->headers[ $header ] ?? false;
}
/**
@@ -89,7 +89,7 @@ public function get_header( $header ) {
*/
public function translate_entry( &$entry ) {
$key = $entry->key();
- return isset( $this->entries[ $key ] ) ? $this->entries[ $key ] : false;
+ return $this->entries[ $key ] ?? false;
}
/**
diff --git a/src/wp-includes/post-formats.php b/src/wp-includes/post-formats.php
index 282670bd21eee..c865081f195fe 100644
--- a/src/wp-includes/post-formats.php
+++ b/src/wp-includes/post-formats.php
@@ -134,7 +134,7 @@ function get_post_format_string( $slug ) {
if ( ! $slug ) {
return $strings['standard'];
} else {
- return ( isset( $strings[ $slug ] ) ) ? $strings[ $slug ] : '';
+ return $strings[ $slug ] ?? '';
}
}
diff --git a/src/wp-includes/post-template.php b/src/wp-includes/post-template.php
index ceedfa48067a8..6e01d59ccc3f6 100644
--- a/src/wp-includes/post-template.php
+++ b/src/wp-includes/post-template.php
@@ -118,8 +118,8 @@ function the_title_attribute( $args = '' ) {
function get_the_title( $post = 0 ) {
$post = get_post( $post );
- $post_title = isset( $post->post_title ) ? $post->post_title : '';
- $post_id = isset( $post->ID ) ? $post->ID : 0;
+ $post_title = $post->post_title ?? '';
+ $post_id = $post->ID ?? 0;
if ( ! is_admin() ) {
if ( ! empty( $post->post_password ) ) {
@@ -191,7 +191,7 @@ function the_guid( $post = 0 ) {
$post = get_post( $post );
$post_guid = isset( $post->guid ) ? get_the_guid( $post ) : '';
- $post_id = isset( $post->ID ) ? $post->ID : 0;
+ $post_id = $post->ID ?? 0;
/**
* Filters the escaped Global Unique Identifier (guid) of the post.
@@ -221,8 +221,8 @@ function the_guid( $post = 0 ) {
function get_the_guid( $post = 0 ) {
$post = get_post( $post );
- $post_guid = isset( $post->guid ) ? $post->guid : '';
- $post_id = isset( $post->ID ) ? $post->ID : 0;
+ $post_guid = $post->guid ?? '';
+ $post_id = $post->ID ?? 0;
/**
* Filters the Global Unique Identifier (guid) of the post.
diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php
index 22a37683eaf96..ea368511cffb6 100644
--- a/src/wp-includes/post.php
+++ b/src/wp-includes/post.php
@@ -2658,7 +2658,7 @@ function get_post_custom_values( $key = '', $post_id = 0 ) {
$custom = get_post_custom( $post_id );
- return isset( $custom[ $key ] ) ? $custom[ $key ] : null;
+ return $custom[ $key ] ?? null;
}
/**
@@ -4296,11 +4296,11 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true )
// These variables are needed by compact() later.
$post_content_filtered = $postarr['post_content_filtered'];
- $post_author = isset( $postarr['post_author'] ) ? $postarr['post_author'] : $user_id;
+ $post_author = $postarr['post_author'] ?? $user_id;
$ping_status = empty( $postarr['ping_status'] ) ? get_default_comment_status( $post_type, 'pingback' ) : $postarr['ping_status'];
$to_ping = isset( $postarr['to_ping'] ) ? sanitize_trackback_urls( $postarr['to_ping'] ) : '';
- $pinged = isset( $postarr['pinged'] ) ? $postarr['pinged'] : '';
- $import_id = isset( $postarr['import_id'] ) ? $postarr['import_id'] : 0;
+ $pinged = $postarr['pinged'] ?? '';
+ $import_id = $postarr['import_id'] ?? 0;
/*
* The 'wp_insert_post_parent' filter expects all variables to be present.
@@ -4312,7 +4312,7 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true )
$menu_order = 0;
}
- $post_password = isset( $postarr['post_password'] ) ? $postarr['post_password'] : '';
+ $post_password = $postarr['post_password'] ?? '';
if ( 'private' === $post_status ) {
$post_password = '';
}
@@ -4381,7 +4381,7 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true )
$post_name = wp_unique_post_slug( $post_name, $post_id, $post_status, $post_type, $post_parent );
// Don't unslash.
- $post_mime_type = isset( $postarr['post_mime_type'] ) ? $postarr['post_mime_type'] : '';
+ $post_mime_type = $postarr['post_mime_type'] ?? '';
// Expected_slashed (everything!).
$data = compact(
diff --git a/src/wp-includes/rest-api.php b/src/wp-includes/rest-api.php
index a8a2aac177288..c5a0c7bf711e8 100644
--- a/src/wp-includes/rest-api.php
+++ b/src/wp-includes/rest-api.php
@@ -906,7 +906,7 @@ function rest_filter_response_fields( $response, $server, $request ) {
// Skip any sub-properties if their parent prop is already marked for inclusion.
break 2;
}
- $ref[ $next ] = isset( $ref[ $next ] ) ? $ref[ $next ] : array();
+ $ref[ $next ] = $ref[ $next ] ?? array();
$ref = &$ref[ $next ];
}
$last = array_shift( $parts );
@@ -3018,7 +3018,7 @@ function rest_filter_response_by_context( $response_data, $schema, $context ) {
$check = array();
if ( $is_array_type ) {
- $check = isset( $schema['items'] ) ? $schema['items'] : array();
+ $check = $schema['items'] ?? array();
} elseif ( $is_object_type ) {
if ( isset( $schema['properties'][ $key ] ) ) {
$check = $schema['properties'][ $key ];
@@ -3347,7 +3347,7 @@ function rest_convert_error_to_response( $error ) {
$status = array_reduce(
$error->get_all_error_data(),
static function ( $status, $error_data ) {
- return is_array( $error_data ) && isset( $error_data['status'] ) ? $error_data['status'] : $status;
+ return $error_data['status'] ?? $status;
},
500
);
diff --git a/src/wp-includes/rest-api/class-wp-rest-server.php b/src/wp-includes/rest-api/class-wp-rest-server.php
index 9df4556ada858..5e0de4350535b 100644
--- a/src/wp-includes/rest-api/class-wp-rest-server.php
+++ b/src/wp-includes/rest-api/class-wp-rest-server.php
@@ -1498,7 +1498,7 @@ public function get_data_for_route( $route, $callbacks, $context = 'view' ) {
$data['namespace'] = $options['namespace'];
}
- $allow_batch = isset( $options['allow_batch'] ) ? $options['allow_batch'] : false;
+ $allow_batch = $options['allow_batch'] ?? false;
if ( isset( $options['schema'] ) && 'help' === $context ) {
$data['schema'] = call_user_func( $options['schema'] );
@@ -1520,7 +1520,7 @@ public function get_data_for_route( $route, $callbacks, $context = 'view' ) {
'methods' => array_keys( $callback['methods'] ),
);
- $callback_batch = isset( $callback['allow_batch'] ) ? $callback['allow_batch'] : $allow_batch;
+ $callback_batch = $callback['allow_batch'] ?? $allow_batch;
if ( $callback_batch ) {
$endpoint_data['allow_batch'] = $callback_batch;
@@ -1602,7 +1602,7 @@ public function serve_batch_request_v1( WP_REST_Request $batch_request ) {
continue;
}
- $single_request = new WP_REST_Request( isset( $args['method'] ) ? $args['method'] : 'POST', $parsed_url['path'] );
+ $single_request = new WP_REST_Request( $args['method'] ?? 'POST', $parsed_url['path'] );
if ( ! empty( $parsed_url['query'] ) ) {
$query_args = null; // Satisfy linter.
@@ -1641,7 +1641,7 @@ public function serve_batch_request_v1( WP_REST_Request $batch_request ) {
$allow_batch = $handler['allow_batch'];
} else {
$route_options = $this->get_route_options( $route );
- $allow_batch = isset( $route_options['allow_batch'] ) ? $route_options['allow_batch'] : false;
+ $allow_batch = $route_options['allow_batch'] ?? false;
}
if ( ! is_array( $allow_batch ) || empty( $allow_batch['v1'] ) ) {
diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php
index cfcb0dbc5c7bc..a1f1bf9b1dc86 100644
--- a/src/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php
+++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php
@@ -136,7 +136,7 @@ public function prepare_item_for_response( $item, $request ) {
'author_block_rating' => $plugin['author_block_rating'] / 20,
'author_block_count' => (int) $plugin['author_block_count'],
'author' => wp_strip_all_tags( $plugin['author'] ),
- 'icon' => ( isset( $plugin['icons']['1x'] ) ? $plugin['icons']['1x'] : 'block-default' ),
+ 'icon' => $plugin['icons']['1x'] ?? 'block-default',
'last_updated' => gmdate( 'Y-m-d\TH:i:s', strtotime( $plugin['last_updated'] ) ),
'humanized_updated' => sprintf(
/* translators: %s: Human-readable time difference. */
diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-blocks-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-blocks-controller.php
index 37178bb837ad6..90e6a6ccbb121 100644
--- a/src/wp-includes/rest-api/endpoints/class-wp-rest-blocks-controller.php
+++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-blocks-controller.php
@@ -58,7 +58,7 @@ public function filter_response_by_context( $data, $context ) {
unset( $data['content']['rendered'] );
// Add the core wp_pattern_sync_status meta as top level property to the response.
- $data['wp_pattern_sync_status'] = isset( $data['meta']['wp_pattern_sync_status'] ) ? $data['meta']['wp_pattern_sync_status'] : '';
+ $data['wp_pattern_sync_status'] = $data['meta']['wp_pattern_sync_status'] ?? '';
unset( $data['meta']['wp_pattern_sync_status'] );
return $data;
}
diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php
index 81fc991ba980f..194e37e6749be 100644
--- a/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php
+++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php
@@ -571,7 +571,7 @@ protected function get_object_type() {
*/
public function get_fields_for_response( $request ) {
$schema = $this->get_item_schema();
- $properties = isset( $schema['properties'] ) ? $schema['properties'] : array();
+ $properties = $schema['properties'] ?? array();
$additional_fields = $this->get_additional_fields();
diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php
index 0315cd23cf600..c4290a7a5204a 100644
--- a/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php
+++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php
@@ -612,7 +612,7 @@ public function get_theme_item( $request ) {
if ( rest_is_field_included( 'styles', $fields ) ) {
$raw_data = $theme->get_raw_data();
- $data['styles'] = isset( $raw_data['styles'] ) ? $raw_data['styles'] : array();
+ $data['styles'] = $raw_data['styles'] ?? array();
}
$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-menu-locations-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-menu-locations-controller.php
index 5c06dc7a6583a..bc16c493eeac2 100644
--- a/src/wp-includes/rest-api/endpoints/class-wp-rest-menu-locations-controller.php
+++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-menu-locations-controller.php
@@ -170,7 +170,7 @@ public function prepare_item_for_response( $item, $request ) {
// Restores the more descriptive, specific name for use within this method.
$location = $item;
$locations = get_nav_menu_locations();
- $menu = isset( $locations[ $location->name ] ) ? $locations[ $location->name ] : 0;
+ $menu = $locations[ $location->name ] ?? 0;
$fields = $this->get_fields_for_response( $request );
$data = array();
@@ -231,7 +231,7 @@ protected function prepare_links( $location ) {
);
$locations = get_nav_menu_locations();
- $menu = isset( $locations[ $location->name ] ) ? $locations[ $location->name ] : 0;
+ $menu = $locations[ $location->name ] ?? 0;
if ( $menu ) {
$path = rest_get_route_for_term( $menu );
if ( $path ) {
diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php
index 0260561866efb..5e7a587666759 100644
--- a/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php
+++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php
@@ -107,8 +107,8 @@ public function get_items( $request ) {
$query_args['locale'] = get_user_locale();
$query_args['wp-version'] = $wp_version; // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable -- it's defined in `version.php` above.
- $query_args['pattern-categories'] = isset( $request['category'] ) ? $request['category'] : false;
- $query_args['pattern-keywords'] = isset( $request['keyword'] ) ? $request['keyword'] : false;
+ $query_args['pattern-categories'] = $request['category'] ?? false;
+ $query_args['pattern-keywords'] = $request['keyword'] ?? false;
$query_args = array_filter( $query_args );
diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php
index 1c83f5caea6f4..e603f4fb85bf8 100644
--- a/src/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php
+++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php
@@ -239,7 +239,7 @@ protected function get_registered_options() {
$default_schema = array(
'type' => empty( $args['type'] ) ? null : $args['type'],
'description' => empty( $args['description'] ) ? '' : $args['description'],
- 'default' => isset( $args['default'] ) ? $args['default'] : null,
+ 'default' => $args['default'] ?? null,
);
$rest_args['schema'] = array_merge( $default_schema, $rest_args['schema'] );
diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php
index 36ef35461c2b9..31d4edc7fe556 100644
--- a/src/wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php
+++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php
@@ -327,13 +327,13 @@ public function prepare_item_for_response( $item, $request ) {
$registered_sidebar = $wp_registered_sidebars[ $id ];
$sidebar['status'] = 'active';
- $sidebar['name'] = isset( $registered_sidebar['name'] ) ? $registered_sidebar['name'] : '';
+ $sidebar['name'] = $registered_sidebar['name'] ?? '';
$sidebar['description'] = isset( $registered_sidebar['description'] ) ? wp_sidebar_description( $id ) : '';
- $sidebar['class'] = isset( $registered_sidebar['class'] ) ? $registered_sidebar['class'] : '';
- $sidebar['before_widget'] = isset( $registered_sidebar['before_widget'] ) ? $registered_sidebar['before_widget'] : '';
- $sidebar['after_widget'] = isset( $registered_sidebar['after_widget'] ) ? $registered_sidebar['after_widget'] : '';
- $sidebar['before_title'] = isset( $registered_sidebar['before_title'] ) ? $registered_sidebar['before_title'] : '';
- $sidebar['after_title'] = isset( $registered_sidebar['after_title'] ) ? $registered_sidebar['after_title'] : '';
+ $sidebar['class'] = $registered_sidebar['class'] ?? '';
+ $sidebar['before_widget'] = $registered_sidebar['before_widget'] ?? '';
+ $sidebar['after_widget'] = $registered_sidebar['after_widget'] ?? '';
+ $sidebar['before_title'] = $registered_sidebar['before_title'] ?? '';
+ $sidebar['after_title'] = $registered_sidebar['after_title'] ?? '';
} else {
$sidebar['status'] = 'inactive';
$sidebar['name'] = $raw_sidebar['name'];
@@ -349,7 +349,7 @@ public function prepare_item_for_response( $item, $request ) {
if ( rest_is_field_included( 'widgets', $fields ) ) {
$sidebars = wp_get_sidebars_widgets();
$widgets = array_filter(
- isset( $sidebars[ $sidebar['id'] ] ) ? $sidebars[ $sidebar['id'] ] : array(),
+ $sidebars[ $sidebar['id'] ] ?? array(),
static function ( $widget_id ) use ( $wp_registered_widgets ) {
return isset( $wp_registered_widgets[ $widget_id ] );
}
diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php
index 4ca84ad03c3b8..aed36218a1a46 100644
--- a/src/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php
+++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php
@@ -541,7 +541,7 @@ protected function prepare_item_for_database( $request ) {
$changes->post_type = $this->post_type;
$changes->post_status = 'publish';
$changes->tax_input = array(
- 'wp_theme' => isset( $request['theme'] ) ? $request['theme'] : get_stylesheet(),
+ 'wp_theme' => $request['theme'] ?? get_stylesheet(),
);
} elseif ( 'custom' !== $template->source ) {
$changes->post_name = $template->slug;
diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php
index 075be9efe4129..1f91fdbeb9f11 100644
--- a/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php
+++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php
@@ -374,7 +374,7 @@ protected function prepare_links( $theme ) {
$id = WP_Theme_JSON_Resolver::get_user_global_styles_post_id();
} else {
$user_cpt = WP_Theme_JSON_Resolver::get_user_data_from_wp_global_styles( $theme );
- $id = isset( $user_cpt['ID'] ) ? $user_cpt['ID'] : null;
+ $id = $user_cpt['ID'] ?? null;
}
if ( $id ) {
diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php
index 9734ae66255c0..86393f173daff 100644
--- a/src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php
+++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php
@@ -599,7 +599,7 @@ public function render( $request ) {
return array(
'preview' => $this->render_legacy_widget_preview_iframe(
$request['id'],
- isset( $request['instance'] ) ? $request['instance'] : null
+ $request['instance'] ?? null
),
);
}
diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php
index 267a75ffaedb9..1d8268c60e1c5 100644
--- a/src/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php
+++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php
@@ -528,7 +528,7 @@ protected function save_widget( $request, $sidebar_id ) {
$id = $request['id'];
$parsed_id = wp_parse_widget_id( $id );
$id_base = $parsed_id['id_base'];
- $number = isset( $parsed_id['number'] ) ? $parsed_id['number'] : null;
+ $number = $parsed_id['number'] ?? null;
$widget_object = $wp_widget_factory->get_widget_object( $id_base );
$creating = false;
} elseif ( $request['id_base'] ) {
diff --git a/src/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php b/src/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php
index 60c3c3ab24a22..51acf7fc90fc4 100644
--- a/src/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php
+++ b/src/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php
@@ -468,7 +468,7 @@ protected function get_registered_fields() {
$default_schema = array(
'type' => $default_args['type'],
'description' => empty( $args['description'] ) ? '' : $args['description'],
- 'default' => isset( $args['default'] ) ? $args['default'] : null,
+ 'default' => $args['default'] ?? null,
);
$rest_args = array_merge( $default_args, $rest_args );
diff --git a/src/wp-includes/revision.php b/src/wp-includes/revision.php
index e8bbcdbce4e52..4e7db396da2cd 100644
--- a/src/wp-includes/revision.php
+++ b/src/wp-includes/revision.php
@@ -89,8 +89,8 @@ function _wp_post_revision_data( $post = array(), $autosave = false ) {
$revision_data['post_status'] = 'inherit';
$revision_data['post_type'] = 'revision';
$revision_data['post_name'] = $autosave ? "$post[ID]-autosave-v1" : "$post[ID]-revision-v1"; // "1" is the revisioning system version.
- $revision_data['post_date'] = isset( $post['post_modified'] ) ? $post['post_modified'] : '';
- $revision_data['post_date_gmt'] = isset( $post['post_modified_gmt'] ) ? $post['post_modified_gmt'] : '';
+ $revision_data['post_date'] = $post['post_modified'] ?? '';
+ $revision_data['post_date_gmt'] = $post['post_modified_gmt'] ?? '';
return $revision_data;
}
diff --git a/src/wp-includes/rewrite.php b/src/wp-includes/rewrite.php
index 647977cc2041e..83dca2c43ddb8 100644
--- a/src/wp-includes/rewrite.php
+++ b/src/wp-includes/rewrite.php
@@ -579,7 +579,7 @@ function url_to_postid( $url ) {
} else {
// Chop off /path/to/blog.
$home_path = parse_url( home_url( '/' ) );
- $home_path = isset( $home_path['path'] ) ? $home_path['path'] : '';
+ $home_path = $home_path['path'] ?? '';
$url = preg_replace( sprintf( '#^%s#', preg_quote( $home_path ) ), '', trailingslashit( $url ) );
}
diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php
index c32e48210911c..09b21a2c5581c 100644
--- a/src/wp-includes/script-loader.php
+++ b/src/wp-includes/script-loader.php
@@ -1953,7 +1953,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-includes/shortcodes.php b/src/wp-includes/shortcodes.php
index 538b6e79daca0..4c0ec76df3d57 100644
--- a/src/wp-includes/shortcodes.php
+++ b/src/wp-includes/shortcodes.php
@@ -390,7 +390,7 @@ function do_shortcode_tag( $m ) {
return $return;
}
- $content = isset( $m[5] ) ? $m[5] : null;
+ $content = $m[5] ?? null;
$output = $m[1] . call_user_func( $shortcode_tags[ $tag ], $attr, $content, $tag ) . $m[6];
diff --git a/src/wp-includes/taxonomy.php b/src/wp-includes/taxonomy.php
index 52a5705331798..fc931df4a95cf 100644
--- a/src/wp-includes/taxonomy.php
+++ b/src/wp-includes/taxonomy.php
@@ -1657,7 +1657,7 @@ function sanitize_term( $term, $taxonomy, $context = 'display' ) {
$do_object = is_object( $term );
- $term_id = $do_object ? $term->term_id : ( isset( $term['term_id'] ) ? $term['term_id'] : 0 );
+ $term_id = $do_object ? $term->term_id : ( $term['term_id'] ?? 0 );
foreach ( (array) $fields as $field ) {
if ( $do_object ) {
@@ -3207,7 +3207,7 @@ function wp_update_term( $term_id, $taxonomy, $args = array() ) {
$parsed_args['slug'] = $slug;
- $term_group = isset( $parsed_args['term_group'] ) ? $parsed_args['term_group'] : 0;
+ $term_group = $parsed_args['term_group'] ?? 0;
if ( $args['alias_of'] ) {
$alias = get_term_by( 'slug', $args['alias_of'], $taxonomy );
if ( ! empty( $alias->term_group ) ) {
diff --git a/src/wp-includes/theme.php b/src/wp-includes/theme.php
index 911c4a942b923..b3488c635d7fc 100644
--- a/src/wp-includes/theme.php
+++ b/src/wp-includes/theme.php
@@ -1063,7 +1063,7 @@ function get_theme_mod( $name, $default_value = false ) {
*/
function set_theme_mod( $name, $value ) {
$mods = get_theme_mods();
- $old_value = isset( $mods[ $name ] ) ? $mods[ $name ] : false;
+ $old_value = $mods[ $name ] ?? false;
/**
* Filters the theme modification, or 'theme_mod', value on save.
@@ -3373,7 +3373,7 @@ function get_registered_theme_feature( $feature ) {
return null;
}
- return isset( $_wp_registered_theme_features[ $feature ] ) ? $_wp_registered_theme_features[ $feature ] : null;
+ return $_wp_registered_theme_features[ $feature ] ?? null;
}
/**
diff --git a/src/wp-includes/update.php b/src/wp-includes/update.php
index 350182b2ce77e..31411295efea6 100644
--- a/src/wp-includes/update.php
+++ b/src/wp-includes/update.php
@@ -99,7 +99,7 @@ function wp_version_check( $extra_stats = array(), $force_check = false ) {
'php' => $php_version,
'locale' => $locale,
'mysql' => $mysql_version,
- 'local_package' => isset( $wp_local_package ) ? $wp_local_package : '',
+ 'local_package' => $wp_local_package ?? '',
'blogs' => $num_blogs,
'users' => get_user_count(),
'multisite_enabled' => $multisite_enabled,
@@ -537,7 +537,7 @@ function wp_update_plugins( $extra_stats = array() ) {
foreach ( $update->translations as $translation ) {
if ( isset( $translation['language'], $translation['package'] ) ) {
$translation['type'] = 'plugin';
- $translation['slug'] = isset( $update->slug ) ? $update->slug : $update->id;
+ $translation['slug'] = $update->slug ?? $update->id;
$updates->translations[] = $translation;
}
@@ -818,7 +818,7 @@ function wp_update_themes( $extra_stats = array() ) {
foreach ( $update->translations as $translation ) {
if ( isset( $translation['language'], $translation['package'] ) ) {
$translation['type'] = 'theme';
- $translation['slug'] = isset( $update->theme ) ? $update->theme : $update->id;
+ $translation['slug'] = $update->theme ?? $update->id;
$new_update->translations[] = $translation;
}
diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php
index 9b25e49aa9d65..829a0f520905a 100644
--- a/src/wp-includes/user.php
+++ b/src/wp-includes/user.php
@@ -2320,7 +2320,7 @@ function wp_insert_user( $userdata ) {
$meta['show_admin_bar_front'] = empty( $userdata['show_admin_bar_front'] ) ? 'true' : $userdata['show_admin_bar_front'];
- $meta['locale'] = isset( $userdata['locale'] ) ? $userdata['locale'] : '';
+ $meta['locale'] = $userdata['locale'] ?? '';
$compacted = compact( 'user_pass', 'user_nicename', 'user_email', 'user_url', 'user_registered', 'user_activation_key', 'display_name' );
$data = wp_unslash( $compacted );
diff --git a/src/wp-includes/widgets.php b/src/wp-includes/widgets.php
index c568cbe301ae3..57ffc16276c46 100644
--- a/src/wp-includes/widgets.php
+++ b/src/wp-includes/widgets.php
@@ -182,7 +182,7 @@ function register_sidebars( $number = 1, $args = array() ) {
$_args['name'] = sprintf( __( 'Sidebar %d' ), $i );
}
} else {
- $_args['name'] = isset( $args['name'] ) ? $args['name'] : __( 'Sidebar' );
+ $_args['name'] = $args['name'] ?? __( 'Sidebar' );
}
/*
@@ -1478,7 +1478,7 @@ function wp_map_sidebars_widgets( $existing_sidebars_widgets ) {
// Sidebars_widgets settings from when this theme was previously active.
$old_sidebars_widgets = get_theme_mod( 'sidebars_widgets' );
- $old_sidebars_widgets = isset( $old_sidebars_widgets['data'] ) ? $old_sidebars_widgets['data'] : false;
+ $old_sidebars_widgets = $old_sidebars_widgets['data'] ?? false;
if ( is_array( $old_sidebars_widgets ) ) {
@@ -1692,8 +1692,8 @@ function wp_widget_rss_form( $args, $inputs = null ) {
);
$inputs = wp_parse_args( $inputs, $default_inputs );
- $args['title'] = isset( $args['title'] ) ? $args['title'] : '';
- $args['url'] = isset( $args['url'] ) ? $args['url'] : '';
+ $args['title'] = $args['title'] ?? '';
+ $args['url'] = $args['url'] ?? '';
$args['items'] = isset( $args['items'] ) ? (int) $args['items'] : 0;
if ( $args['items'] < 1 || 20 < $args['items'] ) {
diff --git a/src/wp-includes/widgets/class-wp-nav-menu-widget.php b/src/wp-includes/widgets/class-wp-nav-menu-widget.php
index 328f4167b9217..10f2ecf907c11 100644
--- a/src/wp-includes/widgets/class-wp-nav-menu-widget.php
+++ b/src/wp-includes/widgets/class-wp-nav-menu-widget.php
@@ -142,8 +142,8 @@ public function update( $new_instance, $old_instance ) {
*/
public function form( $instance ) {
global $wp_customize;
- $title = isset( $instance['title'] ) ? $instance['title'] : '';
- $nav_menu = isset( $instance['nav_menu'] ) ? $instance['nav_menu'] : '';
+ $title = $instance['title'] ?? '';
+ $nav_menu = $instance['nav_menu'] ?? '';
// Get menus.
$menus = wp_get_nav_menus();
diff --git a/src/wp-includes/widgets/class-wp-widget-block.php b/src/wp-includes/widgets/class-wp-widget-block.php
index 44371825ac57c..cf6bdd1f262e2 100644
--- a/src/wp-includes/widgets/class-wp-widget-block.php
+++ b/src/wp-includes/widgets/class-wp-widget-block.php
@@ -103,7 +103,7 @@ public function widget( $args, $instance ) {
private function get_dynamic_classname( $content ) {
$blocks = parse_blocks( $content );
- $block_name = isset( $blocks[0] ) ? $blocks[0]['blockName'] : null;
+ $block_name = $blocks[0]['blockName'] ?? null;
switch ( $block_name ) {
case 'core/paragraph':
diff --git a/src/wp-includes/widgets/class-wp-widget-custom-html.php b/src/wp-includes/widgets/class-wp-widget-custom-html.php
index 771520e1c4bc2..d0705215c9874 100644
--- a/src/wp-includes/widgets/class-wp-widget-custom-html.php
+++ b/src/wp-includes/widgets/class-wp-widget-custom-html.php
@@ -139,7 +139,7 @@ public function widget( $args, $instance ) {
$simulated_text_widget_instance = array_merge(
$instance,
array(
- 'text' => isset( $instance['content'] ) ? $instance['content'] : '',
+ 'text' => $instance['content'] ?? '',
'filter' => false, // Because wpautop is not applied.
'visual' => false, // Because it wasn't created in TinyMCE.
)
diff --git a/src/wp-includes/widgets/class-wp-widget-links.php b/src/wp-includes/widgets/class-wp-widget-links.php
index 58ae2a7919b54..6e9c3e569437d 100644
--- a/src/wp-includes/widgets/class-wp-widget-links.php
+++ b/src/wp-includes/widgets/class-wp-widget-links.php
@@ -39,14 +39,14 @@ public function __construct() {
* @param array $instance Settings for the current Links widget instance.
*/
public function widget( $args, $instance ) {
- $show_description = isset( $instance['description'] ) ? $instance['description'] : false;
- $show_name = isset( $instance['name'] ) ? $instance['name'] : false;
- $show_rating = isset( $instance['rating'] ) ? $instance['rating'] : false;
- $show_images = isset( $instance['images'] ) ? $instance['images'] : true;
- $category = isset( $instance['category'] ) ? $instance['category'] : false;
- $orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : 'name';
+ $show_description = $instance['description'] ?? false;
+ $show_name = $instance['name'] ?? false;
+ $show_rating = $instance['rating'] ?? false;
+ $show_images = $instance['images'] ?? true;
+ $category = $instance['category'] ?? false;
+ $orderby = $instance['orderby'] ?? 'name';
$order = 'rating' === $orderby ? 'DESC' : 'ASC';
- $limit = isset( $instance['limit'] ) ? $instance['limit'] : -1;
+ $limit = $instance['limit'] ?? -1;
$before_widget = preg_replace( '/ id="[^"]*"/', ' id="%id"', $args['before_widget'] );
diff --git a/src/wp-includes/widgets/class-wp-widget-recent-comments.php b/src/wp-includes/widgets/class-wp-widget-recent-comments.php
index 5d9293828332d..a0cdb82259675 100644
--- a/src/wp-includes/widgets/class-wp-widget-recent-comments.php
+++ b/src/wp-includes/widgets/class-wp-widget-recent-comments.php
@@ -190,7 +190,7 @@ public function update( $new_instance, $old_instance ) {
* @param array $instance Current settings.
*/
public function form( $instance ) {
- $title = isset( $instance['title'] ) ? $instance['title'] : '';
+ $title = $instance['title'] ?? '';
$number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;
?>
diff --git a/src/wp-includes/widgets/class-wp-widget-recent-posts.php b/src/wp-includes/widgets/class-wp-widget-recent-posts.php
index c73bb5b0bcf4f..c9c4a266a5e09 100644
--- a/src/wp-includes/widgets/class-wp-widget-recent-posts.php
+++ b/src/wp-includes/widgets/class-wp-widget-recent-posts.php
@@ -56,7 +56,7 @@ public function widget( $args, $instance ) {
if ( ! $number ) {
$number = 5;
}
- $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false;
+ $show_date = $instance['show_date'] ?? false;
$r = new WP_Query(
/**
diff --git a/src/wp-login.php b/src/wp-login.php
index 8810f5d0d81e7..28ef5f2136937 100644
--- a/src/wp-login.php
+++ b/src/wp-login.php
@@ -435,7 +435,7 @@ function wp_login_viewport_meta() {
* Check the request and redirect or display a form based on the current action.
*/
-$action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'login';
+$action = $_REQUEST['action'] ?? 'login';
$errors = new WP_Error();
if ( isset( $_GET['key'] ) ) {
@@ -1264,7 +1264,7 @@ function wp_login_viewport_meta() {
}
}
- $requested_redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
+ $requested_redirect_to = $_REQUEST['redirect_to'] ?? '';
/**
* Filters the login redirect URL.
*
diff --git a/src/wp-signup.php b/src/wp-signup.php
index d11f16698f095..7cf7fd3ae2a5d 100644
--- a/src/wp-signup.php
+++ b/src/wp-signup.php
@@ -969,7 +969,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
@@ -993,7 +993,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/src/wp-trackback.php b/src/wp-trackback.php
index 670d9c457bc81..b670339093aae 100644
--- a/src/wp-trackback.php
+++ b/src/wp-trackback.php
@@ -50,8 +50,8 @@ function trackback_response( $error = 0, $error_message = '' ) {
$post_id = (int) $post_id[ count( $post_id ) - 1 ];
}
-$trackback_url = isset( $_POST['url'] ) ? $_POST['url'] : '';
-$charset = isset( $_POST['charset'] ) ? $_POST['charset'] : '';
+$trackback_url = $_POST['url'] ?? '';
+$charset = $_POST['charset'] ?? '';
// These three are stripslashed here so they can be properly escaped after mb_convert_encoding().
$title = isset( $_POST['title'] ) ? wp_unslash( $_POST['title'] ) : '';