query( "DROP TABLE IF EXISTS {$wpdb->prefix}mammoth_entries" ); // phpcs:ignore WordPress.DB $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}mammoth_forms" ); // phpcs:ignore WordPress.DB } delete_option( 'mammoth_db_version' ); delete_option( 'mammoth_delete_data_on_uninstall' ); delete_option( 'mammoth_retention_days' ); delete_option( 'mammoth_store_ip' ); delete_option( 'mammoth_number_format' ); delete_option( 'mammoth_formula_problems' ); wp_clear_scheduled_hook( 'mammoth_daily_cleanup' ); delete_option( 'mammoth_smtp' ); delete_option( 'mammoth_spam' ); // Imports that were never finished: their files hold entry data. $mammoth_upload = wp_upload_dir( null, false ); $mammoth_dir = trailingslashit( $mammoth_upload['basedir'] ) . 'mammoth-imports'; if ( is_dir( $mammoth_dir ) ) { $mammoth_files = (array) glob( $mammoth_dir . '/*' ); $mammoth_files[] = $mammoth_dir . '/.htaccess'; foreach ( $mammoth_files as $mammoth_file ) { if ( $mammoth_file && is_file( $mammoth_file ) ) { wp_delete_file( $mammoth_file ); } } rmdir( $mammoth_dir ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_rmdir -- our own, now empty, folder. } // Emails waiting to be sent in the background, and their attachments. wp_unschedule_hook( 'mammoth_send_queued_mail' ); wp_unschedule_hook( 'mammoth_mail_queue_sweep' ); delete_option( 'mammoth_mail_queue_failed' ); $mammoth_mail_dir = trailingslashit( $mammoth_upload['basedir'] ) . 'mammoth-mail'; if ( is_dir( $mammoth_mail_dir ) ) { foreach ( (array) glob( $mammoth_mail_dir . '/*/*' ) as $mammoth_file ) { if ( $mammoth_file && is_file( $mammoth_file ) ) { wp_delete_file( $mammoth_file ); } } foreach ( (array) glob( $mammoth_mail_dir . '/*', GLOB_ONLYDIR ) as $mammoth_sub ) { rmdir( $mammoth_sub ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_rmdir -- our own, now empty, folders. } wp_delete_file( $mammoth_mail_dir . '/.htaccess' ); wp_delete_file( $mammoth_mail_dir . '/index.php' ); rmdir( $mammoth_mail_dir ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_rmdir -- our own, now empty, folder. } // Short-lived import and rate-limit data, and emails still waiting. global $wpdb; $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- removing our own transients on uninstall. $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s", $wpdb->esc_like( 'mammoth_mailq_' ) . '%', $wpdb->esc_like( '_transient_mammoth_import_' ) . '%', $wpdb->esc_like( '_transient_timeout_mammoth_import_' ) . '%', $wpdb->esc_like( '_transient_mammoth_rate_' ) . '%', $wpdb->esc_like( '_transient_timeout_mammoth_rate_' ) . '%', // Saved "continue later" answers and the limits on saving and emailing them. $wpdb->esc_like( '_transient_mammoth_draft' ) . '%', $wpdb->esc_like( '_transient_timeout_mammoth_draft' ) . '%', $wpdb->esc_like( '_transient_mammoth_vmail_' ) . '%', $wpdb->esc_like( '_transient_timeout_mammoth_vmail_' ) . '%', // Results of forms sent without JavaScript (they hold typed answers), and SMTP test notes. $wpdb->esc_like( '_transient_mammoth_r_' ) . '%', $wpdb->esc_like( '_transient_timeout_mammoth_r_' ) . '%', $wpdb->esc_like( '_transient_mammoth_smtp_test_' ) . '%', $wpdb->esc_like( '_transient_timeout_mammoth_smtp_test_' ) . '%' ) );