Changeset 4258 for trunk/bbp-includes/forums/template-tags.php
- Timestamp:
- 10/19/2012 07:42:49 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bbp-includes/forums/template-tags.php
r4249 r4258 694 694 695 695 // Bail if there are no subforums 696 if ( !bbp_get_forum_subforum_count( $forum_id ) )696 if ( !bbp_get_forum_subforum_count( $forum_id, false ) ) 697 697 return; 698 698 … … 1117 1117 */ 1118 1118 function bbp_get_forum_topics_link( $forum_id = 0 ) { 1119 1120 1119 $forum = bbp_get_forum( $forum_id ); 1121 1120 $forum_id = $forum->ID; 1122 $topics = bbp_get_forum_topic_count( $forum_id ); 1123 $topics = sprintf( _n( '%s topic', '%s topics', $topics, 'bbpress' ), $topics ); 1121 $topics = sprintf( _n( '%s topic', '%s topics', bbp_get_forum_topic_count( $forum_id, true, false ), 'bbpress' ), bbp_get_forum_topic_count( $forum_id ) ); 1124 1122 $retval = ''; 1125 1123 … … 1157 1155 * @since bbPress (r2464) 1158 1156 * 1157 * @param int $forum_id Optional. Forum id to check 1158 * @param boolean $integer Optional. Whether or not to format the result 1159 1159 * @uses bbp_get_forum_subforum_count() To get the forum's subforum count 1160 * @param int $forum_id Optional. Forum id to check 1161 */ 1162 function bbp_forum_subforum_count( $forum_id = 0 ) { 1163 echo bbp_get_forum_subforum_count( $forum_id ); 1160 */ 1161 function bbp_forum_subforum_count( $forum_id = 0, $integer = false ) { 1162 echo bbp_get_forum_subforum_count( $forum_id, $integer ); 1164 1163 } 1165 1164 /** … … 1169 1168 * 1170 1169 * @param int $forum_id Optional. Forum id 1170 * @param boolean $integer Optional. Whether or not to format the result 1171 1171 * @uses bbp_get_forum_id() To get the forum id 1172 1172 * @uses get_post_meta() To get the subforum count … … 1175 1175 * @return int Forum's subforum count 1176 1176 */ 1177 function bbp_get_forum_subforum_count( $forum_id = 0 ) {1177 function bbp_get_forum_subforum_count( $forum_id = 0, $integer = false ) { 1178 1178 $forum_id = bbp_get_forum_id( $forum_id ); 1179 $forum_count = get_post_meta( $forum_id, '_bbp_forum_subforum_count', true ); 1180 1181 return apply_filters( 'bbp_get_forum_subforum_count', (int) $forum_count, $forum_id ); 1179 $forum_count = absint( get_post_meta( $forum_id, '_bbp_forum_subforum_count', true ) ); 1180 $filter = ( true === $integer ) ? 'bbp_get_forum_subforum_count_int' : 'bbp_get_forum_subforum_count'; 1181 1182 return apply_filters( $filter, $forum_count, $forum_id ); 1182 1183 } 1183 1184 … … 1189 1190 * @param int $forum_id Optional. Forum id 1190 1191 * @param bool $total_count Optional. To get the total count or normal count? 1192 * @param boolean $integer Optional. Whether or not to format the result 1191 1193 * @uses bbp_get_forum_topic_count() To get the forum topic count 1192 1194 */ 1193 function bbp_forum_topic_count( $forum_id = 0, $total_count = true ) {1194 echo bbp_get_forum_topic_count( $forum_id, $total_count );1195 function bbp_forum_topic_count( $forum_id = 0, $total_count = true, $integer = false ) { 1196 echo bbp_get_forum_topic_count( $forum_id, $total_count, $integer ); 1195 1197 } 1196 1198 /** … … 1202 1204 * @param bool $total_count Optional. To get the total count or normal 1203 1205 * count? Defaults to total. 1206 * @param boolean $integer Optional. Whether or not to format the result 1204 1207 * @uses bbp_get_forum_id() To get the forum id 1205 1208 * @uses get_post_meta() To get the forum topic count … … 1208 1211 * @return int Forum topic count 1209 1212 */ 1210 function bbp_get_forum_topic_count( $forum_id = 0, $total_count = true ) {1213 function bbp_get_forum_topic_count( $forum_id = 0, $total_count = true, $integer = false ) { 1211 1214 $forum_id = bbp_get_forum_id( $forum_id ); 1212 $topics = get_post_meta( $forum_id, empty( $total_count ) ? '_bbp_topic_count' : '_bbp_total_topic_count', true ); 1213 1214 return apply_filters( 'bbp_get_forum_topic_count', (int) $topics, $forum_id ); 1215 $meta_key = empty( $total_count ) ? '_bbp_topic_count' : '_bbp_total_topic_count'; 1216 $topics = absint( get_post_meta( $forum_id, $meta_key, true ) ); 1217 $filter = ( true === $integer ) ? 'bbp_get_forum_topic_count_int' : 'bbp_get_forum_topic_count'; 1218 1219 return apply_filters( $filter, $topics, $forum_id ); 1215 1220 } 1216 1221 … … 1222 1227 * @param int $forum_id Optional. Forum id 1223 1228 * @param bool $total_count Optional. To get the total count or normal count? 1229 * @param boolean $integer Optional. Whether or not to format the result 1224 1230 * @uses bbp_get_forum_reply_count() To get the forum reply count 1225 1231 */ 1226 function bbp_forum_reply_count( $forum_id = 0, $total_count = true ) {1227 echo bbp_get_forum_reply_count( $forum_id, $total_count );1232 function bbp_forum_reply_count( $forum_id = 0, $total_count = true, $integer = false ) { 1233 echo bbp_get_forum_reply_count( $forum_id, $total_count, $integer ); 1228 1234 } 1229 1235 /** … … 1235 1241 * @param bool $total_count Optional. To get the total count or normal 1236 1242 * count? 1243 * @param boolean $integer Optional. Whether or not to format the result 1237 1244 * @uses bbp_get_forum_id() To get the forum id 1238 1245 * @uses get_post_meta() To get the forum reply count … … 1241 1248 * @return int Forum reply count 1242 1249 */ 1243 function bbp_get_forum_reply_count( $forum_id = 0, $total_count = true ) {1250 function bbp_get_forum_reply_count( $forum_id = 0, $total_count = true, $integer = false ) { 1244 1251 $forum_id = bbp_get_forum_id( $forum_id ); 1245 $replies = get_post_meta( $forum_id, empty( $total_count ) ? '_bbp_reply_count' : '_bbp_total_reply_count', true ); 1246 1247 return apply_filters( 'bbp_get_forum_reply_count', (int) $replies, $forum_id ); 1252 $meta_key = empty( $total_count ) ? '_bbp_reply_count' : '_bbp_total_reply_count'; 1253 $replies = absint( get_post_meta( $forum_id, $meta_key, true ) ); 1254 $filter = ( true === $integer ) ? 'bbp_get_forum_reply_count_int' : 'bbp_get_forum_reply_count'; 1255 1256 return apply_filters( $filter, $replies, $forum_id ); 1248 1257 } 1249 1258 … … 1255 1264 * @param int $forum_id Optional. Forum id 1256 1265 * @param bool $total_count Optional. To get the total count or normal count? 1266 * @param boolean $integer Optional. Whether or not to format the result 1257 1267 * @uses bbp_get_forum_post_count() To get the forum post count 1258 1268 */ 1259 function bbp_forum_post_count( $forum_id = 0, $total_count = true ) {1260 echo bbp_get_forum_post_count( $forum_id, $total_count );1269 function bbp_forum_post_count( $forum_id = 0, $total_count = true, $integer = false ) { 1270 echo bbp_get_forum_post_count( $forum_id, $total_count, $integer ); 1261 1271 } 1262 1272 /** … … 1268 1278 * @param bool $total_count Optional. To get the total count or normal 1269 1279 * count? 1280 * @param boolean $integer Optional. Whether or not to format the result 1270 1281 * @uses bbp_get_forum_id() To get the forum id 1271 1282 * @uses get_post_meta() To get the forum post count … … 1274 1285 * @return int Forum post count 1275 1286 */ 1276 function bbp_get_forum_post_count( $forum_id = 0, $total_count = true ) {1287 function bbp_get_forum_post_count( $forum_id = 0, $total_count = true, $integer = false ) { 1277 1288 $forum_id = bbp_get_forum_id( $forum_id ); 1278 $topics = bbp_get_forum_topic_count( $forum_id, $total_count ); 1279 $replies = get_post_meta( $forum_id, empty( $total_count ) ? '_bbp_reply_count' : '_bbp_total_reply_count', true ); 1280 1281 return apply_filters( 'bbp_get_forum_post_count', (int) $replies + (int) $topics, $forum_id ); 1289 $topics = bbp_get_forum_topic_count( $forum_id, $total_count, true ); 1290 $meta_key = empty( $total_count ) ? '_bbp_reply_count' : '_bbp_total_reply_count'; 1291 $replies = absint( get_post_meta( $forum_id, $meta_key, true ) ); 1292 $retval = $replies + $topics; 1293 $filter = ( true === $integer ) ? 'bbp_get_forum_post_count_int' : 'bbp_get_forum_post_count'; 1294 1295 return apply_filters( $filter, $retval, $forum_id ); 1282 1296 } 1283 1297 … … 1289 1303 * 1290 1304 * @param int $forum_id Optional. Topic id 1305 * @param boolean $integer Optional. Whether or not to format the result 1291 1306 * @uses bbp_get_forum_topic_count_hidden() To get the forum hidden topic count 1292 1307 */ 1293 function bbp_forum_topic_count_hidden( $forum_id = 0 ) {1294 echo bbp_get_forum_topic_count_hidden( $forum_id );1308 function bbp_forum_topic_count_hidden( $forum_id = 0, $integer = false ) { 1309 echo bbp_get_forum_topic_count_hidden( $forum_id, $integer ); 1295 1310 } 1296 1311 /** … … 1301 1316 * 1302 1317 * @param int $forum_id Optional. Topic id 1318 * @param boolean $integer Optional. Whether or not to format the result 1303 1319 * @uses bbp_get_forum_id() To get the forum id 1304 1320 * @uses get_post_meta() To get the hidden topic count … … 1307 1323 * @return int Topic hidden topic count 1308 1324 */ 1309 function bbp_get_forum_topic_count_hidden( $forum_id = 0 ) {1325 function bbp_get_forum_topic_count_hidden( $forum_id = 0, $integer = false ) { 1310 1326 $forum_id = bbp_get_forum_id( $forum_id ); 1311 $topics = get_post_meta( $forum_id, '_bbp_topic_count_hidden', true ); 1312 1313 return (int) apply_filters( 'bbp_get_forum_topic_count_hidden', (int) $topics, $forum_id ); 1327 $topics = absint( get_post_meta( $forum_id, '_bbp_topic_count_hidden', true ) ); 1328 $filter = ( true === $integer ) ? 'bbp_get_forum_topic_count_hidden_int' : 'bbp_get_forum_topic_count_hidden'; 1329 1330 return apply_filters( $filter, $topics, $forum_id ); 1314 1331 } 1315 1332 … … 1822 1839 1823 1840 // Get some forum data 1841 $tc_int = bbp_get_forum_topic_count( $forum_id, false ); 1842 $rc_int = bbp_get_forum_reply_count( $forum_id, false ); 1824 1843 $topic_count = bbp_get_forum_topic_count( $forum_id ); 1825 1844 $reply_count = bbp_get_forum_reply_count( $forum_id ); … … 1828 1847 // Has replies 1829 1848 if ( !empty( $reply_count ) ) { 1830 $reply_text = sprintf( _n( '%s reply', '%s replies', $r eply_count, 'bbpress' ), $reply_count );1849 $reply_text = sprintf( _n( '%s reply', '%s replies', $rc_int, 'bbpress' ), $reply_count ); 1831 1850 } 1832 1851 … … 1839 1858 // Forum has no last active data 1840 1859 } else { 1841 $topic_text = sprintf( _n( '%s topic', '%s topics', $t opic_count, 'bbpress' ), $topic_count );1860 $topic_text = sprintf( _n( '%s topic', '%s topics', $tc_int, 'bbpress' ), $topic_count ); 1842 1861 } 1843 1862
Note: See TracChangeset
for help on using the changeset viewer.