Changeset 3343571
- Timestamp:
- 08/12/2025 12:57:42 PM (4 months ago)
- Location:
- plugginsight-maintenance-status
- Files:
-
- 11 added
- 3 edited
-
tags/1.0.3 (added)
-
tags/1.0.3/README.txt (added)
-
tags/1.0.3/languages (added)
-
tags/1.0.3/languages/plugginsight-maintenance-status.en_GB.mo (added)
-
tags/1.0.3/languages/plugginsight-maintenance-status.en_GB.po (added)
-
tags/1.0.3/languages/plugginsight-maintenance-status.en_US.mo (added)
-
tags/1.0.3/languages/plugginsight-maintenance-status.en_US.po (added)
-
tags/1.0.3/languages/plugginsight-maintenance-status.pot (added)
-
tags/1.0.3/plugginsight-maintenance-status.css (added)
-
tags/1.0.3/plugginsight-maintenance-status.js (added)
-
tags/1.0.3/plugginsight-maintenance-status.php (added)
-
trunk/README.txt (modified) (6 diffs)
-
trunk/languages/plugginsight-maintenance-status.pot (modified) (2 diffs)
-
trunk/plugginsight-maintenance-status.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
plugginsight-maintenance-status/trunk/README.txt
r3273818 r3343571 3 3 Tags: plugin last updated, plugin maintenance status, last updated check, Maintenance Manager, PluggInsight 4 4 Tested up to: 6.8 5 Stable tag: 1.0.2 5 Stable tag: 1.0.3 6 Requires at least: 5.0 6 7 License: GPLv3 or later 7 8 License URI: https://www.gnu.org/licenses/gpl-3.0.en.html … … 10 11 11 12 == Description == 12 The Plugin Maintenance Status plugin enhances your WordPress plugin management experience by providing convenient access to maintenance details for each installed plugin. With this plugin, you can quickly check the maintenance status of your plugins without even leaving the plugin page. Users can easily monitor for plugins that were removed for injecting malware or any other guideline violation. 13 14 Further it helps the admins make informed decision before updating the site to the latest WordPress version. 13 PluggInsight – Maintenance Status is a lightweight, zero-configuration WordPress plugin designed to help site administrators and developers monitor the health and maintenance status of other installed plugins directly from the admin dashboard. With color coded indicators PluggInsight brings all the essential maintenance information right into the plugins page, streamlining your workflow and enhancing visibility. 15 14 16 15 … … 18 17 = Features = 19 18 - **Simple & Straightforward**: There are no settings to configure 20 - **Plugin Maintenance Details**: Get immediate access to maintenance information for each plugin such as *Last Updated* details, *Tested up to* and the *Latest Version* released, right from the default plugin page itself. Quick links to *Support* page, *Changelog* page and *Review* page helps you make informed decision before updating plugins.19 - **Plugin Maintenance Details**: Get immediate access to maintenance information for each plugin such as *Last Updated* details, *Tested up to* and the *Latest Version* released, right from the default plugin page itself. 21 20 - **Time-saving convenience**: No need to navigate away from the plugin page to check maintenance status. 22 - **Monitor plugins removed from repo**: Any plugins that were removed from WP repo, either by plugin author request or for guideline violation can be easily monitored. 21 - **Monitor plugins removed from repo**: Any plugins that were removed from WP repo, either by plugin author request or for guideline violation can be easily monitored. 23 22 - **Data Sourced from Official Repository**: The plugin uses the WP plugin repository API to source the data. So the data is trustworthy, as Individual plugin authors have tested and reported that their plugins are compatible with the latest WordPress versions. 24 23 - **Cache**: The plugin by default stores the data for a day, which means not every time you visit the plugin page a new API request is not being sent. So doesn't affect loading speed on general use once cached. 25 24 - **Clear cache functionality**: Give the admin to control and clear maintenance cache data of plugins with just a single click. Admins can utilize this feature from the Maintenance Status Plugin Page. 26 - **Colored Status Bar**: A visual identity, which has 5 different colours helps you to easily identify which plugins are not updated or tested with the latest release versions. 25 - **Colored Status Bar**: A visual identity, which has 5 different colours helps you to easily identify which plugins are not updated or tested with the latest release versions. Checkout our [documentation on what each color indicates](https://projektisle.com/docs/plugginsight/configuration/color-coded-status-indicators/?utm_campaign=plugginsight-docs&utm_source=wp.org). 27 26 - **Decide when to update WP itself**: Before updating to the latest version of WordPress, make sure all the plugins you rely on are compatible and tested with the new version. Helps you to avoid plugin conflict with new WP versions. 28 27 - **Translation-ready**: The plugin is fully translatable, allowing you to localize the plugin to your preferred language. … … 37 36 - The plugin uses Tested Up to Data to display this status bar. 38 37 - A plugin removed from WP repo, but still maintained from their private repo, will be only shown as plugin removed. 39 - The plugin checks for the latest major WP release and compare it with the major release mention in the tested up to data. The below color codes show how they are calculated38 - The plugin checks for the latest major WP release and compare it with the major release mention in the tested up to data. 40 39 41 40 42 **Green**: If both has same major release version. 43 44 **Orange**: If difference is more than 1 but less that 3. 45 46 **Red**: If the difference is more than 3. 47 48 **Blue**: If the plugin is tested upto the upcoming major release. 49 50 **Grey**: If the plugin was removed from the repository, either because of plugin author request or for guideline violation. 51 52 So if a plugin hasn't been updated for 5 years, but the author has confirmed that it works with the latest version the status bar will be shown as green. 53 If a plugin was removed from repo by plugin author, but actively maintains from their personal repository, the statur bar will be shown as grey. 41 > Dated: Aug 2025 42 > **Important:** The WordPress API doesn't show the reason for plugin deactivation anymore. Thereby, the plugin cannot particularly display whether the plugin was removed or not. Hence it will just display 'Plugin not found'. 54 43 55 44 … … 76 65 77 66 = Want more Features? = 78 If you have a better idea to implement this functionality of the plugin or if you would like to add more feature. Do submit a request in the GitHub repository. 67 If you have a better idea or if you would like to add more feature. Do submit a request in the GitHub repository. 68 69 = Need more answers? = 70 Check out our [FAQ](https://projektisle.com/docs/plugginsight/faq/?utm_campaign=plugginsight-docs&utm_source=wp.org) section for detailed information. 79 71 80 72 == Screenshots == … … 84 76 85 77 == Changelog == 78 = 1.0.3 = 79 * Code refactored. 80 * **Better Cache Bursting:** The plugin now correctly clears the transient cache upon deactivation, ensuring fresh data is fetched on reactivation. 81 * **Performance Boost:** The code responsible for clearing and refreshing the cache has been optimized, resulting in a **~40% increase in cache refresh speed**. 82 86 83 = 1.0.2 = 87 84 * Version Updates for WP 6.8 -
plugginsight-maintenance-status/trunk/languages/plugginsight-maintenance-status.pot
r3273818 r3343571 3 3 msgstr "" 4 4 "Project-Id-Version: \n" 5 "POT-Creation-Date: 2025-0 4-15 11:23+0530\n"5 "POT-Creation-Date: 2025-08-12 17:57+0530\n" 6 6 "PO-Revision-Date: 2024-12-31 14:48+0530\n" 7 7 "Last-Translator: \n" … … 16 16 "X-Poedit-SearchPath-0: .\n" 17 17 18 #: plugginsight-maintenance-status.php: 5219 #: plugginsight-maintenance-status.php: 5320 #: plugginsight-maintenance-status.php:1 3718 #: plugginsight-maintenance-status.php:44 19 #: plugginsight-maintenance-status.php:45 20 #: plugginsight-maintenance-status.php:180 21 21 msgid "Maintenance Status" 22 22 msgstr "" 23 23 24 #: plugginsight-maintenance-status.php: 6924 #: plugginsight-maintenance-status.php:70 25 25 msgid "Maintenance Status Settings" 26 26 msgstr "" 27 27 28 #: plugginsight-maintenance-status.php:7 028 #: plugginsight-maintenance-status.php:71 29 29 msgid "Manage Maintenance Status Cache" 30 30 msgstr "" 31 31 32 #: plugginsight-maintenance-status.php:7 132 #: plugginsight-maintenance-status.php:72 33 33 msgid "Disclaimer:" 34 34 msgstr "" 35 35 36 #: plugginsight-maintenance-status.php:7 136 #: plugginsight-maintenance-status.php:72 37 37 msgid "The plugin and its developer do not independently verify the accuracy or validity of each plugin's data. The data displayed is obtained from the WP plugin repository, where individual plugin authors have tested and reported that their plugins are compatible with the latest WordPress versions. All the displayed logic in this plugin is based on that data." 38 38 msgstr "" 39 39 40 #: plugginsight-maintenance-status.php:7 240 #: plugginsight-maintenance-status.php:73 41 41 msgid "The below process will depend on the number of plugins you have installed. More plugins installed, more time it will take to reload this cache." 42 42 msgstr "" 43 43 44 #: plugginsight-maintenance-status.php:7 844 #: plugginsight-maintenance-status.php:79 45 45 msgid "Clear Status Cache" 46 46 msgstr "" 47 47 48 #: plugginsight-maintenance-status.php:10 448 #: plugginsight-maintenance-status.php:101 49 49 msgid "Cache cleared and refreshed successfully." 50 50 msgstr "" 51 51 52 #: plugginsight-maintenance-status.php:10 752 #: plugginsight-maintenance-status.php:104 53 53 msgid "Invalid security token. Cache clearing and refreshing failed." 54 54 msgstr "" 55 55 56 #: plugginsight-maintenance-status.php:1 2556 #: plugginsight-maintenance-status.php:169 57 57 msgid "Settings" 58 58 msgstr "" 59 59 60 #: plugginsight-maintenance-status.php:1 3960 #: plugginsight-maintenance-status.php:182 61 61 msgid "Update Status Cache" 62 62 msgstr "" 63 63 64 #: plugginsight-maintenance-status.php:2 4664 #: plugginsight-maintenance-status.php:285 65 65 msgid "Plugin Removed from WP" 66 66 msgstr "" 67 67 68 #: plugginsight-maintenance-status.php:2 4768 #: plugginsight-maintenance-status.php:286 69 69 msgid "Date:" 70 70 msgstr "" 71 71 72 #: plugginsight-maintenance-status.php:2 4872 #: plugginsight-maintenance-status.php:287 73 73 msgid "Reason:" 74 74 msgstr "" 75 75 76 #: plugginsight-maintenance-status.php:253 76 #: plugginsight-maintenance-status.php:295 77 #: plugginsight-maintenance-status.php:304 78 msgid "Plugin not found in the repository" 79 msgstr "" 80 81 #: plugginsight-maintenance-status.php:298 77 82 msgid "Latest Version:" 78 83 msgstr "" 79 84 80 #: plugginsight-maintenance-status.php:2 5485 #: plugginsight-maintenance-status.php:299 81 86 msgid "Last Updated:" 82 87 msgstr "" 83 88 84 #: plugginsight-maintenance-status.php: 25589 #: plugginsight-maintenance-status.php:300 85 90 msgid "Tested Up to:" 86 91 msgstr "" 87 88 #: plugginsight-maintenance-status.php:25989 msgid "Plugin not available in the repository"90 msgstr ""91 92 #: plugginsight-maintenance-status.php:29193 msgid "No name specified"94 msgstr ""95 96 #: plugginsight-maintenance-status.php:29297 msgid "No slug specified"98 msgstr ""99 100 #: plugginsight-maintenance-status.php:293101 msgid "No version specified"102 msgstr ""103 104 #: plugginsight-maintenance-status.php:294105 msgid "No last updated date specified"106 msgstr ""107 108 #: plugginsight-maintenance-status.php:295109 msgid "No tested version specified"110 msgstr ""111 112 #: plugginsight-maintenance-status.php:305113 msgid "No reason specified"114 msgstr "" -
plugginsight-maintenance-status/trunk/plugginsight-maintenance-status.php
r3273818 r3343571 2 2 /** 3 3 * Plugin Name: PluggInsight - Maintenance Status 4 * Plugin URI: https://wordpress.org/plugins/plugginsight-maintenance-status/ 4 5 * Description: Easily access maintenance details for each plugin directly on the WordPress plugin page. 5 * Version: 1.0. 26 * Version: 1.0.3 6 7 * Author: Alan Jacob Mathew 7 8 * Author URI: https://profiles.wordpress.org/alanjacobmathew/ … … 12 13 */ 13 14 14 if ( ! defined( 'ABSPATH' ) ) exit; 15 if ( ! defined( 'ABSPATH' ) ) { 16 exit; 17 } 18 19 // Global variable for the major releases versions. 20 $plugginsight_major_releases = array( 21 '5.0', '5.1', '5.2', '5.3', '5.4', '5.5', '5.6', '5.7', '5.8', '5.9', '6.0', '6.1', '6.2' , '6.3','6.4','6.5','6.6','6.7','6.8' 22 ); 23 $plugginsight_upcoming_major_release = '6.9'; 24 15 25 register_activation_hook(__FILE__, 'plugginsight_maintenance_status_activate_pmswp'); 16 26 register_deactivation_hook(__FILE__, 'plugginsight_maintenance_status_deactivate_pmswp'); 27 register_uninstall_hook(__FILE__, 'plugginsight_maintenance_status_uninstall_pmswp'); 17 28 18 29 function plugginsight_maintenance_status_activate_pmswp() { 19 20 add_filter('manage_plugins_columns', 'plugginsight_add_column_to_plugins_page_pmswp'); 21 } 22 30 //add_filter('manage_plugins_columns', 'plugginsight_add_column_to_plugins_page_pmswp'); 31 } 23 32 24 33 function plugginsight_maintenance_status_deactivate_pmswp() { 25 /* Remove the column from the plugins page */ 26 remove_filter('manage_plugins_columns', 'plugginsight_add_column_to_plugins_page_pmswp'); 27 28 29 /* Clear transient cache. */ 30 global $plugginsight_major_releases; 31 foreach ($plugginsight_major_releases as $release) { 32 delete_transient('plugginsight_maintenance_status_' . $release); 33 } 34 35 remove_submenu_page('plugins.php', 'plugginsight-maintenance-status'); 36 37 /* Remove CSS file */ 38 wp_dequeue_style('plugginsight-maintenance-status'); 39 wp_deregister_style('plugginsight-maintenance-status'); 40 41 /* Remove JS */ 42 wp_dequeue_script('plugginsight-maintenance-status'); 43 wp_deregister_script('plugginsight-maintenance-status'); 44 45 } 34 // Clear transient cache for all installed plugins 35 plugginsight_maintenance_status_clear_cache_only_pmswp(); 36 } 37 46 38 47 39 /* Add a submenu page under the Plugins menu */ … … 58 50 } 59 51 52 function plugginsight_maintenance_status_add_docs_link_pmswp($plugin_meta, $plugin_file) { 53 if (plugin_basename(__FILE__) === $plugin_file) { 54 $docs_url = 'https://projektisle.com/docs/plugginsight/?utm_campaign=plugginsight-setting-page&utm_source=plugin'; 55 $plugin_meta[] = sprintf('<a href="%s" target="_blank">%s</a>', esc_url($docs_url), esc_html__('Docs', 'plugginsight-maintenance-status')); 56 } 57 return $plugin_meta; 58 } 59 add_filter('plugin_row_meta', 'plugginsight_maintenance_status_add_docs_link_pmswp', 10, 2); 60 60 61 61 62 /* Render the plugin page content */ … … 72 73 echo '<p><strong><em>' . esc_html( __('The below process will depend on the number of plugins you have installed. More plugins installed, more time it will take to reload this cache.', 'plugginsight-maintenance-status') ). '</em></strong></p>'; 73 74 74 /* AddClear Cache button */75 /* Clear Cache button */ 75 76 echo '<form method="post">'; 76 77 echo '<input type="hidden" name="plugginsight_maintenance_status_clear_cache_nonce" value="' . esc_attr(wp_create_nonce('plugginsight_maintenance_status_clear_cache_nonce')) . '">'; … … 78 79 echo '<input type="submit" name="plugginsight_maintenance_status_clear_cache" class="button" value="' . esc_html( __('Clear Status Cache', 'plugginsight-maintenance-status') ). '">'; 79 80 echo '</form>'; 80 81 82 /* Handle cache clearing and refreshing */ 81 echo '<p style="margin-top: 1em;">' . 82 esc_html__('Having issues?', 'plugginsight-maintenance-status') . ' ' . 83 '<a href="https://wordpress.org/support/plugin/plugginsight-maintenance-status/" target="_blank">' . esc_html__('Reach out via the community support forum', 'plugginsight-maintenance-status') . '</a> ' . 84 esc_html__('or visit the', 'plugginsight-maintenance-status') . ' ' . 85 '<a href="https://projektisle.com/docs/plugginsight/?utm_campaign=plugginsight-setting-page&utm_source=plugin" target="_blank">' . esc_html__('documentation page', 'plugginsight-maintenance-status') . '</a> ' . 86 esc_html__('for help.', 'plugginsight-maintenance-status') . 87 '</p>'; 88 89 90 /* Handle cache clearing and refreshing, when 'Clear Status Cache button is clicked' */ 83 91 if (isset($_POST['plugginsight_maintenance_status_clear_cache'])) { 84 /* Unsure if the nonce is unslashed and sanitized */85 92 $nonce = isset($_POST['plugginsight_maintenance_status_clear_cache_nonce']) 86 93 ? sanitize_text_field(wp_unslash($_POST['plugginsight_maintenance_status_clear_cache_nonce'])) … … 88 95 89 96 if ($nonce && wp_verify_nonce($nonce, 'plugginsight_maintenance_status_clear_cache_nonce')) { 90 91 /* Clear transients cache */ 92 global $plugginsight_major_releases; 93 foreach ($plugginsight_major_releases as $release) { 94 delete_transient('plugginsight_maintenance_status_' . $release); 95 } 96 97 /* Refresh cache by making new API requests */ 98 foreach ($plugginsight_major_releases as $release) { 99 $plugginsight_plugin_data = plugginsight_maintenance_status_get_plugin_data_pmswp($release); 100 set_transient('plugginsight_maintenance_status_' . $release, $plugginsight_plugin_data, 86400); 101 } 102 103 /* Display success message */ 104 echo '<div class="notice notice-success"><p>' . esc_html(__('Cache cleared and refreshed successfully.', 'plugginsight-maintenance-status')) . '</p></div>'; 105 } else { 106 /* Display error message for invalid nonce */ 107 echo '<div class="notice notice-error"><p>' . esc_html(__('Invalid security token. Cache clearing and refreshing failed.', 'plugginsight-maintenance-status')) . '</p></div>'; 108 } 109 110 } 97 // Clear and refresh cache for all plugins 98 plugginsight_maintenance_status_clear_and_refresh_cache_pmswp(); 99 100 // Display success notice 101 echo '<div class="notice notice-success"><p>' . esc_html(__('Cache cleared and refreshed successfully.', 'plugginsight-maintenance-status')) . '</p></div>'; 102 } else { 103 // Display error notice for invalid nonce 104 echo '<div class="notice notice-error"><p>' . esc_html(__('Invalid security token. Cache clearing and refreshing failed.', 'plugginsight-maintenance-status')) . '</p></div>'; 105 } 106 } 107 111 108 112 109 echo '</div>'; // End wrap container … … 114 111 } 115 112 116 117 118 119 120 /* Add a link to the plugin page in the plugin.php page */ 113 /* Function is called from the 'Clear Status Cache' button */ 114 function plugginsight_maintenance_status_clear_and_refresh_cache_pmswp() { 115 116 if ( ! function_exists('get_plugins') ) { 117 require_once ABSPATH . 'wp-admin/includes/plugin.php'; 118 } 119 $all_plugins = get_plugins(); 120 $plugin_slugs = array(); 121 122 foreach ($all_plugins as $plugin_file => $plugin_data) { 123 $slug = dirname($plugin_file); 124 if ($slug === '.' || empty($slug)) { 125 $slug = basename($plugin_file, '.php'); 126 } 127 $plugin_slugs[] = $slug; 128 } 129 130 // Clear cache for each plugin slug 131 foreach ($plugin_slugs as $slug) { 132 delete_transient('plugginsight_maintenance_status_' . $slug); 133 } 134 135 // Refresh cache for each plugin slug by fetching fresh data 136 foreach ($plugin_slugs as $slug) { 137 $plugin_data = plugginsight_maintenance_status_get_plugin_data_pmswp($slug); 138 if ($plugin_data !== null) { 139 set_transient('plugginsight_maintenance_status_' . $slug, $plugin_data, 86400); 140 } 141 } 142 } 143 144 /* Dedicated function to only clear the cache. Function called only at the deactivation hook */ 145 function plugginsight_maintenance_status_clear_cache_only_pmswp() { 146 // Check if the get_plugins function exists 147 if ( ! function_exists('get_plugins') ) { 148 require_once ABSPATH . 'wp-admin/includes/plugin.php'; 149 } 150 151 $all_plugins = get_plugins(); 152 153 foreach ($all_plugins as $plugin_file => $plugin_data) { 154 $slug = dirname($plugin_file); 155 if ($slug === '.' || empty($slug)) { 156 $slug = basename($plugin_file, '.php'); 157 } 158 delete_transient('plugginsight_maintenance_status_' . $slug); 159 } 160 } 161 162 163 164 /* Quick link to the plugin page from the plugin.php page */ 121 165 add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'plugginsight_maintenance_status_add_plugin_page_link_pmswp'); 122 166 … … 130 174 131 175 132 133 176 add_filter('manage_plugins_columns', 'plugginsight_add_column_to_plugins_page_pmswp'); 134 177 function plugginsight_add_column_to_plugins_page_pmswp($columns) { … … 144 187 145 188 146 147 $plugginsight_major_releases = array(148 '5.0', '5.1', '5.2', '5.3', '5.4', '5.5', '5.6', '5.7', '5.8', '5.9', '6.0', '6.1', '6.2' , '6.3','6.4','6.5','6.6','6.7','6.8'149 );150 $plugginsight_upcoming_major_release = '6.9';151 189 152 190 function plugginsight_get_latest_major_wp_release_pmswp() { … … 234 272 } 235 273 } 274 275 236 276 add_action('manage_plugins_custom_column', 'plugginsight_populate_maintenance_status_column_pmswp', 10, 3); 237 277 … … 239 279 if ($column === 'maintenance_status_column') { 240 280 $plugin_slug = basename(dirname($plugin_file)); 241 $plugin_data = plugginsight_maintenance_status_get_plugin_data_pmswp($plugin_slug); 281 $plugin_data = plugginsight_maintenance_status_get_plugin_data_pmswp($plugin_slug); 242 282 243 283 if ($plugin_data !== null) { 244 284 if (isset($plugin_data->removed) && $plugin_data->removed === true) { 245 // When plugin is removed from repo, either because of author request, or for guideline violation. 246 echo '<strong>' . esc_html(__('Plugin Removed from WP', 'plugginsight-maintenance-status')) . '</strong><br>'; 247 echo '<strong>' . esc_html(__('Date:', 'plugginsight-maintenance-status')) . '</strong> ' . esc_html($plugin_data->closed_date) . '<br>'; 248 echo '<strong>' . esc_html(__('Reason:', 'plugginsight-maintenance-status')) . '</strong> ' . esc_html($plugin_data->reason_text) . '<br>'; 249 $status_color = 'plugginsight_status-bar removed'; 250 echo '<div class="' . esc_attr($status_color) . '"></div>'; 251 } else { 252 // Display available plugin information 253 echo '<strong>' . esc_html(__('Latest Version:', 'plugginsight-maintenance-status')) . '</strong> ' .esc_html($plugin_data->version) . '<br>'; 254 echo '<strong>' . esc_html(__('Last Updated:', 'plugginsight-maintenance-status')) . '</strong> ' .esc_html(plugginsight_maintenance_status_format_last_updated_pmswp($plugin_data->last_updated)) . '<br>'; 255 echo '<strong>' . esc_html(__('Tested Up to:', 'plugginsight-maintenance-status')) . '</strong> ' .esc_html($plugin_data->tested) . '<br>'; 256 echo wp_kses_post(plugginsight_generate_status_bar_pmswp($plugin_data->tested)); 257 } 285 echo '<strong>' . esc_html(__('Plugin Removed from WP', 'plugginsight-maintenance-status')) . '</strong><br>'; 286 echo '<strong>' . esc_html(__('Date:', 'plugginsight-maintenance-status')) . '</strong> ' . esc_html($plugin_data->closed_date ?? '-') . '<br>'; 287 echo '<strong>' . esc_html(__('Reason:', 'plugginsight-maintenance-status')) . '</strong> ' . esc_html($plugin_data->reason_text ?? '-') . '<br>'; 288 echo '<div class="plugginsight_status-bar removed"></div>'; 289 } elseif ( 290 empty($plugin_data->version) && 291 empty($plugin_data->last_updated) && 292 empty($plugin_data->tested) 293 ) { 294 // Invalid or missing data 295 echo esc_html(__('Plugin not found in the repository', 'plugginsight-maintenance-status')); 296 } else { 297 // Show standard info 298 echo '<strong>' . esc_html(__('Latest Version:', 'plugginsight-maintenance-status')) . '</strong> ' . esc_html($plugin_data->version) . '<br>'; 299 echo '<strong>' . esc_html(__('Last Updated:', 'plugginsight-maintenance-status')) . '</strong> ' . esc_html(plugginsight_maintenance_status_format_last_updated_pmswp($plugin_data->last_updated)) . '<br>'; 300 echo '<strong>' . esc_html(__('Tested Up to:', 'plugginsight-maintenance-status')) . '</strong> ' . esc_html($plugin_data->tested) . '<br>'; 301 echo wp_kses_post(plugginsight_generate_status_bar_pmswp($plugin_data->tested)); 302 } 258 303 } else { 259 echo esc_html(__('Plugin not availablein the repository', 'plugginsight-maintenance-status'));304 echo esc_html(__('Plugin not found in the repository', 'plugginsight-maintenance-status')); 260 305 } 261 306 } … … 266 311 267 312 313 268 314 function plugginsight_maintenance_status_get_plugin_data_pmswp($plugin_name) { 269 $cached_data = get_transient('plugginsight_maintenance_status_' . $plugin_name);270 if ($cached_data !== false) {271 return $cached_data;272 }273 274 315 $plugin_slug = sanitize_title($plugin_name); 275 276 316 if (empty($plugin_slug)) { 277 317 $plugin_slug = $plugin_name; 278 318 } 279 319 280 $api_url = esc_url_raw(sprintf('https://api.wordpress.org/plugins/info/1.0/%s.json', $plugin_slug)); 281 $response = wp_remote_get($api_url); 282 283 if (!is_wp_error($response)) { 284 $response_code = wp_remote_retrieve_response_code($response); 285 if ($response_code === 200) { 286 // When Plugin found, return data 287 $data = json_decode(wp_remote_retrieve_body($response)); 288 // New object to store only the necessary data, saves cache storage. 289 $required_data = new stdClass(); 290 // Extract only the required fields and provide default values if missing 291 $required_data->name = isset($data->name) ? $data->name : __('No name specified', 'plugginsight-maintenance-status'); 292 $required_data->slug = isset($data->slug) ? $data->slug : __('No slug specified', 'plugginsight-maintenance-status'); 293 $required_data->version = isset($data->version) ? $data->version : __('No version specified', 'plugginsight-maintenance-status'); 294 $required_data->last_updated = isset($data->last_updated) ? $data->last_updated : __('No last updated date specified', 'plugginsight-maintenance-status'); 295 $required_data->tested = isset($data->tested) ? $data->tested : __('No tested version specified', 'plugginsight-maintenance-status'); 296 // Set transient for caching the required data 297 set_transient('plugginsight_maintenance_status_' . $plugin_name, $required_data, 86400); 298 return $required_data; 299 } elseif ($response_code === 404) { 300 // If Plugin removed or closed. Could be by author request or for guideline violation. 301 $data = json_decode(wp_remote_retrieve_body($response)); 302 if (isset($data->error) && $data->error === 'closed') { 303 304 $data->removed = true; 305 $data->reason_text = isset($data->reason_text) ? $data->reason_text : __('No reason specified', 'plugginsight-maintenance-status'); 306 return $data; 307 } 308 } 309 } 310 311 return null; 312 } 313 314 315 add_action('plugins_loaded', 'plugginsight_maintenance_status_load_textdomain'); 316 317 318 function plugginsight_maintenance_status_load_textdomain() { 319 load_plugin_textdomain('plugginsight-maintenance-status', false, dirname(plugin_basename(__FILE__)) . '/languages/'); 320 $cache_key = 'plugginsight_maintenance_status_' . $plugin_slug; 321 $cached_data = get_transient($cache_key); 322 323 if ($cached_data !== false) { 324 // echo '<script>console.log("Cache hit for plugin: ' . esc_js($plugin_name) . '");</script>'; 325 return $cached_data; 326 } else { 327 // echo '<script>console.log("Cache miss for plugin: ' . esc_js($plugin_name) . '");</script>'; 328 } 329 330 if (!function_exists('plugins_api')) { 331 require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; 332 // echo '<script>console.log("Loaded plugins_api function for'. esc_js($plugin_name) .'");</script>'; 333 } 334 335 $call_api = plugins_api('plugin_information', [ 336 'slug' => $plugin_slug, 337 'fields' => [ 338 'version' => true, 339 'last_updated' => true, 340 'tested' => true, 341 ], 342 ]); 343 344 if (is_wp_error($call_api)) { 345 // echo '<script>console.log(" API error for plugin: ' . esc_js($plugin_slug) . ' ");</script>'; 346 return null; 347 } 348 349 $required_data = new stdClass(); 350 $required_data->version = !empty($call_api->version) ? $call_api->version : null; 351 $required_data->last_updated = !empty($call_api->last_updated) ? $call_api->last_updated : null; 352 $required_data->tested = !empty($call_api->tested) ? $call_api->tested : null; 353 354 // echo '<script>console.log(" Fetched data for plugin: ' . esc_js($plugin_name) . '");</script>'; 355 356 set_transient($cache_key, $required_data, DAY_IN_SECONDS); 357 358 return $required_data; 359 } 360 361 362 363 // Footer on Setting page 364 365 add_filter('admin_footer_text', 'plugginsight_custom_admin_footer_text_pmswp'); 366 367 function plugginsight_custom_admin_footer_text_pmswp($footer_text) { 368 369 $screen = get_current_screen(); 370 if ($screen && $screen->id !== 'plugins_page_plugginsight-maintenance-status') { 371 return $footer_text; 372 } 373 374 $plugin_url = 'https://wordpress.org/plugins/plugginsight-maintenance-status/'; 375 $review_url = $plugin_url . '#reviews'; 376 377 $custom_footer = sprintf( 378 '<a href="%s" target="_blank">PluggInsight</a> is free and always will be. If you find it useful, consider <a href="%s" target="_blank">giving us a shoutout</a>. ★★★★★', 379 esc_url($plugin_url), 380 esc_url($review_url) 381 ); 382 383 return $custom_footer; 320 384 } 321 385 … … 323 387 324 388 /* Uninstall hook to delete language files, only when the plugin is deleted */ 325 register_uninstall_hook(__FILE__, 'plugginsight_maintenance_status_uninstall_pmswp');326 327 389 function plugginsight_maintenance_status_uninstall_pmswp() { 328 global $plugginsight_wp_filesystem; 329 330 if (empty($plugginsight_wp_filesystem)) { 331 WP_Filesystem(); 332 } 333 334 /*Check if filesystem was initialized properly */ 335 if (!is_object($plugginsight_wp_filesystem)) { 390 391 if (!current_user_can('manage_options')) { 336 392 return; 337 393 } 338 339 $plugginsight_language_folder = plugin_dir_path(__FILE__) . 'languages/'; 340 if ($plugginsight_wp_filesystem->is_dir($plugginsight_language_folder)) { 341 $plugginsight_language_files = $plugginsight_wp_filesystem->dirlist($plugginsight_language_folder); 342 foreach ($plugginsight_language_files as $file) { 343 if ($file['type'] !== 'dir') { 344 wp_delete_file($plugginsight_language_folder . $file['name']); 345 } 346 } 347 /* Remove the folder */ 348 $plugginsight_wp_filesystem->rmdir($plugginsight_language_folder); 349 } 350 } 351 394 }
Note: See TracChangeset
for help on using the changeset viewer.