query( $wpdb->prepare( 'DROP TABLE IF EXISTS %i', $wpdb->prefix . 'dropdms_data' ) ); $wpdb->query( $wpdb->prepare( 'DROP TABLE IF EXISTS %i', $wpdb->prefix . 'dropdms_documents' ) ); // phpcs:enable // Categories (the taxonomy is not registered during uninstall, so the terms are removed directly). $dropdms_terms = $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery $wpdb->prepare( 'SELECT term_id, term_taxonomy_id FROM %i WHERE taxonomy = %s', $wpdb->term_taxonomy, 'dropdms_category' ) ); foreach ( (array) $dropdms_terms as $dropdms_term ) { // phpcs:disable WordPress.DB.DirectDatabaseQuery $wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => (int) $dropdms_term->term_taxonomy_id ), array( '%d' ) ); $wpdb->delete( $wpdb->termmeta, array( 'term_id' => (int) $dropdms_term->term_id ), array( '%d' ) ); $wpdb->delete( $wpdb->terms, array( 'term_id' => (int) $dropdms_term->term_id ), array( '%d' ) ); // phpcs:enable } delete_option( 'dropdms_settings' ); delete_option( 'dropdms_schema_version' ); foreach ( wp_roles()->role_objects as $dropdms_role ) { foreach ( array( 'dropdms_view', 'dropdms_upload', 'dropdms_edit', 'dropdms_delete', 'dropdms_manage' ) as $dropdms_cap ) { $dropdms_role->remove_cap( $dropdms_cap ); } }