Changeset 6313
- Timestamp:
- 02/26/2017 06:28:04 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/common/formatting.php
r6302 r6313 304 304 */ 305 305 function bbp_rel_nofollow_callback( $matches = array() ) { 306 $text = $matches[1]; 307 $text = str_replace( array( ' rel="nofollow"', " rel='nofollow'" ), '', $text ); 308 return "<a $text rel=\"nofollow\">"; 306 $text = $matches[1]; 307 $atts = shortcode_parse_atts( $matches[1] ); 308 $rel = 'nofollow'; 309 $home_url = home_url(); 310 311 // Bail on links that match the current domain 312 if ( preg_match( '%href=["\'](' . preg_quote( set_url_scheme( $home_url, 'http' ) ) . ')%i', $text ) || 313 preg_match( '%href=["\'](' . preg_quote( set_url_scheme( $home_url, 'https' ) ) . ')%i', $text ) 314 ) { 315 return "<a {$text}>"; 316 } 317 318 // Avoid collisions with existing "rel" attribute 319 if ( ! empty( $atts['rel'] ) ) { 320 $parts = array_map( 'trim', explode( ' ', $atts['rel'] ) ); 321 if ( false === array_search( 'nofollow', $parts ) ) { 322 $parts[] = 'nofollow'; 323 } 324 325 $rel = implode( ' ', $parts ); 326 unset( $atts['rel'] ); 327 328 $html = ''; 329 foreach ( $atts as $name => $value ) { 330 $html .= "{$name}=\"{$value}\" "; 331 } 332 333 $text = trim( $html ); 334 } 335 336 return "<a {$text} rel=\"{$rel}\">"; 309 337 } 310 338
Note: See TracChangeset
for help on using the changeset viewer.