Помогите добавить nofollow в этот код

12
Shapranov Pavel
На сайте с 27.08.2007
Offline
304
594

Добрый вечер

Помогите добавить nofollow в этот код

function wp_noindex($comment) {
return str_replace('<a ', '<noindex><a ', $comment);
}
function wp_noindex2($comment) {
return str_replace('</a>', '</a></noindex>', $comment);
}

add_filter('comment_text', 'wp_noindex');
add_filter('comment_text', 'wp_noindex2');

Это код плагина для WordPress закрывающий только ссылки в комментириях в noindex, нужно чтобы закрывал и в nofollow. Как это можно реализовать?

robot-sgibatel
На сайте с 11.10.2008
Offline
87
#1

Думаю вот так

function wp_noindex($comment) {
return str_replace('<a ', '<noindex><a rel="nofollow" ', $comment);
}
function wp_noindex2($comment) {
return str_replace('</a>', '</a></noindex>', $comment);
}

add_filter('comment_text', 'wp_noindex');
add_filter('comment_text', 'wp_noindex2');
"Радиация убивает только тех, кто ее боится." © Гомер Джей Симпсон (http://esquire.ru/wil/simpson)
Shapranov Pavel
На сайте с 27.08.2007
Offline
304
#2
robot-sgibatel:
Думаю вот так

Так пробовал - не робит =(

Таггу x_x
На сайте с 31.10.2005
Offline
445
#3

Там не через eval? Попробуйте return str_replace('<a ', '<noindex><a rel=nofollow ', $comment); - то есть без двойных кавычек.

☠️☠️☠️
robot-sgibatel
На сайте с 11.10.2008
Offline
87
#4

Попробуйте вот так:

function wp_noindex($comment) {
return str_replace('<a ', '<noindex><a rel='nofollow' ', $comment);
}
function wp_noindex2($comment) {
return str_replace('</a>', '</a></noindex>', $comment);
}

add_filter('comment_text', 'wp_noindex');
add_filter('comment_text', 'wp_noindex2');

ЗЫ Видел где-то что вот так закрывают <nofollow> </nofollow>

Таггу x_x
На сайте с 31.10.2005
Offline
445
#5
robot-sgibatel:
Видел где-то что вот так закрывают <nofollow> </nofollow>

Такого тега нет, как и noindex, но noindex понимают рама с яндексом, а <nofollow> не поймёт никто, это только как атрибут либо у ссылки либо мета

robot-sgibatel
На сайте с 11.10.2008
Offline
87
#6

Вот где видел - http://master.rucontext.com/

S
На сайте с 28.10.2005
Offline
319
#7
Shapranov Pavel:
Так пробовал - не робит =(

А так?


function wp_noindex($comment) {
return str_replace('<a ', '<noindex><a rel=nofollow ', $comment);
}
function wp_noindex2($comment) {
return str_replace('</a>', '</a></noindex>', $comment);
}

add_filter('comment_text', 'wp_noindex');
add_filter('comment_text', 'wp_noindex2');

Должно работать палюбэ

Shapranov Pavel
На сайте с 27.08.2007
Offline
304
#8
robot-sgibatel:
Вот где видел - http://master.rucontext.com/

Да там уже нормально сделано, специально искал коммент со ссылкой :)

semenov:
А так?

function wp_noindex($comment) {
return str_replace('<a ', '<noindex><a rel=nofollow ', $comment);
}
function wp_noindex2($comment) {
return str_replace('</a>', '</a></noindex>', $comment);
}

add_filter('comment_text', 'wp_noindex');
add_filter('comment_text', 'wp_noindex2');


Должно работать палюбэ

И работает, благодарю :)

Таггу x_x
На сайте с 31.10.2005
Offline
445
#9

удалено ************

robot-sgibatel
На сайте с 11.10.2008
Offline
87
#10
Да там уже нормально сделано, специально искал коммент со ссылкой

Я имею ввиду что там LI счетчик закрыт вот так - <nofollow> </nofollow>

12

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий