WPSEO_Sitemap_Image_Parser::get_content_galleries
Retrieves galleries from the passed content.
Forked from core to skip executing shortcodes for performance.
Метод класса: WPSEO_Sitemap_Image_Parser{}
Хуков нет.
Возвращает
Массив. A list of arrays, each containing gallery data.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_content_galleries( $content );
- $content(строка) (обязательный)
- Content to parse for shortcodes.
Код WPSEO_Sitemap_Image_Parser::get_content_galleries() WPSEO Sitemap Image Parser::get content galleries Yoast 27.9
protected function get_content_galleries( $content ) {
$galleries = [];
if ( ! preg_match_all( '/' . get_shortcode_regex( [ 'gallery' ] ) . '/s', $content, $matches, PREG_SET_ORDER ) ) {
return $galleries;
}
foreach ( $matches as $shortcode ) {
$attributes = shortcode_parse_atts( $shortcode[3] );
if ( $attributes === '' ) { // Valid shortcode without any attributes. R.
$attributes = [];
}
$galleries[] = $attributes;
}
return $galleries;
}