Afghanistan is conspicuously absent from the list of terror-prone countries in President Trump’s indefinite immigration ban, even though al-Qaeda has reopened terrorist training camps there and Afghan immigration factors into recent homegrown terrorism, including the Orlando and Chelsea attacks.

Trump signed an executive order on Friday temporarily blocking entry into the US for immigrants and nonimmigrants from seven Muslim countries — Syria, Iraq, Iran, Libya, Somalia, Sudan and Yemen — until the government can tighten security procedures to screen out terrorists under Trump’s proposed “extreme vetting” program. It would also completely stop the processing and resettling here of Muslim refugees from ISIS hotspot Syria.

“It’s countries that have tremendous terror,” Trump explained. “And it’s countries that people are going to come in and cause us tremendous problems.”

Leaving Afghanistan — as well as high-risk Pakistan and Saudi Arabia — off the list may prove shortsighted, however.

A new Pentagon report reveals that 20 terrorist groups, including ISIS, are now operating in Afghanistan, mostly along the Pakistan border. It notes that “the Taliban and other insurgents have gained territory over the past two years,” as President Obama withdrew US troops, and now control almost 40 percent of the country.

Al-Qaeda, meanwhile, has built massive new terrorist training camps — including one 30-square miles in size, the largest training facility the Pentagon has seen since 9/11 — signaling the group is gearing up to repeat its pre-9/11 horror of exporting terrorism from Afghanistan.

Lost in the noise over Syrian refugees and the terrorist threat they pose is the growing wave of Afghan refugees hitting our shores, as Afghanistan descends into its own civil war. As the security situation has deteriorated, Afghan immigration has surged.

Between 2013 and 2015, the last years reported by the State Department, the total number of Afghan refugees admitted to the US actually outpaced the number of Syrian refugees admitted: 2,324 vs. 1,823. The number of Afghan refugees resettled in US cities — namely, New York, Houston and Sacramento — jumped 21 percent in 2015, after increasing 14 percent in 2014. Afghans reported as admitted in the first three months of 2016 had already exceeded State’s projection for the entire year. Meanwhile, another 10,000-plus Afghans are seeking asylum here.

And these are just the permanent resettlements and do not include the thousands of Afghans that Homeland Security is admitting as “temporary immigrants.” US visas issued annually to Afghans have nearly doubled under the Obama administration, soaring from 2,454 in 2008 to 4,156 in 2015, the latest year for which data are kept.

Few in Washington are raising alarms about the largely uncontrolled influx of these Afghan immigrants, but the security risk is just as great.

Though their numbers are relatively small next to the projected flood of Syrians, “some may cause trouble,” as they have in Germany, which is deporting 12,000 Afghan refugees after some carried out terrorist attacks there, said David North, a fellow at the Center for Immigration Studies.

The government’s screening system has repeatedly failed to ID jihadists

It’s not that there aren’t legitimate refugees among these Afghan nationals. The problem is there’s no vetting procedures in place to reliably sort the “good guys” from the “bad guys.” As a result, the government’s screening system has repeatedly failed to ID jihadists and other turncoats who have betrayed the hospitality extended to them by this country.

Recent examples include: Afghan refugee Hayatulla Dawari, who got as far as naturalization before authorities learned of his involvement with an Afghan terror group and convicted him in 2014; and Afghan refugee Sohiel Omar Kabir, who was sentenced in 2015 to 25 years in federal prison for providing material support to terrorists and conspiring to kill Americans.

Nor does the government monitor these immigrants once they arrive. Investigators now believe Afghan-born Ahmad Khan Rahami, the accused New York City bomber, was radicalized after returning from a 2014 trip to Afghanistan, where his father reportedly once fought as a “mujahedeen.” Afghan-American Omar Mateen, the Orlando terrorist, also maintained Afghan connections through his father, an open supporter of the Taliban.

Our military exchange program is another major hole in security involving Afghan immigration that virtually nobody is talking about. The Pentagon can’t even keep track of the Afghans it brings here for military training exercises designed to help them go back and defend their homeland.

Alarmingly, at least 45 Afghan soldiers have disappeared in the US over the past two years while training at military installations. Many of these AWOL immigrants, who came here on special visas, have extensive training in weapons and explosives. Homeland Security has joined the military in the hunt for the missing Afghans.

Further raising security alarms, the Taliban has infiltrated the Afghan security forces supplying these immigrants. Penetration is so deep that, according to the Pentagon report released earlier this month, the Taliban obtain much of their weapons and ammunition, as well as gasoline, from US-supplied Afghan soldiers.

“Taliban commanders give instructions to their forces to buy weapons, ammunition and fuel from the Afghan army and police,” the report reveals.

It also disclosed that from January 2015 through August 2016, there were 101 insider attacks in which Taliban or other insurgents posing as Afghan security personnel turned on fellow Afghan security force members, killing 257.

Saudi nationals also get a pass under Trump’s restrictions. In fact, they may continue to be ushered in as “trusted travelers” and bypass the normal security process under a deal Obama struck with the kingdom that opened the floodgates to more than 709,000 Saudi students and other visa-holders since 2009. It’s as if 9/11 never happened and 15 Saudi terrorists never infiltrated the country on rubber-stamped visas.

Sperry is a former Hoover Institution media fellow and author of “Infiltration: How Muslim Spies and Subversives Have Penetrated Washington.”