Answer the question
In order to leave comments, you need to log in
What is this piece of code for $content = str_replace($zzz, str_replace('href', 'rel="nofollow" href', $zzz), $content);?
Found the code in init.php. I know that it was made by some SEOs. But why I can't figure it out. Because of this function, the context menu does not work in the admin panel, in the data export interface.
AddEventHandler("main", "OnEndBufferContent", "AutoCloseLinksHandler");
function AutoCloseLinksHandler(&$content)
{
$url = $_SERVER['HTTP_HOST'];
preg_match_all("<a[^<>]*href=[\"|'](.*)[\"|'][^<>]*>", $content, $out_url);
foreach ($out_url[0] as $val => $zzz) {
if (preg_match('~http(s)?://~', $zzz) && !preg_match('~http(s)?://(www.)?' . $url . '~i', $zzz) && !preg_match('~rel="nofollow"~i', $zzz)) {
$content = str_replace($zzz, str_replace('href', 'rel="nofollow" href', $zzz), $content);
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question