Last week GrubHub executive Matt Maloney invited the company’s employees to resign if they agreed with Donald Trump’s “nationalist, anti-immigrant and hateful politics.” I don’t think I was the only person to delete the GrubHub app from my phone: Its stock price immediately fell 4 percent.

Capitalism. I love it.

The stock-price reaction told us Maloney’s effort at mixing business with politics was a betrayal of his duty to the company’s shareholders. We’ll let them figure that one out. But what happens when viewpoint bigotry is widespread, and there’s no market corrective?

I’m talking about American higher education, of course. There are 10 times more Democrats than Republicans on university faculties, and the conservatives are disproportionately to be found in the hard sciences or among older colleagues who are aging out. The imbalance is especially striking in the social sciences and the humanities, where real teaching can take a back seat to political indoctrination.

The academy always tilted left, but it didn’t always matter nearly as much as it does today. Over time the old-school, tweedy professors were replaced by a different sort of academic, one who had loudly demanded free speech as a student, but who then denied it to his students when he became a professor. He was a humdrum scholar, but he thought his politics excused his mediocrity and therefore clung to them all the more fiercely.

The lack of viewpoint diversity has made an academic wasteland of much of American higher education. Unless you’re willing to test your ideas with people with whom you disagree, you’ll never rise above the level of banal complacency. You won’t understand the weaknesses, or even the strengths, of your argument. He who knows only his side of the case knows little enough of that, said John Stuart Mill.

It’s primarily the job of parents, not the federal government, to punish universities that have betrayed their scholarly calling. Let the parents, if they wish, pay $300,000 to have their children taught contempt for everything they hold dear. Or else let them delete the app, as I did with GrubHub.

But there’s also a role for Uncle Sam. Right now the feds require universities to ban discrimination on the basis of race, color, national origin, language, sex, religion and disability before their students can qualify for government-backed student loans. That’s as it should be.

However, the Department of Education has taken this a step further with “Dear Colleague” letters instructing schools to hire more “diversity” officers, institute speech codes, design “affirmative consent” rules for social interactions and provide transgender bathrooms. Under President Obama, the federal government has assumed the right to micro-manage American higher education.

All of that must be junked next January, and replaced with a different sort of “Dear Colleague” letter, one that reminds university administrators of their high calling.

It’s not the job of the federal government to require a university to hire conservative scholars to address the shocking imbalances of views in the academy. But when a university goes out of its way to penalize the few conservative academics who remain on campus, it’s time for the feds to defend academic freedom.

Take tenured Marquette professor John McAdams, who was suspended and barred from setting foot on campus when he criticized a teaching assistant who told a student he couldn’t voice his objections to same-sex marriage.

Or Laura Kipnis. She’s a feisty liberal professor in Northwestern’s film department who wrote a column describing how Title IX’s ban on sexual discrimination had been twisted to create an atmosphere of sexual paranoia that infantilized young women. For blowing the whistle on Title IX, she was hit with a Title IX investigation. Q.E.D., as they said back in geometry class. She was eventually acquitted, but in such cases, the process is the punishment.

What’s needed, come Jan. 20, is a presidential directive that federal funding will be denied to universities that discriminate on the basis of race or religion, or that, on any reasonable view of the matter, restrict the academic freedom of their teachers.

When President Ronald Reagan took office, people wondered if he meant what he had said. Then he fired the striking air traffic controllers. Let the defense of academic freedom be President Trump’s air-traffic-controller moment.

F.H. Buckley’s most recent book is “The Way Back: Restoring the Promise of America.”