]*>(.*?)(?:<\/head\s*>|
|<(script|style|noscript|template)\b.*?<\/\1\s*>/is', '', $head[1] ); if ( false === preg_match_all( '/"\'])*)>/i', $head, $tags ) ) { return ''; } foreach ( $tags[1] as $tag ) { $attributes = self::attributes( $tag ); if ( 'description' !== strtolower( trim( $attributes['name'] ?? '' ) ) ) { continue; } $text = (string) preg_replace( '/\s+/u', ' ', html_entity_decode( $attributes['content'] ?? '', ENT_QUOTES | ENT_HTML5, 'UTF-8' ) ); $text = trim( $text ); if ( '' !== $text ) { return $text; } } return ''; } /** * Reads the attributes of a tag. * * @param string $tag The text between the tag name and the closing bracket. * @return array