diff -r 7b1b88e27a20 -r 48c4eec2b7e6 wp/wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php --- a/wp/wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php Thu Sep 29 08:06:27 2022 +0200 +++ b/wp/wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php Fri Sep 05 18:40:08 2025 +0200 @@ -298,7 +298,7 @@ ); if ( is_wp_error( $api ) ) { - if ( false !== strpos( $api->get_error_message(), 'Plugin not found.' ) ) { + if ( str_contains( $api->get_error_message(), 'Plugin not found.' ) ) { $api->add_data( array( 'status' => 404 ) ); } else { $api->add_data( array( 'status' => 500 ) ); @@ -381,7 +381,7 @@ $installed_locales = apply_filters( 'plugins_update_check_locales', $installed_locales ); $language_packs = array_map( - static function( $item ) { + static function ( $item ) { return (object) $item; }, $api->language_packs @@ -389,7 +389,7 @@ $language_packs = array_filter( $language_packs, - static function( $pack ) use ( $installed_locales ) { + static function ( $pack ) use ( $installed_locales ) { return in_array( $pack->language, $installed_locales, true ); } ); @@ -571,11 +571,13 @@ * * @since 5.5.0 * - * @param mixed $item Unmarked up and untranslated plugin data from {@see get_plugin_data()}. + * @param array $item Unmarked up and untranslated plugin data from {@see get_plugin_data()}. * @param WP_REST_Request $request Request object. * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. */ public function prepare_item_for_response( $item, $request ) { + $fields = $this->get_fields_for_response( $request ); + $item = _get_plugin_data_markup_translate( $item['_file'], $item, false ); $marked = _get_plugin_data_markup_translate( $item['_file'], $item, true ); @@ -600,7 +602,10 @@ $data = $this->add_additional_fields_to_object( $data, $request ); $response = new WP_REST_Response( $data ); - $response->add_links( $this->prepare_links( $item ) ); + + if ( rest_is_field_included( '_links', $fields ) || rest_is_field_included( '_embedded', $fields ) ) { + $response->add_links( $this->prepare_links( $item ) ); + } /** * Filters plugin data for a REST API response. @@ -625,7 +630,14 @@ protected function prepare_links( $item ) { return array( 'self' => array( - 'href' => rest_url( sprintf( '%s/%s/%s', $this->namespace, $this->rest_base, substr( $item['_file'], 0, - 4 ) ) ), + 'href' => rest_url( + sprintf( + '%s/%s/%s', + $this->namespace, + $this->rest_base, + substr( $item['_file'], 0, - 4 ) + ) + ), ), ); } @@ -797,7 +809,7 @@ $matched_search = false; foreach ( $item as $field ) { - if ( is_string( $field ) && false !== strpos( strip_tags( $field ), $search ) ) { + if ( is_string( $field ) && str_contains( strip_tags( $field ), $search ) ) { $matched_search = true; break; }