everest-forms
Last commit date
assets
4 years ago
includes
4 years ago
languages
4 years ago
templates
4 years ago
everest-forms.php
4 years ago
license.txt
8 years ago
readme.txt
4 years ago
uninstall.php
6 years ago
wpml-config.xml
5 years ago
uninstall.php
48 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 ) { |
| 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 | |
| 38 | // Delete usermeta. |
| 39 | $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key LIKE 'evf\_%';" ); |
| 40 | |
| 41 | // Delete posts + data. |
| 42 | $wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type IN ( 'everest_form' );" ); |
| 43 | $wpdb->query( "DELETE meta FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE posts.ID IS NULL;" ); |
| 44 | |
| 45 | // Clear any cached data that has been removed. |
| 46 | wp_cache_flush(); |
| 47 | } |
| 48 |