| 1 |
<?php |
| 2 |
if ( ! class_exists( 'bbPress' ) ) { |
| 3 |
return; |
| 4 |
} |
| 5 |
$parent_forums = []; |
| 6 |
$fcount = wp_count_posts( bbp_get_forum_post_type() ); |
| 7 |
$forum_count = (int) ( $fcount->publish + $fcount->hidden + $fcount->spam ); |
| 8 |
$bbpc_opt = get_option( 'bbp_core_settings' ); |
| 9 |
$filter_set = $bbpc_opt['filter_buttons'] ?? [ 'open', 'closed', 'hidden', 'no_reply', 'all', 'trash' ]; |
| 10 |
?> |
| 11 |
<div class="wrap"> |
| 12 |
<div class="body-dark"> |
| 13 |
<?php |
| 14 |
if ( $forum_count > 0 ) : |
| 15 |
include __DIR__ . '/admin_ui/header.php'; |
| 16 |
?> |
| 17 |
|
| 18 |
<main> |
| 19 |
<div class="easydocs-sidebar-menu"> |
| 20 |
<div class="tab-container"> |
| 21 |
<?php |
| 22 |
$forum_query = new WP_Query( |
| 23 |
[ |
| 24 |
'post_type' => bbp_get_forum_post_type(), |
| 25 |
'posts_per_page' => -1, |
| 26 |
'post_parent' => 0, |
| 27 |
'orderby' => 'menu_order', |
| 28 |
'order' => 'ASC', |
| 29 |
'post_status' => 'publish', |
| 30 |
] |
| 31 |
); |
| 32 |
|
| 33 |
$count = $forum_query->found_posts; |
| 34 |
|
| 35 |
// Left Sidebar Forums. |
| 36 |
include __DIR__ . '/admin_ui/forums.php'; |
| 37 |
?> |
| 38 |
|
| 39 |
<div class="easydocs-tab-content"> |
| 40 |
<?php |
| 41 |
$ids = 0; |
| 42 |
$container = 1; |
| 43 |
if ( is_array( $parent_forums ) ) : |
| 44 |
foreach ( $parent_forums as $item ) : |
| 45 |
$ids ++; |
| 46 |
$container ++; |
| 47 |
$active = $ids == 1 ? ' tab-active' : ''; |
| 48 |
|
| 49 |
$children = new WP_Query( |
| 50 |
[ |
| 51 |
'post_parent' => $item, |
| 52 |
'post_type' => bbp_get_topic_post_type(), |
| 53 |
'orderby' => 'menu_order', |
| 54 |
'order' => 'asc', |
| 55 |
'posts_per_page' => -1, |
| 56 |
'post_status' => [ 'any', 'spam' ], |
| 57 |
] |
| 58 |
); |
| 59 |
|
| 60 |
$count_open = 0; |
| 61 |
$count_closed = 0; |
| 62 |
$count_hidden = 0; |
| 63 |
$count_no_reply = 0; |
| 64 |
$count_solved = 0; |
| 65 |
$count_unsolved = 0; |
| 66 |
$count_trash = 0; |
| 67 |
|
| 68 |
while ( $children->have_posts() ) : |
| 69 |
$children->the_post(); |
| 70 |
$topic_id = get_the_ID(); |
| 71 |
|
| 72 |
$replies = get_children( |
| 73 |
[ |
| 74 |
'post_parent' => $topic_id, |
| 75 |
'post_type' => bbp_get_reply_post_type(), |
| 76 |
'post_status' => [ 'publish', 'draft', 'pending' ], |
| 77 |
] |
| 78 |
); |
| 79 |
|
| 80 |
// Count open/closed topics. |
| 81 |
if ( bbp_is_topic_closed( $topic_id ) ) { |
| 82 |
$count_closed++; |
| 83 |
} else { |
| 84 |
$count_open++; |
| 85 |
} |
| 86 |
|
| 87 |
// Count spam( hidden ) topics. |
| 88 |
if ( bbp_is_topic_spam( $topic_id ) ) { |
| 89 |
$count_hidden++; |
| 90 |
} |
| 91 |
|
| 92 |
// Replies count. |
| 93 |
if ( 0 == count( $replies ) ) { |
| 94 |
$count_no_reply++; |
| 95 |
} |
| 96 |
|
| 97 |
// Count solved. |
| 98 |
if ( $GLOBALS['bbp_solved_topic']->is_solved( $topic_id ) ) { |
| 99 |
$count_solved++; |
| 100 |
} else { |
| 101 |
$count_unsolved++; |
| 102 |
} |
| 103 |
|
| 104 |
|
| 105 |
endwhile; |
| 106 |
|
| 107 |
$trash_topic = new WP_Query( |
| 108 |
[ |
| 109 |
'post_parent' => $item, |
| 110 |
'post_type' => bbp_get_topic_post_type(), |
| 111 |
'posts_per_page' => -1, |
| 112 |
'post_status' => [ 'trash' ], |
| 113 |
] |
| 114 |
); |
| 115 |
|
| 116 |
while ( $trash_topic->have_posts() ) : |
| 117 |
$trash_topic->the_post(); |
| 118 |
$trash_topic_id = get_the_ID(); |
| 119 |
// Count trash. |
| 120 |
if ( bbp_is_topic_trash( $trash_topic_id ) ) { |
| 121 |
$count_trash++; |
| 122 |
} |
| 123 |
endwhile; wp_reset_postdata(); |
| 124 |
?> |
| 125 |
<div class="easydocs-tab <?php echo esc_attr( $active ); ?>" id="tab-<?php echo esc_attr( $item ); ?>"> |
| 126 |
|
| 127 |
<!-- Tab filters. --> |
| 128 |
<?php include __DIR__ . '/admin_ui/tab_filters.php'; ?> |
| 129 |
|
| 130 |
<!-- Children topics. --> |
| 131 |
<?php include __DIR__ . '/admin_ui/topics.php'; ?> |
| 132 |
|
| 133 |
<a class="easydocs-btn easydocs-btn-outline-blue easydocs-btn-sm easydocs-btn-round button button-info section-doc" id="bbpc-topic" target="_blank" name="submit" href="<?php echo admin_url( 'admin.php' ); ?>/Create_Topic.php?bbp_parentID=<?php echo $item; ?>&is_bbp_section="> |
| 134 |
<?php esc_html_e( 'Add Topic', 'bbp-core' ); ?> |
| 135 |
</a> |
| 136 |
</div> |
| 137 |
<?php |
| 138 |
endforeach; |
| 139 |
endif; |
| 140 |
?> |
| 141 |
</div> |
| 142 |
</div> |
| 143 |
</div> |
| 144 |
</main> |
| 145 |
<?php |
| 146 |
else : |
| 147 |
?> |
| 148 |
<div class="eazydocs-no-content"> |
| 149 |
<img src="<?php echo BBPC_IMG; ?>/icon/folder-open.png" alt="<?php esc_attr_e( 'Folder Open', 'bbp-core' ); ?>"> |
| 150 |
<p class="big-p"> <?php esc_html_e( 'No forum has been found . Perhaps', 'bbp-core' ); ?> </p> |
| 151 |
<p> <br> |
| 152 |
<a href="<?php echo admin_url( 'admin.php' ); ?>/Create_Forum.php?bbp_parent_title=" target="_blank" type="button" id="bbpc-forum" class="button button-primary ezd-btn btn-lg"> |
| 153 |
<?php esc_html_e( 'Create Forum', 'bbp-core' ); ?> |
| 154 |
</a> |
| 155 |
</p> |
| 156 |
</div> |
| 157 |
<?php |
| 158 |
endif; //TODO: Fix open topics not being selected issue. |
| 159 |
?> |
| 160 |
</div> |
| 161 |
</div> |
| 162 |
|
| 163 |
<script> |
| 164 |
(function ($) { |
| 165 |
$(document).ready(function () { |
| 166 |
let docContainer = document.querySelectorAll('.easydocs-tab'); |
| 167 |
|
| 168 |
var config = { |
| 169 |
controls: { |
| 170 |
scope: 'local', |
| 171 |
}, |
| 172 |
animation: { |
| 173 |
enable: false, |
| 174 |
}, |
| 175 |
load: { |
| 176 |
filter: '<?php echo esc_js( $bbpc_opt['default_filter'] ?? '.open-topics' ); ?>' |
| 177 |
} |
| 178 |
}; |
| 179 |
|
| 180 |
for (let i = 0; i < docContainer.length; i++) { |
| 181 |
var mixer1 = mixitup(docContainer[i], config); |
| 182 |
} |
| 183 |
}); |
| 184 |
})(jQuery); |
| 185 |
</script> |
| 186 |
|
| 187 |
|