wp-mail-smtp
Last commit date
assets
6 years ago
src
6 years ago
vendor
6 years ago
readme.txt
6 years ago
uninstall.php
6 years ago
wp-mail-smtp.php
6 years ago
wp_mail_smtp.php
6 years ago
uninstall.php
81 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Uninstall all WP Mail SMTP data. |
| 4 | * |
| 5 | * @since 1.3.0 |
| 6 | */ |
| 7 | |
| 8 | // Exit if accessed directly. |
| 9 | if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
| 10 | exit; |
| 11 | } |
| 12 | |
| 13 | // Load plugin file. |
| 14 | require_once 'wp_mail_smtp.php'; |
| 15 | |
| 16 | // Confirm user has decided to remove all data, otherwise stop. |
| 17 | $settings = get_option( 'wp_mail_smtp', array() ); |
| 18 | if ( empty( $settings['general']['uninstall'] ) ) { |
| 19 | return; |
| 20 | } |
| 21 | |
| 22 | /* |
| 23 | * Remove options. |
| 24 | */ |
| 25 | $options = array( |
| 26 | 'wp_mail_smtp_initial_version', |
| 27 | 'wp_mail_smtp_version', |
| 28 | 'wp_mail_smtp_debug', |
| 29 | 'wp_mail_smtp', |
| 30 | '_amn_smtp_last_checked', |
| 31 | // Legacy options. |
| 32 | 'pepipost_ssl', |
| 33 | 'pepipost_port', |
| 34 | 'pepipost_pass', |
| 35 | 'pepipost_user', |
| 36 | 'smtp_pass', |
| 37 | 'smtp_user', |
| 38 | 'smtp_auth', |
| 39 | 'smtp_ssl', |
| 40 | 'smtp_port', |
| 41 | 'smtp_host', |
| 42 | 'mail_set_return_path', |
| 43 | 'mailer', |
| 44 | 'mail_from_name', |
| 45 | 'mail_from', |
| 46 | 'wp_mail_smtp_am_notifications_hidden', |
| 47 | ); |
| 48 | |
| 49 | foreach ( $options as $option ) { |
| 50 | delete_option( $option ); |
| 51 | } |
| 52 | |
| 53 | /* |
| 54 | * Remove product announcements. |
| 55 | */ |
| 56 | $announcements = get_posts( |
| 57 | array( |
| 58 | 'post_type' => array( 'amn_smtp' ), |
| 59 | 'post_status' => 'any', |
| 60 | 'numberposts' => - 1, |
| 61 | 'fields' => 'ids', |
| 62 | ) |
| 63 | ); |
| 64 | if ( ! empty( $announcements ) ) { |
| 65 | foreach ( $announcements as $announcement ) { |
| 66 | wp_delete_post( $announcement, true ); |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | /* |
| 71 | * Logs for Pro plugin only. |
| 72 | */ |
| 73 | if ( function_exists( 'wp_mail_smtp' ) && wp_mail_smtp()->is_pro() ) { |
| 74 | // DB version. |
| 75 | delete_option( 'wp_mail_smtp_logs_db_version' ); |
| 76 | // DB table. |
| 77 | global $wpdb; |
| 78 | $table = \WPMailSMTP\Pro\Emails\Logs\Logs::get_table_name(); |
| 79 | $wpdb->query( "DROP TABLE $table;" ); // phpcs:ignore |
| 80 | } |
| 81 |