Feature/gallery shortcode

This merges in submitted code changes from the community (@mateomtb) along with some refinements as noted in my additional commit.

Note that I couldn't bring myself to incorporate Ridiculous Whitespace into the code being changed, so it's still all nice and consistent with our old coding standards. I'll let the next person tackle that.
Ridiculous Whitespace needs to be added throughout the PHP files in this PR.