diff --git src/includes/forums/functions.php src/includes/forums/functions.php
index 56ec78c..f9ce602 100644
|
|
function bbp_bump_forum_reply_count( $forum_id = 0, $difference = 1, $update_anc |
1205 | 1205 | * @uses update_post_meta() To update the forum's last active id meta |
1206 | 1206 | * @uses apply_filters() Calls 'bbp_update_forum_last_topic_id' with the last |
1207 | 1207 | * reply id and forum id |
1208 | | * @return bool True on success, false on failure |
| 1208 | * @return int Id of the forum's most recent topic |
1209 | 1209 | */ |
1210 | 1210 | function bbp_update_forum_last_topic_id( $forum_id = 0, $topic_id = 0 ) { |
1211 | 1211 | $forum_id = bbp_get_forum_id( $forum_id ); |
… |
… |
function bbp_update_forum_last_topic_id( $forum_id = 0, $topic_id = 0 ) { |
1218 | 1218 | |
1219 | 1219 | // Loop through children and add together forum reply counts |
1220 | 1220 | $children = bbp_forum_query_subforum_ids( $forum_id ); |
1221 | | if ( !empty( $children ) ) { |
| 1221 | if ( ! empty( $children ) ) { |
1222 | 1222 | foreach ( $children as $child ) { |
1223 | 1223 | $children_last_topic = bbp_update_forum_last_topic_id( $child ); // Recursive |
1224 | 1224 | } |
… |
… |
function bbp_update_forum_last_topic_id( $forum_id = 0, $topic_id = 0 ) { |
1236 | 1236 | |
1237 | 1237 | // Get the most recent topic in this forum_id |
1238 | 1238 | $recent_topic = get_posts( $post_vars ); |
1239 | | if ( !empty( $recent_topic ) ) { |
| 1239 | if ( ! empty( $recent_topic ) ) { |
1240 | 1240 | $topic_id = $recent_topic[0]->ID; |
1241 | 1241 | } |
1242 | 1242 | } |
… |
… |
function bbp_update_forum_last_topic_id( $forum_id = 0, $topic_id = 0 ) { |
1246 | 1246 | $children_last_topic = (int) $children_last_topic; |
1247 | 1247 | |
1248 | 1248 | // If child forums have higher id, use that instead |
1249 | | if ( !empty( $children ) && ( $children_last_topic > $topic_id ) ) { |
| 1249 | if ( ! empty( $children ) && ( $children_last_topic > $topic_id ) ) { |
1250 | 1250 | $topic_id = $children_last_topic; |
1251 | 1251 | } |
1252 | 1252 | |
… |
… |
function bbp_update_forum_last_topic_id( $forum_id = 0, $topic_id = 0 ) { |
1275 | 1275 | * @uses update_post_meta() To update the forum's last active id meta |
1276 | 1276 | * @uses apply_filters() Calls 'bbp_update_forum_last_reply_id' with the last |
1277 | 1277 | * reply id and forum id |
1278 | | * @return bool True on success, false on failure |
| 1278 | * @return int Id of the forum's most recent reply |
1279 | 1279 | */ |
1280 | 1280 | function bbp_update_forum_last_reply_id( $forum_id = 0, $reply_id = 0 ) { |
1281 | 1281 | $forum_id = bbp_get_forum_id( $forum_id ); |
… |
… |
function bbp_update_forum_last_reply_id( $forum_id = 0, $reply_id = 0 ) { |
1288 | 1288 | |
1289 | 1289 | // Loop through children and get the most recent reply id |
1290 | 1290 | $children = bbp_forum_query_subforum_ids( $forum_id ); |
1291 | | if ( !empty( $children ) ) { |
| 1291 | if ( ! empty( $children ) ) { |
1292 | 1292 | foreach ( $children as $child ) { |
1293 | 1293 | $children_last_reply = bbp_update_forum_last_reply_id( $child ); // Recursive |
1294 | 1294 | } |
… |
… |
function bbp_update_forum_last_reply_id( $forum_id = 0, $reply_id = 0 ) { |
1296 | 1296 | |
1297 | 1297 | // If this forum has topics... |
1298 | 1298 | $topic_ids = bbp_forum_query_topic_ids( $forum_id ); |
1299 | | if ( !empty( $topic_ids ) ) { |
| 1299 | if ( ! empty( $topic_ids ) ) { |
1300 | 1300 | |
1301 | 1301 | // ...get the most recent reply from those topics... |
1302 | 1302 | $reply_id = bbp_forum_query_last_reply_id( $forum_id, $topic_ids ); |
… |
… |
function bbp_update_forum_last_reply_id( $forum_id = 0, $reply_id = 0 ) { |
1311 | 1311 | $children_last_reply = (int) $children_last_reply; |
1312 | 1312 | |
1313 | 1313 | // If child forums have higher ID, check for newer reply id |
1314 | | if ( !empty( $children ) && ( $children_last_reply > $reply_id ) ) { |
| 1314 | if ( ! empty( $children ) && ( $children_last_reply > $reply_id ) ) { |
1315 | 1315 | $reply_id = $children_last_reply; |
1316 | 1316 | } |
1317 | 1317 | |
… |
… |
function bbp_update_forum_last_reply_id( $forum_id = 0, $reply_id = 0 ) { |
1340 | 1340 | * @uses update_post_meta() To update the forum's last active id meta |
1341 | 1341 | * @uses apply_filters() Calls 'bbp_update_forum_last_active_id' with the last |
1342 | 1342 | * active post id and forum id |
1343 | | * @return bool True on success, false on failure |
| 1343 | * @return int Id of the forum's last active post |
1344 | 1344 | */ |
1345 | 1345 | function bbp_update_forum_last_active_id( $forum_id = 0, $active_id = 0 ) { |
1346 | 1346 | |
… |
… |
function bbp_update_forum_last_active_id( $forum_id = 0, $active_id = 0 ) { |
1354 | 1354 | |
1355 | 1355 | // Loop through children and add together forum reply counts |
1356 | 1356 | $children = bbp_forum_query_subforum_ids( $forum_id ); |
1357 | | if ( !empty( $children ) ) { |
| 1357 | if ( ! empty( $children ) ) { |
1358 | 1358 | foreach ( $children as $child ) { |
1359 | 1359 | $children_last_active = bbp_update_forum_last_active_id( $child, $active_id ); |
1360 | 1360 | } |
… |
… |
function bbp_update_forum_last_active_id( $forum_id = 0, $active_id = 0 ) { |
1362 | 1362 | |
1363 | 1363 | // Don't count replies if the forum is a category |
1364 | 1364 | $topic_ids = bbp_forum_query_topic_ids( $forum_id ); |
1365 | | if ( !empty( $topic_ids ) ) { |
| 1365 | if ( ! empty( $topic_ids ) ) { |
1366 | 1366 | $active_id = bbp_forum_query_last_reply_id( $forum_id, $topic_ids ); |
1367 | 1367 | $active_id = $active_id > max( $topic_ids ) ? $active_id : max( $topic_ids ); |
1368 | 1368 | |
… |
… |
function bbp_update_forum_last_active_id( $forum_id = 0, $active_id = 0 ) { |
1377 | 1377 | $children_last_active = (int) $children_last_active; |
1378 | 1378 | |
1379 | 1379 | // If child forums have higher id, use that instead |
1380 | | if ( !empty( $children ) && ( $children_last_active > $active_id ) ) { |
| 1380 | if ( ! empty( $children ) && ( $children_last_active > $active_id ) ) { |
1381 | 1381 | $active_id = $children_last_active; |
1382 | 1382 | } |
1383 | 1383 | |
… |
… |
function bbp_update_forum_last_active_id( $forum_id = 0, $active_id = 0 ) { |
1402 | 1402 | * @uses update_post_meta() To update the forum last active time |
1403 | 1403 | * @uses apply_filters() Calls 'bbp_update_forum_last_active' with the new time |
1404 | 1404 | * and forum id |
1405 | | * @return bool True on success, false on failure |
| 1405 | * @return string MySQL timestamp of last active topic/reply |
1406 | 1406 | */ |
1407 | 1407 | function bbp_update_forum_last_active_time( $forum_id = 0, $new_time = '' ) { |
1408 | 1408 | $forum_id = bbp_get_forum_id( $forum_id ); |
… |
… |
function bbp_update_forum_last_active_time( $forum_id = 0, $new_time = '' ) { |
1413 | 1413 | } |
1414 | 1414 | |
1415 | 1415 | // Update only if there is a time |
1416 | | if ( !empty( $new_time ) ) { |
| 1416 | if ( ! empty( $new_time ) ) { |
1417 | 1417 | update_post_meta( $forum_id, '_bbp_last_active_time', $new_time ); |
1418 | 1418 | } |
1419 | 1419 | |
1420 | | return (int) apply_filters( 'bbp_update_forum_last_active', $new_time, $forum_id ); |
| 1420 | return apply_filters( 'bbp_update_forum_last_active', $new_time, $forum_id ); |
1421 | 1421 | } |
1422 | 1422 | |
1423 | 1423 | /** |