Changeset 4611 for trunk/includes/topics/functions.php
- Timestamp:
- 12/20/2012 04:08:55 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/topics/functions.php
r4561 r4611 2214 2214 2215 2215 // If it's a reply, then get the parent (topic id) 2216 if ( bbp_is_reply( $topic_id ) ) 2216 if ( bbp_is_reply( $topic_id ) ) { 2217 2217 $topic_id = bbp_get_reply_topic_id( $topic_id ); 2218 else2218 } else { 2219 2219 $topic_id = bbp_get_topic_id( $topic_id ); 2220 2221 if ( empty( $forum_id ) ) 2220 } 2221 2222 if ( empty( $forum_id ) ) { 2222 2223 $forum_id = get_post_field( 'post_parent', $topic_id ); 2224 } 2223 2225 2224 2226 update_post_meta( $topic_id, '_bbp_forum_id', (int) $forum_id ); … … 2266 2268 2267 2269 // If it's a reply, then get the parent (topic id) 2268 if ( bbp_is_reply( $topic_id ) ) 2270 if ( bbp_is_reply( $topic_id ) ) { 2269 2271 $topic_id = bbp_get_reply_topic_id( $topic_id ); 2270 else2272 } else { 2271 2273 $topic_id = bbp_get_topic_id( $topic_id ); 2274 } 2272 2275 2273 2276 // Get replies of topic if not passed 2274 if ( empty( $reply_count ) ) 2277 if ( empty( $reply_count ) ) { 2275 2278 $reply_count = bbp_get_public_child_count( $topic_id, bbp_get_reply_post_type() ); 2279 } 2276 2280 2277 2281 update_post_meta( $topic_id, '_bbp_reply_count', (int) $reply_count ); … … 2302 2306 2303 2307 // If it's a reply, then get the parent (topic id) 2304 if ( bbp_is_reply( $topic_id ) ) 2308 if ( bbp_is_reply( $topic_id ) ) { 2305 2309 $topic_id = bbp_get_reply_topic_id( $topic_id ); 2306 else2310 } else { 2307 2311 $topic_id = bbp_get_topic_id( $topic_id ); 2312 } 2308 2313 2309 2314 // Get replies of topic 2310 if ( empty( $reply_count ) ) 2315 if ( empty( $reply_count ) ) { 2311 2316 $reply_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( '" . join( '\',\'', array( bbp_get_trash_status_id(), bbp_get_spam_status_id() ) ) . "') AND post_type = '%s';", $topic_id, bbp_get_reply_post_type() ) ); 2317 } 2312 2318 2313 2319 update_post_meta( $topic_id, '_bbp_reply_count_hidden', (int) $reply_count ); … … 2337 2343 2338 2344 // If it's a reply, then get the parent (topic id) 2339 if ( bbp_is_reply( $topic_id ) ) 2345 if ( bbp_is_reply( $topic_id ) ) { 2340 2346 $topic_id = bbp_get_reply_topic_id( $topic_id ); 2341 else2347 } else { 2342 2348 $topic_id = bbp_get_topic_id( $topic_id ); 2343 2344 if ( empty( $active_id ) ) 2349 } 2350 2351 if ( empty( $active_id ) ) { 2345 2352 $active_id = bbp_get_public_child_last_id( $topic_id, bbp_get_reply_post_type() ); 2353 } 2346 2354 2347 2355 // Adjust last_id's based on last_reply post_type 2348 if ( empty( $active_id ) || !bbp_is_reply( $active_id ) ) 2356 if ( empty( $active_id ) || !bbp_is_reply( $active_id ) ) { 2349 2357 $active_id = $topic_id; 2358 } 2350 2359 2351 2360 // Update only if published 2352 if ( bbp_get_public_status_id() == get_post_status( $active_id ) ) 2361 if ( bbp_get_public_status_id() == get_post_status( $active_id ) ) { 2353 2362 update_post_meta( $topic_id, '_bbp_last_active_id', (int) $active_id ); 2363 } 2354 2364 2355 2365 return apply_filters( 'bbp_update_topic_last_active_id', (int) $active_id, $topic_id ); … … 2372 2382 2373 2383 // If it's a reply, then get the parent (topic id) 2374 if ( bbp_is_reply( $topic_id ) ) 2384 if ( bbp_is_reply( $topic_id ) ) { 2375 2385 $topic_id = bbp_get_reply_topic_id( $topic_id ); 2376 else2386 } else { 2377 2387 $topic_id = bbp_get_topic_id( $topic_id ); 2388 } 2378 2389 2379 2390 // Check time and use current if empty 2380 if ( empty( $new_time ) ) 2391 if ( empty( $new_time ) ) { 2381 2392 $new_time = get_post_field( 'post_date', bbp_get_public_child_last_id( $topic_id, bbp_get_reply_post_type() ) ); 2393 } 2382 2394 2383 2395 // Update only if published 2384 if ( !empty( $new_time ) ) 2396 if ( !empty( $new_time ) ) { 2385 2397 update_post_meta( $topic_id, '_bbp_last_active_time', $new_time ); 2398 } 2386 2399 2387 2400 return apply_filters( 'bbp_update_topic_last_active_time', $new_time, $topic_id ); … … 2417 2430 } 2418 2431 2419 if ( empty( $reply_id ) ) 2432 if ( empty( $reply_id ) ) { 2420 2433 $reply_id = bbp_get_public_child_last_id( $topic_id, bbp_get_reply_post_type() ); 2434 } 2421 2435 2422 2436 // Adjust last_id's based on last_reply post_type 2423 if ( empty( $reply_id ) || !bbp_is_reply( $reply_id ) ) 2437 if ( empty( $reply_id ) || !bbp_is_reply( $reply_id ) ) { 2424 2438 $reply_id = 0; 2439 } 2425 2440 2426 2441 // Update if reply is published 2427 if ( bbp_is_reply_published( $reply_id ) ) 2442 if ( bbp_is_reply_published( $reply_id ) ) { 2428 2443 update_post_meta( $topic_id, '_bbp_last_reply_id', (int) $reply_id ); 2444 } 2429 2445 2430 2446 return apply_filters( 'bbp_update_topic_last_reply_id', (int) $reply_id, $topic_id ); … … 2454 2470 2455 2471 // If it's a reply, then get the parent (topic id) 2456 if ( bbp_is_reply( $topic_id ) ) 2472 if ( bbp_is_reply( $topic_id ) ) { 2457 2473 $topic_id = bbp_get_reply_topic_id( $topic_id ); 2458 elseif ( bbp_is_topic( $topic_id ) )2474 } elseif ( bbp_is_topic( $topic_id ) ) { 2459 2475 $topic_id = bbp_get_topic_id( $topic_id ); 2460 else2476 } else { 2461 2477 return; 2478 } 2462 2479 2463 2480 // Query the DB to get voices in this topic … … 2496 2513 2497 2514 // If it's a reply, then get the parent (topic id) 2498 if ( bbp_is_reply( $topic_id ) ) 2515 if ( bbp_is_reply( $topic_id ) ) { 2499 2516 $topic_id = bbp_get_reply_topic_id( $topic_id ); 2500 elseif ( bbp_is_topic( $topic_id ) )2517 } elseif ( bbp_is_topic( $topic_id ) ) { 2501 2518 $topic_id = bbp_get_topic_id( $topic_id ); 2502 else2519 } else { 2503 2520 return; 2521 } 2504 2522 2505 2523 $anonymous_replies = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( ID ) FROM {$wpdb->posts} WHERE ( post_parent = %d AND post_status = '%s' AND post_type = '%s' AND post_author = 0 ) OR ( ID = %d AND post_type = '%s' AND post_author = 0 );", $topic_id, bbp_get_public_status_id(), bbp_get_reply_post_type(), $topic_id, bbp_get_topic_post_type() ) );
Note: See TracChangeset
for help on using the changeset viewer.