Plugin Directory

Changeset 3343571


Ignore:
Timestamp:
08/12/2025 12:57:42 PM (4 months ago)
Author:
alanjacobmathew
Message:

v 1.0.3

Location:
plugginsight-maintenance-status
Files:
11 added
3 edited

Legend:

Unmodified
Added
Removed
  • plugginsight-maintenance-status/trunk/README.txt

    r3273818 r3343571  
    33Tags: plugin last updated, plugin maintenance status, last updated check, Maintenance Manager, PluggInsight
    44Tested up to: 6.8
    5 Stable tag: 1.0.2
     5Stable tag: 1.0.3
     6Requires at least: 5.0
    67License: GPLv3 or later
    78License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
     
    1011
    1112== 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.
     13PluggInsight – 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.
    1514
    1615
     
    1817= Features =
    1918- **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.
    2120- **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. 
    2322- **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.
    2423- **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.
    2524- **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).
    2726- **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.
    2827- **Translation-ready**: The plugin is fully translatable, allowing you to localize the plugin to your preferred language.
     
    3736- The plugin uses Tested Up to Data to display this status bar.
    3837- 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 calculated
     38- The plugin checks for the latest major WP release and compare it with the major release mention in the tested up to data.
    4039
    4140
    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'.
    5443
    5544
     
    7665
    7766= 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. 
     67If 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? =
     70Check out our [FAQ](https://projektisle.com/docs/plugginsight/faq/?utm_campaign=plugginsight-docs&utm_source=wp.org) section for detailed information. 
    7971
    8072== Screenshots ==
     
    8476
    8577== 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
    8683= 1.0.2 =
    8784* Version Updates for WP 6.8
  • plugginsight-maintenance-status/trunk/languages/plugginsight-maintenance-status.pot

    r3273818 r3343571  
    33msgstr ""
    44"Project-Id-Version: \n"
    5 "POT-Creation-Date: 2025-04-15 11:23+0530\n"
     5"POT-Creation-Date: 2025-08-12 17:57+0530\n"
    66"PO-Revision-Date: 2024-12-31 14:48+0530\n"
    77"Last-Translator: \n"
     
    1616"X-Poedit-SearchPath-0: .\n"
    1717
    18 #: plugginsight-maintenance-status.php:52
    19 #: plugginsight-maintenance-status.php:53
    20 #: plugginsight-maintenance-status.php:137
     18#: plugginsight-maintenance-status.php:44
     19#: plugginsight-maintenance-status.php:45
     20#: plugginsight-maintenance-status.php:180
    2121msgid "Maintenance Status"
    2222msgstr ""
    2323
    24 #: plugginsight-maintenance-status.php:69
     24#: plugginsight-maintenance-status.php:70
    2525msgid "Maintenance Status Settings"
    2626msgstr ""
    2727
    28 #: plugginsight-maintenance-status.php:70
     28#: plugginsight-maintenance-status.php:71
    2929msgid "Manage Maintenance Status Cache"
    3030msgstr ""
    3131
    32 #: plugginsight-maintenance-status.php:71
     32#: plugginsight-maintenance-status.php:72
    3333msgid "Disclaimer:"
    3434msgstr ""
    3535
    36 #: plugginsight-maintenance-status.php:71
     36#: plugginsight-maintenance-status.php:72
    3737msgid "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."
    3838msgstr ""
    3939
    40 #: plugginsight-maintenance-status.php:72
     40#: plugginsight-maintenance-status.php:73
    4141msgid "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."
    4242msgstr ""
    4343
    44 #: plugginsight-maintenance-status.php:78
     44#: plugginsight-maintenance-status.php:79
    4545msgid "Clear Status Cache"
    4646msgstr ""
    4747
    48 #: plugginsight-maintenance-status.php:104
     48#: plugginsight-maintenance-status.php:101
    4949msgid "Cache cleared and refreshed successfully."
    5050msgstr ""
    5151
    52 #: plugginsight-maintenance-status.php:107
     52#: plugginsight-maintenance-status.php:104
    5353msgid "Invalid security token. Cache clearing and refreshing failed."
    5454msgstr ""
    5555
    56 #: plugginsight-maintenance-status.php:125
     56#: plugginsight-maintenance-status.php:169
    5757msgid "Settings"
    5858msgstr ""
    5959
    60 #: plugginsight-maintenance-status.php:139
     60#: plugginsight-maintenance-status.php:182
    6161msgid "Update Status Cache"
    6262msgstr ""
    6363
    64 #: plugginsight-maintenance-status.php:246
     64#: plugginsight-maintenance-status.php:285
    6565msgid "Plugin Removed from WP"
    6666msgstr ""
    6767
    68 #: plugginsight-maintenance-status.php:247
     68#: plugginsight-maintenance-status.php:286
    6969msgid "Date:"
    7070msgstr ""
    7171
    72 #: plugginsight-maintenance-status.php:248
     72#: plugginsight-maintenance-status.php:287
    7373msgid "Reason:"
    7474msgstr ""
    7575
    76 #: plugginsight-maintenance-status.php:253
     76#: plugginsight-maintenance-status.php:295
     77#: plugginsight-maintenance-status.php:304
     78msgid "Plugin not found in the repository"
     79msgstr ""
     80
     81#: plugginsight-maintenance-status.php:298
    7782msgid "Latest Version:"
    7883msgstr ""
    7984
    80 #: plugginsight-maintenance-status.php:254
     85#: plugginsight-maintenance-status.php:299
    8186msgid "Last Updated:"
    8287msgstr ""
    8388
    84 #: plugginsight-maintenance-status.php:255
     89#: plugginsight-maintenance-status.php:300
    8590msgid "Tested Up to:"
    8691msgstr ""
    87 
    88 #: plugginsight-maintenance-status.php:259
    89 msgid "Plugin not available in the repository"
    90 msgstr ""
    91 
    92 #: plugginsight-maintenance-status.php:291
    93 msgid "No name specified"
    94 msgstr ""
    95 
    96 #: plugginsight-maintenance-status.php:292
    97 msgid "No slug specified"
    98 msgstr ""
    99 
    100 #: plugginsight-maintenance-status.php:293
    101 msgid "No version specified"
    102 msgstr ""
    103 
    104 #: plugginsight-maintenance-status.php:294
    105 msgid "No last updated date specified"
    106 msgstr ""
    107 
    108 #: plugginsight-maintenance-status.php:295
    109 msgid "No tested version specified"
    110 msgstr ""
    111 
    112 #: plugginsight-maintenance-status.php:305
    113 msgid "No reason specified"
    114 msgstr ""
  • plugginsight-maintenance-status/trunk/plugginsight-maintenance-status.php

    r3273818 r3343571  
    22/**
    33 * Plugin Name: PluggInsight - Maintenance Status
     4 * Plugin URI: https://wordpress.org/plugins/plugginsight-maintenance-status/
    45 * Description: Easily access maintenance details for each plugin directly on the WordPress plugin page.
    5  * Version: 1.0.2
     6 * Version: 1.0.3
    67 * Author: Alan Jacob Mathew
    78 * Author URI: https://profiles.wordpress.org/alanjacobmathew/
     
    1213 */
    1314
    14 if ( ! defined( 'ABSPATH' ) ) exit;
     15if ( ! 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
    1525register_activation_hook(__FILE__, 'plugginsight_maintenance_status_activate_pmswp');
    1626register_deactivation_hook(__FILE__, 'plugginsight_maintenance_status_deactivate_pmswp');
     27register_uninstall_hook(__FILE__, 'plugginsight_maintenance_status_uninstall_pmswp');
    1728
    1829function 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}
    2332
    2433function 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
    4638
    4739/* Add a submenu page under the Plugins menu */
     
    5850}
    5951
     52function 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}
     59add_filter('plugin_row_meta', 'plugginsight_maintenance_status_add_docs_link_pmswp', 10, 2);
     60
    6061
    6162/* Render the plugin page content */
     
    7273    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>';
    7374
    74     /* Add Clear Cache button */
     75    /* Clear Cache button */
    7576    echo '<form method="post">';
    7677    echo '<input type="hidden" name="plugginsight_maintenance_status_clear_cache_nonce" value="' . esc_attr(wp_create_nonce('plugginsight_maintenance_status_clear_cache_nonce')) . '">';
     
    7879    echo '<input type="submit" name="plugginsight_maintenance_status_clear_cache" class="button" value="' . esc_html( __('Clear Status Cache', 'plugginsight-maintenance-status') ). '">';
    7980    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' */
    8391if (isset($_POST['plugginsight_maintenance_status_clear_cache'])) {
    84     /* Unsure if the nonce is unslashed and sanitized */
    8592    $nonce = isset($_POST['plugginsight_maintenance_status_clear_cache_nonce'])
    8693        ? sanitize_text_field(wp_unslash($_POST['plugginsight_maintenance_status_clear_cache_nonce']))
     
    8895
    8996    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
    111108
    112109echo '</div>'; // End wrap container
     
    114111}
    115112
    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 */
     114function 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 */
     145function 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 */
    121165add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'plugginsight_maintenance_status_add_plugin_page_link_pmswp');
    122166
     
    130174
    131175
    132 
    133176add_filter('manage_plugins_columns', 'plugginsight_add_column_to_plugins_page_pmswp');
    134177function plugginsight_add_column_to_plugins_page_pmswp($columns) {
     
    144187
    145188
    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';
    151189
    152190function plugginsight_get_latest_major_wp_release_pmswp() {
     
    234272    }
    235273}
     274
     275
    236276add_action('manage_plugins_custom_column', 'plugginsight_populate_maintenance_status_column_pmswp', 10, 3);
    237277
     
    239279    if ($column === 'maintenance_status_column') {
    240280        $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);    
    242282   
    243283        if ($plugin_data !== null) {
    244284            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            }
    258303        } else {
    259             echo esc_html(__('Plugin not available in the repository', 'plugginsight-maintenance-status'));
     304            echo esc_html(__('Plugin not found in the repository', 'plugginsight-maintenance-status'));
    260305        }
    261306    }
     
    266311
    267312
     313
    268314function 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 
    274315    $plugin_slug = sanitize_title($plugin_name);
    275 
    276316    if (empty($plugin_slug)) {
    277317        $plugin_slug = $plugin_name;
    278318    }
    279319
    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 
     365add_filter('admin_footer_text', 'plugginsight_custom_admin_footer_text_pmswp');
     366
     367function 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;
    320384}
    321385
     
    323387
    324388/* Uninstall hook to delete language files, only when the plugin is deleted */
    325 register_uninstall_hook(__FILE__, 'plugginsight_maintenance_status_uninstall_pmswp');
    326 
    327389function 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')) {
    336392        return;
    337393    }
    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.