diff --git a/src/wp-admin/edit-comments.php b/src/wp-admin/edit-comments.php index d7f14f2cd09aa..f14a2b52c6fa8 100644 --- a/src/wp-admin/edit-comments.php +++ b/src/wp-admin/edit-comments.php @@ -331,7 +331,7 @@ } if ( $spammed > 0 ) { - $ids = isset( $_REQUEST['ids'] ) ? $_REQUEST['ids'] : 0; + $ids = $_REQUEST['ids'] ?? 0; $messages[] = sprintf( /* translators: %s: Number of comments. */ @@ -353,7 +353,7 @@ } if ( $trashed > 0 ) { - $ids = isset( $_REQUEST['ids'] ) ? $_REQUEST['ids'] : 0; + $ids = $_REQUEST['ids'] ?? 0; $messages[] = sprintf( /* translators: %s: Number of comments. */ diff --git a/src/wp-admin/edit-form-advanced.php b/src/wp-admin/edit-form-advanced.php index 12344df3ba57a..f4c23e078e1ed 100644 --- a/src/wp-admin/edit-form-advanced.php +++ b/src/wp-admin/edit-form-advanced.php @@ -76,7 +76,7 @@ */ $post_ID = isset( $post_ID ) ? (int) $post_ID : 0; $user_ID = isset( $user_ID ) ? (int) $user_ID : 0; -$action = isset( $action ) ? $action : ''; +$action = $action ?? ''; if ( (int) get_option( 'page_for_posts' ) === $post->ID && empty( $post->post_content ) ) { add_action( 'edit_form_after_title', '_wp_posts_page_notice' ); diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php index 3c5dab31b500b..36f41664d1ecc 100644 --- a/src/wp-admin/includes/ajax-actions.php +++ b/src/wp-admin/includes/ajax-actions.php @@ -1790,7 +1790,7 @@ function wp_ajax_closed_postboxes() { $hidden = isset( $_POST['hidden'] ) ? explode( ',', $_POST['hidden'] ) : array(); $hidden = array_filter( $hidden ); - $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; + $page = $_POST['page'] ?? ''; if ( sanitize_key( $page ) != $page ) { wp_die( 0 ); @@ -1821,7 +1821,7 @@ function wp_ajax_closed_postboxes() { */ function wp_ajax_hidden_columns() { check_ajax_referer( 'screen-options-nonce', 'screenoptionnonce' ); - $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; + $page = $_POST['page'] ?? ''; if ( sanitize_key( $page ) != $page ) { wp_die( 0 ); @@ -1970,13 +1970,13 @@ function wp_ajax_menu_locations_save() { function wp_ajax_meta_box_order() { check_ajax_referer( 'meta-box-order' ); $order = isset( $_POST['order'] ) ? (array) $_POST['order'] : false; - $page_columns = isset( $_POST['page_columns'] ) ? $_POST['page_columns'] : 'auto'; + $page_columns = $_POST['page_columns'] ?? 'auto'; if ( 'auto' !== $page_columns ) { $page_columns = (int) $page_columns; } - $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; + $page = $_POST['page'] ?? ''; if ( sanitize_key( $page ) != $page ) { wp_die( 0 ); @@ -2034,8 +2034,8 @@ function wp_ajax_get_permalink() { function wp_ajax_sample_permalink() { check_ajax_referer( 'samplepermalink', 'samplepermalinknonce' ); $post_id = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0; - $title = isset( $_POST['new_title'] ) ? $_POST['new_title'] : ''; - $slug = isset( $_POST['new_slug'] ) ? $_POST['new_slug'] : null; + $title = $_POST['new_title'] ?? ''; + $slug = $_POST['new_slug'] ?? null; wp_die( get_sample_permalink_html( $post_id, $title, $slug ) ); } @@ -2374,7 +2374,7 @@ function wp_ajax_save_widget() { $error = '

' . __( 'An error has occurred. Please reload the page and try again.' ) . '

'; $sidebars = wp_get_sidebars_widgets(); - $sidebar = isset( $sidebars[ $sidebar_id ] ) ? $sidebars[ $sidebar_id ] : array(); + $sidebar = $sidebars[ $sidebar_id ] ?? array(); // Delete. if ( isset( $_POST['delete_widget'] ) && $_POST['delete_widget'] ) { @@ -3334,12 +3334,12 @@ function wp_ajax_send_attachment_to_editor() { remove_filter( 'media_send_to_editor', 'image_media_send_to_editor' ); if ( str_starts_with( $post->post_mime_type, 'image' ) ) { - $align = isset( $attachment['align'] ) ? $attachment['align'] : 'none'; - $size = isset( $attachment['image-size'] ) ? $attachment['image-size'] : 'medium'; - $alt = isset( $attachment['image_alt'] ) ? $attachment['image_alt'] : ''; + $align = $attachment['align'] ?? 'none'; + $size = $attachment['image-size'] ?? 'medium'; + $alt = $attachment['image_alt'] ?? ''; // No whitespace-only captions. - $caption = isset( $attachment['post_excerpt'] ) ? $attachment['post_excerpt'] : ''; + $caption = $attachment['post_excerpt'] ?? ''; if ( '' === trim( $caption ) ) { $caption = ''; } @@ -3349,7 +3349,7 @@ function wp_ajax_send_attachment_to_editor() { } elseif ( wp_attachment_is( 'video', $post ) || wp_attachment_is( 'audio', $post ) ) { $html = stripslashes_deep( $_POST['html'] ); } else { - $html = isset( $attachment['post_title'] ) ? $attachment['post_title'] : ''; + $html = $attachment['post_title'] ?? ''; $rel = $rel ? ' rel="attachment wp-att-' . $id . '"' : ''; // Hard-coded string, $id is already sanitized. if ( ! empty( $url ) ) { @@ -3402,7 +3402,7 @@ function wp_ajax_send_link_to_editor() { $link_text = wp_basename( $src ); } - $post = get_post( isset( $_POST['post_id'] ) ? $_POST['post_id'] : 0 ); + $post = get_post( $_POST['post_id'] ?? 0 ); // Ping WordPress for an embed. $check_embed = $wp_embed->run_shortcode( '[embed]' . $src . '[/embed]' ); @@ -3627,7 +3627,7 @@ function wp_ajax_query_themes() { } } - $old_filter = isset( $args['browse'] ) ? $args['browse'] : 'search'; + $old_filter = $args['browse'] ?? 'search'; /** This filter is documented in wp-admin/includes/class-wp-theme-install-list-table.php */ $args = apply_filters( 'install_themes_table_api_args_' . $old_filter, $args ); diff --git a/src/wp-admin/includes/class-core-upgrader.php b/src/wp-admin/includes/class-core-upgrader.php index 165e1f7baee5d..fab9a39d4097b 100644 --- a/src/wp-admin/includes/class-core-upgrader.php +++ b/src/wp-admin/includes/class-core-upgrader.php @@ -399,7 +399,7 @@ public static function should_update_to_version( $offered_ver ) { public function check_files() { global $wp_version, $wp_local_package; - $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 ) ) { return false; diff --git a/src/wp-admin/includes/class-custom-image-header.php b/src/wp-admin/includes/class-custom-image-header.php index f1361440fa9cd..cf8c2ee3f07ff 100644 --- a/src/wp-admin/includes/class-custom-image-header.php +++ b/src/wp-admin/includes/class-custom-image-header.php @@ -1338,7 +1338,7 @@ final public function create_attachment_object( $cropped, $parent_attachment_id * @return int Attachment ID. */ final public function insert_attachment( $attachment, $cropped ) { - $parent_id = isset( $attachment['post_parent'] ) ? $attachment['post_parent'] : null; + $parent_id = $attachment['post_parent'] ?? null; unset( $attachment['post_parent'] ); $attachment_id = wp_insert_attachment( $attachment, $cropped ); @@ -1571,8 +1571,8 @@ public function get_uploaded_header_images() { foreach ( $header_images as &$header_image ) { $header_meta = get_post_meta( $header_image['attachment_id'] ); - $header_image['timestamp'] = isset( $header_meta[ $timestamp_key ] ) ? $header_meta[ $timestamp_key ] : ''; - $header_image['alt_text'] = isset( $header_meta[ $alt_text_key ] ) ? $header_meta[ $alt_text_key ] : ''; + $header_image['timestamp'] = $header_meta[ $timestamp_key ] ?? ''; + $header_image['alt_text'] = $header_meta[ $alt_text_key ] ?? ''; } return $header_images; diff --git a/src/wp-admin/includes/class-language-pack-upgrader.php b/src/wp-admin/includes/class-language-pack-upgrader.php index 03095700311dd..ca487ffbbbeb1 100644 --- a/src/wp-admin/includes/class-language-pack-upgrader.php +++ b/src/wp-admin/includes/class-language-pack-upgrader.php @@ -265,7 +265,7 @@ public function bulk_upgrade( $language_updates = array(), $args = array() ) { $language_updates_results[] = array( 'language' => $language_update->language, 'type' => $language_update->type, - 'slug' => isset( $language_update->slug ) ? $language_update->slug : 'default', + 'slug' => $language_update->slug ?? 'default', 'version' => $language_update->version, ); } diff --git a/src/wp-admin/includes/class-plugin-installer-skin.php b/src/wp-admin/includes/class-plugin-installer-skin.php index ed165ed2d150e..47b507272c7cc 100644 --- a/src/wp-admin/includes/class-plugin-installer-skin.php +++ b/src/wp-admin/includes/class-plugin-installer-skin.php @@ -39,7 +39,7 @@ public function __construct( $args = array() ) { $this->type = $args['type']; $this->url = $args['url']; - $this->api = isset( $args['api'] ) ? $args['api'] : array(); + $this->api = $args['api'] ?? array(); $this->overwrite = $args['overwrite']; parent::__construct( $args ); @@ -259,8 +259,8 @@ private function do_overwrite() { $blocked_message = '

' . esc_html__( 'The plugin cannot be updated due to the following:' ) . '

'; $blocked_message .= '