Yoast\WP\SEO\Builders
Indexable_Link_Builder::gather_links
Gathers all links from content.
Метод класса: Indexable_Link_Builder{}
Хуков нет.
Возвращает
Строку[]. An array of urls.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->gather_links( $content );
- $content(строка) (обязательный)
- The content.
Код Indexable_Link_Builder::gather_links() Indexable Link Builder::gather links Yoast 28.0
protected function gather_links( $content ) {
if ( \strpos( $content, 'href' ) === false ) {
// Nothing to do.
return [];
}
$links = [];
$regexp = '<a\s[^>]*href=("??)([^" >]*?)\1[^>]*>';
// Used modifiers iU to match case insensitive and make greedy quantifiers lazy.
if ( \preg_match_all( "/$regexp/iU", $content, $matches, \PREG_SET_ORDER ) ) {
foreach ( $matches as $match ) {
$links[] = \trim( $match[2], "'" );
}
}
return $links;
}