Any bit of air leaking into the pump could cause the foaming. A small crack in the skimmer, a pinhole in the vacuum hose, a bad seal on the pipe leading into the pump, gasket on the pumps' basket could all be a source. Make sure all the o-rings are lubricated well. Does the foaming slow down at all if you turn off the pump for a few minutes? If not then it's not an air leak. Have you used any algaecide in the pool? Is your CH level close to the correct levels??
With the constant shocking however i would put the mostly likely guess however are just the garbage that are being killed off by the shocking process. Keep shocking as long as the pump isn't giving you any problems. You're making great progress!!