Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function add_nofollow( $content ) {
- $my_xurl = "*.openstreetmap.fr";
- $my_purl = "*.tile.openstreetmap.fr";
- preg_match_all( '~<a.*>~isU', $content, $uri_match );
- for ( $i = 0; $i <= sizeof( $uri_match[0] ); $i ++ ) {
- if ( isset( $uri_match[0][ $i ] ) && ! preg_match( '~nofollow~is', $uri_match[0][ $i ] )
- && ( preg_match( '~' . preg_quote( $my_xurl ) . '~', $uri_match[0][ $i ] ))
- && ( preg_match( '~' . preg_quote( $my_purl ) . '~', $uri_match[0][ $i ] ))
- ) {
- $uri_change = trim( $uri_match[0][ $i ], ">" );
- $uri_change .= ' rel="nofollow">';
- $content = str_replace( $uri_match[0][ $i ], $uri_change, $content );
- }
- }
- return $content;
- }
- add_filter( 'the_content', 'add_nofollow' );
Add Comment
Please, Sign In to add comment