The theory is that Dumbledore always seems to know everything. I think there is a lot of different reason for that. One of them would be him communicating with the Dumbledore chocolate frog portait. The evidence is him stating that they can remove all his title but as long as they don't remove his chocolat card he is fine with it.
The first time we see his card, Ron says he has a lot of them. The portrait then walk away. Probably to warn the real Dumbledore that Harry was in the train safe and sound.
If Harry kept his card on him, portrait Dumbledore could have listen to a lots of conversation. But Harry probably doesn't keep it on him. Even if he just keep it in his room, it can give Dumbledore a lot of intel.
Here I'm just talking about Harry but that could also apply for a lot of people in the wizarding world.