Changeset 2998 for branches/plugin/bbp-includes/bbp-forum-template.php
- Timestamp:
- 04/21/2011 02:51:30 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-includes/bbp-forum-template.php
r2993 r2998 1190 1190 1191 1191 /** 1192 * Output the visibility of the forum 1193 * 1194 * @since bbPress (r2997) 1195 * 1196 * @param int $forum_id Optional. Forum id 1197 * @uses bbp_get_forum_visibility() To get the forum visibility 1198 */ 1199 function bbp_forum_visibility( $forum_id = 0 ) { 1200 echo bbp_get_forum_visibility( $forum_id ); 1201 } 1202 /** 1203 * Return the visibility of the forum 1204 * 1205 * @since bbPress (r2997) 1206 * 1207 * @param int $forum_id Optional. Forum id 1208 * @uses bbp_get_forum_id() To get the forum id 1209 * @uses get_post_visibility() To get the forum's visibility 1210 * @uses apply_filters() Calls 'bbp_get_forum_visibility' with the visibility 1211 * and forum id 1212 * @return string Status of forum 1213 */ 1214 function bbp_get_forum_visibility( $forum_id = 0 ) { 1215 $forum_id = bbp_get_forum_id( $forum_id ); 1216 1217 return apply_filters( 'bbp_get_forum_visibility', get_post_meta( $forum_id, '_bbp_visibility', true ) ); 1218 } 1219 1220 /** 1192 1221 * Is the forum a category? 1193 1222 * … … 1257 1286 1258 1287 /** 1288 * Is the forum public? 1289 * 1290 * @since bbPress (r2997) 1291 * 1292 * @param int $forum_id Optional. Forum id 1293 * @param bool $check_ancestors Check if the ancestors are public (only if 1294 * they're a category) 1295 * @uses get_post_meta() To get the forum public meta 1296 * @uses bbp_get_forum_ancestors() To get the forum ancestors 1297 * @uses bbp_is_forum_category() To check if the forum is a category 1298 * @uses bbp_is_forum_closed() To check if the forum is closed 1299 * @return bool True if closed, false if not 1300 */ 1301 function bbp_is_forum_public( $forum_id = 0, $check_ancestors = true ) { 1302 global $bbp; 1303 1304 $forum_id = bbp_get_forum_id( $forum_id ); 1305 $visibility = bbp_get_forum_visibility( $forum_id ); 1306 1307 // If post status is public, return true 1308 $retval = ( 'public' == $visibility ) ? true : false; 1309 1310 // Check ancestors and inherit their privacy setting for display 1311 if ( !empty( $check_ancestors ) ) { 1312 $ancestors = bbp_get_forum_ancestors( $forum_id ); 1313 1314 foreach ( (array) $ancestors as $ancestor ) { 1315 if ( bbp_is_forum( $ancestor ) && bbp_is_forum_public( $ancestor, false ) ) { 1316 $retval = true; 1317 } 1318 } 1319 } 1320 1321 return apply_filters( 'bbp_is_forum_public', (bool) $retval ); 1322 } 1323 1324 /** 1259 1325 * Is the forum private? 1260 1326 * … … 1274 1340 1275 1341 $forum_id = bbp_get_forum_id( $forum_id ); 1276 $visibility = get_post_meta( $forum_id, '_bbp_visibility', true ); 1277 1278 if ( !empty( $visibility ) && 'private' == $visibility ) 1279 return true; 1280 1342 $visibility = bbp_get_forum_visibility( $forum_id ); 1343 1344 // If post status is private, return true 1345 $retval = ( 'private' == $visibility ) ? true : false; 1346 1347 // Check ancestors and inherit their privacy setting for display 1281 1348 if ( !empty( $check_ancestors ) ) { 1282 1349 $ancestors = bbp_get_forum_ancestors( $forum_id ); 1283 1350 1284 1351 foreach ( (array) $ancestors as $ancestor ) { 1285 if ( bbp_is_forum_private( $ancestor, false ) ) 1286 return true; 1352 if ( bbp_is_forum( $ancestor ) && bbp_is_forum_private( $ancestor, false ) ) { 1353 $retval = true; 1354 } 1287 1355 } 1288 1356 } 1289 1357 1290 return false; 1358 return apply_filters( 'bbp_is_forum_private', (bool) $retval ); 1359 } 1360 1361 /** 1362 * Is the forum hidden? 1363 * 1364 * @since bbPress (r2997) 1365 * 1366 * @param int $forum_id Optional. Forum id 1367 * @param bool $check_ancestors Check if the ancestors are private (only if 1368 * they're a category) 1369 * @uses get_post_meta() To get the forum private meta 1370 * @uses bbp_get_forum_ancestors() To get the forum ancestors 1371 * @uses bbp_is_forum_category() To check if the forum is a category 1372 * @uses bbp_is_forum_closed() To check if the forum is closed 1373 * @return bool True if closed, false if not 1374 */ 1375 function bbp_is_forum_hidden( $forum_id = 0, $check_ancestors = true ) { 1376 global $bbp; 1377 1378 $forum_id = bbp_get_forum_id( $forum_id ); 1379 $visibility = bbp_get_forum_visibility( $forum_id ); 1380 1381 // If post status is private, return true 1382 $retval = ( 'hidden' == $visibility ) ? true : false; 1383 1384 // Check ancestors and inherit their privacy setting for display 1385 if ( !empty( $check_ancestors ) ) { 1386 $ancestors = bbp_get_forum_ancestors( $forum_id ); 1387 1388 foreach ( (array) $ancestors as $ancestor ) { 1389 if ( bbp_is_forum( $ancestor ) && bbp_is_forum_hidden( $ancestor, false ) ) { 1390 $retval = true; 1391 } 1392 } 1393 } 1394 1395 return apply_filters( 'bbp_is_forum_hidden', (bool) $retval ); 1291 1396 } 1292 1397
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)