Compare commits

..

11 Commits
2.0.0 ... main

Author SHA1 Message Date
Jason Cosper
39c1cbd522
Accessability improvements! 2023-06-19 09:09:09 -07:00
Jason Cosper
0b7deb3bf6
Update README.md
Making an attempt to meet WP Plugin Directory requirements
2023-05-30 09:18:18 -07:00
Jason Cosper
74bd81a9be
Update plu-redux.php
Making an attempt to meet WP Plugin Directory requirements
2023-05-30 09:12:07 -07:00
Jason Cosper
f2128c6482
Update README.md 2023-05-30 08:57:51 -07:00
Jason Cosper
16f648e649
Update plu-redux.php
Plugin now uses site's preferred date format.
Also cleaned up some wonky formatting.
2023-05-30 08:55:38 -07:00
Jason Cosper
fc95c38368 Version 2.2.0 2023-05-27 10:32:16 -07:00
Jason Cosper
81d5626519
Update README.md 2023-05-26 16:57:43 -07:00
Jason Cosper
6b73263aac
Update plu-redux.php
Dammit! Forgot to bump the version number.
2023-05-26 16:55:52 -07:00
Jason Cosper
0c16b76f17
Update plu-redux.php
* Fixed issue #1 — bug that would arise when WP-CLI is not available
* Added Git Updater header
2023-05-26 16:55:01 -07:00
Jason Cosper
82cffb82b4
Update plu-redux.php 2023-05-05 12:03:17 -07:00
Jason Cosper
4af73b93dc Added WP-CLI command 2023-05-05 17:23:13 +00:00
2 changed files with 180 additions and 6 deletions

View File

@ -1,4 +1,4 @@
# Plugin Last Updated Redux # PLU Redux
Displays a "Last Updated" date for all of your plugins installed by way of the WordPress Plugin Directory. Displays a "Last Updated" date for all of your plugins installed by way of the WordPress Plugin Directory.
@ -10,6 +10,42 @@ On plugins that have not been updated in over two years, a warning emoji is disp
2. Activate the plugin through the 'Plugins' screen in WordPress. 2. Activate the plugin through the 'Plugins' screen in WordPress.
3. That's it! The plugin will automatically display the last updated date for installed plugins available in the WordPress Plugin Directory. 3. That's it! The plugin will automatically display the last updated date for installed plugins available in the WordPress Plugin Directory.
## Usage
Once activated, the plugin will automatically display the last updated date for each plugin in your site's list of installed plugins.
For the Site Health check, navigate to "Tools → Site Health" in your WordPress dashboard.
## Site Health Check
The custom Site Health check will list any installed plugins that have not been updated in 2 years.
* If it finds any such plugins, it will return a "critical" status with the names of the old plugins.
* If it doesn't find any, it will return a "good" status, indicating that all installed plugins have been updated within the last 2 years.
## WP-CLI Command
PLU Redux includes a WP-CLI command that displays the "Last Updated" date of installed plugins. Here's how you use it:
```
wp plu list
```
This command will output a list of installed (WordPress Plugin Directory listed) plugins alongside their "Last Updated" date:
```
+-----------------------------------+---------------------------+
| Plugin Name | Last Updated |
+-----------------------------------+---------------------------+
| Akismet Anti-Spam Spam Protection | 2023-04-05 10:17am GMT |
| Lazy Load | 2018-11-22 04:43am GMT ← |
| Proxy Cache Purge | 2022-06-09 10:57pm GMT |
+-----------------------------------+---------------------------+
```
Plugins that have not been updated in over two years will be highlighted with an arrow (←) to the right of the "Last Updated" date.
## Frequently Asked Questions ## Frequently Asked Questions
### How does the plugin determine if a plugin hasn't been updated in over two years? ### How does the plugin determine if a plugin hasn't been updated in over two years?
@ -28,6 +64,31 @@ Sadly, no. PLU Redux only works with plugins that are available in the WordPress
## Changelog ## Changelog
### 2.2.3
* Added `aria-label` to warning emoji to improve accessability. Special thanks to Dale Reardon for letting me know about this!
### 2.2.2
* Making an attempt to meet WP Plugin Directory requirements.
* Added some documentation around the site health check to the README.
### 2.2.1
* Plugin now uses site's preferred date format.
* Also cleaned up some wonky formatting. 😅
### 2.2.0
* Added a Site Health check that lists any outdated plugins.
### 2.1.1
* Fixed bug that would prevent plugin from being installable when WP-CLI is not available.
* Added Git Updater header.
### 2.1.0
* Added a WP-CLI command.
### 2.0.0 ### 2.0.0
* Brought code up to date. * Brought code up to date.
* Added feature where a warning emoji is displayed next to plugins that have not been updated in over two years. * Added feature where a warning emoji is displayed next to plugins that have not been updated in over two years.

View File

