Advertisement
urosevic

Uklanjanje nofollow iz linkova u tekstu komentara

May 16th, 2020
1,272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.39 KB | None | 0 0
  1. // Skloni nofollow iz teksta komentara samo na front-endu
  2. if (false === strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
  3.     add_filter('comment_text', 'wpsr_au_remove_nofollow');
  4. }
  5. function wpsr_au_remove_nofollow($text) {
  6.     $text = preg_replace("/(<a[^>]*[^\s])(\s*)nofollow(\s*)/i", "$1$2", $text);
  7.     $text = preg_replace("/(<a[^>]*[^\s])(\s*rel=[\"\']\s*[\"\'])/i", "$1", $text);
  8.     return $text;
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement