WordPress.org

Making WordPress.org

Changeset 3556


Ignore:
Timestamp:
06/22/2016 03:21:57 PM (2 years ago)
Author:
ocean90
Message:

Plugin Directory: Change the API endpoint for locale banners to /locale-banner so it can be used for other requests.

See #1728.

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

Legend:

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

    r3545 r3556  
    1414        new Routes\Internal_Stats();
    1515        new Routes\Plugin();
    16         new Routes\Plugin_Translations();
     16        new Routes\Locale_Banner();
    1717        new Routes\Plugin_Favorites();
    1818        new Routes\Commit_Subscriptions();
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-locale-banner.php

    r3554 r3556  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\API\Routes;
     3use WordPressdotorg\Plugin_Directory\API\Base;
    34use WP_REST_Server;
    45
     
    89 * @package WordPressdotorg_Plugin_Directory
    910 */
    10 class Plugin_Translations extends Plugin {
     11class Locale_Banner extends Base {
    1112
    1213    function __construct() {
    13         register_rest_route( 'plugins/v1', '/plugin/(?P<plugin_slug>[^/]+)/translations/?', array(
    14             'methods'  => WP_REST_Server::READABLE,
    15             'callback' => array( $this, 'translations' ),
     14        register_rest_route( 'plugins/v1', '/locale-banner', array(
     15            'methods'  => WP_REST_Server::EDITABLE,
     16            'callback' => array( $this, 'locale_banner' ),
    1617            'args' => array(
    1718                'plugin_slug' => array(
     
    2829     * @return array A formatted array of all the data for the plugin.
    2930     */
    30     function translations( $request ) {
     31    function locale_banner( $request ) {
    3132        global $wpdb;
    3233
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/functions.php

    r3463 r3556  
    7676        wp_enqueue_script( 'wporg-plugins-accordion', get_template_directory_uri() . '/js/section-accordion.js', array(), '20160525', true );
    7777
    78         $slug = get_queried_object()->post_name;
    79         wp_enqueue_script( 'wporg-plugins-locale-banner', get_template_directory_uri() . '/js/locale-banner.js', array(), '20160619', true );
     78        wp_enqueue_script( 'wporg-plugins-locale-banner', get_template_directory_uri() . '/js/locale-banner.js', array(), '20160622', true );
    8079        wp_localize_script( 'wporg-plugins-locale-banner', 'wporgLocaleBanner', array(
    81             'apiURL' => rest_url( "/plugins/v1/plugin/$slug/translations" ),
     80            'apiURL' => rest_url( '/plugins/v1/locale-banner' ),
     81            'currentPlugin' => get_queried_object()->post_name,
    8282        ) );
    8383    }
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/js/locale-banner.js

    r3463 r3556  
    33
    44    $.ajax({
     5        type: 'POST',
    56        url : wporgLocaleBanner.apiURL,
    67        dataType : 'json',
     8        data: {
     9            'plugin_slug' : wporgLocaleBanner.currentPlugin
     10        },
    711        success : function( response ) {
    812            if ( ! response.suggest_string ) {
Note: See TracChangeset for help on using the changeset viewer.