| 1 |
<ul class="easydocs-accordion"> |
| 2 |
<?php |
| 3 |
while ( $children->have_posts() ) : |
| 4 |
$children->the_post(); |
| 5 |
$current_topic_id = get_the_ID(); |
| 6 |
|
| 7 |
$replies = new WP_Query( |
| 8 |
[ |
| 9 |
'post_parent' => $current_topic_id, |
| 10 |
'post_type' => bbp_get_reply_post_type(), |
| 11 |
'post_status' => [ 'publish', 'draft', 'pending' ], |
| 12 |
] |
| 13 |
); |
| 14 |
|
| 15 |
$pending_replies = []; |
| 16 |
|
| 17 |
$no_reply = 0 == $replies->found_posts ? 'no-reply' : ''; |
| 18 |
$is_solved = isset($GLOBALS['bbp_solved_topic']) && $GLOBALS['bbp_solved_topic']->is_solved( $current_topic_id ) ? ' solved' : ' unsolved'; |
| 19 |
$is_open = bbp_is_topic_closed( $current_topic_id ) ? ' closed-topics' : ' open-topics'; |
| 20 |
$is_hidden = bbp_is_topic_spam( $current_topic_id ) ? ' hidden-topics' : ''; |
| 21 |
$approve_btn = ''; |
| 22 |
|
| 23 |
if ( bbp_is_topic_spam( $current_topic_id ) ) { |
| 24 |
$url = admin_url( 'admin.php' ) . '/Approve_Topic.php?bbpc_approve_topic_id=' . $current_topic_id; |
| 25 |
$approve_btn = sprintf( '<a class="bbpc-approve-btn" href=%1$s><span class="dashicons dashicons-yes" title="%2$s"></span></a>', $url, __( 'Approve this topic', 'bbp-core' ) ); |
| 26 |
} |
| 27 |
|
| 28 |
$filter_class = $no_reply . $is_solved . $is_open . $is_hidden; |
| 29 |
|
| 30 |
?> |
| 31 |
<li <?php post_class( 'easydocs-accordion-item accordion ez-section-acc-item mix ' . esc_attr( $filter_class ) ); ?> data-id="<?php echo esc_attr( $current_topic_id ); ?>"> |
| 32 |
<div class="accordion-title ez-section-title"> |
| 33 |
<?php |
| 34 |
$edit_link = 'javascript:void( 0 )'; |
| 35 |
$target = '_self'; |
| 36 |
if ( current_user_can( 'editor' ) || current_user_can( 'administrator' ) ) { |
| 37 |
$edit_link = get_edit_post_link( $current_topic_id ); |
| 38 |
$target = '_blank'; |
| 39 |
} |
| 40 |
?> |
| 41 |
<div class="left-content"> |
| 42 |
<h4> |
| 43 |
<a href="<?php echo esc_attr( $edit_link ); ?>" target="<?php echo esc_attr( $target ); ?>"> |
| 44 |
|
| 45 |
<?php the_title(); ?> |
| 46 |
</a> |
| 47 |
<?php |
| 48 |
$allowed_html = [ |
| 49 |
'a' => [ |
| 50 |
'href' => [], |
| 51 |
'class' => [], |
| 52 |
], |
| 53 |
'span' => [ |
| 54 |
'class' => [], |
| 55 |
'title' => [], |
| 56 |
], |
| 57 |
]; |
| 58 |
|
| 59 |
echo wp_kses( $approve_btn, $allowed_html ); |
| 60 |
|
| 61 |
while ( $replies->have_posts() ) : |
| 62 |
$replies->the_post(); |
| 63 |
$reply_id = get_the_ID(); |
| 64 |
|
| 65 |
if ( bbp_is_reply_pending( $reply_id ) ) { |
| 66 |
$pending_replies[] = $reply_id; |
| 67 |
} |
| 68 |
|
| 69 |
endwhile; |
| 70 |
wp_reset_postdata(); |
| 71 |
|
| 72 |
|
| 73 |
$pending_replies_count = count( $pending_replies ); |
| 74 |
$reply_count = $replies->found_posts - $pending_replies_count; |
| 75 |
?> |
| 76 |
<div title="<?php echo esc_attr( $reply_count ) . __( ' Published replies', 'bbp-core' ); ?>"> |
| 77 |
<span class="bbpc-reply-count bbpc-published-replies"> |
| 78 |
<?php echo esc_html( $reply_count ); ?> |
| 79 |
</span> |
| 80 |
</div> |
| 81 |
<?php if ( $pending_replies_count > 0 ) : ?> |
| 82 |
<div click-target='<?php echo esc_attr( $current_topic_id ); ?>' title="<?php echo esc_attr( $pending_replies_count ) . __( ' Pending replies', 'bbp-core' ); ?>"> |
| 83 |
<span class="bbpc-reply-count bbpc-pending-replies"> |
| 84 |
<?php echo esc_html( $pending_replies_count ); ?> |
| 85 |
</span> |
| 86 |
</div> |
| 87 |
<?php endif; ?> |
| 88 |
</h4> |
| 89 |
<ul class="actions"> |
| 90 |
<li> |
| 91 |
<a href="<?php echo get_permalink( $current_topic_id ); ?>" target="_blank" title="<?php esc_attr_e( 'View this reply in new tab', 'bbp() - core' ); ?>"> |
| 92 |
<span class="dashicons dashicons-external"></span> |
| 93 |
</a> |
| 94 |
</li> |
| 95 |
|
| 96 |
<?php if ( current_user_can( 'editor' ) || current_user_can( 'administrator' ) ) : ?> |
| 97 |
<li class="delete"> |
| 98 |
<a href="<?php echo admin_url( 'admin.php' ); ?>/menu/Delete_Topic.php?topic_ID=<?php the_ID(); ?>" class="section-delete" title="<?php esc_attr_e( 'Move this topic to the Trash', 'bbp-core' ); ?>"> |
| 99 |
<span class="dashicons dashicons-trash"></span> |
| 100 |
</a> |
| 101 |
</li> |
| 102 |
<?php endif; ?> |
| 103 |
</ul> |
| 104 |
</div> |
| 105 |
</div> |
| 106 |
<!-- Accordion children --> |
| 107 |
<div class="easydocs-accordion-body nesting-accordion"> |
| 108 |
<?php if ( ! empty( $pending_replies_count ) ) : ?> |
| 109 |
<ul class="bbpc-nested-replies" reply-target=<?php echo esc_attr( $current_topic_id ); ?>> |
| 110 |
<?php |
| 111 |
foreach ( $pending_replies as $p_reply ) { |
| 112 |
setup_postdata( $p_reply ); |
| 113 |
?> |
| 114 |
<li reply-id="<?php the_ID(); ?>" class="bbpc-reply-wrap"> |
| 115 |
<?php |
| 116 |
echo esc_html( wp_trim_words( get_the_content(), 10, '...' ) ); |
| 117 |
echo ' - '; |
| 118 |
the_author(); |
| 119 |
?> |
| 120 |
<?php |
| 121 |
if ( bbp_is_reply_pending( $p_reply ) ) { |
| 122 |
$url = admin_url( 'admin.php' ) . '/Approve_Topic.php?bbpc_approve_reply_id=' . $p_reply; |
| 123 |
$approve_btn = sprintf( '<a class="bbpc-approve-btn" href=%1$s><span class="dashicons dashicons-yes" title="%2$s"></span></a>', $url, __( 'Approve this topic', 'bbp-core' ) ); |
| 124 |
} |
| 125 |
|
| 126 |
$allowed_html = [ |
| 127 |
'a' => [ |
| 128 |
'href' => [], |
| 129 |
'class' => [], |
| 130 |
], |
| 131 |
'span' => [ |
| 132 |
'class' => [], |
| 133 |
'title' => [], |
| 134 |
], |
| 135 |
|
| 136 |
]; |
| 137 |
|
| 138 |
echo wp_kses( $approve_btn, $allowed_html ); |
| 139 |
?> |
| 140 |
</li> |
| 141 |
<?php |
| 142 |
} |
| 143 |
|
| 144 |
wp_reset_postdata(); |
| 145 |
?> |
| 146 |
</ul> |
| 147 |
<?php endif; ?> |
| 148 |
</div> |
| 149 |
<!-- ./Accordion children ends --> |
| 150 |
</li> |
| 151 |
<?php |
| 152 |
endwhile; |
| 153 |
wp_reset_postdata(); |
| 154 |
?> |
| 155 |
</ul> |
| 156 |
|