From ff06256ea15c088053e660cab569bfb97a57ebed Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Thu, 30 Jul 2026 14:03:19 +0530 Subject: [PATCH 1/3] Use isset() instead of in_array() over array_keys() --- src/wp-admin/includes/class-theme-installer-skin.php | 2 +- src/wp-admin/includes/dashboard.php | 2 +- src/wp-admin/nav-menus.php | 6 +++--- src/wp-includes/block-editor.php | 2 +- src/wp-includes/link-template.php | 2 +- src/wp-includes/media.php | 2 +- src/wp-includes/sitemaps.php | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/wp-admin/includes/class-theme-installer-skin.php b/src/wp-admin/includes/class-theme-installer-skin.php index 81e40122d5bc5..70f3452606fdd 100644 --- a/src/wp-admin/includes/class-theme-installer-skin.php +++ b/src/wp-admin/includes/class-theme-installer-skin.php @@ -248,7 +248,7 @@ private function do_overwrite() { $is_invalid_parent = false; if ( ! empty( $new_theme_data['Template'] ) ) { - $is_invalid_parent = ! in_array( $new_theme_data['Template'], array_keys( $all_themes ), true ); + $is_invalid_parent = ! isset( $all_themes[ $new_theme_data['Template'] ] ); } $rows = array( diff --git a/src/wp-admin/includes/dashboard.php b/src/wp-admin/includes/dashboard.php index 5fdbaf7a4fa40..c19e41944a784 100644 --- a/src/wp-admin/includes/dashboard.php +++ b/src/wp-admin/includes/dashboard.php @@ -579,7 +579,7 @@ function wp_dashboard_quick_press( $message = false, $notice_type = 'error' ) { $user_id = get_current_user_id(); // Don't create an option if this is a super admin who does not belong to this site. - if ( in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ), true ) ) { + if ( isset( get_blogs_of_user( $user_id )[ get_current_blog_id() ] ) ) { update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID. } } diff --git a/src/wp-admin/nav-menus.php b/src/wp-admin/nav-menus.php index 9998852d06d82..6a9925b0d4708 100644 --- a/src/wp-admin/nav-menus.php +++ b/src/wp-admin/nav-menus.php @@ -196,7 +196,7 @@ // If this menu item is a child of the previous. if ( ! empty( $menu_item_data['menu_item_parent'] ) - && in_array( (int) $menu_item_data['menu_item_parent'], array_keys( $dbids_to_orders ), true ) + && isset( $dbids_to_orders[ (int) $menu_item_data['menu_item_parent'] ] ) && isset( $orders_to_dbids[ $dbids_to_orders[ $menu_item_id ] - 1 ] ) && ( (int) $menu_item_data['menu_item_parent'] === $orders_to_dbids[ $dbids_to_orders[ $menu_item_id ] - 1 ] ) ) { @@ -230,7 +230,7 @@ ) { $_possible_parent_id = (int) get_post_meta( $orders_to_dbids[ $dbids_to_orders[ $parent_db_id ] - 1 ], '_menu_item_menu_item_parent', true ); - if ( in_array( $_possible_parent_id, array_keys( $dbids_to_orders ), true ) ) { + if ( isset( $dbids_to_orders[ $_possible_parent_id ] ) ) { $menu_item_data['menu_item_parent'] = $_possible_parent_id; } else { $menu_item_data['menu_item_parent'] = 0; @@ -256,7 +256,7 @@ // Else this menu item is not a child of the previous. } elseif ( empty( $menu_item_data['menu_order'] ) || empty( $menu_item_data['menu_item_parent'] ) - || ! in_array( (int) $menu_item_data['menu_item_parent'], array_keys( $dbids_to_orders ), true ) + || ! isset( $dbids_to_orders[ (int) $menu_item_data['menu_item_parent'] ] ) || empty( $orders_to_dbids[ $dbids_to_orders[ $menu_item_id ] - 1 ] ) || $orders_to_dbids[ $dbids_to_orders[ $menu_item_id ] - 1 ] !== (int) $menu_item_data['menu_item_parent'] ) { diff --git a/src/wp-includes/block-editor.php b/src/wp-includes/block-editor.php index c21e8d9e9feec..f08c934864916 100644 --- a/src/wp-includes/block-editor.php +++ b/src/wp-includes/block-editor.php @@ -184,7 +184,7 @@ function get_default_block_editor_settings() { } $default_size = get_option( 'image_default_size', 'large' ); - $image_default_size = in_array( $default_size, array_keys( $image_size_names ), true ) ? $default_size : 'large'; + $image_default_size = isset( $image_size_names[ $default_size ] ) ? $default_size : 'large'; $image_dimensions = array(); $all_sizes = wp_get_registered_image_subsizes(); diff --git a/src/wp-includes/link-template.php b/src/wp-includes/link-template.php index 223d6b5548fc6..484a8c8f8591c 100644 --- a/src/wp-includes/link-template.php +++ b/src/wp-includes/link-template.php @@ -3993,7 +3993,7 @@ function get_dashboard_url( $user_id = 0, $path = '', $scheme = 'admin' ) { } else { $current_blog = get_current_blog_id(); - if ( $current_blog && ( user_can( $user_id, 'manage_network' ) || in_array( $current_blog, array_keys( $blogs ), true ) ) ) { + if ( $current_blog && ( user_can( $user_id, 'manage_network' ) || isset( $blogs[ $current_blog ] ) ) ) { $url = admin_url( $path, $scheme ); } else { $active = get_active_blog_for_user( $user_id ); diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php index 7d0a0b5d0e737..874f92b2769ae 100644 --- a/src/wp-includes/media.php +++ b/src/wp-includes/media.php @@ -114,7 +114,7 @@ function image_constrain_size_for_editor( $width, $height, $size = 'medium', $co if ( (int) $content_width > 0 ) { $max_width = min( (int) $content_width, $max_width ); } - } elseif ( ! empty( $_wp_additional_image_sizes ) && in_array( $size, array_keys( $_wp_additional_image_sizes ), true ) ) { + } elseif ( isset( $_wp_additional_image_sizes[ $size ] ) ) { $max_width = (int) $_wp_additional_image_sizes[ $size ]['width']; $max_height = (int) $_wp_additional_image_sizes[ $size ]['height']; // Only in admin. Assume that theme authors know what they're doing. diff --git a/src/wp-includes/sitemaps.php b/src/wp-includes/sitemaps.php index 656fc5ecaa975..40701d5ac9212 100644 --- a/src/wp-includes/sitemaps.php +++ b/src/wp-includes/sitemaps.php @@ -116,7 +116,7 @@ function get_sitemap_url( $name, $subtype_name = '', $page = 1 ) { return false; } - if ( $subtype_name && ! in_array( $subtype_name, array_keys( $provider->get_object_subtypes() ), true ) ) { + if ( $subtype_name && ! isset( $provider->get_object_subtypes()[ $subtype_name ] ) ) { return false; } From 07d0b301f5c493095d9c77a39b08579b642bedab Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Fri, 7 Aug 2026 17:43:28 +0530 Subject: [PATCH 2/3] Refactor user blog checks in dashboard.php --- src/wp-admin/includes/dashboard.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/wp-admin/includes/dashboard.php b/src/wp-admin/includes/dashboard.php index 0d3117603f149..7a78025214f10 100644 --- a/src/wp-admin/includes/dashboard.php +++ b/src/wp-admin/includes/dashboard.php @@ -568,11 +568,13 @@ function wp_dashboard_quick_press( $message = false, $notice_type = 'error' ) { $post->post_title = ''; // Remove the auto draft title. } } else { - $post = get_default_post_to_edit( 'post', true ); - $user_id = get_current_user_id(); + $post = get_default_post_to_edit( 'post', true ); + $user_id = get_current_user_id(); + $user_blogs = get_blogs_of_user( $user_id ); + $current_blog_id = get_current_blog_id(); // Don't create an option if this is a super admin who does not belong to this site. - if ( isset( get_blogs_of_user( $user_id )[ get_current_blog_id() ] ) ) { + if ( isset( $user_blogs[ $current_blog_id ] ) ) { update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID. } } From ee5a06288e9dd1422ea1247ecc2f3acfe0239ec4 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Fri, 7 Aug 2026 17:45:46 +0530 Subject: [PATCH 3/3] Refactor subtype name check in sitemaps.php --- src/wp-includes/sitemaps.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/sitemaps.php b/src/wp-includes/sitemaps.php index 40701d5ac9212..e1d805d671133 100644 --- a/src/wp-includes/sitemaps.php +++ b/src/wp-includes/sitemaps.php @@ -116,8 +116,12 @@ function get_sitemap_url( $name, $subtype_name = '', $page = 1 ) { return false; } - if ( $subtype_name && ! isset( $provider->get_object_subtypes()[ $subtype_name ] ) ) { - return false; + if ( $subtype_name ) { + $object_subtypes = $provider->get_object_subtypes(); + + if ( ! isset( $object_subtypes[ $subtype_name ] ) ) { + return false; + } } $page = absint( $page );