This is an attempt to generalize
Inspired by that question and the given answers, I have the following
Conjecture: Let $c:[a, b] \to \Bbb R$ be a continuous function. Then $$ \tag{1} \int_a^b f(x) c(x) \, dx \ge 0 $$ holds for all convex functions $f:[a, b] \to \Bbb R$ if and only if $$ \tag{2} \int_a^b c(x) \,dx = \int_a^b x c(x) \, dx = 0 \, . $$
The “only if” direction is easy: If $(1)$ holds for the four convex functions $x \mapsto \pm 1$, $x \mapsto \pm x$ then $(2)$ holds.
So the interesting part is the “if” direction. In the above mentioned Q&A this has been proven for the functions $c(x) = \cos(k x)$ (on the interval $[0, 2 \pi]$). Some of the proofs given there use the fact that $$ \int_0^{2\pi} \cos (x) \, dx = \int_0^{2\pi} x \cos (x) \, dx = 0 \, , $$ but all proofs use also symmetries of the cosine function, trigonometric identities, or where the cosine is positive and negative in $[0, 2 \pi]$. My conjecture is that these additional properties of the cosine are not needed, and that $(2)$ alone is sufficient to prove $(1)$ for all convex functions $f$.
As pointed out in the comments, the following is wrong:
There is a simple proof for the “if” direction under the additional assumption that $f$ is twice continuously differentiable: Let $c_1$ be an antiderivative of $c$, and $c_2$ be an antiderivative of $c_1$. By adding a constant to $c_2$, if necessary, we can assume that $c_2(x) \ge 0$ on $[a, b]$. If $(1)$ holds then $c_1(a) = c_1(b)$ and $c_2(a) = c_2(b)$, and for all convex functions $f$ on $[a, b]$ is, using integration by parts (twice): $$ \int_a^b f(x) c(x) \, dx = \int_a^b f''(x) c_2(x) \, dx \ge 0 \,. $$
What I am looking for is a proof of the conjecture (the “if” direction) which works for all convex functions $f$, without additional assumptions on differentiability.