379 $installed_locales = array_values( get_available_languages() ); |
379 $installed_locales = array_values( get_available_languages() ); |
380 /** This filter is documented in wp-includes/update.php */ |
380 /** This filter is documented in wp-includes/update.php */ |
381 $installed_locales = apply_filters( 'plugins_update_check_locales', $installed_locales ); |
381 $installed_locales = apply_filters( 'plugins_update_check_locales', $installed_locales ); |
382 |
382 |
383 $language_packs = array_map( |
383 $language_packs = array_map( |
384 static function( $item ) { |
384 static function ( $item ) { |
385 return (object) $item; |
385 return (object) $item; |
386 }, |
386 }, |
387 $api->language_packs |
387 $api->language_packs |
388 ); |
388 ); |
389 |
389 |
390 $language_packs = array_filter( |
390 $language_packs = array_filter( |
391 $language_packs, |
391 $language_packs, |
392 static function( $pack ) use ( $installed_locales ) { |
392 static function ( $pack ) use ( $installed_locales ) { |
393 return in_array( $pack->language, $installed_locales, true ); |
393 return in_array( $pack->language, $installed_locales, true ); |
394 } |
394 } |
395 ); |
395 ); |
396 |
396 |
397 if ( $language_packs ) { |
397 if ( $language_packs ) { |
569 /** |
569 /** |
570 * Prepares the plugin for the REST response. |
570 * Prepares the plugin for the REST response. |
571 * |
571 * |
572 * @since 5.5.0 |
572 * @since 5.5.0 |
573 * |
573 * |
574 * @param mixed $item Unmarked up and untranslated plugin data from {@see get_plugin_data()}. |
574 * @param array $item Unmarked up and untranslated plugin data from {@see get_plugin_data()}. |
575 * @param WP_REST_Request $request Request object. |
575 * @param WP_REST_Request $request Request object. |
576 * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. |
576 * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. |
577 */ |
577 */ |
578 public function prepare_item_for_response( $item, $request ) { |
578 public function prepare_item_for_response( $item, $request ) { |
|
579 $fields = $this->get_fields_for_response( $request ); |
|
580 |
579 $item = _get_plugin_data_markup_translate( $item['_file'], $item, false ); |
581 $item = _get_plugin_data_markup_translate( $item['_file'], $item, false ); |
580 $marked = _get_plugin_data_markup_translate( $item['_file'], $item, true ); |
582 $marked = _get_plugin_data_markup_translate( $item['_file'], $item, true ); |
581 |
583 |
582 $data = array( |
584 $data = array( |
583 'plugin' => substr( $item['_file'], 0, - 4 ), |
585 'plugin' => substr( $item['_file'], 0, - 4 ), |
598 ); |
600 ); |
599 |
601 |
600 $data = $this->add_additional_fields_to_object( $data, $request ); |
602 $data = $this->add_additional_fields_to_object( $data, $request ); |
601 |
603 |
602 $response = new WP_REST_Response( $data ); |
604 $response = new WP_REST_Response( $data ); |
603 $response->add_links( $this->prepare_links( $item ) ); |
605 |
|
606 if ( rest_is_field_included( '_links', $fields ) || rest_is_field_included( '_embedded', $fields ) ) { |
|
607 $response->add_links( $this->prepare_links( $item ) ); |
|
608 } |
604 |
609 |
605 /** |
610 /** |
606 * Filters plugin data for a REST API response. |
611 * Filters plugin data for a REST API response. |
607 * |
612 * |
608 * @since 5.5.0 |
613 * @since 5.5.0 |