@ -9,14 +9,14 @@
* been updated in over two years, a warning emoji is displayed * been updated in over two years, a warning emoji is displayed
* next to the "Last Updated" datestamp. * next to the "Last Updated" datestamp.
* *
* @package Plugin Last Updated Redux * @package PLU Redux
* @author Jason Cosper <boogah@gmail.com> * @author Jason Cosper <boogah@gmail.com>
* @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+
* @link https://github.com/boogah/plu-redux * @link https://github.com/boogah/plu-redux
* *
* @wordpress-plugin * @wordpress-plugin
* Plugin Name: Plugin Last Updated Redux * Plugin Name: PLU Redux
* Version: 2.0.0 * Version: 2.2.3
* Requires at least: 6.0 * Requires at least: 6.0
* Requires PHP: 7.4 * Requires PHP: 7.4
* Author: Jason Cosper * Author: Jason Cosper
@ -24,6 +24,7 @@
* License: GPL-2.0+ * License: GPL-2.0+
* License URI: https://www.gnu.org/licenses/gpl-2.0.txt * License URI: https://www.gnu.org/licenses/gpl-2.0.txt
* Description: Display the last updated date for plugins in the <a href="http://wordpress.org/plugins/">WordPress Plugin Directory</a>. * Description: Display the last updated date for plugins in the <a href="http://wordpress.org/plugins/">WordPress Plugin Directory</a>.
* GitHub Plugin URI: boogah/plu-redux
*/ */
// If this file is called directly, abort. // If this file is called directly, abort.
@ -58,8 +59,8 @@ function plu_redux_plugin_meta( $plugin_meta, $plugin_file ) {
$two_years_ago = strtotime('-2 years'); // get a Unix timestamp for 2 years ago $two_years_ago = strtotime('-2 years'); // get a Unix timestamp for 2 years ago
$last_updated_timestamp = strtotime($last_updated); // get a Unix timestamp for the last updated date $last_updated_timestamp = strtotime($last_updated); // get a Unix timestamp for the last updated date
$is_old = $last_updated_timestamp < $two_years_ago; // check if the last updated date is older than 2 years $is_old = $last_updated_timestamp < $two_years_ago; // check if the last updated date is older than 2 years
$warning = $is_old ? '⚠️ ' : ''; // if the last updated date is older than 2 years, add a warning symbol $warning = $is_old ? '<span role="img" aria-label="warning">⚠️</span> ' : ''; // if the last updated date is older than 2 years, add a warning symbol
$plugin_meta['last_updated'] = $warning . 'Last Updated: ' . esc_html( $last_updated ); // add the last updated date to the plugin meta array $plugin_meta['last_updated'] = $warning . 'Last Updated: ' . date_i18n( get_option( 'date_format' ), strtotime($last_updated)); // add the last updated date to the plugin meta array
} }
return $plugin_meta; // return the modified plugin meta array return $plugin_meta; // return the modified plugin meta array
@ -93,3 +94,115 @@ function plu_redux_get_last_updated( $slug ) {
return false; return false;
} }
/**
* WP-CLI command to display last updated dates of installed plugins.
*/
function plu_redux_last_updated_command() {
$plugins = get_plugins();
$table = new \cli\Table();
$table->setHeaders(array('Plugin Name', 'Last Updated'));
foreach ($plugins as $plugin_file => $plugin_info) {
// Extract the plugin's slug from the plugin filename
list($slug) = explode('/', $plugin_file);
// Generate a unique hash of the plugin's slug
$slug_hash = md5($slug);
// Get the last updated date from the cache
$last_updated = get_transient("plu_redux_{$slug_hash}");
// If the cache does not have the date, retrieve it from the WordPress API and cache it
if (false === $last_updated) {
$last_updated = plu_redux_get_last_updated($slug);
set_transient("plu_redux_{$slug_hash}", $last_updated, 86400); // cache for one day
}
if ($last_updated) {
// Check if last update was more than 2 years ago
$two_years_ago = strtotime('-2 years'); // get a Unix timestamp for 2 years ago
$last_updated_timestamp = strtotime($last_updated); // get a Unix timestamp for the last updated date
$is_old = $last_updated_timestamp < $two_years_ago; // check if the last updated date is older than 2 years
$warning = $is_old ? ' ←' : ''; // if the last updated date is older than 2 years, add a warning symbol
$table->addRow(array($plugin_info['Name'], $last_updated . $warning));
}
}
$table->display();
}
if ( class_exists( 'WP_CLI' ) ) {
\WP_CLI::add_command('plu list', 'plu_redux_last_updated_command');
}
// This filter hook is used to add a custom Site Health check
add_filter( 'site_status_tests', 'plu_redux_health_check' );
function plu_redux_health_check( $tests ) {
$tests['direct']['plugin_health_check'] = array(
'label' => __( 'Check for any plugins that have not been updated in 2 years' ),
'test' => 'perform_plugin_health_check',
);
return $tests;
}
function perform_plugin_health_check() {
$plugins = get_plugins();
$old_plugins = array();
foreach ($plugins as $plugin_file => $plugin_info) {
list($slug) = explode('/', $plugin_file);
$slug_hash = md5($slug);
$last_updated = get_transient("plu_redux_{$slug_hash}");
if (false === $last_updated) {
$last_updated = plu_redux_get_last_updated($slug);
set_transient("plu_redux_{$slug_hash}", $last_updated, 86400);
}
if ($last_updated) {
$two_years_ago = strtotime('-2 years');
$last_updated_timestamp = strtotime($last_updated);
$is_old = $last_updated_timestamp < $two_years_ago;
if ($is_old) {
$old_plugins[] = $plugin_info['Name'];
}
}
}
if (empty($old_plugins)) {
$result = array(
'label' => __( 'All plugins have been updated within the last 2 years' ),
'status' => 'good',
'badge' => array(
'label' => __( 'Plugins' ),
'color' => 'blue',
),
'description' => sprintf(
'<p>' . __( 'All plugins have been updated within the last 2 years.' ) . '</p>'
),
'actions' => '',
'test' => 'perform_plugin_health_check',
);
} else {
$result = array(
'label' => __( 'Some of your plugins have not been updated in over 2 years' ),
'status' => 'critical',
'badge' => array(
'label' => __( 'Plugins' ),
'color' => 'red',
),
'description' => sprintf(
'<p>' . __( 'The following plugins have not been updated in over 2 years: <em>%s.</em> It is highly suggested you look for <a href="http://wordpress.org/plugins/">actively developed alternatives</a>.' ) . '</p>',
implode(", ", $old_plugins)
),
'actions' => '',
'test' => 'perform_plugin_health_check',
);
}
return $result;
}