| 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 |
|