Conor McGregor pleaded guilty to a single count of disorderly conduct stemming from an April rampage at Brooklyn’s Barclays Center, which may pave the way for the UFC’s popular star to return to the Octagon before the end of the year.

McGregor’s plea was entered Thursday in Brooklyn criminal court as part of a deal with the Brooklyn District Attorney’s office. McGregor was given no jail time and will not have a criminal record. Nor will his travel visa be affected. He also was ordered to pay full restitution to the bus company for damages incurred in the April 5 incident in which video appeared to show McGregor throwing a metal handcart into the window of a bus carrying UFC athletes and employees after a UFC 223 media event. McGregor, 30, had complied with that portion of the deal and also must do five days of community service and attend an anger management program lasting one to three days.

“I just want to say I’m thankful for the D.A. and the judge for allowing me to move forward,” McGregor told reporters. “I want to say to my friends, my family, my fans, thank you for the support.”

Lightweight Michael Chiesa and flyweight Ray Borg suffered minor injuries from flying glass and were pulled from their April 7 bouts.

McGregor (21-3) has not fought in the UFC since November 2016, but lost to Floyd Mayweather in a TKO last August in his professional boxing debut. A lightweight title fight with Khabib Nurmagomedov, who is 26-0 and holds the belt now, would be huge, in part because he was going after Nurmagomedov, who was on the bus that night in April.

UFC President Dana White said after the incident that there had been bad feelings between McGregor’s camp and Nurmagomedov, the Russian fighter whose bout with Max Holloway for McGregor’s vacated belt was scratched when Holloway was deemed unfit. Nurmagomedov was filmed in a confrontation at a hotel with Artem Lobov, a friend of McGregor, earlier in the week.

McGregor, who is from Dublin, faced a possible 12 criminal charges related to the incident, including two felony criminal mischief charges carrying a maximum sentence of seven years in prison. Cian Cowley, a McGregor teammate at SBG Ireland, also was arrested in April and pleaded guilty to disorderly conduct.

Read more from The Post:

Jerry Jones says Cowboys will stand for the anthem but calls Trump’s stance ‘problematic’

What to watch as NFL players report to training camp

A date with a porn star has Jimmy Garoppolo all too aware he’s ‘under a microscope’

Dez Bryant could be the beneficiary of Browns’ uncertainty about Josh Gordon

Back from suspension and another injury, Ravens’ Jimmy Smith counts the steps to his return