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