protected function get_content_galleries($content) { if (!has_shortcode($content, 'gallery')) { return array(); } $galleries = array(); if (!preg_match_all('/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER)) { return $galleries; } foreach ($matches as $shortcode) { if ('gallery' === $shortcode[2]) { $attributes = shortcode_parse_atts($shortcode[3]); if ('' === $attributes) { // Valid shortcode without any attributes. R. $attributes = array(); } $galleries[] = $attributes; } } return $galleries; }