My ADHD trick for social media is to use my ADHD to restrain my access to it.
First of all I deleted all Facebook/Instagram/LinkedIn/etc applications from my phone. This worked decently until I started using web browser to access them. For that, I changed my password to one that is very long, has special characters and there is some uncertainty in them ("Was the last word upper or lower case?"). Of course I logged off and prevented my browser from remembering passwords for those services. With this setup it became incredibly tedious to log in (ADHD does its job here). Of course, if I needed to access a class facebook group, I could do it (but ideally from an incognito card, so I am logged out on close). However, when I picked my phone during classes and subconsciously went to facebook.com, I faced the wall of having to guess that password again. This effectively killed the habit.
Things got a bit problematic when I joined a sports club which utilized facebook a lot for announcements. Without a constant access I was cut out of the context most of the time. What worked really well was to simply set up a second account "Firstname LastnameSports", add no friends, and link my main account in the profile picture. Unfortunately, this way I have access to the default facebook wall, but thankfully with no follows and friends the content is so dumb and boring that I don't have any urge to use it.
Regarding the general problem of sitting in a class and paying attention, medication really helps. Just note that there are different substances and it is advised to figure out which one works the best. A caveat to that is that, at least for me, they work much worse, if not sometimes negatively, while I am hungry. They also lower appetite making things more tricky. A good thing is to remember to stay well fed, and to always have some water around you.