Ticket #1799: 1799.4.patch
File 1799.4.patch, 12.2 KB (added by , 11 years ago) |
---|
-
src/includes/core/actions.php
diff --git src/includes/core/actions.php src/includes/core/actions.php index f038bfc..adb8f0f 100644
add_action( 'bbp_deleted_reply', 'bbp_update_reply_walker' ); 250 250 add_action( 'bbp_spammed_reply', 'bbp_update_reply_walker' ); 251 251 add_action( 'bbp_unspammed_reply', 'bbp_update_reply_walker' ); 252 252 253 // Update forum topic/reply counts 254 add_action( 'bbp_new_reply', 'bbp_increase_forum_reply_count' ); 255 add_action( 'bbp_new_topic', 'bbp_increase_forum_topic_count' ); 256 add_action( 'bbp_trashed_reply', 'bbp_decrease_forum_reply_count' ); 257 add_action( 'bbp_trashed_topic', 'bbp_decrease_forum_topic_count' ); 258 add_action( 'bbp_trashed_topic', 'bbp_increase_forum_topic_count_hidden' ); 259 add_action( 'bbp_untrashed_reply', 'bbp_increase_forum_reply_count' ); 260 add_action( 'bbp_untrashed_topic', 'bbp_increase_forum_topic_count' ); 261 add_action( 'bbp_untrashed_topic', 'bbp_decrease_forum_topic_count_hidden' ); 262 add_action( 'bbp_spammed_reply', 'bbp_decrease_forum_reply_count' ); 263 add_action( 'bbp_spammed_topic', 'bbp_decrease_forum_topic_count' ); 264 add_action( 'bbp_spammed_topic', 'bbp_increase_forum_topic_count_hidden' ); 265 add_action( 'bbp_unspammed_reply', 'bbp_increase_forum_reply_count' ); 266 add_action( 'bbp_unspammed_topic', 'bbp_increase_forum_topic_count' ); 267 add_action( 'bbp_unspammed_topic', 'bbp_decrease_forum_topic_count_hidden' ); 268 269 // Update topic reply counts 270 add_action( 'bbp_new_reply', 'bbp_increase_topic_reply_count' ); 271 add_action( 'bbp_trashed_reply', 'bbp_decrease_topic_reply_count' ); 272 add_action( 'bbp_trashed_reply', 'bbp_increase_topic_reply_count_hidden' ); 273 add_action( 'bbp_untrashed_reply', 'bbp_increase_topic_reply_count' ); 274 add_action( 'bbp_untrashed_reply', 'bbp_decrease_topic_reply_count_hidden' ); 275 add_action( 'bbp_spammed_reply', 'bbp_decrease_topic_reply_count' ); 276 add_action( 'bbp_spammed_reply', 'bbp_increase_topic_reply_count_hidden' ); 277 add_action( 'bbp_unspammed_reply', 'bbp_increase_topic_reply_count' ); 278 add_action( 'bbp_unspammed_reply', 'bbp_decrease_topic_reply_count_hidden' ); 279 253 280 // Users topic & reply counts 254 281 add_action( 'bbp_new_topic', 'bbp_increase_user_topic_count' ); 255 282 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 cf77b19..f3112b1 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 ) { 1115 1164 } 1116 1165 1117 1166 /** 1167 * Increase the total hidden topic count of a forum by one 1168 * 1169 * @since bbPress () 1170 * 1171 * @param int $forum_id Optional. Forum id. 1172 * @uses bbp_get_forum_id() To get the forum id 1173 * @uses bbp_bump_forum_topic_count_hidden() To bump forum hidden topic count 1174 */ 1175 function bbp_increase_forum_topic_count_hidden( $forum_id = 0 ) { 1176 if ( empty( $forum_id ) ) { 1177 return; 1178 } 1179 1180 if ( bbp_is_topic( $forum_id ) ) { 1181 $forum_id = bbp_get_topic_forum_id( $forum_id ); 1182 } 1183 1184 bbp_bump_forum_topic_count_hidden( $forum_id ); 1185 } 1186 1187 /** 1188 * Decrease the total hidden topic count of a forum by one 1189 * 1190 * @since bbPress () 1191 * 1192 * @param int $forum_id Optional. Forum id. 1193 * @uses bbp_get_forum_id() To get the forum id 1194 * @uses bbp_bump_forum_topic_count_hidden() To bump forum hidden topic count 1195 */ 1196 function bbp_decrease_forum_topic_count_hidden( $forum_id = 0 ) { 1197 if ( empty( $forum_id ) ) { 1198 return; 1199 } 1200 1201 if ( bbp_is_topic( $forum_id ) ) { 1202 $forum_id = bbp_get_topic_forum_id( $forum_id ); 1203 } 1204 1205 bbp_bump_forum_topic_count_hidden( $forum_id, -1 ); 1206 } 1207 1208 /** 1118 1209 * Bump the total topic count of a forum 1119 1210 * 1120 1211 * @since bbPress (r3825) … … function bbp_bump_forum_reply_count( $forum_id = 0, $difference = 1, $update_anc 1164 1255 return (int) apply_filters( 'bbp_bump_forum_reply_count', (int) $total_reply_count + (int) $difference, $forum_id, (int) $difference, (bool) $update_ancestors ); 1165 1256 } 1166 1257 1258 /** 1259 * Increase the total reply count of a forum by one 1260 * 1261 * @since bbPress () 1262 * 1263 * @param int $forum_id Optional. Forum id. 1264 * @uses bbp_get_forum_id() To get the forum id 1265 * @uses bbp_bump_forum_reply_count() To bump forum topic count 1266 */ 1267 function bbp_increase_forum_reply_count( $forum_id = 0 ) { 1268 if ( empty( $forum_id ) ) { 1269 return; 1270 } 1271 1272 if ( bbp_is_reply( $forum_id ) ) { 1273 $reply_id = $forum_id; 1274 $forum_id = bbp_get_reply_forum_id( $reply_id ); 1275 1276 // Don't update if this is a new, unpublished, reply 1277 if ( 'bbp_new_reply' === current_action() && ! bbp_is_reply_published( $reply_id ) ) { 1278 return; 1279 } 1280 } 1281 1282 bbp_bump_forum_reply_count( $forum_id, 1 ); 1283 } 1284 1285 /** 1286 * Decrease the total reply count of a forum by one 1287 * 1288 * @since bbPress () 1289 * 1290 * @param int $forum_id Optional. Forum id. 1291 * @uses bbp_get_forum_id() To get the forum id 1292 * @uses bbp_bump_forum_reply_count() To bump forum topic count 1293 */ 1294 function bbp_decrease_forum_reply_count( $forum_id = 0 ) { 1295 if ( empty( $forum_id ) ) { 1296 return; 1297 } 1298 1299 if ( bbp_is_reply( $forum_id ) ) { 1300 $forum_id = bbp_get_reply_forum_id( $forum_id ); 1301 } 1302 1303 bbp_bump_forum_reply_count( $forum_id, -1 ); 1304 } 1305 1167 1306 /** Forum Updaters ************************************************************/ 1168 1307 1169 1308 /** … … function bbp_update_forum( $args = '' ) { 1617 1756 } 1618 1757 1619 1758 // Counts 1620 bbp_update_forum_subforum_count ( $r['forum_id'] ); 1621 bbp_update_forum_reply_count ( $r['forum_id'] ); 1622 bbp_update_forum_topic_count ( $r['forum_id'] ); 1623 bbp_update_forum_topic_count_hidden( $r['forum_id'] ); 1759 bbp_update_forum_subforum_count( $r['forum_id'] ); 1760 1761 // Only update topic count if we're deleting a topic, or in the dashboard 1762 if ( in_array( current_action(), array( 'bbp_deleted_topic', 'save_post' ) ) ) { 1763 bbp_update_forum_reply_count( $r['forum_id'] ); 1764 bbp_update_forum_topic_count( $r['forum_id'] ); 1765 bbp_update_forum_topic_count_hidden( $r['forum_id'] ); 1766 } 1624 1767 1625 1768 // Update the parent forum if one was passed 1626 1769 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 ad32198..2144fb1 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 fd278f6..530bc50 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 ) { 2372 2423 return (int) apply_filters( 'bbp_bump_topic_reply_count_hidden', (int) $new_count, $topic_id, (int) $difference ); 2373 2424 } 2374 2425 2426 /** 2427 * Increase the total hidden reply count of a topic by one 2428 * 2429 * @since bbPress () 2430 * 2431 * @param int $topic_id Optional. Topic id. 2432 * @uses bbp_is_reply() To check if the passed topic id is a reply 2433 * @uses bbp_get_reply_topic_id() To get the topic id 2434 * @uses bbp_bump_topic_reply_count_hidden() To bump topic hidden reply count 2435 */ 2436 function bbp_increase_topic_reply_count_hidden( $topic_id = 0 ) { 2437 if ( empty( $topic_id ) ) { 2438 return; 2439 } 2440 2441 if ( bbp_is_reply( $topic_id ) ) { 2442 $topic_id = bbp_get_reply_topic_id( $topic_id ); 2443 } 2444 2445 bbp_bump_topic_reply_count_hidden( $topic_id ); 2446 } 2447 2448 /** 2449 * Decrease the total hidden reply count of a topic by one 2450 * 2451 * @since bbPress () 2452 * 2453 * @param int $topic_id Optional. Topic id. 2454 * @uses bbp_is_reply() To check if the passed topic id is a reply 2455 * @uses bbp_get_reply_topic_id() To get the topic id 2456 * @uses bbp_bump_topic_reply_count_hidden() To bump topic hidden reply count 2457 */ 2458 function bbp_decrease_topic_reply_count_hidden( $topic_id = 0 ) { 2459 if ( empty( $topic_id ) ) { 2460 return; 2461 } 2462 2463 if ( bbp_is_reply( $topic_id ) ) { 2464 $topic_id = bbp_get_reply_topic_id( $topic_id ); 2465 } 2466 2467 bbp_bump_topic_reply_count_hidden( $topic_id, -1 ); 2468 } 2469 2375 2470 /** Topic Updaters ************************************************************/ 2376 2471 2377 2472 /**