diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php index fc06af0c9bd37..944d0b7d985b2 100644 --- a/src/wp-admin/includes/ajax-actions.php +++ b/src/wp-admin/includes/ajax-actions.php @@ -1808,7 +1808,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 ); @@ -1839,7 +1839,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 ); @@ -1988,13 +1988,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 ); @@ -2052,8 +2052,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 ) ); } @@ -2393,7 +2393,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'] ) { @@ -3353,12 +3353,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 = ''; } @@ -3368,7 +3368,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 ) ) { @@ -3421,7 +3421,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]' ); @@ -3647,7 +3647,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 5cb818cd59bd2..184376654295e 100644 --- a/src/wp-admin/includes/class-core-upgrader.php +++ b/src/wp-admin/includes/class-core-upgrader.php @@ -403,7 +403,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 d6a5e823c8421..f95f9bc95dfe5 100644 --- a/src/wp-admin/includes/class-custom-image-header.php +++ b/src/wp-admin/includes/class-custom-image-header.php @@ -1351,7 +1351,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 ); @@ -1584,8 +1584,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 89b9f9ac87d96..733b109183846 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 aa97833c59a85..13b4dd7097cc9 100644 --- a/src/wp-admin/includes/class-plugin-installer-skin.php +++ b/src/wp-admin/includes/class-plugin-installer-skin.php @@ -45,7 +45,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 ); @@ -265,8 +265,8 @@ private function do_overwrite() { $blocked_message = '

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

'; $blocked_message .= '