Mark Salling
Mark Salling pleaded guilty to child pornography. Pictured: attends the Tinder Plus Launch Party featuring Jason Derulo and ZEDD at Hangar 8 Santa Monica at Barker Hangar on June 17, 2015 in Santa Monica, California. Getty Images/Tommaso Boddi

Mark Salling has pleaded guilty to child pornography charges.

On Wednesday, the former "Glee" star pleaded guilty to possession of child abuse images involving a prepubescent minor. "I am pleading guilty because I am guilty of the charges and wish to take advantage of the promises set forth in this agreement, and not for any other reason," Salling said in the documents obtained by The Guardian.

By pleading guilty, Salling avoided the maximum sentence of 20 years. However, he was ordered to pay each of his victims $50,000 and enter a treatment program for sex offenders.

Acording to Us Weekly, the actor's plea agreement said Salling, 35, agreed to serve four to seven years in jail. He must also register as a sex offender and is prohibited from talking to anyone under 18 years old, unless a parent or legal guardian is around. After Salling is released, he is ordered to stay 100 feet away from schoolyards, parks, public swimming pools, playgrounds and video arcade venues. In addition, he will also be supervised for 20 years.

The actor was arrested in December 2015 after the Los Angeles Police Department task force for internet crimes against children received a report that Salling had an extensive collection of child porn at his home in Sunland, California. The authorities discovered that he had over 50,000 photos and videos in his laptop and another 4,000 in a flash drive. Following Salling's indictment, he was fired from the "Gods and Secrets" film.

Salling previously dated his "Glee" co-star Naya Rivera, who confessed that she was not surprised by the charges against her ex-boyfriend. "He was always just a very dark soul to me," Rivera told Entertainment Tonight. "I always felt like there was something that he was wrestling with."

In Rivera's 2016 memoir, "Sorry Not Sorry," she revealed that Salling dumped her in 2010 after his publicist advised him that being single would help his image. "When Mark dumped me, I thought it was the worst thing ever," Rivera confessed. "Everyone should have that one relationship where you look back and ask yourself, 'What the hell was I thinking?'"

What can you say about Salling's decision to plead guilty? Drop a comment below.