This is about the multivariable chain rule. Here I'll take $n=2$ as an example to explain the derivative equation. For convenience, I assume the derivatives of $f$ is continuous, although this assumption is not neccessary. Actually, the differentiability of $f$ will be enough, see here for example.
In this case, $g(t)=f(p_1+t(x_1-p_1),p_2+t(x_2-p_2))$. Thus
\begin{align*}
\frac{g(t)-g(t_0)}{t-t_0}&=\frac{f(p_1+t(x_1-p_1),p_2+t(x_2-p_2))-f(p_1+t_0(x_1-p_1),p_2+t_0(x_2-p_2))}{t-t_0}\\&=\frac{f(p_1+t(x_1-p_1),p_2+t(x_2-p_2))-f(p_1+t_0(x_1-p_1),p_2+t(x_2-p_2))}{[p_1+t(x_1-p_1)]-[p_1+t_0(x_1-p_1)]}\cdot(x_1-p_1)\\&+\frac{f(p_1+t_0(x_1-p_1),p_2+t(x_2-p_2))-f(p_1+t_0(x_1-p_1),p_2+t_0(x_2-p_2))}{[p_2+t(x_2-p_2)]-[p_2+t_0(x_2-p_2)]}\cdot(x_2-p_2).
\end{align*}
Letting $t\to t_0$ and using the continuity of $f'_2$ gives the desired result.