`get_post_galleries()` can return incorrect gallery items.
|Reported by:||dd32||Owned by:||dd32|
get_post_galleries() is a little hacky in the way it works and doesn't work as intended when a plain [gallery] shortcode is within the content and the given post_id doesn't match the global $post object.
For example, take the following scenario:
post_content = [gallery] $GLOBALS['post'] = null; $data = get_post_galleries( $id );
$data now contains a gallery of all unattached media, as the shortcode handler doesn't have the global $post context and instead queries for post_parent = 0.
If the global $post was set to another post, the gallery would be of that posts media.