You may want to look into just finding some kind of sharing plugin you can use that’s already built for you. I’m sure there are tons out there for free you can try.
functions.php of your Child theme.
Here’s the complete guide from the Codex:
And here are a couple of good articles that explain these topics a little more: