# Bound on order of commutator subgroup of a $p$-group

I was reading an article where it is claimed that

If $$G$$ is a finite $$p$$-group with $$|G|=p^n$$ and nilpotency class of $$n-2$$ where $$n\ge 7$$ then $$p\le|Z(G)|\le p^2$$ and $$p^{n-3}\le |G'|\le p^{n-2}$$.

I am not sure how these follow, I tried but couldn't succeed. I know from this post that nilpotency class of $$G'$$ is at most $$n-3$$ but I can not use it to get the required bound. I am really sorry if I am missing something easy.

If anyone can help me I will be really grateful.

Thanks