PluginProbe
Friends / 2.8.1
Friends v2.8.1
4.3.2 4.3.1 4.3.0 4.2.2 4.2.1 4.2.0 4.1.0 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.0 2.9.1 All 88 releases
friends / templates / frontend / messages / friend.php

friend.php in Friends 2.8.1, at templates/frontend/messages/friend.php

72 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * This template contains the messages from a friend on /friends/.
4 *
5 * @package Friends
6 */
7
8 ?>
9 <div class="card mt-2 p-2">
10 <strong><?php esc_html_e( 'Messages', 'friends' ); ?></strong>
11 <?php
12 while ( $args['existing_messages']->have_posts() ) {
13 $post = $args['existing_messages']->next_post();
14 setup_postdata( $post );
15 $class = '';
16 if ( get_post_status( $post ) === 'friends_unread' ) {
17 $class .= ' unread';
18 }
19 ?>
20 <div class="friend-message" id="message-<?php echo esc_attr( get_the_ID() ); ?>" data-id="<?php echo esc_attr( get_the_ID() ); ?>" data-nonce="<?php echo esc_attr( wp_create_nonce( 'friends-mark-read' ) ); ?>">
21 <a href="" class="display-message<?php echo esc_attr( $class ); ?>" title="<?php echo esc_attr( get_post_modified_time( 'r' ) ); ?>">
22 <?php
23 // translators: %s is a time span.
24 echo esc_html( sprintf( __( '%s ago' ), human_time_diff( get_post_modified_time( 'U', true ) ) ) ); // phpcs:ignore WordPress.WP.I18n.MissingArgDomain
25 echo ': ';
26 the_title();
27 ?>
28 </a>
29 <div style="display: none" class="conversation">
30 <div class="messages">
31 <?php
32
33 $content = get_the_content();
34 preg_match_all( '/<span class="date">([^<]+)</', $content, $matches );
35 if ( $matches ) {
36 $replace = array();
37 foreach ( $matches[1] as $gmdate ) {
38
39 $replace[ $gmdate ] = esc_html(
40 sprintf(
41 // translators: %s is a time span.
42 __( '%s ago' ), // phpcs:ignore WordPress.WP.I18n.MissingArgDomain
43 human_time_diff( strtotime( $gmdate ) )
44 )
45 );
46 }
47 $content = str_replace( array_keys( $replace ), array_values( $replace ), $content );
48 }
49
50 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- This was handled upon post insert.
51 echo apply_filters( 'the_content', $content );
52 ?>
53 </div>
54 <?php
55 Friends\Friends::template_loader()->get_template_part(
56 'frontend/messages/message-form',
57 null,
58 array_merge(
59 $args,
60 array(
61 'subject' => get_the_title(),
62 )
63 )
64 );
65 ?>
66 </div>
67 </div>
68 <?php
69 }
70 ?>
71 </div>
72