If $m,~n,~p$, and $q$ are real numbers and $f(x)=mx+n$ and $g(x)=px+q$, then the equation $f(g(x))=g(f(x))$ has a solution
$\textbf{(A) }\text{for all choices of }m,~n,~p, \text{ and } q\qquad\\ \textbf{(B) }\text{if and only if }m=p\text{ and }n=q\qquad\\ \textbf{(C) }\text{if and only if }mq-np=0\qquad\\ \textbf{(D) }\text{if and only if }n(1-p)-q(1-m)=0\qquad\\ \textbf{(E) }\text{if and only if }(1-n)(1-p)-(1-q)(1-m)=0$
\[f(g(x) = g(f(x)) \qquad \implies \qquad m(px + q) + n = p(mx + n) + q\]
This simplifies to $mq + n = pn + q$ or $n(1 - p) - q(1 - m) = 0.$

The answer is $\boxed{\textbf{(D)}}.$