Código:
Lo que hace exactamente es a todos los links de la pagina agregar al principio un dominio.com y al final rel="nofollow" target="_blank"> y aplicarselo al filtro the_content.<?php function jab_nombre_dominio_de_url($uri){ preg_match("/^(http:\/\/)?([^\/]+)/i", $uri, $matches); $host = $matches[2]; preg_match("/[^\.\/]+\.[^\.\/]+$/", $host, $matches); return $matches[0]; } function jab_parse_link_externo($matches){ global $jab_imagen_nueva_ventana; if (($jab_imagen_nueva_ventana && jab_tal_imagen($matches[3])) || ( jab_nombre_dominio_de_url($matches[3]) != jab_nombre_dominio_de_url($_SERVER["HTTP_HOST"]) )) { return '<a href="http://dominio.com/?' . $matches[2] . '//' . $matches[3] . '"' . $matches[1] . $matches[4] . ' rel="nofollow" target="_blank">' . $matches[5] . '</a>'; } else { return '<a href="' . $matches[2] . '//' . $matches[3] . '"' . $matches[1] . $matches[4] . '>' . $matches[5] . '</a>'; } } function jab_link_externo($text) { $pattern = '/<a (.*?)href="(.*?)\/\/(.*?)"(.*?)>(.*?)<\/a>/i'; $text = preg_replace_callback($pattern,'jab_parse_link_externo',$text); return $text; } add_filter('the_content', 'jab_link_externo', 999); ?>
No he podido hacerlo andar en php puro osea yo no uso wordpress la variable que no me da es
Código:
ya que es una funcion de wordpress yo en donde imprimo todo lo que publican es con $contenido como lo puedo lograr gracias.add_filter('the_content', 'jab_link_externo', 999);
Este seria el resultado a lograr
Cita:
<a href="http://dominio.com/?http://www.aqui-liks-ect..-/file/610" rel="nofollow" target="_blank">