Changeset 9715
- Timestamp:
- 04/13/2020 10:56:06 PM (5 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/functions.php
r9646 r9715 7 7 */ 8 8 require __DIR__ . '/inc/registrations.php'; 9 10 /** 11 * HTML head tags and customizations. 12 */ 13 require __DIR__ . '/inc/head.php'; 9 14 10 15 /** … … 416 421 417 422 /** 418 * Output a <meta name="description" content=""> tag for Functions, Hooks, Classes and Methods.419 */420 function add_meta_description_for_summary() {421 if ( ! is_singular( array( 'wp-parser-function', 'wp-parser-hook', 'wp-parser-class', 'wp-parser-method' ) ) ) {422 return;423 }424 425 $summary = wp_strip_all_tags( get_summary() );426 427 // Trim down to ~150 char based on full words.428 if ( strlen( $summary ) > 150 ) {429 $words = preg_split( "/[\n\r\t ]+/", $summary, -1, PREG_SPLIT_NO_EMPTY );430 431 $summary = '';432 while ( $words ) {433 $word = array_shift( $words );434 if ( strlen( $summary ) + strlen( $word ) >= 141 ) { /* 150 - strlen( ' …' ) */435 break;436 }437 438 $summary .= $word . ' ';439 }440 441 if ( $words ) {442 $summary .= '…';443 }444 }445 446 if ( $summary ) {447 printf( '<meta name="description" content="%s">' . "\n", esc_attr( $summary ) );448 }449 }450 add_action( 'wp_head', __NAMESPACE__ . '\add_meta_description_for_summary' );451 452 /**453 423 * Outputs `<link rel="canonical">` tags where appropriate. 454 424 */
Note: See TracChangeset
for help on using the changeset viewer.