Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions features/plugin-list-wporg-status.feature
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,50 @@ Feature: Check the status of plugins on WordPress.org
| wordpress-importer | active | 2025-09-26 |
| no-longer-in-directory | closed | 2017-11-13 |
| never-wporg | | |

@less-than-wp-5.3
Scenario: The wp.org last updated date is still rendered on WordPress < 5.3
Given a WP install
And I run `wp option update timezone_string Asia/Tokyo`
And a wp-content/plugins/wporg-dated/wporg-dated.php file:
"""
<?php
/**
* Plugin Name: Plugin with a WordPress.org release date
* Version: 1.0.0
*/
"""
And that HTTP requests to https://api.wordpress.org/plugins/info/1.2/?action=plugin_information&request%5Blocale%5D=en_US&request%5Bslug%5D=wporg-dated will respond with:
"""
HTTP/1.1 200
Content-Type: application/json

{
"name": "Plugin with a WordPress.org release date",
"slug": "wporg-dated",
"last_updated": "2025-09-26 9:07pm GMT"
}
"""
And that HTTP requests to https://plugins.trac.wordpress.org/log/wporg-dated/?limit=1&mode=stop_on_copy&format=rss will respond with:
"""
HTTP/1.1 200
Content-Type: application/rss+xml;charset=utf-8

<?xml version="1.0"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
<channel>
<item>
<pubDate>Fri, 26 Sep 2025 21:07:26 GMT</pubDate>
</item>
</channel>
</rss>
"""

# wp_date() only exists since WordPress 5.3, so this goes through the
# get_date_from_gmt() fallback. The pubDate above is 21:07 UTC, which is already
# the next day in Asia/Tokyo, so this also pins that the fallback renders in the
# site timezone rather than in UTC.
When I run `wp plugin list --fields=name,wporg_last_updated`
Then STDOUT should be a table containing rows:
| name | wporg_last_updated |
| wporg-dated | 2025-09-27 |
24 changes: 24 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,27 @@ parameters:
- identifier: missingType.property
- identifier: missingType.parameter
- identifier: missingType.return

# johnbillion/wp-compat checks every WordPress symbol against the WordPress 4.9
# baseline that wp-cli-tests configures. It only recognizes function_exists() and
# method_exists() guards, so it cannot see the `wp_version_compare()` checks that
# gate the plugin dependency features, and reports those as errors.
#
# The entries below match on the message as well as the identifier, so that a call to
# something introduced later than the version each feature is gated on still gets
# reported rather than swallowed by a file-wide ignore.

# `wp plugin install --with-dependencies` aborts on WordPress < 6.5 in
# `Plugin_Command::install()`, before reaching `get_plugin_dependencies()`, and
# `wp plugin install-dependencies` does the same check in the command method itself.
-
identifier: WPCompat.methodNotAvailable
message: '#^WP_Plugin_Dependencies::(get_dependencies|initialize)\(\) is only available since WordPress version 6\.5\.0\.$#'
path: src/Plugin_Command.php

# WordPress 5.3 only formalized the already documented `...$arg` parameter of
# `do_action()` by adding it to the function signature. Additional arguments were
# collected through `func_get_args()` before that.
-
identifier: WPCompat.parameterNotAvailable.doaction.arg
path: src/Plugin_Command.php
14 changes: 13 additions & 1 deletion src/Plugin_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,19 @@ protected function get_wporg_data( $plugin_name ) {
if ( false !== $xml ) {
$xml_pub_date = $xml->xpath( '//pubDate' );
if ( $xml_pub_date ) {
$data['last_updated'] = wp_date( 'Y-m-d', strtotime( $xml_pub_date[0] ) ?: null );
$pub_date = strtotime( $xml_pub_date[0] ) ?: null;

if ( function_exists( 'wp_date' ) ) {
$data['last_updated'] = wp_date( 'Y-m-d', $pub_date );
} else {
// wp_date() is WordPress 5.3+. get_date_from_gmt() renders in the site
// timezone the same way, without date_i18n()'s pre-5.3 contract of
// expecting a timestamp that already has the offset added to it.
$data['last_updated'] = get_date_from_gmt(
gmdate( 'Y-m-d H:i:s', $pub_date ?? time() ),
'Y-m-d'
);
}
}
}
}
Expand Down