| @@ -3,13 +3,18 @@ | ||
| 3 | 3 | Plugin Name: PlugVersions |
| 4 | 4 | Description: it retains up to three versions when you update a plugin. It works also with premium and custom plugins. |
| 5 | 5 | Author: Jose Mortellaro |
| 6 | 6 | Author URI: https://josemortellaro.com |
| 7 | +Plugin URI: https://josemortellaro.com | |
| 7 | 8 | Domain Path: /languages/ |
| 8 | 9 | Text Domain: plugversions |
| 9 | 10 | License: GPLv2 or later |
| 10 | 11 | License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
| 11 | -Version: 0.0.8 | |
| 12 | +Version: 0.3.0 | |
| 13 | +Requires at least: 4.9 | |
| 14 | +Tested up to: 6.8 | |
| 15 | +Requires PHP: 7.4 | |
| 16 | +Tags: plugin, versions, revisions, restore, rollback, backup, management | |
| 12 | 17 | */ |
| 13 | 18 | /* This program is free software; you can redistribute it and/or modify |
| 14 | 19 | it under the terms of the GNU General Public License as published by |
| 15 | 20 | the Free Software Foundation; either version 2 of the License, or |
| @@ -31,11 +36,14 @@ | ||
| 31 | 36 | |
| 32 | 37 | add_filter( 'site_transient_update_plugins', function( $obj ) { |
| 33 | 38 | /** |
| 34 | 39 | * Remove plugin revisions from the update notifications |
| 40 | + * This filter is applied to the site transient update plugins object. | |
| 41 | + * It checks if the object is set and is an object, then it iterates through the response array. | |
| 42 | + * If it finds a key that matches the plugin revision key, it removes that entry from the response. | |
| 35 | 43 | * |
| 36 | 44 | * @since 0.0.1 |
| 37 | - */ | |
| 45 | + */ | |
| 38 | 46 | if( isset( $obj ) && is_object( $obj ) && isset( $obj->response ) ) { |
| 39 | 47 | $response = $obj->response; |
| 40 | 48 | $key = eos_plugin_revision_key(); |
| 41 | 49 | foreach( $response as $p => $arr ){ |
| @@ -49,8 +57,11 @@ | ||
| 49 | 57 | } ); |
| 50 | 58 | |
| 51 | 59 | /** |
| 52 | 60 | * Return revision key |
| 61 | + * This key is used to identify the plugin revisions. | |
| 62 | + * It is based on the current time and is sanitized to ensure it is safe for use. | |
| 63 | + * If the key does not exist, it creates a new one and saves it in the site options. | |
| 53 | 64 | * |
| 54 | 65 | * @since 0.0.1 |
| 55 | 66 | */ |
| 56 | 67 | function eos_plugin_revision_key(){ |
| @@ -68,10 +79,18 @@ | ||
| 68 | 79 | return false; |
| 69 | 80 | } |
| 70 | 81 | |
| 71 | 82 | /** |
| 72 | - * Create zip pclzip. | |
| 83 | + * Create a zip file using PclZip. | |
| 84 | + * This function creates a zip file from a specified directory using the PclZip library. | |
| 85 | + * It checks if the PclZip class exists, retrieves all files from the directory, | |
| 86 | + * and creates a zip file at the specified destination. | |
| 87 | + * If the zip creation fails, it returns false; otherwise, it returns true. | |
| 73 | 88 | * |
| 89 | + * @param string $destination The path where the zip file will be created. | |
| 90 | + * @param string $zip_dirname The directory name to be zipped. | |
| 91 | + * @return bool True on success, false on failure. | |
| 92 | + * | |
| 74 | 93 | * @since 0.0.6 |
| 75 | 94 | * |
| 76 | 95 | */ |
| 77 | 96 | function eos_pv_create_zip_pclzip( $destination, $zip_dirname ) { |
| @@ -83,8 +102,9 @@ | ||
| 83 | 102 | $zip = new PclZip( str_replace( '/.zip', '.zip', $destination . '.zip' ) ); |
| 84 | 103 | if ( defined( 'PCLZIP_OPT_REMOVE_PATH' ) ) { |
| 85 | 104 | $zip_created = $zip->create( $files, PCLZIP_OPT_REMOVE_PATH, WP_PLUGIN_DIR ); |
| 86 | 105 | if( 0 == $zip_created ) { |
| 106 | + // If the zip creation fails, return false | |
| 87 | 107 | return false; |
| 88 | 108 | } |
| 89 | 109 | return true; |
| 90 | 110 | } |
| @@ -94,9 +114,11 @@ | ||
| 94 | 114 | } |
| 95 | 115 | } |
| 96 | 116 | |
| 97 | 117 | /** |
| 98 | - * Get files by path. | |
| 118 | + * This function retrieves all files from a given directory path, including subdirectories. | |
| 119 | + * It uses the RecursiveDirectoryIterator and RecursiveIteratorIterator classes to traverse the directory structure. | |
| 120 | + * The function returns an array of file paths, with backslashes replaced by forward slashes for consistency. | |
| 99 | 121 | * |
| 100 | 122 | * @since 0.0.6 |
| 101 | 123 | */ |
| 102 | 124 | function eos_pv_get_files( $path ) { |
| @@ -109,5 +131,5 @@ | ||
| 109 | 131 | $files_paths[] = $file_path; |
| 110 | 132 | } |
| 111 | 133 | } |
| 112 | 134 | return $files_paths; |
| 113 | -} | |
| 135 | +} | |