PluginProbe
PlugVersions – Easily roll back to previous versions of your plugins. / 0.0.4
PlugVersions – Easily roll back to previous versions of your plugins. v0.0.4
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 +43 -4 0.0.20.0.4 View file →
@@ -4,10 +4,10 @@
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 7 Domain Path: /languages/
8 -Text Domain: plugins-revisions
9 -Version: 0.0.2
8 +Text Domain: plugversions
9 +Version: 0.0.4
10 10 */
11 11 /* This program is free software; you can redistribute it and/or modify
12 12 it under the terms of the GNU General Public License as published by
13 13 the Free Software Foundation; either version 2 of the License, or
@@ -16,11 +16,11 @@
16 16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 18 GNU General Public License for more details.
19 19 */
20 -defined( 'ABSPATH' ) || exit; // Exit if accessed directly
20 +defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
21 21
22 -//Definitions
22 +//Definitions.
23 23 define( 'PLUGIN_REVISIONS_PLUGIN_DIR', untrailingslashit( dirname( __FILE__ ) ) );
24 24 define( 'PLUGIN_REVISIONS_PLUGIN_URL', untrailingslashit( plugins_url( '', __FILE__ ) ) );
25 25
26 26 if( is_admin() ){
@@ -25,4 +25,43 @@
25 25
26 26 if( is_admin() ){
27 27 require_once PLUGIN_REVISIONS_PLUGIN_DIR.'/admin/pr-admin.php';
28 28 }
29 +
30 +add_filter( 'site_transient_update_plugins',function( $obj ){
31 + /**
32 + * Remove plugin revisions from the update notifications
33 + *
34 + * @since 0.0.1
35 + */
36 + if( isset( $obj ) && is_object( $obj ) && isset( $obj->response ) ){
37 + $response = $obj->response;
38 + $key = eos_plugin_revision_key();
39 + foreach( $response as $p => $arr ){
40 + if( false !== strpos( $p,'pr-'.$key.'-' ) && isset( $response[$p] ) ){
41 + unset( $response[$p] );
42 + }
43 + }
44 + $obj->response = $response;
45 + }
46 + return $obj;
47 +} );
48 +
49 +/**
50 + * Return revision key
51 + *
52 + * @since 0.0.1
53 + */
54 +function eos_plugin_revision_key(){
55 + $opts = get_site_option( 'plugin_revisions' );
56 + if( $opts && isset( $opts['time' ] ) ){
57 + $key = substr( md5( sanitize_text_field( $opts['time' ] ) ),0,8 );
58 + return $key;
59 + }
60 + else{
61 + $time = time();
62 + $opts['time'] = $time;
63 + update_site_option( 'plugin_revisions',$opts );
64 + return substr( md5( $time ),0,8 );
65 + }
66 + return false;
67 +}