Classical two-site fidelity and quantum phase transitions in the Ising model and the extended Hubbard model