Changeset 13304
- Timestamp:
- 03/11/2024 05:37:44 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/functions.php
r13303 r13304 324 324 325 325 /** 326 * Shorten excerpt length on index pages, so plugins cards are all the same height.327 *328 * @param string $excerpt The excerpt.329 * @return string330 */331 function excerpt_length( $excerpt ) {332 /*333 * Don't run this filter during rest-api requests.334 * This shouldn't normally be needed, but this avoids accidental shortening of the API fields.335 */336 if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {337 return $excerpt;338 }339 340 if ( is_home() || is_archive() ) {341 /*342 * translators: If your word count is based on single characters (e.g. East Asian characters),343 * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.344 * Do not translate into your own language.345 */346 if ( strpos( _x( 'words', 'Word count type. Do not translate!', 'wporg-plugins' ), 'characters' ) === 0 ) {347 // Use the default limit of 55 characters for East Asian locales.348 $excerpt = wp_trim_words( $excerpt );349 } else {350 // Limit the excerpt to 15 words for other locales.351 $excerpt = wp_trim_words( $excerpt, 15 );352 }353 }354 355 return $excerpt;356 }357 add_filter( 'get_the_excerpt', __NAMESPACE__ . '\excerpt_length' );358 359 /**360 326 * Adds meta tags for richer social media integrations. 361 327 */
Note: See TracChangeset
for help on using the changeset viewer.