diff --git a/includes/class-messages.php b/includes/class-messages.php index 2f280ecc..395b5d5b 100644 --- a/includes/class-messages.php +++ b/includes/class-messages.php @@ -493,15 +493,23 @@ public function friends_display_messages( $args ) { } $args['accounts'] = apply_filters( 'friends_message_form_accounts', array(), $args['friend_user'] ); + add_filter( 'excerpt_length', array( $this, 'friends_message_excerpt_length' ) ); + Friends::template_loader()->get_template_part( 'frontend/messages/friend', null, $args ); + remove_filter( 'excerpt_length', array( $this, 'friends_message_excerpt_length' ) ); + } } + public function friends_message_excerpt_length() { + return 10; + } + /** * Embed the message form for the friend user. * diff --git a/templates/frontend/messages/friend.php b/templates/frontend/messages/friend.php index 0a08d5df..8d2e0b4d 100644 --- a/templates/frontend/messages/friend.php +++ b/templates/frontend/messages/friend.php @@ -16,11 +16,6 @@ get_posts() as $_post ) { - $subject = get_the_title( $_post ); - if ( ! $subject ) { - $subject = get_the_excerpt( $_post ); - } - $messages = get_posts( array( 'post_parent' => $_post->ID, @@ -32,20 +27,26 @@ ); array_unshift( $messages, $_post ); - $class = ''; + $classes = array( 'display-message' => true ); + $subject = false; $last_message_time = false; foreach ( $messages as $message ) { if ( get_post_status( $message ) === 'friends_unread' ) { - $class .= ' unread'; + $classes['unread'] = true; } $post_time = get_post_modified_time( 'U', true, $message ); if ( ! $last_message_time || $post_time > $last_message_time ) { $last_message_time = $post_time; + + $subject = get_the_title( $message ); + if ( ! $subject ) { + $subject = get_the_excerpt( $message ); + } } } ?>