Code:// Strip html and truncate to create a META value.
function seoHTMLtoMETA($str, $type = 'KEYWORDS', $length = 70) {
require_once 'includes/seo_fns.php';
$str = preg_replace('/(\[(\S+)\]|&(?![a-zA-Z]{2,6};))/sU', '', $str); // Remove BBCode and chopped off entities
$str = check_html($str, 'nohtml'); // Remove HTML tags
$str = preg_replace('/(\s+)/', ' ', $str); // Remove all internal whitepace, replace with single space
$entities = array('(tm)','"', '©', '>', '<',
' ', '™', '®', ';',
chr(10), chr(13), chr(9));
$str = html_entity_decode(seo_simple_strip_tags($str));
if ($type == 'DESCRIPTION') $str = str_replace($entities, '', $str);
$str = htmlspecialchars($str);
// Remove stop words from keyword content, then convert to most popular keywords
if ($type == 'KEYWORDS' and $str > '') $str = seoGetAutoKeys($str);
$metavalue = truncate_string($str, $length);
if (mb_strlen($str) > mb_strlen($metavalue)) $metavalue .= "...";
return $metavalue;
}
|