| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
| 4 |
die; |
| 5 |
} |
| 6 |
|
| 7 |
// Free version specific options |
| 8 |
delete_transient( 'happyforms_review_notice_recommend' ); |
| 9 |
delete_option( 'happyforms_modal_dismissed_onboarding' ); |
| 10 |
delete_option( 'happyforms_show_powered_by' ); |
| 11 |
delete_option( '_happyforms_received_submissions' ); |
| 12 |
|
| 13 |
// Stop cleanup if upgrade version is currently active. |
| 14 |
if ( defined( 'HAPPYFORMS_UPGRADE_VERSION' ) ) { |
| 15 |
return; |
| 16 |
} |
| 17 |
|
| 18 |
// Forms |
| 19 |
$statuses = array( 'publish', 'trash', 'any' ); |
| 20 |
|
| 21 |
foreach( $statuses as $status ) { |
| 22 |
$form_ids = get_posts( array( |
| 23 |
'post_type' => 'happyform', |
| 24 |
'post_status' => $status, |
| 25 |
'numberposts' => -1, |
| 26 |
'fields' => 'ids', |
| 27 |
) ); |
| 28 |
|
| 29 |
foreach( $form_ids as $form_id ) { |
| 30 |
wp_delete_post( $form_id, true ); |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
// General options |
| 35 |
delete_option( 'widget_happyforms_widget' ); |
| 36 |
delete_option( 'happyforms-tracking' ); |
| 37 |
delete_option( 'ttf_updates_key_happyforms' ); |
| 38 |
|
| 39 |
// User meta |
| 40 |
$users = get_users(); |
| 41 |
|
| 42 |
foreach( $users as $user ) { |
| 43 |
delete_user_meta( $user->ID, 'happyforms-dismissed-notices' ); |
| 44 |
delete_transient( 'happyforms_admin_notices_' . md5( $user->user_login ) ); |
| 45 |
delete_user_meta( $user->ID, 'happyforms-settings-sections-states' ); |
| 46 |
} |
| 47 |
|
| 48 |
// Migrations |
| 49 |
delete_option( 'happyforms-data-version' ); |
| 50 |
|
| 51 |
// Old deactivation flag |
| 52 |
delete_option( '_happyforms_cleanup_on_deactivate' ); |