| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Fired when the plugin is uninstalled. |
| 5 |
* |
| 6 |
* When populating this file, consider the following flow |
| 7 |
* of control: |
| 8 |
* |
| 9 |
* - This method should be static |
| 10 |
* - Check if the $_REQUEST content actually is the plugin name |
| 11 |
* - Run an admin referrer check to make sure it goes through authentication |
| 12 |
* - Verify the output of $_GET makes sense |
| 13 |
* - Repeat with other user roles. Best directly by using the links/query string parameters. |
| 14 |
* - Repeat things for multisite. Once for a single site in the network, once sitewide. |
| 15 |
* |
| 16 |
* This file may be updated more in future version of the Boilerplate; however, this is the |
| 17 |
* general skeleton and outline for how the file should work. |
| 18 |
* |
| 19 |
* For more information, see the following discussion: |
| 20 |
* https://github.com/tommcfarlin/WordPress-Plugin-Boilerplate/pull/123#issuecomment-28541913 |
| 21 |
* |
| 22 |
* @link https://ays-pro.com/ |
| 23 |
* @since 1.0.0 |
| 24 |
* |
| 25 |
* @package Poll_Maker_Ays |
| 26 |
*/ |
| 27 |
|
| 28 |
// If uninstall not called from WordPress, then exit. |
| 29 |
if (!defined('WP_UNINSTALL_PLUGIN')) { |
| 30 |
exit; |
| 31 |
} |
| 32 |
|
| 33 |
if (get_option('ays_poll_maker_upgrade_plugin', 'false') === 'false') { |
| 34 |
global $wpdb; |
| 35 |
$polls_table = $wpdb->prefix . 'ayspoll_polls'; |
| 36 |
$cats_table = $wpdb->prefix . 'ayspoll_categories'; |
| 37 |
$answers_table = $wpdb->prefix . 'ayspoll_answers'; |
| 38 |
$reports_table = $wpdb->prefix . 'ayspoll_reports'; |
| 39 |
$settings_table = $wpdb->prefix . 'ayspoll_settings'; |
| 40 |
|
| 41 |
$wpdb->query("DROP TABLE IF EXISTS `$answers_table`"); |
| 42 |
$wpdb->query("DROP TABLE IF EXISTS `$polls_table`"); |
| 43 |
$wpdb->query("DROP TABLE IF EXISTS `$reports_table`"); |
| 44 |
$wpdb->query("DROP TABLE IF EXISTS `$cats_table`"); |
| 45 |
$wpdb->query("DROP TABLE IF EXISTS `$settings_table`"); |
| 46 |
|
| 47 |
delete_option("ays_poll_db_version"); |
| 48 |
delete_option('ays_poll_maker_upgrade_plugin'); |
| 49 |
delete_option('ays_poll_maker_first_time_activation_page'); |
| 50 |
delete_option('ays_poll_maker_poll_creation_challange'); |
| 51 |
delete_option('ays_poll_agree_terms'); |
| 52 |
delete_option('ays_poll_show_agree_terms'); |
| 53 |
} |
| 54 |
|
| 55 |
$api_url = "https://poll-plugin.com/poll-maker/uninstall/"; |
| 56 |
|
| 57 |
wp_remote_post( $api_url, array( |
| 58 |
'timeout' => 30, |
| 59 |
'body' => wp_json_encode(array( |
| 60 |
'type' => 'poll-maker', |
| 61 |
)), |
| 62 |
) ); |