Changeset 3008 for branches/plugin/bbp-includes/bbp-forum-template.php
- Timestamp:
- 04/21/2011 08:35:23 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-includes/bbp-forum-template.php
r2998 r3008 74 74 // Don't show private forums to normal users 75 75 if ( !current_user_can( 'read_private_forums' ) && empty( $r['meta_key'] ) && empty( $r['meta_value'] ) ) { 76 $r['meta_key'] = '_bbp_visibility'; 77 $r['meta_value'] = 'public'; 76 $r['meta_query'] = array( array( 77 'key' => '_bbp_visibility', 78 'value' => 'public, private', 79 'compare' => 'IN' 80 ) ); 78 81 } 79 82 … … 1186 1189 $forum_id = bbp_get_forum_id( $forum_id ); 1187 1190 1188 return apply_filters( 'bbp_get_forum_status', get_post_meta( $forum_id, '_bbp_status', true ) );1191 return apply_filters( 'bbp_get_forum_status', get_post_meta( $forum_id, '_bbp_status', true ), $forum_id ); 1189 1192 } 1190 1193 … … 1215 1218 $forum_id = bbp_get_forum_id( $forum_id ); 1216 1219 1217 return apply_filters( 'bbp_get_forum_visibility', get_post_meta( $forum_id, '_bbp_visibility', true ) );1220 return apply_filters( 'bbp_get_forum_visibility', get_post_meta( $forum_id, '_bbp_visibility', true ), $forum_id ); 1218 1221 } 1219 1222 … … 1230 1233 $forum_id = bbp_get_forum_id( $forum_id ); 1231 1234 $type = get_post_meta( $forum_id, '_bbp_forum_type', true ); 1232 1233 if ( !empty( $type ) && 'category' == $type ) 1234 return true; 1235 1236 return false; 1235 $retval = ( !empty( $type ) && 'category' == $type ); 1236 1237 return apply_filters( 'bbp_is_forum_category', (bool) $retval, $forum_id ); 1237 1238 } 1238 1239 … … 1269 1270 1270 1271 $forum_id = bbp_get_forum_id( $forum_id ); 1271 1272 if ( $bbp->closed_status_id == bbp_get_forum_status( $forum_id ) ) 1273 return true; 1272 $retval = ( $bbp->closed_status_id == bbp_get_forum_status( $forum_id ) ); 1274 1273 1275 1274 if ( !empty( $check_ancestors ) ) { … … 1277 1276 1278 1277 foreach ( (array) $ancestors as $ancestor ) { 1279 if ( bbp_is_forum_category( $ancestor, false ) && bbp_is_forum_closed( $ancestor, false ) ) 1280 return true; 1278 if ( bbp_is_forum_category( $ancestor, false ) && bbp_is_forum_closed( $ancestor, false ) ) { 1279 $retval = true; 1280 } 1281 1281 } 1282 1282 } 1283 1283 1284 return false;1284 return apply_filters( 'bbp_is_forum_closed', (bool) $retval, $forum_id, $check_ancestors ); 1285 1285 } 1286 1286 … … 1306 1306 1307 1307 // If post status is public, return true 1308 $retval = ( 'public' == $visibility ) ? true : false;1308 $retval = ( 'public' == $visibility ); 1309 1309 1310 1310 // Check ancestors and inherit their privacy setting for display … … 1319 1319 } 1320 1320 1321 return apply_filters( 'bbp_is_forum_public', (bool) $retval );1321 return apply_filters( 'bbp_is_forum_public', (bool) $retval, $forum_id, $check_ancestors ); 1322 1322 } 1323 1323 … … 1343 1343 1344 1344 // If post status is private, return true 1345 $retval = ( 'private' == $visibility ) ? true : false;1345 $retval = ( 'private' == $visibility ); 1346 1346 1347 1347 // Check ancestors and inherit their privacy setting for display … … 1356 1356 } 1357 1357 1358 return apply_filters( 'bbp_is_forum_private', (bool) $retval );1358 return apply_filters( 'bbp_is_forum_private', (bool) $retval, $forum_id, $check_ancestors ); 1359 1359 } 1360 1360 … … 1380 1380 1381 1381 // If post status is private, return true 1382 $retval = ( 'hidden' == $visibility ) ? true : false;1382 $retval = ( 'hidden' == $visibility ); 1383 1383 1384 1384 // Check ancestors and inherit their privacy setting for display … … 1393 1393 } 1394 1394 1395 return apply_filters( 'bbp_is_forum_hidden', (bool) $retval ); 1396 } 1395 return apply_filters( 'bbp_is_forum_hidden', (bool) $retval, $forum_id, $check_ancestors ); 1396 } 1397 1398 function bbp_suppress_private_forum_meta( $retval, $forum_id ) { 1399 if ( bbp_is_forum_private( $forum_id, false ) && !current_user_can( 'read_private_forums' ) ) 1400 return '-'; 1401 1402 return $retval; 1403 } 1404 add_filter( 'bbp_get_forum_topic_count', 'bbp_suppress_private_forum_meta', 10, 2 ); 1405 add_filter( 'bbp_get_forum_reply_count', 'bbp_suppress_private_forum_meta', 10, 2 ); 1406 add_filter( 'bbp_get_forum_post_count', 'bbp_suppress_private_forum_meta', 10, 2 ); 1407 add_filter( 'bbp_get_forum_freshness_link', 'bbp_suppress_private_forum_meta', 10, 2 ); 1408 1409 function bbp_suppress_private_author_link( $author_link, $args ) { 1410 if ( empty( $args['post_id'] ) || current_user_can( 'read_private_forums' ) ) 1411 return $author_link; 1412 1413 $post_type = get_post_field( 'post_type', $args['post_id'] ); 1414 1415 switch ( $post_type ) { 1416 case bbp_get_topic_post_type() : 1417 if ( bbp_is_forum_private( bbp_get_topic_forum_id( $args['post_id'] ) ) ) 1418 return ''; 1419 1420 break; 1421 1422 case bbp_get_reply_post_type() : 1423 if ( bbp_is_forum_private( bbp_get_reply_forum_id( $args['post_id'] ) ) ) 1424 return ''; 1425 1426 break; 1427 1428 default : 1429 if ( bbp_is_forum_private( $args['post_id'] ) ) 1430 return ''; 1431 1432 break; 1433 } 1434 1435 return $author_link; 1436 } 1437 add_filter( 'bbp_get_author_link', 'bbp_suppress_private_author_link', 10, 2 ); 1438 add_filter( 'bbp_get_topic_author_link', 'bbp_suppress_private_author_link', 10, 2 ); 1439 add_filter( 'bbp_get_reply_author_link', 'bbp_suppress_private_author_link', 10, 2 ); 1397 1440 1398 1441 /**
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)