Changeset 5732
- Timestamp:
- 05/12/2015 10:27:33 PM (10 years ago)
- Location:
- trunk/src/includes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/forums/functions.php
r5731 r5732 1051 1051 function bbp_bump_forum_topic_count( $forum_id = 0, $difference = 1, $update_ancestors = true ) { 1052 1052 1053 // Bail if no bump 1054 if ( empty( $difference ) ) { 1055 return false; 1056 } 1057 1053 1058 // Get some counts 1054 1059 $forum_id = bbp_get_forum_id( $forum_id ); 1055 1060 $topic_count = bbp_get_forum_topic_count( $forum_id, false, true ); 1056 1061 $total_topic_count = bbp_get_forum_topic_count( $forum_id, true, true ); 1062 $difference = (int) $difference; 1057 1063 1058 1064 // Update this forum id 1059 update_post_meta( $forum_id, '_bbp_topic_count', (int) $topic_count + (int) $difference);1060 update_post_meta( $forum_id, '_bbp_total_topic_count', (int) $total_topic_count + (int) $difference);1065 update_post_meta( $forum_id, '_bbp_topic_count', (int) ( $topic_count + $difference ) ); 1066 update_post_meta( $forum_id, '_bbp_total_topic_count', (int) ( $total_topic_count + $difference ) ); 1061 1067 1062 1068 // Check for ancestors … … 1076 1082 1077 1083 // Update counts 1078 update_post_meta( $parent_forum_id, '_bbp_topic_count', (int) $parent_topic_count + (int) $difference);1079 update_post_meta( $parent_forum_id, '_bbp_total_topic_count', (int) $parent_total_topic_count + (int) $difference);1084 update_post_meta( $parent_forum_id, '_bbp_topic_count', (int) ( $parent_topic_count + $difference ) ); 1085 update_post_meta( $parent_forum_id, '_bbp_total_topic_count', (int) ( $parent_total_topic_count + $difference ) ); 1080 1086 } 1081 1087 } 1082 1088 } 1083 1089 1084 return (int) apply_filters( 'bbp_bump_forum_topic_count', (int) $total_topic_count + (int) $difference, $forum_id, (int) $difference, (bool) $update_ancestors ); 1090 $forum_topic_count = (int) ( $total_topic_count + $difference ); 1091 1092 return (int) apply_filters( 'bbp_bump_forum_topic_count', $forum_topic_count, $forum_id, $difference, $update_ancestors ); 1085 1093 } 1086 1094 … … 1101 1109 function bbp_bump_forum_topic_count_hidden( $forum_id = 0, $difference = 1 ) { 1102 1110 1111 // Bail if no bump 1112 if ( empty( $difference ) ) { 1113 return false; 1114 } 1115 1103 1116 // Get some counts 1104 1117 $forum_id = bbp_get_forum_id( $forum_id ); 1105 1118 $topic_count = bbp_get_forum_topic_count_hidden( $forum_id, true ); 1106 $new_count = (int) $topic_count + (int) $difference; 1119 $difference = (int) $difference; 1120 $new_count = (int) ( $topic_count + $difference ); 1107 1121 1108 1122 // Update this forum id 1109 update_post_meta( $forum_id, '_bbp_topic_count_hidden', (int)$new_count );1110 1111 return (int) apply_filters( 'bbp_bump_forum_topic_count_hidden', (int) $new_count, $forum_id, (int)$difference );1123 update_post_meta( $forum_id, '_bbp_topic_count_hidden', $new_count ); 1124 1125 return (int) apply_filters( 'bbp_bump_forum_topic_count_hidden', $new_count, $forum_id, $difference ); 1112 1126 } 1113 1127 … … 1128 1142 function bbp_bump_forum_reply_count( $forum_id = 0, $difference = 1, $update_ancestors = true ) { 1129 1143 1144 // Bail if no bump 1145 if ( empty( $difference ) ) { 1146 return false; 1147 } 1148 1130 1149 // Get some counts 1131 1150 $forum_id = bbp_get_forum_id( $forum_id ); 1132 1151 $topic_count = bbp_get_forum_reply_count( $forum_id, false, true ); 1133 1152 $total_reply_count = bbp_get_forum_reply_count( $forum_id, true, true ); 1153 $difference = (int) $difference; 1134 1154 1135 1155 // Update this forum id 1136 update_post_meta( $forum_id, '_bbp_reply_count', (int) $topic_count + (int) $difference);1137 update_post_meta( $forum_id, '_bbp_total_reply_count', (int) $total_reply_count + (int) $difference);1156 update_post_meta( $forum_id, '_bbp_reply_count', (int) ( $topic_count + $difference ) ); 1157 update_post_meta( $forum_id, '_bbp_total_reply_count', (int) ( $total_reply_count + $difference ) ); 1138 1158 1139 1159 // Check for ancestors … … 1153 1173 1154 1174 // Update counts 1155 update_post_meta( $parent_forum_id, '_bbp_reply_count', (int) $parent_topic_count + (int) $difference);1156 update_post_meta( $parent_forum_id, '_bbp_total_reply_count', (int) $parent_total_reply_count + (int) $difference);1175 update_post_meta( $parent_forum_id, '_bbp_reply_count', (int) ( $parent_topic_count + $difference ) ); 1176 update_post_meta( $parent_forum_id, '_bbp_total_reply_count', (int) ( $parent_total_reply_count + $difference ) ); 1157 1177 } 1158 1178 } 1159 1179 } 1160 1180 1161 return (int) apply_filters( 'bbp_bump_forum_reply_count', (int) $total_reply_count + (int) $difference, $forum_id, (int) $difference, (bool) $update_ancestors ); 1181 $forum_reply_count = (int) ( $total_reply_count + $difference ); 1182 1183 return (int) apply_filters( 'bbp_bump_forum_reply_count', $forum_reply_count, $forum_id, $difference, $update_ancestors ); 1162 1184 } 1163 1185 -
trunk/src/includes/topics/functions.php
r5729 r5732 2336 2336 function bbp_bump_topic_reply_count( $topic_id = 0, $difference = 1 ) { 2337 2337 2338 // Bail if no bump 2339 if ( empty( $difference ) ) { 2340 return false; 2341 } 2342 2338 2343 // Get counts 2339 2344 $topic_id = bbp_get_topic_id( $topic_id ); 2340 2345 $reply_count = bbp_get_topic_reply_count( $topic_id, true ); 2341 $new_count = (int) $reply_count + (int) $difference; 2346 $difference = (int) $difference; 2347 $new_count = (int) ( $reply_count + $difference ); 2342 2348 2343 2349 // Update this topic id's reply count 2344 update_post_meta( $topic_id, '_bbp_reply_count', (int)$new_count );2345 2346 return (int) apply_filters( 'bbp_bump_topic_reply_count', (int) $new_count, $topic_id, (int)$difference );2350 update_post_meta( $topic_id, '_bbp_reply_count', $new_count ); 2351 2352 return (int) apply_filters( 'bbp_bump_topic_reply_count', $new_count, $topic_id, $difference ); 2347 2353 } 2348 2354 … … 2363 2369 function bbp_bump_topic_reply_count_hidden( $topic_id = 0, $difference = 1 ) { 2364 2370 2371 // Bail if no bump 2372 if ( empty( $difference ) ) { 2373 return false; 2374 } 2375 2365 2376 // Get counts 2366 2377 $topic_id = bbp_get_topic_id( $topic_id ); 2367 2378 $reply_count = bbp_get_topic_reply_count_hidden( $topic_id, true ); 2368 $new_count = (int) $reply_count + (int) $difference; 2379 $difference = (int) $difference; 2380 $new_count = (int) ( $reply_count + $difference ); 2369 2381 2370 2382 // Update this topic id's hidder reply count 2371 update_post_meta( $topic_id, '_bbp_reply_count_hidden', (int)$new_count );2372 2373 return (int) apply_filters( 'bbp_bump_topic_reply_count_hidden', (int) $new_count, $topic_id, (int)$difference );2383 update_post_meta( $topic_id, '_bbp_reply_count_hidden', $new_count ); 2384 2385 return (int) apply_filters( 'bbp_bump_topic_reply_count_hidden', $new_count, $topic_id, $difference ); 2374 2386 } 2375 2387 -
trunk/src/includes/users/functions.php
r5666 r5732 1787 1787 function bbp_bump_user_topic_count( $user_id = 0, $difference = 1 ) { 1788 1788 1789 // Bail if no bump 1790 if ( empty( $difference ) ) { 1791 return false; 1792 } 1793 1789 1794 // Validate user ID 1790 1795 $user_id = bbp_get_user_id( $user_id ); … … 1799 1804 } 1800 1805 1806 $difference = (int) $difference; 1807 $user_topic_count = (int) ( $count + $difference ); 1808 1801 1809 // Add them up and filter them 1802 $new_count = apply_filters( 'bbp_bump_user_topic_count', ( (int) $count + (int) $difference ), $user_id, $difference, $count );1810 $new_count = (int) apply_filters( 'bbp_bump_user_topic_count', $user_topic_count, $user_id, $difference, $count ); 1803 1811 1804 1812 return bbp_update_user_topic_count( $user_id, $new_count ); … … 1817 1825 function bbp_bump_user_reply_count( $user_id = 0, $difference = 1 ) { 1818 1826 1827 // Bail if no bump 1828 if ( empty( $difference ) ) { 1829 return false; 1830 } 1831 1819 1832 // Validate user ID 1820 1833 $user_id = bbp_get_user_id( $user_id ); … … 1828 1841 $count = bbp_get_user_reply_count_raw( $user_id ); 1829 1842 } 1843 1844 $difference = (int) $difference; 1845 $user_reply_count = (int) ( $count + $difference ); 1830 1846 1831 1847 // Add them up and filter them
Note: See TracChangeset
for help on using the changeset viewer.