Spin-cluster theory in magnetic materials and applications to spin glasses