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
plugversions / admin / pr-ajax-admin.php

pr-ajax-admin.php in PlugVersions – Easily roll back to previous versions of your plugins. 0.0.4, at admin/pr-ajax-admin.php

38 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * It includes the code for the Ajax activities.
4
5 * @package Plugversions
6 */
7
8 defined( 'PLUGIN_REVISIONS_PLUGIN_DIR' ) || exit; // Exit if not accessed from Plugversions.
9
10 add_action( 'wp_ajax_eos_plugin_reviews_restore_version','eos_plugin_reviews_restore_version' );
11 /**
12 * Restore plugin version
13 *
14 * @since 0.0.1
15 */
16 function eos_plugin_reviews_restore_version(){
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 $key = eos_plugin_revision_key();
19 if( $key ){
20 $time = time();
21 $dir = sanitize_text_field( $_POST['dir'] );
22 $plugin = sanitize_text_field( $_POST['parent_plugin'] );
23 $plugin_data = get_plugin_data( dirname( PLUGIN_REVISIONS_PLUGIN_DIR ) . '/' . $plugin );
24 $version = $plugin_data['Version'];
25 $plugin_version = dirname( PLUGIN_REVISIONS_PLUGIN_DIR ) . '/pr-' . $key . '-' . sanitize_option( 'upload_path',$version ) . '-ver-' . $time . dirname( $plugin );
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 ) );
29 do_action( 'activate_plugin',$plugin );
30 do_action( "activate_{$plugin}" );
31 do_action( 'activated_plugin', $plugin );
32 echo (bool) ( $r1 && $r2 && $r3 );
33 }
34 }
35 die();
36 exit;
37 }
38