Skip to content

Commit 0b5240b

Browse files
Merge pull request #138 from OpenSourceOrg/fix/discourse-preview
Trim the Discourse comment body to 50 words
2 parents dac9391 + d4c031a commit 0b5240b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

themes/osi/functions.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,3 +407,16 @@ function osi_adjust_offset_pagination( int $found_posts, WP_Query $query ) {
407407
return $found_posts;
408408
}
409409
add_filter( 'found_posts', 'osi_adjust_offset_pagination', 1, 2 );
410+
411+
/**
412+
* Trim the Discourse comment body to 50 words.
413+
*
414+
* @param string $comment_body The comment body.
415+
*
416+
* @return string The trimmed comment body.
417+
*/
418+
function osi_wpdc_comment_body( string $comment_body ) {
419+
$trimmed_comment_body = wp_trim_words( $comment_body, 50, '(...)' );
420+
return $trimmed_comment_body;
421+
}
422+
add_filter( 'wpdc_comment_body', 'osi_wpdc_comment_body', 10, 1 );

0 commit comments

Comments
 (0)