Changeset 3162
- Timestamp:
- 05/15/2011 08:53:28 AM (14 years ago)
- Location:
- branches/plugin/bbp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-includes/bbp-core-hooks.php
r3150 r3162 295 295 add_filter( 'wp_insert_post_data', 'bbp_fix_post_author', 30, 2 ); 296 296 297 // Suppress private forum details 298 add_filter( 'bbp_get_forum_topic_count', 'bbp_suppress_private_forum_meta', 10, 2 ); 299 add_filter( 'bbp_get_forum_reply_count', 'bbp_suppress_private_forum_meta', 10, 2 ); 300 add_filter( 'bbp_get_forum_post_count', 'bbp_suppress_private_forum_meta', 10, 2 ); 301 add_filter( 'bbp_get_forum_freshness_link', 'bbp_suppress_private_forum_meta', 10, 2 ); 302 add_filter( 'bbp_get_author_link', 'bbp_suppress_private_author_link', 10, 2 ); 303 add_filter( 'bbp_get_topic_author_link', 'bbp_suppress_private_author_link', 10, 2 ); 304 add_filter( 'bbp_get_reply_author_link', 'bbp_suppress_private_author_link', 10, 2 ); 305 297 306 /** 298 307 * Add filters to anonymous post author data -
branches/plugin/bbp-includes/bbp-forum-template.php
r3161 r3162 1430 1430 } 1431 1431 1432 /** 1433 * Replace forum meta details for users that cannot view them. 1434 * 1435 * @since bbPress (r3162) 1436 * 1437 * @param string $retval 1438 * @param int $forum_id 1439 * 1440 * @uses bbp_is_forum_private() 1441 * @uses current_user_can() 1442 * 1443 * @return string 1444 */ 1432 1445 function bbp_suppress_private_forum_meta( $retval, $forum_id ) { 1433 1446 if ( bbp_is_forum_private( $forum_id, false ) && !current_user_can( 'read_private_forums' ) ) 1434 1447 return '-'; 1435 1448 1436 return $retval; 1437 } 1438 add_filter( 'bbp_get_forum_topic_count', 'bbp_suppress_private_forum_meta', 10, 2 ); 1439 add_filter( 'bbp_get_forum_reply_count', 'bbp_suppress_private_forum_meta', 10, 2 ); 1440 add_filter( 'bbp_get_forum_post_count', 'bbp_suppress_private_forum_meta', 10, 2 ); 1441 add_filter( 'bbp_get_forum_freshness_link', 'bbp_suppress_private_forum_meta', 10, 2 ); 1442 1449 return apply_filters( 'bbp_suppress_private_forum_meta', $retval ); 1450 } 1451 1452 /** 1453 * Replace forum author details for users that cannot view them. 1454 * 1455 * @since bbPress (r3162) 1456 * 1457 * @param string $retval 1458 * @param int $forum_id 1459 * 1460 * @uses bbp_is_forum_private() 1461 * @uses get_post_field() 1462 * @uses bbp_get_topic_post_type() 1463 * @uses bbp_is_forum_private() 1464 * @uses bbp_get_topic_forum_id() 1465 * @uses bbp_get_reply_post_type() 1466 * @uses bbp_get_reply_forum_id() 1467 * 1468 * @return string 1469 */ 1443 1470 function bbp_suppress_private_author_link( $author_link, $args ) { 1444 if ( empty( $args['post_id'] ) || current_user_can( 'read_private_forums' ) ) 1445 return $author_link; 1446 1447 $post_type = get_post_field( 'post_type', $args['post_id'] ); 1448 1449 switch ( $post_type ) { 1450 case bbp_get_topic_post_type() : 1451 if ( bbp_is_forum_private( bbp_get_topic_forum_id( $args['post_id'] ) ) ) 1452 return ''; 1453 1454 break; 1455 1456 case bbp_get_reply_post_type() : 1457 if ( bbp_is_forum_private( bbp_get_reply_forum_id( $args['post_id'] ) ) ) 1458 return ''; 1459 1460 break; 1461 1462 default : 1463 if ( bbp_is_forum_private( $args['post_id'] ) ) 1464 return ''; 1465 1466 break; 1467 } 1468 1469 return $author_link; 1470 } 1471 add_filter( 'bbp_get_author_link', 'bbp_suppress_private_author_link', 10, 2 ); 1472 add_filter( 'bbp_get_topic_author_link', 'bbp_suppress_private_author_link', 10, 2 ); 1473 add_filter( 'bbp_get_reply_author_link', 'bbp_suppress_private_author_link', 10, 2 ); 1471 1472 // Assume the author link is the return value 1473 $retval = $author_link; 1474 1475 // Show the normal author link 1476 if ( !empty( $args['post_id'] ) && !current_user_can( 'read_private_forums' ) ) { 1477 1478 // What post type are we 1479 $post_type = get_post_field( 'post_type', $args['post_id'] ); 1480 1481 switch ( $post_type ) { 1482 1483 // Topic 1484 case bbp_get_topic_post_type() : 1485 if ( bbp_is_forum_private( bbp_get_topic_forum_id( $args['post_id'] ) ) ) 1486 $retval = ''; 1487 1488 break; 1489 1490 // Reply 1491 case bbp_get_reply_post_type() : 1492 if ( bbp_is_forum_private( bbp_get_reply_forum_id( $args['post_id'] ) ) ) 1493 $retval = ''; 1494 1495 break; 1496 1497 // Post 1498 default : 1499 if ( bbp_is_forum_private( $args['post_id'] ) ) 1500 $retval = ''; 1501 1502 break; 1503 } 1504 } 1505 1506 return apply_filters( 'bbp_suppress_private_author_link', $author_link ); 1507 } 1474 1508 1475 1509 /**
Note: See TracChangeset
for help on using the changeset viewer.