Making WordPress.org

Changeset 6496


Ignore:
Timestamp:
02/01/2018 04:27:18 AM (7 years ago)
Author:
dd32
Message:

Plugin Directory: API: Update the list of fields included by default in the info/1.2 endpoint.

See #111.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/standalone
Files:
2 edited

Legend:

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

    r6487 r6496  
    3636
    3737    static $plugins_info_fields_defaults = array(
    38         'added'         => true,
    39         'compatibility' => true,
    40         'contributors'  => true,
    41         'downloaded'    => true,
    42         'downloadlink'  => true,
    43         'donate_link'   => true,
    44         'homepage'      => true,
    45         'last_updated'  => true,
    46         'rating'        => true,
    47         'ratings'       => true,
    48         'requires'      => true,
    49         'requires_php'  => true,
    50         'sections'      => true,
    51         'tags'          => true,
    52         'tested'        => true,
     38        'added'             => true,
     39        'compatibility'     => true,
     40        'contributors'      => false,
     41        'bare_contributors' => true,
     42        'downloaded'        => true,
     43        'downloadlink'      => true,
     44        'donate_link'       => true,
     45        'homepage'          => true,
     46        'last_updated'      => true,
     47        'rating'            => true,
     48        'ratings'           => true,
     49        'requires'          => true,
     50        'requires_php'      => true,
     51        'sections'          => true,
     52        'tags'              => true,
     53        'tested'            => true,
     54    );
     55
     56    // Alterations made to default fields in the info/1.2 API.
     57    static $plugins_info_fields_defaults_12 = array(
     58        'downloaded'        => false,
     59        'bare_contributors' => false,
     60        'compatibility'     => false,
     61        'description'       => false,
     62        'banners'           => true,
     63        'reviews'           => true,
     64        'active_installs'   => true,
     65        'contributors'      => true,
    5366    );
    5467
     
    7285    );
    7386
     87    // Alterations made to the default fields in the info/1.2 API.
     88    static $query_plugins_fields_defaults_12 = array(
     89        'compatibility'   => false,
     90        'sections'        => false,
     91        'contributors'    => false,
     92        'versions'        => false,
     93        'screenshots'     => false,
     94        'last_updated'    => true,
     95        'icons'           => true,
     96        'active_installs' => true,
     97    );
     98
    7499    public function __construct( $args ) {
    75100        $args = (object) $args;
     
    105130
    106131        if ( 'plugin_information' == $method ) {
    107             $fields = array_merge( $fields, self::$plugins_info_fields_defaults );
     132            $fields = array_merge(
     133                $fields,
     134                self::$plugins_info_fields_defaults,
     135                ( defined( 'PLUGINS_API_VERSION' ) && PLUGINS_API_VERSION >= 1.2 ) ? self::$plugins_info_fields_defaults_12 : array()
     136            );
    108137        } elseif ( 'query_plugins' == $method ) {
    109             $fields = array_merge( $fields, self::$query_plugins_fields_defaults );
     138            $fields = array_merge(
     139                $fields,
     140                self::$query_plugins_fields_defaults,
     141                ( defined( 'PLUGINS_API_VERSION' ) && PLUGINS_API_VERSION >= 1.2 ) ? self::$query_plugins_fields_defaults_12 : array()
     142            );
    110143        } else {
    111144            return array();
     
    117150            $fields['compatibility'] = false;
    118151            $fields['description']   = false;
    119         }
    120 
    121         // In the 1.2+ version of the info API, we default to returning a more detailed list of contributors.
    122         // This can be enabled in older versions of the API by passing the 'contributors' field.
    123         if ( defined( 'PLUGINS_API_VERSION' ) && PLUGINS_API_VERSION >= 1.2 ) {
    124             $fields['contributors'] = true;
    125         } elseif ( ! isset( $this->requested_fields['contributors'] ) ) {
    126             $fields['bare_contributors'] = true;
    127152        }
    128153
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/standalone/class-plugins-info-api.php

    r6486 r6496  
    169169
    170170        // Back-compatible routines.
    171         // WordPress 4.x and older need a "bare" contributor map
     171        // WordPress 4.9 and older need a "bare" contributor map [ user => profile ]
    172172        if ( ! empty( $fields['bare_contributors'] ) ) {
    173173            $contribs                 = $response['contributors'];
Note: See TracChangeset for help on using the changeset viewer.