query( $wpdb->prepare( 'DROP TABLE IF EXISTS %i', $wpdb->prefix . 'knowscapes_ai_client_rate' ) ); $like_transient = $wpdb->esc_like( '_transient_knowscapes_ai_client_' ) . '%'; // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $names = $wpdb->get_col( $wpdb->prepare( "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE %s", $like_transient ) ); // Go through the API so an external object cache drops them as well. if ( is_array( $names ) ) { foreach ( $names as $option_name ) { delete_transient( substr( $option_name, strlen( '_transient_' ) ) ); } } // Sweep up anything the API left behind, including orphaned timeout rows. $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s OR option_name LIKE %s", $like_transient, $wpdb->esc_like( '_transient_timeout_knowscapes_ai_client_' ) . '%' ) ); // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching } if ( is_multisite() ) { // A network uninstall has to clear every site, not just the current one. $knowscapes_ai_client_site_ids = get_sites( array( 'fields' => 'ids', 'number' => 0, 'update_site_meta_cache' => false, ) ); foreach ( $knowscapes_ai_client_site_ids as $knowscapes_ai_client_site_id ) { switch_to_blog( $knowscapes_ai_client_site_id ); knowscapes_ai_client_uninstall_site(); restore_current_blog(); } } else { knowscapes_ai_client_uninstall_site(); }