'
]*>.*?
)%ims', '\n$1\n', $content); if ($wp_version < '2.3') { $content = preg_replace_callback('!
]*)>(.*?)!ims', 'tguy_cmu_escape_backslash_callback', $content); } $content = preg_replace_callback('!
]*)>(?:\r\n|\n|\r|)(.*?)(?:\r\n|\n|\r|)
!ims', 'tguy_cmu_encode_xml_callback', $content);
return $content;
}
function tguy_cmu_tidy_code($content) {
$content = preg_replace_callback('!]*)>(.*?)!ims', 'tguy_cmu_unescape_qq_callback', $content); $content = preg_replace_callback('!
]*)>(.*?)
!ims', 'tguy_cmu_untexturize_code_callback', $content);
return $content;
}
function tguy_cmu_encode_xml_callback($matches) {
$attributes = $matches[1];
$escapedContent = $matches[2];
$attrMatches = array();
$markup = 'default';
if (0 < preg_match('!^(.*?)\s+(?:markup|allow)="([^"]*)"(.*)$!i', $attributes, $attrMatches)) {
$markup = strtolower($attrMatches[2]);
$attributes = $attrMatches[1] . $attrMatches[3];
}
if ($markup == 'default') {
if (0 < preg_match('!^(.*)lang="([^"]*)"(.*)$!i', $attributes, $attrMatches)) {
$lang = strtolower($attrMatches[2]);
$attributes = $attrMatches[1] . $attrMatches[3];
if ($lang == 'html' || $lang == 'xhtml') {
$markup = 'none';
}
}
}
if ($markup == 'all') {
} else {
if ($markup == 'none' || $markup == '') {
$allowedTags = '';
} else if ($markup == 'default' || $markup == 'tags') { // 'tags' allowed for backward compatibility
$allowedTags = 'em|strong|b|i|ins|del|a|span|comment';
} else {
$allowedTags = preg_replace('!\s+!', '|', trim($markup));
}
$escapedContent = htmlspecialchars($escapedContent, ENT_NOQUOTES);
if ($allowedTags != '') {
$escapedContent = preg_replace_callback('!</?('.$allowedTags.')( .*?)?>!is',
'tguy_cmu_unescape_tag', $escapedContent);
if (false !== strpos($allowedTags, 'comment')) {
$escapedContent = preg_replace_callback('|<!--.*?-->|is',
'tguy_cmu_unescape_tag', $escapedContent);
}
}
}
return "$escapedContent
";
}
function tguy_cmu_unescape_tag($matches) {
return str_replace(
array(">", "<", """, "&"),
array(">", "<", "\"", "&"),
$matches[0]);
}
function tguy_cmu_escape_backslash_callback($matches) {
return "".str_replace('\\', '\\\\', $matches[2]).""; } function tguy_cmu_unescape_qq_callback($matches) { return "
".str_replace('\"', '"', $matches[2]).""; } function tguy_cmu_untexturize_code_callback($matches) { $fancy = array('×', '‘', '’', '′', '“', '”', '″', '—', '–', '…', '“'); $plain = array('x' ,'\'' , '\'' , '\'' , '"' , '"' , '"' , '--' , '--' , '...' , '``' ); return "
".str_replace($fancy, $plain, $matches[2])."
";
}
// ===== Add Meta Noindex Rules on Singular Comment Page Section ======
function wpi_comment_paging_noindex_meta()
{ global $wp_query;
if (version_compare( (float) get_bloginfo('version'), 2.7, '>=') ){
if ($wp_query->is_singular && get_option('page_comments')){ // comments paging enabled
if (isset($wp_query->query['cpage'])
&& absint($wp_query->query['cpage']) >= 1 ){
echo ''.PHP_EOL;
}
}
}
}
add_action('wp_head','wpi_comment_paging_noindex_meta');
// ===== Add a Microid to all Comments ================================
function comment_add_microid($classes) {
$c_email=get_comment_author_email();
$c_url=get_comment_author_url();
if (!empty($c_email) && !empty($c_url)) {
$microid = 'microid-mailto+http:sha1:' . sha1(sha1('mailto:'.$c_email).sha1($c_url));
$classes[] = $microid;
}
return $classes;
}
add_filter('comment_class','comment_add_microid');
// ===== Comments Loop ================================================
function mytheme_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>