Shane is introduced in season 4 as Miranda's son and is later revealed that his father is Tim. Shane bonds with Amy over horses, especially Pal, before knowing they had the same father and acted as they were family. When he finds out that Tim is his father, he gets angry at Tim and Miranda from keeping it from him. However, Amy had a feeling and knew it was true. Lou accepts Shane and includes him in on her own baby-naming ceremony as one of the family with his own stone above the fireplace. Soon afterward, he leaves with Miranda. In the middle of season 5, he comes back on his own and spends his summer with the Fleming-Bartlett family as an attempt to get to know his family better. That, however, backfires when he gets involved with Amy and Ty in a showdown with the people who stole Tim's racehorse, Cisco. Shane had documented the entire situation on his new smartphone and uploaded the video to Facebook, including the part where they were shot at by the guard. Unfortunately, the family agreed not to tell Miranda and she found out through the video on Facebook. She headed to Heartland and took Shane away and moved him to Moose Jaw. Tim searched for them for five months before finding them. With Jack's help, Tim goes and talks to her. This ends badly and Miranda and Tim end up in a custody battle. Tim, knowing he could very possibly lose along with the break-up with Janice, starts drinking again. Jack, knowing how serious this could be, reached out to Miranda to give him a chance. Tim talks with Miranda the entire night and the next morning, after talking to Amy, he dumps out the liquor with Miranda watching from the Dude Ranch window with a look of approval. Shane comes to Heartland in the season 5 finale and tells them what he wants to happen and not to let them make all the decisions for him.
Just an update on your timeline as it's a tad out of order:
Miranda and Shane show up at Heartland and Tim finds out that Shane is his son. Just as Tim starts to accept the fact, Miranda disappears, taking Shane with her. Tim spends the next 5 months searching for Miranda and Shane and is about to give up when Shane, having run away shows up at Heartland. At this point, he does not know that Tim is his Father; he just knows that Heartland is the one place he was happy and that since leaving there his mom has moved him 5 times in 5 months. Shane spends a couple of days with Tim before being sent back to his mother. At this point, Jack “kidnaps” Tim for a road trip, taking him to Moose Jaw and making him try to work things out with Miranda, as he doesn’t want to see the same thing happen with Shane that happened with Amy and Lou. Miranda won’t listen to Tim so while Tim is sleeping, Jack goes and talks to Miranda on his own, trying to convince her to give Tim a chance. Cut to Lou’s Baby Naming Ceremony episode. Everyone is getting ready for dinner when Amy runs into Miranda and Shane at Maggie’s Diner and invites them back to Heartland for dinner. At dinner, Tim, thinking Miranda had already told Shane the truth, accidently let’s slip that Shane is “our son” to Miranda, revealing the secret to everyone. Shane is upset, Lou is shocked, Amy isn’t very surprised as she had a feeling something strange was going on. Lou gets over it and includes Shane as part of the family. Shane and Miranda leave. A couple episodes later, Shane is back to spend the summer with his family and get to know them. This is when all the problems go down with the stolen horse and being shot at. Miranda sees the video on Facebook, declares Tim an unfit father, and cuts off all contact between him and Shane so he tries to get Joint custody. He even goes as far as asking Janice to marry him to prove he has a “stable family life” but when she finds out and dumps him he starts drinking again. So far this is all the further I have made it in the show. I just wanted to post this comment because the timeline above was a little bit off from what actually happens in the show.