ai-engine
Last commit date
app
2 years ago
classes
2 years ago
common
2 years ago
constants
2 years ago
images
3 years ago
languages
3 years ago
themes
2 years ago
vendor
3 years ago
ai-engine.php
2 years ago
readme.txt
2 years ago
uninstall.php
2 years ago
uninstall.php
34 lines
| 1 | <?php |
| 2 | if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
| 3 | die; |
| 4 | } |
| 5 | |
| 6 | function mwai_remove_database() { |
| 7 | global $wpdb; |
| 8 | $table_name1 = $wpdb->prefix . "mwai_chats"; |
| 9 | $table_name2 = $wpdb->prefix . "mwai_logmeta"; |
| 10 | $table_name3 = $wpdb->prefix . "mwai_logs"; |
| 11 | $table_name4 = $wpdb->prefix . "mwai_vectors"; |
| 12 | $sql = "DROP TABLE IF EXISTS $table_name1, $table_name2, $table_name3, $table_name4"; |
| 13 | $wpdb->query( $sql ); |
| 14 | } |
| 15 | |
| 16 | function mwai_remove_options() { |
| 17 | global $wpdb; |
| 18 | $options = $wpdb->get_results( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE 'mwai_%'" ); |
| 19 | foreach( $options as $option ) { |
| 20 | delete_option( $option->option_name ); |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | function mwai_uninstall () { |
| 25 | $options = get_option( 'mwai_options', [] ); |
| 26 | $cleanUninstall = $options['clean_uninstall']; |
| 27 | if ( $cleanUninstall ) { |
| 28 | mwai_remove_options(); |
| 29 | mwai_remove_database(); |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | mwai_uninstall(); |
| 34 |