| 1 |
<?php if( !defined('WP_UNINSTALL_PLUGIN') ) exit; // if uninstall.php is not called by WordPress, die |
| 2 |
/** |
| 3 |
* Fired when the plugin is uninstalled. |
| 4 |
*/ |
| 5 |
|
| 6 |
if(get_option('leyka_delete_plugin_data')) { // Completely remove all campaigns & donations data |
| 7 |
|
| 8 |
global $wpdb; |
| 9 |
|
| 10 |
$leyka_posts_ids = $wpdb->get_col("SELECT ID FROM {$wpdb->prefix}posts WHERE post_type='leyka_campaign' OR post_type='leyka_donation'"); |
| 11 |
foreach($leyka_posts_ids as $id) { |
| 12 |
wp_delete_post($id, true); // All revisions, post metas and comments will also be deleted |
| 13 |
} |
| 14 |
|
| 15 |
$success_page = get_post(get_option('leyka_success_page')); |
| 16 |
if(stristr($success_page->post_name, 'thank-you-for-your-donation') !== false) { |
| 17 |
wp_delete_post($success_page->ID, true); |
| 18 |
} |
| 19 |
|
| 20 |
$failure_page = get_post(get_option('leyka_failure_page')); |
| 21 |
if(stristr($failure_page->post_name, 'sorry-donation-failure') !== false) { |
| 22 |
wp_delete_post($failure_page->ID, true); |
| 23 |
} |
| 24 |
|
| 25 |
$pd_terms_page = get_post(get_option('leyka_pd_terms_page')); |
| 26 |
if(stristr($pd_terms_page->post_name, 'personal-data-usage-terms') !== false) { |
| 27 |
wp_delete_post($pd_terms_page->ID, true); |
| 28 |
} |
| 29 |
|
| 30 |
} |
| 31 |
|
| 32 |
if(get_option('leyka_delete_plugin_options')) { |
| 33 |
foreach(wp_load_alloptions() as $option => $value) { |
| 34 |
if(stristr($option, 'leyka_') !== false) { |
| 35 |
delete_option($option); |
| 36 |
} |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
remove_role('donations_manager'); |
| 41 |
remove_role('donations_administrator'); |