Changeset 5738
- Timestamp:
- 05/13/2015 12:35:20 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/topics/functions.php
r5732 r5738 2041 2041 $stickies = ( empty( $stickies ) || ! is_array( $stickies ) ) ? array() : $stickies; 2042 2042 2043 return apply_filters( 'bbp_get_stickies', $stickies, (int)$forum_id );2043 return apply_filters( 'bbp_get_stickies', $stickies, $forum_id ); 2044 2044 } 2045 2045 … … 2418 2418 } 2419 2419 2420 update_post_meta( $topic_id, '_bbp_forum_id', (int) $forum_id ); 2421 2422 return apply_filters( 'bbp_update_topic_forum_id', (int) $forum_id, $topic_id ); 2420 $forum_id = (int) $forum_id; 2421 2422 update_post_meta( $topic_id, '_bbp_forum_id', $forum_id ); 2423 2424 return (int) apply_filters( 'bbp_update_topic_forum_id', $forum_id, $topic_id ); 2423 2425 } 2424 2426 … … 2437 2439 $topic_id = bbp_get_topic_id( $topic_id ); 2438 2440 2439 update_post_meta( $topic_id, '_bbp_topic_id', (int)$topic_id );2440 2441 return apply_filters( 'bbp_update_topic_topic_id', (int)$topic_id );2441 update_post_meta( $topic_id, '_bbp_topic_id', $topic_id ); 2442 2443 return apply_filters( 'bbp_update_topic_topic_id', $topic_id ); 2442 2444 } 2443 2445 … … 2473 2475 } 2474 2476 2475 update_post_meta( $topic_id, '_bbp_reply_count', (int) $reply_count ); 2476 2477 return apply_filters( 'bbp_update_topic_reply_count', (int) $reply_count, $topic_id ); 2477 $reply_count = (int) $reply_count; 2478 2479 update_post_meta( $topic_id, '_bbp_reply_count', $reply_count ); 2480 2481 return (int) apply_filters( 'bbp_update_topic_reply_count', $reply_count, $topic_id ); 2478 2482 } 2479 2483 … … 2516 2520 } 2517 2521 2518 update_post_meta( $topic_id, '_bbp_reply_count_hidden', (int) $reply_count ); 2519 2520 return apply_filters( 'bbp_update_topic_reply_count_hidden', (int) $reply_count, $topic_id ); 2522 $reply_count = (int) $reply_count; 2523 2524 update_post_meta( $topic_id, '_bbp_reply_count_hidden', $reply_count ); 2525 2526 return (int) apply_filters( 'bbp_update_topic_reply_count_hidden', $reply_count, $topic_id ); 2521 2527 } 2522 2528 … … 2557 2563 } 2558 2564 2565 $active_id = (int) $active_id; 2566 2559 2567 // Update only if published 2560 2568 if ( bbp_get_public_status_id() === get_post_status( $active_id ) ) { 2561 update_post_meta( $topic_id, '_bbp_last_active_id', (int)$active_id );2562 } 2563 2564 return apply_filters( 'bbp_update_topic_last_active_id', (int)$active_id, $topic_id );2569 update_post_meta( $topic_id, '_bbp_last_active_id', $active_id ); 2570 } 2571 2572 return (int) apply_filters( 'bbp_update_topic_last_active_id', $active_id, $topic_id ); 2565 2573 } 2566 2574 … … 2638 2646 } 2639 2647 2648 $reply_id = (int) $reply_id; 2649 2640 2650 // Update if reply is published 2641 2651 if ( bbp_is_reply_published( $reply_id ) ) { 2642 update_post_meta( $topic_id, '_bbp_last_reply_id', (int)$reply_id );2643 } 2644 2645 return apply_filters( 'bbp_update_topic_last_reply_id', (int)$reply_id, $topic_id );2652 update_post_meta( $topic_id, '_bbp_last_reply_id', $reply_id ); 2653 } 2654 2655 return (int) apply_filters( 'bbp_update_topic_last_reply_id', $reply_id, $topic_id ); 2646 2656 } 2647 2657 … … 2678 2688 2679 2689 // Query the DB to get voices in this topic 2680 $voices = $wpdb->get_col( $wpdb->prepare( "SELECT COUNT( DISTINCT post_author ) FROM {$wpdb->posts} WHERE ( post_parent = %d AND post_status = '%s' AND post_type = '%s' ) OR ( ID = %d AND post_type = '%s' );", $topic_id, bbp_get_public_status_id(), bbp_get_reply_post_type(), $topic_id, bbp_get_topic_post_type() ) ); 2681 2682 // If there's an error, make sure we have at least have 1 voice 2683 $voices = ( empty( $voices ) || is_wp_error( $voices ) ) ? 1 : $voices[0]; 2690 $voices = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( DISTINCT post_author ) FROM {$wpdb->posts} WHERE ( post_parent = %d AND post_status = '%s' AND post_type = '%s' ) OR ( ID = %d AND post_type = '%s' );", $topic_id, bbp_get_public_status_id(), bbp_get_reply_post_type(), $topic_id, bbp_get_topic_post_type() ) ); 2684 2691 2685 2692 // Update the voice count for this topic id 2686 update_post_meta( $topic_id, '_bbp_voice_count', (int)$voices );2687 2688 return apply_filters( 'bbp_update_topic_voice_count', (int)$voices, $topic_id );2693 update_post_meta( $topic_id, '_bbp_voice_count', $voices ); 2694 2695 return (int) apply_filters( 'bbp_update_topic_voice_count', $voices, $topic_id ); 2689 2696 } 2690 2697 … … 2722 2729 $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() ) ); 2723 2730 2724 update_post_meta( $topic_id, '_bbp_anonymous_reply_count', (int)$anonymous_replies );2725 2726 return apply_filters( 'bbp_update_topic_anonymous_reply_count', (int)$anonymous_replies, $topic_id );2731 update_post_meta( $topic_id, '_bbp_anonymous_reply_count', $anonymous_replies ); 2732 2733 return (int) apply_filters( 'bbp_update_topic_anonymous_reply_count', $anonymous_replies, $topic_id ); 2727 2734 } 2728 2735
Note: See TracChangeset
for help on using the changeset viewer.