Making WordPress.org


Ignore:
Timestamp:
12/19/2016 07:00:06 AM (7 years ago)
Author:
dd32
Message:

Plugin Directory: Allow us to return the FAQ section with <h4> instead of <dl> for existing WordPress versions.
Also fixes the hot_tags endpoint to work correctly.

See #2112.

File:
1 edited

Legend:

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

    r4125 r4559  
    112112            if ( 'reviews' === $field && ! $include ) {
    113113                unset( $response['sections']['reviews'] );
     114            }
     115            if ( 'enhanced_faq' === $field ) {
     116                if ( $include ) {
     117                     $response['sections']['faq'] = $response['sections']['enhanced_faq'];
     118                }
     119                unset( $response['sections']['enhanced_faq'] );
    114120            }
    115121        }
     
    180186     */
    181187    public function popular_tags( $request ) {
    182         if ( false === ( $response = false&& wp_cache_get( $cache_key = $this->popular_tags_cache_key( $request ), self::CACHE_GROUP ) ) ) {
    183             $response = $this->internal_rest_api_call( 'plugins/v1/popular-categories', array( 'locale' => $request->locale ) );
     188        if ( false === ( $response = wp_cache_get( $cache_key = $this->popular_tags_cache_key( $request ), self::CACHE_GROUP ) ) ) {
     189            $response = $this->internal_rest_api_call( 'plugins/v1/popular-tags', array( 'locale' => $request->locale ) );
    184190
    185191            if ( 200 != $response->status ) {
     
    191197        }
    192198
    193         if ( $request->number && count( $response ) > $request->number ) {
    194             $response = array_slice( $response, 0, $request->number, true );
     199        $number_items_requested = 100;
     200        if ( !empty( $request->number ) ) {
     201            $number_items_requested = $request->number;
     202        }
     203
     204        if ( count( $response ) > $number_items_requested ) {
     205            $response = array_slice( $response, 0, $number_items_requested, true );
    195206        }
    196207
    197208        $this->output( (object) $response );
    198209    }
    199     /**
    200      * Generates a cache key for a 'hot_categories' API request.
     210
     211    /**
     212     * Generates a cache key for a 'hot_tags' API request.
    201213     */
    202214    protected function popular_tags_cache_key( $request ) {
    203         return 'hot_categories:' . $request->locale;
     215        return 'hot_tags:' . $request->locale;;
    204216    }
    205217
Note: See TracChangeset for help on using the changeset viewer.