Before you scroll, please know that this post contains spoilers for Shazam! Fury of the Gods. Don't say we didn't warn you!

In the first Shazam! movie, there's a pretty infamous moment when Billy manages to get Superman to hang out with Freddy at lunch. We see the fallout of this moment in Shazam! Fury of the Gods, where everyone knows (and maybe doesn't fully appreciate) the fact that Freddy is apparently pals with the Justice League. Of course, in the movie proper, the moment was played pretty coyly—we only ever see Superman from the neck down and never actually see his face. It’s pretty clever, then, that in Fury of the Gods, Wonder Woman gets the same treatment in a dream sequence with a much different punchline (the Wizard Shazam has never pulled off a classier dress, that's for sure).

But ultimately, by the end of the movie we circle back around to Wonder Woman and, against all odds, do end up actually seeing her. Gal Gadot reprises her role as Diana for a brief moment at the end of the movie and even has a nice, playful conversation with Billy, who is about as awkward and goofy as you'd expect him to be in the presence of a literal goddess.

So, what prompted Fury of the Gods to take a shot at a cameo like this, even after they'd already gotten away with a perfectly funny gag? Well, according to director David F. Sandberg, it all tied back to that Superman moment in the original film.

"What happened in (the first Shazam!) was that it was supposed to be Henry Cavill,” he explains. “We were shooting the scene and (Henry's people) were like, 'Oh, he won't be able to actually get here, so you'll have to shoot it with a stand in and we'll come back at a later date and shoot his coverage to make it work.' But that day never came, so we had to improvise with the footage and it all worked out. But in this one, Gal Gadot was always in the script, but I was like, 'Are we sure this is going to happen?'"

Turns out he wasn’t wrong to ask.

"On the day we were shooting, (Gal's people) said she wasn't going to be able to come in, so we were going to have to shoot with a stand-in and then pick up her pieces,” Sandberg continues. “That was when I started thinking, so if we don't get her to be here, how do we solve this? I thought about having Hespera come back, because we knew we'd need a god to revive Billy. But then it actually ended up working out and we actually got to put her in there. I mean, if she hadn't shown up at the end, we couldn't have had the (dream sequence) with the wizard's head! You can only have that scene if she shows up at the end, or fans would be like, 'Another headless cameo? What's going on?'"

Sandberg made clear that he also understood the joke was overstaying its welcome in the way he shot Gal's cameo.

"When we first cut to her, I did frame it with her head out, but then we quickly went, 'No, no, she's here!' before audiences could storm out of the theaters," he laughs.

Luckily for us (and for Billy), everything was able to pan out in the end—though it's unclear what this moment might mean for Wonder Woman moving forward. We already know that Henry Cavill won't be reprising his turn as Superman as the cinematic universe moves forward, but Diana—immortal and ageless as she is—is obviously in a unique position among the established members of the Justice League. Looks like we'll just have to keep our eyes and ears open as we move forward for any clues!

Shazam! Fury of the Gods, starring Zachary Levi and directed by David F. Sandberg, hits theaters March 17th. Visit our official Shazam! Fury of the Gods page to buy tickets and catch up on all of the latest news, trailers and more!

Mason Downey writes about comics, movies and superhero history for Look for more of his work on GameSpot, IGN and Polygon and follow him on Twitter at @rustypolished.

NOTE: The views and opinions expressed in this feature are solely those of Mason Downey and do not necessarily reflect those of DC Entertainment or Warner Bros., nor should they be read as confirmation or denial of future DC plans.