everest-forms
Last commit date
addons
4 months ago
assets
4 months ago
bin
5 months ago
dist
4 months ago
includes
4 months ago
languages
4 months ago
src
4 months ago
templates
11 months ago
traits
1 year ago
vendor
4 months ago
composer.json
5 months ago
everest-forms.php
4 months ago
license.txt
8 years ago
readme.txt
4 months ago
uninstall.php
3 years ago
wp
1 year ago
wpml-config.xml
5 years ago
uninstall.php
50 lines
| 1 | <?php |
| 2 | /** |
| 3 | * EverestForms Uninstall |
| 4 | * |
| 5 | * Uninstalls the plugin deletes user roles, tables, and options. |
| 6 | * |
| 7 | * @package EverestForms\Uninstaller |
| 8 | * @version 1.0.0 |
| 9 | */ |
| 10 | |
| 11 | defined( 'WP_UNINSTALL_PLUGIN' ) || exit; |
| 12 | |
| 13 | global $wpdb; |
| 14 | |
| 15 | wp_clear_scheduled_hook( 'everest_forms_cleanup_logs' ); |
| 16 | wp_clear_scheduled_hook( 'everest_forms_cleanup_sessions' ); |
| 17 | |
| 18 | /* |
| 19 | * Only remove ALL data if EVF_REMOVE_ALL_DATA constant is set to true in user's |
| 20 | * wp-config.php. This is to prevent data loss when deleting the plugin from the backend |
| 21 | * and to ensure only the site owner can perform this action. |
| 22 | */ |
| 23 | if ( ( defined( 'EVF_REMOVE_ALL_DATA' ) && true === EVF_REMOVE_ALL_DATA ) || 'yes' === get_option( 'everest_forms_uninstall_option' ) ) { |
| 24 | include_once dirname( __FILE__ ) . '/includes/class-evf-install.php'; |
| 25 | |
| 26 | // Roles + caps. |
| 27 | EVF_Install::remove_roles(); |
| 28 | |
| 29 | // Tables. |
| 30 | EVF_Install::drop_tables(); |
| 31 | |
| 32 | // Pages. |
| 33 | wp_trash_post( get_option( 'everest_forms_default_form_page_id' ) ); |
| 34 | |
| 35 | // Delete options. |
| 36 | $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE 'evf\_%';" ); |
| 37 | $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE 'everest_forms\_%';" ); |
| 38 | |
| 39 | // Delete usermeta. |
| 40 | $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key LIKE 'evf\_%';" ); |
| 41 | $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key LIKE 'everest_forms\_%';" ); |
| 42 | |
| 43 | // Delete posts + data. |
| 44 | $wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type IN ( 'everest_form' );" ); |
| 45 | $wpdb->query( "DELETE meta FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE posts.ID IS NULL;" ); |
| 46 | |
| 47 | // Clear any cached data that has been removed. |
| 48 | wp_cache_flush(); |
| 49 | } |
| 50 |