PluginProbe
PlugVersions – Easily roll back to previous versions of your plugins. / 0.3.1
PlugVersions – Easily roll back to previous versions of your plugins. v0.3.1
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 +25 -5 0.0.8 → 0.3.1 View file →
@@ -3,13 +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 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.1
13 +Requires PHP: 7.4
14 +Tags: plugin, versions, revisions, restore, rollback, backup, management
12 15 */
13 16 /* This program is free software; you can redistribute it and/or modify
14 17 it under the terms of the GNU General Public License as published by
15 18 the Free Software Foundation; either version 2 of the License, or
@@ -31,11 +34,14 @@
31 34
32 35 add_filter( 'site_transient_update_plugins', function( $obj ) {
33 36 /**
34 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.
35 41 *
36 42 * @since 0.0.1
37 - */
43 + */
38 44 if( isset( $obj ) && is_object( $obj ) && isset( $obj->response ) ) {
39 45 $response = $obj->response;
40 46 $key = eos_plugin_revision_key();
41 47 foreach( $response as $p => $arr ){
@@ -49,8 +55,11 @@
49 55 } );
50 56
51 57 /**
52 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.
53 62 *
54 63 * @since 0.0.1
55 64 */
56 65 function eos_plugin_revision_key(){
@@ -68,10 +77,18 @@
68 77 return false;
69 78 }
70 79
71 80 /**
72 - * 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.
73 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 + *
74 91 * @since 0.0.6
75 92 *
76 93 */
77 94 function eos_pv_create_zip_pclzip( $destination, $zip_dirname ) {
@@ -83,8 +100,9 @@
83 100 $zip = new PclZip( str_replace( '/.zip', '.zip', $destination . '.zip' ) );
84 101 if ( defined( 'PCLZIP_OPT_REMOVE_PATH' ) ) {
85 102 $zip_created = $zip->create( $files, PCLZIP_OPT_REMOVE_PATH, WP_PLUGIN_DIR );
86 103 if( 0 == $zip_created ) {
104 + // If the zip creation fails, return false
87 105 return false;
88 106 }
89 107 return true;
90 108 }
@@ -94,9 +112,11 @@
94 112 }
95 113 }
96 114
97 115 /**
98 - * 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.
99 119 *
100 120 * @since 0.0.6
101 121 */
102 122 function eos_pv_get_files( $path ) {
@@ -109,5 +129,5 @@
109 129 $files_paths[] = $file_path;
110 130 }
111 131 }
112 132 return $files_paths;
113 -}
133 +}