Skip to content

Commit d3e0c71

Browse files
authored
fix: detect closed WordPress.org plugins (#550)
1 parent 2077d49 commit d3e0c71

2 files changed

Lines changed: 15 additions & 10 deletions

File tree

‎features/plugin-list-wporg-status.feature‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ Feature: Check the status of plugins on WordPress.org
3030
Content-Type: application/json
3131
3232
{
33-
error: "closed",
34-
name: "No Longer in Directory",
35-
slug: "no-longer-in-directory",
36-
description: "This plugin has been closed as of October 2, 2018 and is not available for download. This closure is permanent. Reason: Guideline Violation.",
37-
closed: true,
38-
closed_date: "2018-10-02",
39-
reason: "guideline-violation",
40-
reason_text: "Guideline Violation"
33+
"error": "closed",
34+
"name": "No Longer in Directory",
35+
"slug": "no-longer-in-directory",
36+
"description": "This plugin has been closed as of October 2, 2018 and is not available for download. This closure is permanent. Reason: Guideline Violation.",
37+
"closed": true,
38+
"closed_date": "2018-10-02",
39+
"reason": "guideline-violation",
40+
"reason_text": "Guideline Violation"
4141
}
4242
"""
4343
And that HTTP requests to https://plugins.trac.wordpress.org/log/wordpress-importer/?limit=1&mode=stop_on_copy&format=rss will respond with:

‎src/Plugin_Command.php‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,9 +1127,14 @@ protected function get_wporg_data( $plugin_name ) {
11271127
$plugin_data = false;
11281128
}
11291129
if ( $plugin_data ) {
1130-
$data['status'] = 'active';
1130+
if ( ! empty( $plugin_data['closed'] ) || ( isset( $plugin_data['error'] ) && 'closed' === $plugin_data['error'] ) ) {
1131+
$data['status'] = 'closed';
1132+
} else {
1133+
$data['status'] = 'active';
1134+
}
1135+
11311136
if ( ! $this->check_wporg['last_updated'] ) {
1132-
return $data; // The plugin is active on .org, but we don't need the date.
1137+
return $data; // The plugin is active or closed on .org, but we don't need the date.
11331138
}
11341139
// The plugins API already reports when the plugin was last updated, so use
11351140
// that instead of also scraping the trac log, which is rate-limited and

0 commit comments

Comments
 (0)