| 1 |
<?php |
| 2 |
/** |
| 3 |
* Deactivation function |
| 4 |
* |
| 5 |
* @package Wow_Plugin |
| 6 |
* @subpackage Includes/Dectivation |
| 7 |
* @author Wow-Company <support@wow-company.com> |
| 8 |
* @copyright 2019 Wow-Company |
| 9 |
* @license GNU Public License |
| 10 |
* @version 1.0 |
| 11 |
|
| 12 |
*/ |
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
exit; |
| 15 |
} |
| 16 |
|
| 17 |
/** |
| 18 |
* Get the plugin folder in 'uploads' |
| 19 |
*/ |
| 20 |
$upload = wp_upload_dir(); |
| 21 |
$field = dirname( plugin_basename( __FILE__ ), 2 ); |
| 22 |
$basedir = $upload['basedir'] . '/' . $field . '/'; |
| 23 |
|
| 24 |
/** |
| 25 |
* Delete the plugin folder and files from wp-upload |
| 26 |
*/ |
| 27 |
if ( is_dir( $basedir ) ) { |
| 28 |
|
| 29 |
$is_empty = count( glob( $basedir . '*' ) ) ? true : false; |
| 30 |
if ( $is_empty === true ) { |
| 31 |
$handle = opendir( $basedir ); |
| 32 |
|
| 33 |
while ( false !== ( $file = readdir( $handle ) ) ) { |
| 34 |
|
| 35 |
if ( $file != "." && $file != ".." ) { |
| 36 |
wp_delete_file( $basedir . $file ); |
| 37 |
} |
| 38 |
|
| 39 |
} |
| 40 |
closedir( $basedir ); |
| 41 |
} |
| 42 |
rmdir( $basedir ); |
| 43 |
} |
| 44 |
|