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 0fe5c62064b64..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 ( in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ), true ) ) { + if ( isset( $user_blogs[ $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 a31e77b00e26c..075ca04700489 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..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 && ! in_array( $subtype_name, array_keys( $provider->get_object_subtypes() ), true ) ) { - return false; + if ( $subtype_name ) { + $object_subtypes = $provider->get_object_subtypes(); + + if ( ! isset( $object_subtypes[ $subtype_name ] ) ) { + return false; + } } $page = absint( $page );