Changeset 6923 for trunk/src/includes/forums/template.php
- Timestamp:
- 11/09/2019 05:35:42 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/forums/template.php
r6903 r6923 484 484 function bbp_get_forum_last_active_id( $forum_id = 0 ) { 485 485 $forum_id = bbp_get_forum_id( $forum_id ); 486 $active_id = get_post_meta( $forum_id, '_bbp_last_active_id', true );487 488 // Filter & return 489 return (int) apply_filters( 'bbp_get_forum_last_active_id', (int)$active_id, $forum_id );486 $active_id = (int) get_post_meta( $forum_id, '_bbp_last_active_id', true ); 487 488 // Filter & return 489 return (int) apply_filters( 'bbp_get_forum_last_active_id', $active_id, $forum_id ); 490 490 } 491 491 … … 606 606 function bbp_get_forum_parent_id( $forum_id = 0 ) { 607 607 $forum_id = bbp_get_forum_id( $forum_id ); 608 $parent_id = get_post_field( 'post_parent', $forum_id );608 $parent_id = (int) get_post_field( 'post_parent', $forum_id ); 609 609 610 610 // Meta-data fallback 611 611 if ( empty( $parent_id ) ) { 612 $parent_id = get_post_meta( $forum_id, '_bbp_forum_id', true );612 $parent_id = (int) get_post_meta( $forum_id, '_bbp_forum_id', true ); 613 613 } 614 614 615 615 // Filter 616 616 if ( ! empty( $parent_id ) ) { 617 $parent_id = bbp_get_forum_id( $parent_id );618 } 619 620 // Filter & return 621 return (int) apply_filters( 'bbp_get_forum_parent_id', (int)$parent_id, $forum_id );617 $parent_id = (int) bbp_get_forum_id( $parent_id ); 618 } 619 620 // Filter & return 621 return (int) apply_filters( 'bbp_get_forum_parent_id', $parent_id, $forum_id ); 622 622 } 623 623 … … 868 868 function bbp_get_forum_last_topic_id( $forum_id = 0 ) { 869 869 $forum_id = bbp_get_forum_id( $forum_id ); 870 $topic_id = get_post_meta( $forum_id, '_bbp_last_topic_id', true );871 872 // Filter & return 873 return (int) apply_filters( 'bbp_get_forum_last_topic_id', (int)$topic_id, $forum_id );870 $topic_id = (int) get_post_meta( $forum_id, '_bbp_last_topic_id', true ); 871 872 // Filter & return 873 return (int) apply_filters( 'bbp_get_forum_last_topic_id', $topic_id, $forum_id ); 874 874 } 875 875 … … 994 994 function bbp_get_forum_last_reply_id( $forum_id = 0 ) { 995 995 $forum_id = bbp_get_forum_id( $forum_id ); 996 $reply_id = get_post_meta( $forum_id, '_bbp_last_reply_id', true );997 998 // Filter & return 999 return (int) apply_filters( 'bbp_get_forum_last_reply_id', (int)$reply_id, $forum_id );996 $reply_id = (int) get_post_meta( $forum_id, '_bbp_last_reply_id', true ); 997 998 // Filter & return 999 return (int) apply_filters( 'bbp_get_forum_last_reply_id', $reply_id, $forum_id ); 1000 1000 } 1001 1001 … … 1176 1176 1177 1177 // Get deleted topics 1178 $deleted_int = bbp_get_forum_topic_count_hidden( $forum_id, true);1178 $deleted_int = bbp_get_forum_topic_count_hidden( $forum_id, false, true ); 1179 1179 1180 1180 // This forum has hidden topics … … 1182 1182 1183 1183 // Hidden text 1184 $deleted_num = bbp_get_forum_topic_count_hidden( $forum_id, false );1184 $deleted_num = bbp_get_forum_topic_count_hidden( $forum_id, false, false ); 1185 1185 $extra = ' ' . sprintf( _n( '(+%s hidden)', '(+%s hidden)', $deleted_int, 'bbpress' ), $deleted_num ); 1186 1186 … … 1217 1217 function bbp_get_forum_subforum_count( $forum_id = 0, $integer = false ) { 1218 1218 $forum_id = bbp_get_forum_id( $forum_id ); 1219 $forum_count = get_post_meta( $forum_id, '_bbp_forum_subforum_count', true );1219 $forum_count = (int) get_post_meta( $forum_id, '_bbp_forum_subforum_count', true ); 1220 1220 $filter = ( true === $integer ) 1221 1221 ? 'bbp_get_forum_subforum_count_int' … … 1251 1251 $forum_id = bbp_get_forum_id( $forum_id ); 1252 1252 $meta_key = empty( $total_count ) ? '_bbp_topic_count' : '_bbp_total_topic_count'; 1253 $topics = get_post_meta( $forum_id, $meta_key, true );1253 $topics = (int) get_post_meta( $forum_id, $meta_key, true ); 1254 1254 $filter = ( true === $integer ) 1255 1255 ? 'bbp_get_forum_topic_count_int' … … 1285 1285 $forum_id = bbp_get_forum_id( $forum_id ); 1286 1286 $meta_key = empty( $total_count ) ? '_bbp_reply_count' : '_bbp_total_reply_count'; 1287 $replies = get_post_meta( $forum_id, $meta_key, true );1287 $replies = (int) get_post_meta( $forum_id, $meta_key, true ); 1288 1288 $filter = ( true === $integer ) 1289 1289 ? 'bbp_get_forum_reply_count_int' … … 1320 1320 $topics = bbp_get_forum_topic_count( $forum_id, $total_count, true ); 1321 1321 $replies = bbp_get_forum_reply_count( $forum_id, $total_count, true ); 1322 $retval = $replies + $topics;1322 $retval = ( $replies + $topics ); 1323 1323 $filter = ( true === $integer ) 1324 1324 ? 'bbp_get_forum_post_count_int' … … 1333 1333 * 1334 1334 * @since 2.0.0 bbPress (r2883) 1335 * 1336 * @param int $forum_id Optional. Topic id 1335 * @since 2.6.0 bbPress (r6922) Changed function signature to add total counts 1336 * 1337 * @param int $forum_id Optional. Forum id 1338 * @param bool $total_count Optional. To get the total count or normal count? 1337 1339 * @param boolean $integer Optional. Whether or not to format the result 1338 1340 */ 1339 function bbp_forum_topic_count_hidden( $forum_id = 0, $ integer = false) {1340 echo bbp_get_forum_topic_count_hidden( $forum_id, $ integer );1341 function bbp_forum_topic_count_hidden( $forum_id = 0, $total_count = true, $integer = null ) { 1342 echo bbp_get_forum_topic_count_hidden( $forum_id, $total_count, $integer ); 1341 1343 } 1342 1344 /** … … 1345 1347 * 1346 1348 * @since 2.0.0 bbPress (r2883) 1347 * 1348 * @param int $forum_id Optional. Topic id 1349 * @since 2.6.0 bbPress (r6922) Changed function signature to add total counts 1350 * 1351 * @param int $forum_id Optional. Forum id 1352 * @param bool $total_count Optional. To get the total count or normal count? 1349 1353 * @param boolean $integer Optional. Whether or not to format the result 1350 1354 * @return int Topic hidden topic count 1351 1355 */ 1352 function bbp_get_forum_topic_count_hidden( $forum_id = 0, $ integer = false) {1356 function bbp_get_forum_topic_count_hidden( $forum_id = 0, $total_count = true, $integer = null ) { 1353 1357 $forum_id = bbp_get_forum_id( $forum_id ); 1354 $topics = get_post_meta( $forum_id, '_bbp_topic_count_hidden', true ); 1358 $meta_key = empty( $total_count ) ? '_bbp_topic_count_hidden' : '_bbp_topic_reply_count_hidden'; 1359 $topics = (int) get_post_meta( $forum_id, $meta_key, true ); 1355 1360 $filter = ( true === $integer ) 1356 1361 ? 'bbp_get_forum_topic_count_hidden_int' … … 1358 1363 1359 1364 return apply_filters( $filter, $topics, $forum_id ); 1365 } 1366 1367 /** 1368 * Output total hidden reply count of a forum (hidden includes trashed, spammed, 1369 * and pending replies) 1370 * 1371 * @since 2.6.0 bbPress (r6922) 1372 * 1373 * @param int $forum_id Optional. Forum id 1374 * @param bool $total_count Optional. To get the total count or normal count? 1375 * @param boolean $integer Optional. Whether or not to format the result 1376 */ 1377 function bbp_forum_reply_count_hidden( $forum_id = 0, $total_count = true, $integer = false ) { 1378 echo bbp_get_forum_reply_count_hidden( $forum_id, $total_count, $integer ); 1379 } 1380 /** 1381 * Return total hidden reply count of a forum (hidden includes trashed, 1382 * spammed and pending replies) 1383 * 1384 * @since 2.6.0 bbPress (r6922) 1385 * 1386 * @param int $forum_id Optional. Forum id 1387 * @param bool $total_count Optional. To get the total count or normal 1388 * count? 1389 * @param boolean $integer Optional. Whether or not to format the result 1390 * @return int Forum reply count 1391 */ 1392 function bbp_get_forum_reply_count_hidden( $forum_id = 0, $total_count = true, $integer = false ) { 1393 $forum_id = bbp_get_forum_id( $forum_id ); 1394 $meta_key = empty( $total_count ) ? '_bbp_reply_count_hidden' : '_bbp_total_reply_count_hidden'; 1395 $replies = (int) get_post_meta( $forum_id, $meta_key, true ); 1396 $filter = ( true === $integer ) 1397 ? 'bbp_get_forum_reply_count_hidden_int' 1398 : 'bbp_get_forum_reply_count_hidden'; 1399 1400 return apply_filters( $filter, $replies, $forum_id ); 1360 1401 } 1361 1402
Note: See TracChangeset
for help on using the changeset viewer.