get_comment_author_link хук-фильтр . WP 1.5.0
Позволяет изменить ссылку на сайт комментатора, возвращаемую функцией get_comment_author_link().
Использование
add_filter( 'get_comment_author_link', 'filter_function_name_6292', 10, 3 ); function filter_function_name_6292( $return, $author, $comment_ID ){ // Изменяем при надобности... return $return; }
- $return(строка)
- Ссылка на сайт комментатора в html формате (<a></a>), если она была указана и корректна. Иначе - имя автора комментария.
- $author(строка)
- Имя автора комментария, получаемое функцией get_comment_author().
- $comment_ID(число)
- ID комментария.
Примеры
#1 Изменяет ссылку, чтобы она открывалась в новой вкладке.
Добавим к ссылке атрибут target='_blank':
add_filter( 'get_comment_author_link', 'add_target_blank_comment_author_link' ); function add_target_blank_comment_author_link( $return ) { $search = 'external nofollow\''; $replace = 'external nofollow noreferrer\' target=\'_blank\''; return str_replace( $search, $replace, $return ); }
Заметки
- C версии 4.1.0 Добавлены параметры $author и $comment_ID.
Список изменений
С версии 1.5.0 | Введена. |
С версии 4.1.0 | The $author and $comment_ID parameters were added. |
Где вызывается хук
get_comment_author_link
wp-includes/comment-template.php 241
return apply_filters( 'get_comment_author_link', $return, $author, $comment->comment_ID );