WPSEO_Sitemap_Image_Parser::get_content_galleries PHP Method

get_content_galleries() protected method

Forked from core to skip executing shortcodes for performance.
protected get_content_galleries ( string $content ) : array
$content string Content to parse for shortcodes.
return array A list of arrays, each containing gallery data.
    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;
    }