Skip to content

Commit

Permalink
Merge pull request #138 from OpenSourceOrg/fix/discourse-preview
Browse files Browse the repository at this point in the history
Trim the Discourse comment body to 50 words
  • Loading branch information
geoffguillain authored Sep 26, 2024
2 parents dac9391 + d4c031a commit 0b5240b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions themes/osi/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,3 +407,16 @@ function osi_adjust_offset_pagination( int $found_posts, WP_Query $query ) {
return $found_posts;
}
add_filter( 'found_posts', 'osi_adjust_offset_pagination', 1, 2 );

/**
* Trim the Discourse comment body to 50 words.
*
* @param string $comment_body The comment body.
*
* @return string The trimmed comment body.
*/
function osi_wpdc_comment_body( string $comment_body ) {
$trimmed_comment_body = wp_trim_words( $comment_body, 50, '(...)' );
return $trimmed_comment_body;
}
add_filter( 'wpdc_comment_body', 'osi_wpdc_comment_body', 10, 1 );

0 comments on commit 0b5240b

Please sign in to comment.