| 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 Survey_Maker |
| 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_survey_maker_upgrade_plugin','false') === 'false' ){ |
| 34 |
global $wpdb; |
| 35 |
|
| 36 |
$surveys_table = $wpdb->prefix . 'ayssurvey_surveys'; |
| 37 |
$questions_table = $wpdb->prefix . 'ayssurvey_questions'; |
| 38 |
$sections_table = $wpdb->prefix . 'ayssurvey_sections'; |
| 39 |
$survey_categories_table = $wpdb->prefix . 'ayssurvey_survey_categories'; |
| 40 |
$question_categories_table = $wpdb->prefix . 'ayssurvey_question_categories'; |
| 41 |
$answers_table = $wpdb->prefix . 'ayssurvey_answers'; |
| 42 |
$submissions_table = $wpdb->prefix . 'ayssurvey_submissions'; |
| 43 |
$submissions_questions_table = $wpdb->prefix . 'ayssurvey_submissions_questions'; |
| 44 |
$settings_table = $wpdb->prefix . 'ayssurvey_settings'; |
| 45 |
$popup_surveys_table = $wpdb->prefix . 'ayssurvey_popup_surveys'; |
| 46 |
|
| 47 |
$wpdb->query("DROP TABLE IF EXISTS `".$surveys_table."`"); |
| 48 |
$wpdb->query("DROP TABLE IF EXISTS `".$questions_table."`"); |
| 49 |
$wpdb->query("DROP TABLE IF EXISTS `".$sections_table."`"); |
| 50 |
$wpdb->query("DROP TABLE IF EXISTS `".$survey_categories_table."`"); |
| 51 |
$wpdb->query("DROP TABLE IF EXISTS `".$question_categories_table."`"); |
| 52 |
$wpdb->query("DROP TABLE IF EXISTS `".$answers_table."`"); |
| 53 |
$wpdb->query("DROP TABLE IF EXISTS `".$submissions_table."`"); |
| 54 |
$wpdb->query("DROP TABLE IF EXISTS `".$submissions_questions_table."`"); |
| 55 |
$wpdb->query("DROP TABLE IF EXISTS `".$settings_table."`"); |
| 56 |
$wpdb->query("DROP TABLE IF EXISTS `".$popup_surveys_table."`"); |
| 57 |
|
| 58 |
delete_option( "ays_survey_db_version"); |
| 59 |
delete_option( "ays_survey_maker_upgrade_plugin"); |
| 60 |
delete_option('survey_maker_first_time_activation_page'); |
| 61 |
// delete_option('survey_maker_agree_terms'); |
| 62 |
// delete_option('survey_maker_show_agree_terms'); |
| 63 |
unregister_post_type( 'ays-survey-maker' ); |
| 64 |
} |
| 65 |
|
| 66 |
$api_url = "https://poll-plugin.com/survey-maker/uninstall/"; |
| 67 |
|
| 68 |
wp_remote_post( $api_url, array( |
| 69 |
'timeout' => 30, |
| 70 |
'body' => wp_json_encode(array( |
| 71 |
'type' => 'survey-maker', |
| 72 |
)), |
| 73 |
) ); |