Ticket #1799: 1799.5.patch
File 1799.5.patch, 13.0 KB (added by , 10 years ago) |
---|
-
src/includes/core/actions.php
diff --git src/includes/core/actions.php src/includes/core/actions.php index f3395d5..4ce609d 100644
add_action( 'bbp_unspammed_reply', 'bbp_update_reply_walker' ); 254 254 add_action( 'bbp_approved_reply', 'bbp_update_reply_walker' ); 255 255 add_action( 'bbp_unapproved_reply', 'bbp_update_reply_walker' ); 256 256 257 // Update forum topic/reply counts 258 add_action( 'bbp_new_reply', 'bbp_increase_forum_reply_count' ); 259 add_action( 'bbp_new_topic', 'bbp_increase_forum_topic_count' ); 260 add_action( 'bbp_trashed_reply', 'bbp_decrease_forum_reply_count' ); 261 add_action( 'bbp_trashed_topic', 'bbp_decrease_forum_topic_count' ); 262 add_action( 'bbp_trashed_topic', 'bbp_increase_forum_topic_count_hidden' ); 263 add_action( 'bbp_untrashed_reply', 'bbp_increase_forum_reply_count' ); 264 add_action( 'bbp_untrashed_topic', 'bbp_increase_forum_topic_count' ); 265 add_action( 'bbp_untrashed_topic', 'bbp_decrease_forum_topic_count_hidden' ); 266 add_action( 'bbp_spammed_reply', 'bbp_decrease_forum_reply_count' ); 267 add_action( 'bbp_spammed_topic', 'bbp_decrease_forum_topic_count' ); 268 add_action( 'bbp_spammed_topic', 'bbp_increase_forum_topic_count_hidden' ); 269 add_action( 'bbp_unspammed_reply', 'bbp_increase_forum_reply_count' ); 270 add_action( 'bbp_unspammed_topic', 'bbp_increase_forum_topic_count' ); 271 add_action( 'bbp_unspammed_topic', 'bbp_decrease_forum_topic_count_hidden' ); 272 add_action( 'bbp_approved_reply', 'bbp_increase_forum_reply_count' ); 273 add_action( 'bbp_approved_topic', 'bbp_increase_forum_topic_count' ); 274 add_action( 'bbp_approved_topic', 'bbp_decrease_forum_topic_count_hidden' ); 275 add_action( 'bbp_unapproved_reply', 'bbp_decrease_forum_reply_count' ); 276 add_action( 'bbp_unapproved_topic', 'bbp_decrease_forum_topic_count' ); 277 add_action( 'bbp_unapproved_topic', 'bbp_increase_forum_topic_count_hidden' ); 278 279 // Update topic reply counts 280 add_action( 'bbp_new_reply', 'bbp_increase_topic_reply_count' ); 281 add_action( 'bbp_trashed_reply', 'bbp_decrease_topic_reply_count' ); 282 add_action( 'bbp_trashed_reply', 'bbp_increase_topic_reply_count_hidden' ); 283 add_action( 'bbp_untrashed_reply', 'bbp_increase_topic_reply_count' ); 284 add_action( 'bbp_untrashed_reply', 'bbp_decrease_topic_reply_count_hidden' ); 285 add_action( 'bbp_spammed_reply', 'bbp_decrease_topic_reply_count' ); 286 add_action( 'bbp_spammed_reply', 'bbp_increase_topic_reply_count_hidden' ); 287 add_action( 'bbp_unspammed_reply', 'bbp_increase_topic_reply_count' ); 288 add_action( 'bbp_unspammed_reply', 'bbp_decrease_topic_reply_count_hidden' ); 289 add_action( 'bbp_approved_reply', 'bbp_increase_topic_reply_count' ); 290 add_action( 'bbp_approved_reply', 'bbp_decrease_forum_reply_count_hidden' ); 291 add_action( 'bbp_unapproved_reply', 'bbp_decrease_forum_reply_count' ); 292 add_action( 'bbp_unapproved_reply', 'bbp_increase_topic_reply_count_hidden' ); 293 257 294 // Users topic & reply counts 258 295 add_action( 'bbp_new_topic', 'bbp_increase_user_topic_count' ); 259 296 add_action( 'bbp_new_reply', 'bbp_increase_user_reply_count' ); -
src/includes/forums/functions.php
diff --git src/includes/forums/functions.php src/includes/forums/functions.php index c6ae18b..4d6a949 100644
function bbp_bump_forum_topic_count( $forum_id = 0, $difference = 1, $update_anc 1089 1089 } 1090 1090 1091 1091 /** 1092 * Increase the total topic count of a forum by one 1093 * 1094 * @since bbPress () 1095 * 1096 * @param int $forum_id Optional. Forum id. 1097 * @uses bbp_get_forum_id() To get the forum id 1098 * @uses bbp_bump_forum_topic_count() To bump forum topic count 1099 */ 1100 function bbp_increase_forum_topic_count( $forum_id = 0 ) { 1101 if ( empty( $forum_id ) ) { 1102 return; 1103 } 1104 1105 if ( bbp_is_topic( $forum_id ) ) { 1106 $topic_id = $forum_id; 1107 $forum_id = bbp_get_topic_forum_id( $topic_id ); 1108 1109 // If this is a new, unpublished, topic, increase hidden count and bail 1110 if ( 'bbp_new_topic' === current_action() && ( ! bbp_is_topic_published( $topic_id ) && ! bbp_is_topic_closed( $topic_id ) ) ) { 1111 bbp_increase_forum_topic_count_hidden( $forum_id ); 1112 return; 1113 } 1114 } 1115 1116 bbp_bump_forum_topic_count( $forum_id ); 1117 } 1118 1119 /** 1120 * Decrease the total topic count of a forum by one 1121 * 1122 * @since bbPress () 1123 * 1124 * @param int $forum_id Optional. Forum id. 1125 * @uses bbp_get_forum_id() To get the forum id 1126 * @uses bbp_bump_forum_topic_count() To bump forum topic count 1127 */ 1128 function bbp_decrease_forum_topic_count( $forum_id = 0 ) { 1129 if ( empty( $forum_id ) ) { 1130 return; 1131 } 1132 1133 if ( bbp_is_topic( $forum_id ) ) { 1134 $forum_id = bbp_get_topic_forum_id( $forum_id ); 1135 } 1136 1137 bbp_bump_forum_topic_count( $forum_id, -1 ); 1138 } 1139 1140 /** 1092 1141 * Bump the total hidden topic count of a forum 1093 1142 * 1094 1143 * @since bbPress (r3825) … … function bbp_bump_forum_topic_count_hidden( $forum_id = 0, $difference = 1 ) { 1116 1165 } 1117 1166 1118 1167 /** 1168 * Increase the total hidden topic count of a forum by one 1169 * 1170 * @since bbPress () 1171 * 1172 * @param int $forum_id Optional. Forum id. 1173 * @uses bbp_get_forum_id() To get the forum id 1174 * @uses bbp_bump_forum_topic_count_hidden() To bump forum hidden topic count 1175 */ 1176 function bbp_increase_forum_topic_count_hidden( $forum_id = 0 ) { 1177 if ( empty( $forum_id ) ) { 1178 return; 1179 } 1180 1181 if ( bbp_is_topic( $forum_id ) ) { 1182 $forum_id = bbp_get_topic_forum_id( $forum_id ); 1183 } 1184 1185 bbp_bump_forum_topic_count_hidden( $forum_id ); 1186 } 1187 1188 /** 1189 * Decrease the total hidden topic count of a forum by one 1190 * 1191 * @since bbPress () 1192 * 1193 * @param int $forum_id Optional. Forum id. 1194 * @uses bbp_get_forum_id() To get the forum id 1195 * @uses bbp_bump_forum_topic_count_hidden() To bump forum hidden topic count 1196 */ 1197 function bbp_decrease_forum_topic_count_hidden( $forum_id = 0 ) { 1198 if ( empty( $forum_id ) ) { 1199 return; 1200 } 1201 1202 if ( bbp_is_topic( $forum_id ) ) { 1203 $forum_id = bbp_get_topic_forum_id( $forum_id ); 1204 } 1205 1206 bbp_bump_forum_topic_count_hidden( $forum_id, -1 ); 1207 } 1208 1209 /** 1119 1210 * Bump the total topic count of a forum 1120 1211 * 1121 1212 * @since bbPress (r3825) … … function bbp_bump_forum_reply_count( $forum_id = 0, $difference = 1, $update_anc 1165 1256 return (int) apply_filters( 'bbp_bump_forum_reply_count', (int) $total_reply_count + (int) $difference, $forum_id, (int) $difference, (bool) $update_ancestors ); 1166 1257 } 1167 1258 1259 /** 1260 * Increase the total reply count of a forum by one 1261 * 1262 * @since bbPress () 1263 * 1264 * @param int $forum_id Optional. Forum id. 1265 * @uses bbp_get_forum_id() To get the forum id 1266 * @uses bbp_bump_forum_reply_count() To bump forum topic count 1267 */ 1268 function bbp_increase_forum_reply_count( $forum_id = 0 ) { 1269 if ( empty( $forum_id ) ) { 1270 return; 1271 } 1272 1273 if ( bbp_is_reply( $forum_id ) ) { 1274 $reply_id = $forum_id; 1275 $forum_id = bbp_get_reply_forum_id( $reply_id ); 1276 1277 // Don't update if this is a new, unpublished, reply 1278 if ( 'bbp_new_reply' === current_action() && ! bbp_is_reply_published( $reply_id ) ) { 1279 return; 1280 } 1281 } 1282 1283 bbp_bump_forum_reply_count( $forum_id, 1 ); 1284 } 1285 1286 /** 1287 * Decrease the total reply count of a forum by one 1288 * 1289 * @since bbPress () 1290 * 1291 * @param int $forum_id Optional. Forum id. 1292 * @uses bbp_get_forum_id() To get the forum id 1293 * @uses bbp_bump_forum_reply_count() To bump forum topic count 1294 */ 1295 function bbp_decrease_forum_reply_count( $forum_id = 0 ) { 1296 if ( empty( $forum_id ) ) { 1297 return; 1298 } 1299 1300 if ( bbp_is_reply( $forum_id ) ) { 1301 $forum_id = bbp_get_reply_forum_id( $forum_id ); 1302 } 1303 1304 bbp_bump_forum_reply_count( $forum_id, -1 ); 1305 } 1306 1168 1307 /** Forum Updaters ************************************************************/ 1169 1308 1170 1309 /** … … function bbp_update_forum( $args = '' ) { 1622 1761 } 1623 1762 1624 1763 // Counts 1625 bbp_update_forum_subforum_count ( $r['forum_id'] ); 1626 bbp_update_forum_reply_count ( $r['forum_id'] ); 1627 bbp_update_forum_topic_count ( $r['forum_id'] ); 1628 bbp_update_forum_topic_count_hidden( $r['forum_id'] ); 1764 bbp_update_forum_subforum_count( $r['forum_id'] ); 1765 1766 // Only update topic count if we're deleting a topic, or in the dashboard 1767 if ( in_array( current_action(), array( 'bbp_deleted_topic', 'save_post' ) ) ) { 1768 bbp_update_forum_reply_count( $r['forum_id'] ); 1769 bbp_update_forum_topic_count( $r['forum_id'] ); 1770 bbp_update_forum_topic_count_hidden( $r['forum_id'] ); 1771 } 1629 1772 1630 1773 // Update the parent forum if one was passed 1631 1774 if ( !empty( $r['post_parent'] ) && is_numeric( $r['post_parent'] ) ) { -
src/includes/replies/functions.php
diff --git src/includes/replies/functions.php src/includes/replies/functions.php index a4698d0..98c51f0 100644
function bbp_update_reply_walker( $reply_id, $last_active_time = '', $forum_id = 984 984 } 985 985 986 986 // Counts 987 bbp_update_topic_voice_count ( $ancestor ); 988 bbp_update_topic_reply_count ( $ancestor ); 989 bbp_update_topic_reply_count_hidden( $ancestor ); 987 bbp_update_topic_voice_count( $ancestor ); 988 989 // Only update reply count if we're deleting a reply, or in the dashboard 990 if ( in_array( current_action(), array( 'bbp_deleted_reply', 'save_post' ) ) ) { 991 bbp_update_topic_reply_count( $ancestor ); 992 bbp_update_topic_reply_count_hidden( $ancestor ); 993 } 990 994 991 995 // Forum meta relating to most recent topic 992 996 } elseif ( bbp_is_forum( $ancestor ) ) { … … function bbp_update_reply_walker( $reply_id, $last_active_time = '', $forum_id = 1010 1014 } 1011 1015 1012 1016 // Counts 1013 bbp_update_forum_reply_count( $ancestor ); 1017 // Only update reply count if we're deleting a reply, or in the dashboard 1018 if ( in_array( current_action(), array( 'bbp_deleted_reply', 'save_post' ) ) ) { 1019 bbp_update_forum_reply_count( $ancestor ); 1020 } 1014 1021 } 1015 1022 } 1016 1023 } -
src/includes/topics/functions.php
diff --git src/includes/topics/functions.php src/includes/topics/functions.php index c23e4b3..ee3f9aa 100644
function bbp_bump_topic_reply_count( $topic_id = 0, $difference = 1 ) { 2347 2347 } 2348 2348 2349 2349 /** 2350 * Increase the total reply count of a topic by one 2351 * 2352 * @since bbPress () 2353 * 2354 * @param int $topic_id Optional. Forum id. 2355 * @uses bbp_is_reply() To check if the passed topic id is a reply 2356 * @uses bbp_get_reply_topic_id() To get the topic id 2357 * @uses bbp_bump_topic_reply_count() To bump topic reply count 2358 */ 2359 function bbp_increase_topic_reply_count( $topic_id = 0 ) { 2360 if ( empty( $topic_id ) ) { 2361 return; 2362 } 2363 2364 if ( bbp_is_reply( $topic_id ) ) { 2365 $reply_id = $topic_id; 2366 $topic_id = bbp_get_reply_topic_id( $reply_id ); 2367 2368 // If this is a new, unpublished, reply, update hidden count and bail 2369 if ( 'bbp_new_reply' === current_action() && ! bbp_is_reply_published( $reply_id ) ) { 2370 bbp_increase_topic_reply_count_hidden( $topic_id ); 2371 return; 2372 } 2373 } 2374 2375 bbp_bump_topic_reply_count( $topic_id ); 2376 } 2377 2378 /** 2379 * Decrease the total reply count of a topic by one 2380 * 2381 * @since bbPress () 2382 * 2383 * @param int $topic_id Optional. Topic id. 2384 * @uses bbp_is_reply() To check if the passed topic id is a reply 2385 * @uses bbp_get_reply_topic_id() To get the topic id 2386 * @uses bbp_bump_topic_reply_count() To bump topic reply count 2387 */ 2388 function bbp_decrease_topic_reply_count( $topic_id = 0 ) { 2389 if ( empty( $topic_id ) ) { 2390 return; 2391 } 2392 2393 if ( bbp_is_reply( $topic_id ) ) { 2394 $topic_id = bbp_get_reply_topic_id( $topic_id ); 2395 } 2396 2397 bbp_bump_topic_reply_count( $topic_id, -1 ); 2398 } 2399 2400 /** 2350 2401 * Bump the total hidden reply count of a topic 2351 2402 * 2352 2403 * @since bbPress (r3825) … … function bbp_bump_topic_reply_count_hidden( $topic_id = 0, $difference = 1 ) { 2373 2424 return (int) apply_filters( 'bbp_bump_topic_reply_count_hidden', (int) $new_count, $topic_id, (int) $difference ); 2374 2425 } 2375 2426 2427 /** 2428 * Increase the total hidden reply count of a topic by one 2429 * 2430 * @since bbPress () 2431 * 2432 * @param int $topic_id Optional. Topic id. 2433 * @uses bbp_is_reply() To check if the passed topic id is a reply 2434 * @uses bbp_get_reply_topic_id() To get the topic id 2435 * @uses bbp_bump_topic_reply_count_hidden() To bump topic hidden reply count 2436 */ 2437 function bbp_increase_topic_reply_count_hidden( $topic_id = 0 ) { 2438 if ( empty( $topic_id ) ) { 2439 return; 2440 } 2441 2442 if ( bbp_is_reply( $topic_id ) ) { 2443 $topic_id = bbp_get_reply_topic_id( $topic_id ); 2444 } 2445 2446 bbp_bump_topic_reply_count_hidden( $topic_id ); 2447 } 2448 2449 /** 2450 * Decrease the total hidden reply count of a topic by one 2451 * 2452 * @since bbPress () 2453 * 2454 * @param int $topic_id Optional. Topic id. 2455 * @uses bbp_is_reply() To check if the passed topic id is a reply 2456 * @uses bbp_get_reply_topic_id() To get the topic id 2457 * @uses bbp_bump_topic_reply_count_hidden() To bump topic hidden reply count 2458 */ 2459 function bbp_decrease_topic_reply_count_hidden( $topic_id = 0 ) { 2460 if ( empty( $topic_id ) ) { 2461 return; 2462 } 2463 2464 if ( bbp_is_reply( $topic_id ) ) { 2465 $topic_id = bbp_get_reply_topic_id( $topic_id ); 2466 } 2467 2468 bbp_bump_topic_reply_count_hidden( $topic_id, -1 ); 2469 } 2470 2376 2471 /** Topic Updaters ************************************************************/ 2377 2472 2378 2473 /**