Making WordPress.org

Opened 3 years ago

Closed 3 years ago

#6032 closed defect (bug) (fixed)

plugins_api() 'downloadlink', 'reviews', and 'versions' query args do nothing.

Reported by: jsmoriss's profile jsmoriss Owned by: dd32's profile dd32
Milestone: Priority: normal
Component: API Keywords:
Cc:

Description

The following query should return the plugin reviews, and not a download link or the versions array, but these three query arguments do not work.

Example test script:

#!/usr/bin/php
<?php

define( 'BASE_PATH', '/.../wordpress/' );

require( BASE_PATH . 'wp-load.php' );
require( BASE_PATH . 'wp-admin/includes/plugin-install.php' );

$plugin_api_data = plugins_api( 'plugin_information', array(
	'slug' => 'wordpress-seo',
	'fields' => array(
		'active_installs'   => false,
		'added'             => false,
		'banners'           => false,
		'compatibility'     => false,
		'description'       => false,
		'donate_link'       => false,
		'downloaded'        => false,
		'downloadlink'      => false,	// Does not work.
		'contributors'      => false,
		'group'             => false,
		'homepage'          => false,
		'icons'             => false,
		'last_updated'      => false,
		'rating'            => true,
		'ratings'           => true,
		'reviews'           => true,	// Does not work.
		'requires'          => false,
		'requires_php'      => false,
		'sections'          => false,
		'short_description' => false,
		'tags'              => false,
		'tested'            => false,
		'versions'          => false,	// Does not work.
	),
) );

print_r( $plugin_api_data );

Outputs (I've trimmed the screenshots and versions arrays for brevity):

stdClass Object
(
    [name] => Yoast SEO
    [slug] => wordpress-seo
    [version] => 17.9
    [author] => <a href="https://yoa.st/1uk">Team Yoast</a>
    [author_profile] => https://profiles.wordpress.org/joostdevalk/
    [rating] => 96
    [ratings] => Array
        (
            [5] => 25772
            [4] => 619
            [3] => 178
            [2] => 125
            [1] => 731
        )

    [num_ratings] => 27425
    [support_threads] => 460
    [support_threads_resolved] => 372
    [download_link] => https://downloads.wordpress.org/plugin/wordpress-seo.17.9.zip
    [screenshots] => Array
        (
            [1] => Array
                (
                    [src] => https://ps.w.org/wordpress-seo/assets/screenshot-1.png?rev=2643727
                    [caption] => The Yoast SEO plugin general meta box. You'll see this on edit post pages, for posts, pages and custom post types.
                )

        )

    [versions] => Array
        (
            [17.9] => https://downloads.wordpress.org/plugin/wordpress-seo.17.9.zip
            [trunk] => https://downloads.wordpress.org/plugin/wordpress-seo.zip
        )

)

Change History (8)

#1 @dd32
3 years ago

  • Owner set to dd32
  • Status changed from new to accepted

I'll take a closer look this week, but note that for reviews they should be present in the response as sections.reviews not just reviews:

curl -s 'https://api.wordpress.org/plugins/info/1.2/?action=plugin_information&request\[slug\]=wordpress-seo&request\[fields\]=reviews' | jq '.sections.reviews'

They should be included by default as of the 1.2 API, but they're not so I'm guessing I've got an array_merge() in the wrong order.

Version 0, edited 3 years ago by dd32 (next)

This ticket was mentioned in Slack in #meta by dd32. View the logs.


3 years ago

#3 follow-up: @dd32
3 years ago

In 11535:

Plugin Directory: API: Allow clients to disable the versions and download_link fields.

Full changes:

  • Can disable the versions response key.
  • Can disable the download_link response key.
  • Incorrectly documented downloadlink key will affect the download_link key.
  • Requesting reviews without sections will now result in sections.reviews being returned still
  • Typos in documentation & code cleanup.

See #6032.

#4 @jsmoriss
3 years ago

Awesome! Thanks @dd32 ! :)

js.

#5 in reply to: ↑ 3 @dd32
3 years ago

Replying to dd32:

  • Requesting reviews without sections will now result in sections.reviews being returned still

Hmm.. That might be a mistake. Now explicitly disabling sections (but not touching 'reviews' which defaults to on) returns sections.reviews anyway: https://api.wordpress.org/plugins/info/1.2/?action=plugin_information&request[slug]=hello-dolly&request[fields][sections]=0

I might revert that, or disable reviews if sections is disabled without an explicit request for reviews.. later today..

#6 @dd32
3 years ago

In 11536:

Plugin Directory: API: Turning off sections should turn off reviews unless explicitely turned on.

This allows for sections to be turned off, without also having to turn off reviews explicitly, while allowing reviews without sections.

Follow up to [11535].
See #6032.

#7 @dd32
3 years ago

In 11543:

Plugin Directory: API: Allow clients to turn off teh screenshots field.

See #6032.

#8 @dd32
3 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed
Note: See TracTickets for help on using tickets.