Changeset 5731
- Timestamp:
- 05/12/2015 10:15:51 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/forums/functions.php
r5684 r5731 1193 1193 $children = bbp_forum_query_subforum_ids( $forum_id ); 1194 1194 if ( !empty( $children ) ) { 1195 foreach ( (array)$children as $child ) {1195 foreach ( $children as $child ) { 1196 1196 $children_last_topic = bbp_update_forum_last_topic_id( $child ); // Recursive 1197 1197 } … … 1263 1263 $children = bbp_forum_query_subforum_ids( $forum_id ); 1264 1264 if ( !empty( $children ) ) { 1265 foreach ( (array)$children as $child ) {1265 foreach ( $children as $child ) { 1266 1266 $children_last_reply = bbp_update_forum_last_reply_id( $child ); // Recursive 1267 1267 } … … 1329 1329 $children = bbp_forum_query_subforum_ids( $forum_id ); 1330 1330 if ( !empty( $children ) ) { 1331 foreach ( (array)$children as $child ) {1331 foreach ( $children as $child ) { 1332 1332 $children_last_active = bbp_update_forum_last_active_id( $child, $active_id ); 1333 1333 } … … 1357 1357 // Update only if published 1358 1358 if ( bbp_get_public_status_id() === get_post_status( $active_id ) ) { 1359 update_post_meta( $forum_id, '_bbp_last_active_id', (int)$active_id );1360 } 1361 1362 return (int) apply_filters( 'bbp_update_forum_last_active_id', (int)$active_id, $forum_id );1359 update_post_meta( $forum_id, '_bbp_last_active_id', $active_id ); 1360 } 1361 1362 return (int) apply_filters( 'bbp_update_forum_last_active_id', $active_id, $forum_id ); 1363 1363 } 1364 1364 … … 1410 1410 } 1411 1411 1412 update_post_meta( $forum_id, '_bbp_forum_subforum_count', (int) $subforums ); 1413 1414 return (int) apply_filters( 'bbp_update_forum_subforum_count', (int) $subforums, $forum_id ); 1412 $subforums = (int) $subforums; 1413 1414 update_post_meta( $forum_id, '_bbp_forum_subforum_count', $subforums ); 1415 1416 return (int) apply_filters( 'bbp_update_forum_subforum_count', $subforums, $forum_id ); 1415 1417 } 1416 1418 … … 1441 1443 $children = bbp_forum_query_subforum_ids( $forum_id ); 1442 1444 if ( !empty( $children ) ) { 1443 foreach ( (array)$children as $child ) {1445 foreach ( $children as $child ) { 1444 1446 $children_topic_count += bbp_update_forum_topic_count( $child ); // Recursive 1445 1447 } … … 1450 1452 1451 1453 // Calculate total topics in this forum 1452 $total_topics = $topics + $children_topic_count;1454 $total_topics = (int) ( $topics + $children_topic_count ); 1453 1455 1454 1456 // Update the count 1455 update_post_meta( $forum_id, '_bbp_topic_count', (int)$topics );1456 update_post_meta( $forum_id, '_bbp_total_topic_count', (int)$total_topics );1457 1458 return (int) apply_filters( 'bbp_update_forum_topic_count', (int)$total_topics, $forum_id );1457 update_post_meta( $forum_id, '_bbp_topic_count', $topics ); 1458 update_post_meta( $forum_id, '_bbp_total_topic_count', $total_topics ); 1459 1460 return (int) apply_filters( 'bbp_update_forum_topic_count', $total_topics, $forum_id ); 1459 1461 } 1460 1462 … … 1503 1505 } 1504 1506 1507 $topic_count = (int) $topic_count; 1508 1505 1509 // Update the count 1506 update_post_meta( $forum_id, '_bbp_topic_count_hidden', (int)$topic_count );1507 } 1508 1509 return (int) apply_filters( 'bbp_update_forum_topic_count_hidden', (int)$topic_count, $forum_id );1510 update_post_meta( $forum_id, '_bbp_topic_count_hidden', $topic_count ); 1511 } 1512 1513 return (int) apply_filters( 'bbp_update_forum_topic_count_hidden', $topic_count, $forum_id ); 1510 1514 } 1511 1515 … … 1546 1550 1547 1551 // Don't count replies if the forum is a category 1548 $topic_ids = bbp_forum_query_topic_ids( $forum_id ); 1549 if ( !empty( $topic_ids ) ) { 1552 $reply_count = 0; 1553 $topic_ids = bbp_forum_query_topic_ids( $forum_id ); 1554 if ( ! empty( $topic_ids ) ) { 1550 1555 $topic_ids = implode( ',', wp_parse_id_list( $topic_ids ) ); 1551 1556 $reply_count = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent IN ( {$topic_ids} ) AND post_status = '%s' AND post_type = '%s';", bbp_get_public_status_id(), bbp_get_reply_post_type() ) ); 1552 } else {1553 $reply_count = 0;1554 1557 } 1555 1558 1556 1559 // Calculate total replies in this forum 1557 $total_replies = (int) $reply_count + $children_reply_count;1560 $total_replies = (int) ( $reply_count + $children_reply_count ); 1558 1561 1559 1562 // Update the count 1560 update_post_meta( $forum_id, '_bbp_reply_count', (int)$reply_count );1561 update_post_meta( $forum_id, '_bbp_total_reply_count', (int)$total_replies );1562 1563 return (int) apply_filters( 'bbp_update_forum_reply_count', (int)$total_replies, $forum_id );1563 update_post_meta( $forum_id, '_bbp_reply_count', $reply_count ); 1564 update_post_meta( $forum_id, '_bbp_total_reply_count', $total_replies ); 1565 1566 return (int) apply_filters( 'bbp_update_forum_reply_count', $total_replies, $forum_id ); 1564 1567 } 1565 1568
Note: See TracChangeset
for help on using the changeset viewer.