Changeset 873
- Timestamp:
- 09/29/2014 05:48:02 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/functions.php
r869 r873 69 69 add_filter( 'the_excerpt', __NAMESPACE__ . '\\lowercase_P_dangit_just_once' ); 70 70 add_filter( 'the_content', __NAMESPACE__ . '\\make_doclink_clickable', 10, 5 ); 71 add_filter( 'the_content', __NAMESPACE__ . '\\autolink_credits' ); 71 72 72 73 // Add the handbook's 'Watch' action link. … … 503 504 ); 504 505 } 506 507 /** 508 * For specific credit pages, link @usernames references to their profiles on 509 * profiles.wordpress.org. 510 * 511 * Simplistic matching. Does not verify that the @username is a legitimate 512 * WP.org user. 513 * 514 * @param string $content Post content 515 * @return string 516 */ 517 function autolink_credits( $content ) { 518 // Only apply to the 'credits' (themes handbook) and 'credits-2' (plugin 519 // handbook) pages 520 if ( is_single( 'credits' ) || is_single( 'credits-2' ) ) { 521 $content = preg_replace_callback( 522 '/\B@(\w+)/i', 523 function ( $matches ) { 524 return sprintf( 525 '<a href="https://profiles.wordpress.org/%s">@%s</a>', 526 esc_attr( $matches[1] ), 527 esc_html( $matches[1] ) 528 ); 529 }, 530 $content 531 ); 532 } 533 534 return $content; 535 }
Note: See TracChangeset
for help on using the changeset viewer.