A unified control theorem is presented in this paper, whose aim is to suppress the transversal intersections of stable and unstable manifolds of homoclinic and heteroclinic orbits in the Poincarè map embedding in system dynamics. Based on the control theorem, a primary resonant optimal control technique (PROCT for short) is applied to a general single-dof nonlinear oscillator. The novelty of this technique is able to obtain the unified analytical expressions of the control gain and the control parameters for suppressing the homoclinic and heteroclinic bifurcations, where the control gain can guarantee that the control region where the homoclinic and heteroclinic bifurcations do not occur can be enlarged as much as possible at least cost. The technique is applied to a nonlinear oscillator with a pair of nested homoclinic and heteroclinic orbits. By the PROCT, the transversal intersections of homoclinic and heteroclinic orbits can be suppressed, respectively. The hopping phenomenon that there coexist two kinds of chaotic attractors of Duffing-type and pendulum-type can be suppressed. On the contrary, if the first amplitude coefficient is greater than the critical heteroclinic bifurcation value, then another degenerate hopping behavior of chaos will take place again. Therefore, the phenomenon of hopping is the dominant type of chaos in this oscillator, whose suppressing or inducing is admissible from the points of practical and theoretical view.