Changeset 3826 for branches/plugin/bbp-includes/bbp-topic-functions.php
- Timestamp:
- 03/26/2012 07:36:47 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-includes/bbp-topic-functions.php
r3808 r3826 2047 2047 } 2048 2048 2049 /** Count Bumpers *************************************************************/ 2050 2051 /** 2052 * Bump the total reply count of a topic 2053 * 2054 * @since bbPress (r3825) 2055 * 2056 * @param int $topic_id Optional. Forum id. 2057 * @param int $difference Optional. Default 1 2058 * @param bool $update_ancestors Optional. Default true 2059 * @uses bbp_get_topic_id() To get the topic id 2060 * @uses update_post_meta() To update the topic's reply count meta 2061 * @uses apply_filters() Calls 'bbp_bump_topic_reply_count' with the reply 2062 * count, topic id, and difference 2063 * @return int Forum reply count 2064 */ 2065 function bbp_bump_topic_reply_count( $topic_id = 0, $difference = 1 ) { 2066 2067 // Get counts 2068 $topic_id = bbp_get_topic_id( $topic_id ); 2069 $reply_count = bbp_get_topic_reply_count( $topic_id, false ); 2070 $new_count = (int) $reply_count + (int) $difference; 2071 2072 // Update this topic id's reply count 2073 update_post_meta( $topic_id, '_bbp_reply_count', (int) $new_count ); 2074 2075 return (int) apply_filters( 'bbp_bump_topic_reply_count', (int) $new_count, $topic_id, (int) $difference ); 2076 } 2077 2078 /** 2079 * Bump the total hidden reply count of a topic 2080 * 2081 * @since bbPress (r3825) 2082 * 2083 * @param int $topic_id Optional. Forum id. 2084 * @param int $difference Optional. Default 1 2085 * @uses bbp_get_topic_id() To get the topic id 2086 * @uses update_post_meta() To update the topic's reply count meta 2087 * @uses apply_filters() Calls 'bbp_bump_topic_reply_count_hidden' with the 2088 * reply count, topic id, and difference 2089 * @return int Forum hidden reply count 2090 */ 2091 function bbp_bump_topic_reply_count_hidden( $topic_id = 0, $difference = 1 ) { 2092 2093 // Get counts 2094 $topic_id = bbp_get_topic_id( $topic_id ); 2095 $reply_count = bbp_get_topic_reply_count_hidden( $topic_id, false ); 2096 $new_count = (int) $reply_count + (int) $difference; 2097 2098 // Update this topic id's hidder reply count 2099 update_post_meta( $topic_id, '_bbp_reply_count_hidden', (int) $new_count ); 2100 2101 return (int) apply_filters( 'bbp_bump_topic_reply_count_hidden', (int) $new_count, $topic_id, (int) $difference ); 2102 } 2103 2049 2104 /** Topic Updaters ************************************************************/ 2050 2105 … … 2319 2374 $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() ) ); 2320 2375 2321 // If there's an error, make sure we at least have 1 voice2376 // If there's an error, make sure we have at least have 1 voice 2322 2377 $voices = ( empty( $voices ) || is_wp_error( $voices ) ) ? 1 : $voices[0]; 2323 2378
Note: See TracChangeset
for help on using the changeset viewer.