From e490203981c60e96f8a1289248b62381dde97df4 Mon Sep 17 00:00:00 2001 From: Geoff Date: Thu, 26 Sep 2024 00:06:47 -1000 Subject: [PATCH 1/3] Trim the Discourse comment body to 50 words --- themes/osi/functions.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/themes/osi/functions.php b/themes/osi/functions.php index 4a84a35..0a0a75d 100755 --- a/themes/osi/functions.php +++ b/themes/osi/functions.php @@ -407,3 +407,15 @@ 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 + * @return void + */ +function osi_wpdc_comment_body( $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 ); From f95840dd92d542a3ee755341cc29191a149c06ef Mon Sep 17 00:00:00 2001 From: Geoff Date: Thu, 26 Sep 2024 00:17:33 -1000 Subject: [PATCH 2/3] Linting errors --- themes/osi/functions.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/themes/osi/functions.php b/themes/osi/functions.php index 0a0a75d..e94a710 100755 --- a/themes/osi/functions.php +++ b/themes/osi/functions.php @@ -411,8 +411,9 @@ function osi_adjust_offset_pagination( int $found_posts, WP_Query $query ) { /** * Trim the Discourse comment body to 50 words. * - * @param string $comment_body - * @return void + * @param string $comment_body The comment body. + * + * @return string The trimmed comment body. */ function osi_wpdc_comment_body( $comment_body ) { $trimmed_comment_body = wp_trim_words( $comment_body, 50, '(...)' ); From d4c031a2c649281e8ccdefaa2cbf4309936e3efc Mon Sep 17 00:00:00 2001 From: Geoff Date: Thu, 26 Sep 2024 00:20:00 -1000 Subject: [PATCH 3/3] Fix linting --- themes/osi/functions.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/themes/osi/functions.php b/themes/osi/functions.php index e94a710..7aa6fea 100755 --- a/themes/osi/functions.php +++ b/themes/osi/functions.php @@ -411,11 +411,11 @@ function osi_adjust_offset_pagination( int $found_posts, WP_Query $query ) { /** * Trim the Discourse comment body to 50 words. * - * @param string $comment_body The comment body. - * + * @param string $comment_body The comment body. + * * @return string The trimmed comment body. */ -function osi_wpdc_comment_body( $comment_body ) { +function osi_wpdc_comment_body( string $comment_body ) { $trimmed_comment_body = wp_trim_words( $comment_body, 50, '(...)' ); return $trimmed_comment_body; }