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.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 | admin/pr-ajax-admin.php +5 -31 0.0.6 → 0.0.4 View file →
@@ -16,47 +16,21 @@
16 16 function eos_plugin_reviews_restore_version(){
17 17 if( isset( $_POST['nonce'] ) && isset( $_POST['dir'] ) && isset( $_POST['parent_plugin'] ) && wp_verify_nonce( sanitize_text_field( $_POST['nonce'] ),'plugin_reviews_restore_version' ) ){
18 18 $key = eos_plugin_revision_key();
19 19 if( $key ){
20 - global $wp_filesystem;
21 - if( empty( $wp_filesystem ) || ! function_exists( 'unzip_file' ) ) {
22 - require_once ABSPATH .'/wp-admin/includes/file.php';
23 - WP_Filesystem();
24 - }
25 20 $time = time();
26 - $dir = sanitize_text_field( $_POST['dir'] ); // $dir is the path of the plugin versoin that will be restored.
21 + $dir = sanitize_text_field( $_POST['dir'] );
27 22 $plugin = sanitize_text_field( $_POST['parent_plugin'] );
28 23 $plugin_data = get_plugin_data( dirname( PLUGIN_REVISIONS_PLUGIN_DIR ) . '/' . $plugin );
29 24 $version = $plugin_data['Version'];
30 25 $plugin_version = dirname( PLUGIN_REVISIONS_PLUGIN_DIR ) . '/pr-' . $key . '-' . sanitize_option( 'upload_path',$version ) . '-ver-' . $time . dirname( $plugin );
31 - // $plugin_version is the path assigned to the plugin that will be replaced.
32 -
33 - $r_unzip = true;
34 - if( 'zip' === pathinfo( $dir, PATHINFO_EXTENSION ) ) {
35 - if( ! function_exists( 'unzip_file' ) ) {
36 - die();
37 - exit;
38 - }
39 - $r_unzip = unzip_file(
40 - dirname( PLUGIN_REVISIONS_PLUGIN_DIR ) . '/' . $dir,
41 - dirname( PLUGIN_REVISIONS_PLUGIN_DIR )
42 - ); // Unzip the chosen version.
43 - if( $r_unzip ) {
44 - unlink( dirname( PLUGIN_REVISIONS_PLUGIN_DIR ) . '/' . $dir ); // Delete the zip after unzipping it.
45 - }
46 - }
47 - $r1 = rename( dirname( PLUGIN_REVISIONS_PLUGIN_DIR ) . '/' . dirname( $plugin ), $plugin_version ); // Rename the actual plugin that will be replaced giving a unique title.
48 - $r2 = rename( dirname( PLUGIN_REVISIONS_PLUGIN_DIR ) . '/' . str_replace( '.zip', '', $dir ) , dirname( PLUGIN_REVISIONS_PLUGIN_DIR ) . '/' . dirname( $plugin ) ); // Rename the chosen plugin version with the official plugin name.
49 - $replaced_version_path = str_replace( $time,'',$plugin_version ); // Remove the time() from the title in the replaced plugin.
50 - $r3 = rename( $plugin_version, $replaced_version_path );
51 - $r_zip = eos_pv_create_zip_pclzip( $replaced_version_path, '/pr-' . $key . '-' . sanitize_option( 'upload_path', $version ) . '-ver-' . dirname( $plugin ) );
52 - if( $r_zip ) {
53 - $wp_filesystem->delete( $replaced_version_path, true );
54 - }
26 + $r1 = rename( dirname( PLUGIN_REVISIONS_PLUGIN_DIR ) . '/' . dirname( $plugin ), $plugin_version );
27 + $r2 = rename( dirname( PLUGIN_REVISIONS_PLUGIN_DIR ) . '/' . $dir , dirname( PLUGIN_REVISIONS_PLUGIN_DIR ) . '/' . dirname( $plugin ) );
28 + $r3 = rename( $plugin_version,str_replace( $time,'',$plugin_version ) );
55 29 do_action( 'activate_plugin',$plugin );
56 30 do_action( "activate_{$plugin}" );
57 31 do_action( 'activated_plugin', $plugin );
58 - echo (bool) ( $r_unzip && $r1 && $r2 && $r3 && $r_zip ); // Echo true if everything was successfull.
32 + echo (bool) ( $r1 && $r2 && $r3 );
59 33 }
60 34 }
61 35 die();
62 36 exit;