| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
exit; // Exit if accessed directly. |
| 5 |
} |
| 6 |
|
| 7 |
$i = 0; |
| 8 |
|
| 9 |
if( $messages->have_posts() ) { |
| 10 |
wp_enqueue_script( 'fep-replies-show-hide' ); |
| 11 |
if( fep_get_option( 'block_other_users', 1 ) ){ |
| 12 |
wp_enqueue_script( 'fep-block-unblock-script'); |
| 13 |
} |
| 14 |
$hide_read = apply_filters( 'fep_filter_hide_message_initially_if_read', true ); |
| 15 |
?> |
| 16 |
<div class="fep-message"><?php |
| 17 |
while ( $messages->have_posts() ) { |
| 18 |
$i++; |
| 19 |
|
| 20 |
$messages->the_post(); |
| 21 |
$read_class = ( $hide_read && fep_is_read() ) ? ' fep-hide-if-js' : ''; |
| 22 |
$content_class = array(); |
| 23 |
$content_class[] = 'fep-message-content'; |
| 24 |
$content_class[] = 'fep-message-content-' . get_the_ID(); |
| 25 |
//$content_class[] = 'fep-message-content-author-' . get_the_author_meta('ID'); |
| 26 |
$per_mgs_class = array(); |
| 27 |
$per_mgs_class[] = 'fep-per-message'; |
| 28 |
$per_mgs_class[] = 'fep-per-message-' . get_the_ID(); |
| 29 |
//$per_mgs_class[] = 'fep-per-message-' . get_the_author_meta('ID'); |
| 30 |
|
| 31 |
if( get_current_user_id() == get_the_author_meta('ID') ){ |
| 32 |
$content_class[] = 'fep-message-content-own'; |
| 33 |
$per_mgs_class[] = 'fep-per-message-own'; |
| 34 |
} |
| 35 |
if( fep_is_user_admin( get_the_author_meta('ID') ) ){ |
| 36 |
$content_class[] = 'fep-message-content-admin'; |
| 37 |
$per_mgs_class[] = 'fep-per-message-admin'; |
| 38 |
} |
| 39 |
if( $hide_read && fep_is_read() ){ |
| 40 |
$content_class[] = 'fep-hide-if-js'; |
| 41 |
//$per_mgs_class[] = 'fep-hide-if-js'; |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
fep_make_read(); |
| 46 |
fep_make_read( true ); ?> |
| 47 |
|
| 48 |
<?php if( $i === 1 ){ |
| 49 |
|
| 50 |
$participants = fep_get_participants( get_the_ID() ); |
| 51 |
$par = array(); |
| 52 |
foreach( $participants as $participant ) { |
| 53 |
|
| 54 |
if( get_current_user_id() != $participant && fep_get_option( 'block_other_users', 1 ) ){ |
| 55 |
$block_unblock_text = fep_is_user_blocked_for_user( get_current_user_id(), $participant ) ? __("Unblock", "front-end-pm") : __("Block", "front-end-pm"); |
| 56 |
$par[] = fep_get_userdata( $participant, 'display_name', 'id' ) . '(<a href="#" class="fep_block_unblock_user" data-user_id="' . $participant . '">'. $block_unblock_text . '</a>)'; |
| 57 |
} else { |
| 58 |
$par[] = fep_get_userdata( $participant, 'display_name', 'id' ); |
| 59 |
} |
| 60 |
} ?> |
| 61 |
<div class="fep-per-message fep-per-message-top fep-per-message-<?php the_ID(); ?>"> |
| 62 |
<div class="fep-message-title-heading"><?php the_title(); ?></div> |
| 63 |
<div class="fep-message-title-heading participants"><?php _e("Participants", 'front-end-pm'); ?>: <?php echo apply_filters( 'fep_filter_display_participants', implode( ', ', $par ), $par, $participants ); ?></div> |
| 64 |
<div class="fep-message-toggle-all fep-align-right"><?php _e("Toggle Messages", 'front-end-pm'); ?></div> |
| 65 |
</div> |
| 66 |
<?php } ?> |
| 67 |
<div id="fep-message-<?php the_ID(); ?>" class="<?php echo fep_sanitize_html_class( $per_mgs_class ); ?>"> |
| 68 |
<div class="fep-message-title fep-message-title-<?php the_ID(); ?>"> |
| 69 |
<div class="author"><?php the_author_meta('display_name'); ?></div> |
| 70 |
<div class="date"><?php the_time(); ?></div> |
| 71 |
</div> |
| 72 |
<div class="<?php echo fep_sanitize_html_class( $content_class ); ?>"> |
| 73 |
<?php the_content(); ?> |
| 74 |
|
| 75 |
<?php if( $i === 1 ){ |
| 76 |
do_action ( 'fep_display_after_parent_message' ); |
| 77 |
} else { |
| 78 |
do_action ( 'fep_display_after_reply_message' ); |
| 79 |
} ?> |
| 80 |
<?php do_action ( 'fep_display_after_message', $i ); ?> |
| 81 |
</div> |
| 82 |
</div><?php |
| 83 |
} ?> |
| 84 |
</div><?php |
| 85 |
wp_reset_postdata(); |
| 86 |
|
| 87 |
include( fep_locate_template( 'reply_form.php') ); |
| 88 |
|
| 89 |
} else { |
| 90 |
echo "<div class='fep-error'>".__("You do not have permission to view this message!", 'front-end-pm')."</div>"; |
| 91 |
} |