Making WordPress.org

Changeset 9668


Ignore:
Timestamp:
04/01/2020 03:03:01 AM (5 years ago)
Author:
dd32
Message:

Plugin Directory: Switch the locale banner to a GET request and cache the request for up-to 1 hour.

See #3604.

Location:
sites/trunk/wordpress.org/public_html/wp-content
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-locale-banner.php

    r9667 r9668  
    1414    function __construct() {
    1515        register_rest_route( 'plugins/v1', '/locale-banner', array(
    16             'methods'  => WP_REST_Server::EDITABLE,
     16            'methods'  => WP_REST_Server::ALLMETHODS,
    1717            'callback' => array( $this, 'locale_banner' ),
    1818            'args'     => array(
     
    210210        }
    211211
    212         $result = [
     212        $result = new \WP_REST_Response( [
    213213            'suggest_string' => $suggest_string,
    214214            'translated'     => $translated_locales,
    215         ];
     215        ] );
     216
     217        // Allow this API to be cached, varied by Accept-Language header.
     218        $result->header( 'Vary', 'Accept-Language' );
     219        $result->header( 'Expires', gmdate( 'r', time() + 3600 ) );
     220        $result->header( 'Cache-Control', 'max-age=3600' );
    216221
    217222        return $result;
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/functions.php

    r9543 r9668  
    8888
    8989    if ( ! is_404() ) {
    90         wp_enqueue_script( 'wporg-plugins-locale-banner', get_stylesheet_directory_uri() . '/js/locale-banner.js', array( 'jquery' ), '20181209', true );
     90        wp_enqueue_script( 'wporg-plugins-locale-banner', get_stylesheet_directory_uri() . '/js/locale-banner.js', array( 'jquery' ), '20200401', true );
    9191        wp_localize_script( 'wporg-plugins-locale-banner', 'wporgLocaleBanner', array(
    9292            'apiURL'        => rest_url( '/plugins/v1/locale-banner' ),
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/js/locale-banner.js

    r7962 r9668  
    77
    88    $.ajax( {
    9         type: 'POST',
     9        type: 'GET',
    1010        url: wporgLocaleBanner.apiURL,
    1111        dataType: 'json',
Note: See TracChangeset for help on using the changeset viewer.