Stanley depth of weakly polymatroidal ideals and squarefree monomial ideals