Looking to restock his refrigerator three days after Hurricane Irma tore through Palm Beach County, attorney Richard Ryles headed to the Publix in Palm Beach.

But, like scores of mainland residents discovered in the aftermath of the storm, the wealthy island was off-limits to nearly everyone who didn’t live or work in the tony town — not just during the storm but for seven days after.

"There was no legitimate reason for them to have police out there stopping people at 11 a.m. on Wednesday morning," said Ryles, who lives and works in West Palm Beach. "If we did that in West Palm Beach or Riviera Beach, people would be up in arms."

RELATED: The Post’s complete coverage of Hurricane Irma

The fear of such outcry hasn’t stopped Palm Beach before, as it has often been criticized — and sued successfully — for its efforts to protect its residents from outsiders. Requiring service workers to get town ID cards and prohibiting men from jogging shirtless are among the more infamous laws the town has passed, only to have them overturned by federal judges.

This time — with electricity out, trees down and sand covering the roads after the Sept. 10 storm — town officials said they had to take steps to assure the multi-million-dollar mansions and exclusive stores on Worth Avenue were protected from looters. Further, with power lines down and streets dark, visitors could be hurt or hinder cleanup efforts, said Kirk Blouin, director of public safety for Palm Beach.

Around-the-clock police checkpoints restricting entry to the island and a nighttime curfew actually were set up the day before Irma hit Florida and weren’t discontinued until Sunday, Sept. 17, although the restrictions were progressively eased through the week.

"This was unusually long because the resources to fix the (electrical) facilities were spread throughout the state," Blouin said. Once the lion’s share of the island had power, the police checkpoints were dismantled and the public was allowed back on the island. Blouin said he can understand people’s frustration, but "overall, I think we did a good job."

Ryles, who is black and grew up in West Palm Beach, said he’s heard similar excuses before. But he said that after years of living with the belief that "I’m not welcome in Palm Beach," he’s had enough.

He said he tried to go to Palm Beach only because the Publix at CityPlace had no power, his family needed groceries and the one in Palm Beach was open and stocked. He doesn’t believe police ordered him off the island because he is black. A white man in the car in front of him received the same treatment.

While he ruefully thought, "Welcome to my world," he said at that point they both shared a similar fate: Both had been declared dangers to the elite on Palm Beach.

"It’s classism at its height and at some point in time we have to call out those who would deny people their constitutional rights and hold them accountable," he said. "It’s just wrong."

Since Ryles doesn’t practice constitutional law, he hired attorney Sid Garcia to investigate whether the town can be sued for closing the town to outsiders. Garcia, in turn, reached out to attorney James Green, a former president of the American Civil Liberties Union of Florida who has successfully sued Palm Beach.

Green said the town’s decision to seal its borders for a week might be offensive but isn’t necessarily illegal.

"While I don’t like it — as a citizen, I think everyone should have freedom to travel on public streets and in public parks — federal, state and local governments have broad leeway immediately before and in the immediate aftermath of natural disasters," he said. "Things that would normally be unlawful can be constitutionally acceptable in the wake of natural disasters."

However, he said there are limitations. Courts have ruled that such restrictions have to be tailored to accomplish the limited purpose of protecting people and property. If challenged in court, town officials would have to prove they had a good reason to open the island only to residents, business owners, workers and those helping with restoration efforts.

"If a criterion for passage onto the island of Palm Beach discriminated on the basis of residency or association with residency, the town has an obligation in court, if challenged, to show that the discriminatory criterion advanced a substantial local interest," Green said.

As the week dragged on, the town had less justification to seal itself off, he said.

Police in other upscale island communities in Florida said they have similar policies as Palm Beach. "It has nothing to do with wealth," said Charles Press, chief of police in Key Biscayne near Miami. "It has to do with the demographics of recovery from the storm."

The wealthy island near Miami has much in common with Palm Beach. Long before President Donald Trump dubbed Mar-A-Lago, his private club in Palm Beach, the Winter White House, President Richard Nixon gave a similar moniker to the home he owned in Key Biscayne.

Like Palm Beach, Key Biscayne emerged from its encounter with Hurricane Irma with downed trees and no power. Still, Press said, by the end of the day after the storm, a decision was made to reopen the island to the public.

Bob Garlo, chief of police in Jupiter Island, said he was surprised to encounter a Palm Beach police checkpoint on the Saturday morning six days after the storm, when he and his wife tried to go to the Breakers, where they have a gym membership. Like 130 people who attended a wedding at The Breakers the night before, Garlo and his wife were allowed on the island.

But Garlo said that once he learned there were still areas of the town without power, he understood the rationale for the blockade. Jupiter Island, an exclusive enclave north of Tequesta, where golfing greats Tiger Woods and Greg Norman live, was reopened to the public three days after Irma blew through when Martin County officials lifted the curfew.

Before that, only those who lived on Jupiter Island or had authorization from owners to be there were allowed to return, Garlo said.

Those who live or own businesses in Palm Beach applauded the efforts to keep the Palm Beach County town safe. Surf shop owner Rick Wentley said the checkpoints were needed. With no power, it would have been easy for criminals to clean out storm-darkened businesses and homes that could remain empty until the owners return for the winter, he said.

"It’s a unique situation," said Wentley, who owns Aristokids, P.B. Boys Club and P.B. Girls Club on South County Road but lives in West Palm Beach. "You have a very wealthy island. … You may have some (home) looted and not find out till November or December. They could have pulled a piece of plywood off a window, gone in my store and cleaned it out."

While surfers he knows railed about the closure, he said, "When I came to a checkpoint, I thought, ‘Good for these guys.’"

The town is both a victim and a beneficiary of its location, Palm Beach’s public safety director said. Because it is on a barrier island and is lushly landscaped, it suffered significant storm damage. But, he said, with only four entry points, it can easily be closed to the public.

"If I were a police chief in West Palm Beach or Jupiter or Lantana, I would execute it the way we did," Blouin said. "But their geographic boundaries would make it difficult."

While he said he doesn’t like to restrict access to the town’s roads and beaches, Blouin said he has no regrets about securing the town until power was restored and travel was safe.

"I live in West Palm Beach and work here," he said. "I know there are certain feelings about the town of Palm Beach, but that’s neither here nor there. I thought we did a good job. I’m sorry people are upset by it."