query( "DROP TABLE IF EXISTS {$wpdb->prefix}idownalert_events" ); $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\\_transient\\_idownalert\\_%' OR option_name LIKE '\\_transient\\_timeout\\_idownalert\\_%'" ); // phpcs:enable } /** * Remove the drop-ins (only ours) and the data folder in uploads. */ function idownalert_uninstall_files() { // WordPress loads drop-ins only from WP_CONTENT_DIR, so that is where ours are. foreach ( array( 'db-error.php', 'fatal-error-handler.php' ) as $idownalert_name ) { $idownalert_file = trailingslashit( WP_CONTENT_DIR ) . $idownalert_name; // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- local file. if ( file_exists( $idownalert_file ) && false !== strpos( (string) file_get_contents( $idownalert_file, false, null, 0, 1024 ), 'iDownAlert drop-in' ) ) { wp_delete_file( $idownalert_file ); } } // The data folder is in the main site's uploads directory. $idownalert_switched = is_multisite() && ! is_main_site() && switch_to_blog( get_main_site_id() ); $idownalert_uploads = wp_upload_dir( null, false ); if ( $idownalert_switched ) { restore_current_blog(); } if ( empty( $idownalert_uploads['basedir'] ) ) { return; } $idownalert_dir = trailingslashit( $idownalert_uploads['basedir'] ) . 'idownalert'; foreach ( array( 'config.php', 'state.json', 'db-down.flag', 'index.php', '.htaccess' ) as $idownalert_name ) { if ( file_exists( $idownalert_dir . '/' . $idownalert_name ) ) { wp_delete_file( $idownalert_dir . '/' . $idownalert_name ); } } if ( is_dir( $idownalert_dir ) ) { @rmdir( $idownalert_dir ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_rmdir, WordPress.PHP.NoSilencedErrors.Discouraged -- may hold files we did not create. } } if ( is_multisite() ) { foreach ( get_sites( array( 'fields' => 'ids', 'number' => 0, ) ) as $idownalert_site_id ) { switch_to_blog( $idownalert_site_id ); idownalert_uninstall_site(); restore_current_blog(); } } else { idownalert_uninstall_site(); } idownalert_uninstall_files();