Making WordPress.org


Ignore:
Timestamp:
04/29/2024 03:19:13 AM (4 months ago)
Author:
dd32
Message:

Translate: Retrieve WordPress.org API via wp_safe_remote_get() rather than direct file_get_contents().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/inc/routes/class-wp-directory.php

    r6690 r13605  
    200200     */
    201201    public function get_language_packs( $type, $slug ) {
    202         $http_context = stream_context_create( array(
    203             'http' => array(
    204                 'user_agent' => 'WordPress.org Translate',
    205             ),
    206         ) );
    207202        if ( 'plugin' === $type ) {
    208203            $type = 'plugins';
     
    210205            $type = 'themes';
    211206        }
    212         $json = file_get_contents( "https://api.wordpress.org/translations/$type/1.0/?slug={$slug}", null, $http_context );
     207
     208        $json = wp_remote_retrieve_body(
     209            wp_safe_remote_get(
     210                "https://api.wordpress.org/translations/$type/1.0/?slug={$slug}",
     211                array(
     212                    'user-agent' => 'WordPress.org Translate',
     213                )
     214            )
     215        );
    213216        $language_packs = $json && '{' == $json[0] ? json_decode( $json ) : null;
    214217
Note: See TracChangeset for help on using the changeset viewer.