Theorem. Suppose that $f(x)$ has a continuous derivative on the interval $[0, 1]$, and that $\int_0^1 f(x)\, dx=0$. Then $$\int_0^1 |f'(x)|^2\, dx\ge 4\pi^2\int_0^1 |f(x)|^2\, dx.$$
Proof. We may suppose that $f$ has period $1$.
I have taken the statement of the theorem and the first line of the proof from the book that I'm studying. However, I think the formulation of the theorem as above is flawed because it may not be the case that $f(0)=f(1)$ and then the periodic extension of $f$ fails to be continuous at integers.
For instance, if $f(x)=x-1/2$ the inequality is not satisfied. So my question is whether I am right to assume that the author should have written that $f$ is $C^1$ over $\mathbb{R}$ rather than $[0, 1]$ and the statement as it stands is wrong.
You are right: the inequality is false as stated. For it to hold with the constant $4\pi^2$, one needs to assume that $f(0)=f(1)$; then the periodic extension is continuous. Since the derivative is bounded on $(0,1)$, the extension is actually Lipschitz continuous; thus, it is represented by the integral of its derivative, and the argument in the proof of Wirtinger's inequality works.
Without the assumption $f(0)=f(1)$, one can only say that
$$\int_0^1 |f'(x)|^2\, dx\ge \pi^2\int_0^1 |f(x)|^2\, dx\tag{1}$$ with equality attained by $f(x)=\cos \pi x$.
To prove (1), extend $f$ to $[-1,1]$ by even reflection; $f(-x)=f(x)$, and apply Wirtinger's inequality to the extended function. Since the interval became twice as long, the constant loses the factor of $2^2$.