Changeset 3860
- Timestamp:
- 05/01/2012 10:08:50 PM (13 years ago)
- Location:
- branches/plugin
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-includes/bbp-core-caps.php
r3758 r3860 556 556 * sites that have global forums enabled want to create topics and replies 557 557 * 558 * @since bbPress (r3860) 559 * 560 * @uses apply_filters() Allow override of hardcoded anonymous role 561 * @return string 562 */ 563 function bbp_get_anonymous_role() { 564 return apply_filters( 'bbp_get_anonymous_role', 'bbp_anonymous' ); 565 } 566 567 /** 568 * The participant role for registered users without roles 569 * 570 * This is primarily for multisite compatibility when users without roles on 571 * sites that have global forums enabled want to create topics and replies 572 * 558 573 * @since bbPress (r3410) 559 574 * 575 * @uses apply_filters() Allow override of hardcoded participant role 576 * @return string 577 */ 578 function bbp_get_participant_role() { 579 return apply_filters( 'bbp_get_participant_role', 'bbp_participant' ); 580 } 581 582 /** 583 * The moderator role for bbPress users 584 * 585 * @since bbPress (r3410) 586 * 560 587 * @param string $role 561 * @uses apply_filters() 588 * @uses apply_filters() Allow override of hardcoded moderator role 562 589 * @return string 563 590 */ 564 function bbp_get_participant_role() {565 566 // Hardcoded participant role567 $role = 'bbp_participant';568 569 // Allow override570 return apply_filters( 'bbp_get_participant_role', $role );571 }572 573 /**574 * The moderator role for bbPress users575 *576 * @since bbPress (r3410)577 *578 * @param string $role579 * @uses apply_filters()580 * @return string581 */582 591 function bbp_get_moderator_role() { 583 584 // Hardcoded moderated user role 585 $role = 'bbp_moderator'; 586 587 // Allow override 588 return apply_filters( 'bbp_get_moderator_role', $role ); 592 return apply_filters( 'bbp_get_moderator_role', 'bbp_moderator' ); 589 593 } 590 594 -
branches/plugin/bbp-includes/bbp-reply-template.php
r3845 r3860 950 950 * @uses bbp_get_reply_author_url() To get the reply author url 951 951 * @uses bbp_get_reply_author_avatar() To get the reply author avatar 952 * bbp_get_reply_author_display_name() To get the reply author display952 * @uses bbp_get_reply_author_display_name() To get the reply author display 953 953 * name 954 * @uses bbp_get_user_display_role() To get the reply author display role 955 * @uses bbp_get_reply_author_id() To get the reply author id 954 956 * @uses apply_filters() Calls 'bbp_get_reply_author_link' with the 955 957 * author link and args … … 962 964 'type' => 'both', 963 965 'size' => 80, 964 'sep' => ' ' 966 'sep' => ' ', 967 'show_role' => true 965 968 ); 966 969 $r = bbp_parse_args( $args, $defaults, 'get_reply_author_link' ); … … 998 1001 $author_link[] = sprintf( '<a href="%1$s"%2$s%3$s>%4$s</a>', $author_url, $link_title, $link_class, $link_text ); 999 1002 } 1003 1004 if ( true === $show_role ) { 1005 $author_link[] = bbp_get_reply_author_role( array( 'reply_id' => $reply_id ) ); 1006 } 1007 1000 1008 $author_link = join( $sep, $author_link ); 1001 1009 … … 1107 1115 1108 1116 return apply_filters( 'bbp_get_reply_author_email', $author_email, $reply_id ); 1117 } 1118 1119 /** 1120 * Output the reply author role 1121 * 1122 * @since bbPress (r3860) 1123 * 1124 * @param array $args Optional. 1125 * @uses bbp_get_reply_author_role() To get the reply author role 1126 */ 1127 function bbp_reply_author_role( $args = array() ) { 1128 echo bbp_get_reply_author_role( $args ); 1129 } 1130 /** 1131 * Return the reply author role 1132 * 1133 * @since bbPress (r3860) 1134 * 1135 * @param array $args Optional. 1136 * @uses bbp_get_reply_id() To get the reply id 1137 * @uses bbp_get_user_display_role() To get the user display role 1138 * @uses bbp_get_reply_author_id() To get the reply author id 1139 * @uses apply_filters() Calls bbp_get_reply_author_role with the author 1140 * role & args 1141 * @return string Reply author role 1142 */ 1143 function bbp_get_reply_author_role( $args = array() ) { 1144 $defaults = array( 1145 'reply_id' => 0, 1146 'class' => 'bbp-author-role', 1147 'before' => '', 1148 'after' => '' 1149 ); 1150 $args = bbp_parse_args( $args, $defaults, 'get_reply_author_role' ); 1151 extract( $args, EXTR_SKIP ); 1152 1153 $reply_id = bbp_get_reply_id( $reply_id ); 1154 $role = bbp_get_user_display_role( bbp_get_reply_author_id( $reply_id ) ); 1155 $author_role = sprintf( '%1$s<div class="%2$s">%3$s</div>%4$s', $before, $class, $role, $after ); 1156 1157 return apply_filters( 'bbp_get_reply_author_role', $author_role, $args ); 1109 1158 } 1110 1159 … … 1748 1797 $classes[] = 'bbp-parent-topic-' . bbp_get_reply_topic_id( $reply_id ); 1749 1798 $classes[] = 'user-id-' . bbp_get_reply_author_id( $reply_id ); 1750 $classes[] = ( bbp_get_reply_author_id( $reply_id ) == bbp_get_topic_author_id( bbp_get_reply_topic_id( $reply_id ) ) ? 'topic-author' : '' ); 1799 $classes[] = ( bbp_get_reply_author_id( $reply_id ) == bbp_get_topic_author_id( bbp_get_reply_topic_id( $reply_id ) ) ? 'topic-author' : '' ); 1751 1800 $classes = array_filter( $classes ); 1752 1801 $classes = get_post_class( $classes, $reply_id ); -
branches/plugin/bbp-includes/bbp-topic-template.php
r3855 r3860 1214 1214 * @uses bbp_is_topic_anonymous() To check if the topic is by an 1215 1215 * anonymous user 1216 * @uses bbp_get_topic_author_url() To get the topic author url 1216 1217 * @uses bbp_get_topic_author_avatar() To get the topic author avatar 1217 * @uses bbp_get_topic_author_url() To get the topic author url 1218 * @uses bbp_get_topic_author_display_name() To get the topic author display 1219 * name 1220 * @uses bbp_get_user_display_role() To get the topic author display role 1221 * @uses bbp_get_topic_author_id() To get the topic author id 1218 1222 * @uses apply_filters() Calls 'bbp_get_topic_author_link' with the link 1219 1223 * and args … … 1226 1230 'type' => 'both', 1227 1231 'size' => 80, 1228 'sep' => ' ' 1232 'sep' => ' ', 1233 'show_role' => true 1229 1234 ); 1230 1235 $r = bbp_parse_args( $args, $defaults, 'get_topic_author_link' ); … … 1272 1277 $author_link[] = sprintf( '<a href="%1$s"%2$s%3$s>%4$s</a>', $author_url, $link_title, $link_class, $link_text ); 1273 1278 } 1279 1280 if ( true === $show_role ) { 1281 $author_link[] = bbp_get_topic_author_role( array( 'topic_id' => $topic_id ) ); 1282 } 1283 1274 1284 $author_link = join( $sep, $author_link ); 1275 1285 … … 1384 1394 return apply_filters( 'bbp_get_topic_author_email', $author_email, $topic_id ); 1385 1395 } 1396 1397 /** 1398 * Output the topic author role 1399 * 1400 * @since bbPress (r3860) 1401 * 1402 * @param array $args Optional. 1403 * @uses bbp_get_topic_author_role() To get the topic author role 1404 */ 1405 function bbp_topic_author_role( $args = array() ) { 1406 echo bbp_get_topic_author_role( $args ); 1407 } 1408 /** 1409 * Return the topic author role 1410 * 1411 * @since bbPress (r3860) 1412 * 1413 * @param array $args Optional. 1414 * @uses bbp_get_topic_id() To get the topic id 1415 * @uses bbp_get_user_display_role() To get the user display role 1416 * @uses bbp_get_topic_author_id() To get the topic author id 1417 * @uses apply_filters() Calls bbp_get_topic_author_role with the author 1418 * role & args 1419 * @return string topic author role 1420 */ 1421 function bbp_get_topic_author_role( $args = array() ) { 1422 $defaults = array( 1423 'topic_id' => 0, 1424 'class' => 'bbp-author-role', 1425 'before' => '', 1426 'after' => '' 1427 ); 1428 $args = bbp_parse_args( $args, $defaults, 'get_topic_author_role' ); 1429 extract( $args, EXTR_SKIP ); 1430 1431 $topic_id = bbp_get_topic_id( $topic_id ); 1432 $role = bbp_get_user_display_role( bbp_get_topic_author_id( $topic_id ) ); 1433 $author_role = sprintf( '%1$s<div class="%2$s">%3$s</div>%4$s', $before, $class, $role, $after ); 1434 1435 return apply_filters( 'bbp_get_topic_author_role', $author_role, $args ); 1436 } 1437 1386 1438 1387 1439 /** -
branches/plugin/bbp-includes/bbp-user-functions.php
r3856 r3860 1400 1400 } 1401 1401 1402 /** 1403 * Return a user's main role 1404 * 1405 * @since bbPress (r3860) 1406 * 1407 * @param int $user_id 1408 * @uses bbp_get_user_id() To get the user id 1409 * @uses get_userdata() To get the user data 1410 * @uses apply_filters() Calls 'bbp_get_user_role' with the 1411 * role and user id 1412 * @return string 1413 */ 1414 function bbp_get_user_role( $user_id = 0 ) { 1415 1416 // Validate user id 1417 $user_id = bbp_get_user_id( $user_id, false, false ); 1418 if ( empty( $user_id ) ) 1419 return false; 1420 1421 // Get userdata 1422 $user = get_userdata( $user_id ); 1423 1424 // Get the user's main role 1425 $role = isset( $user->roles ) ? array_shift( $user->roles ) : bbp_get_anonymous_role(); 1426 1427 return apply_filters( 'bbp_get_user_role', $role, $user_id, $user ); 1428 } 1429 1402 1430 /** Premissions ***************************************************************/ 1403 1431 -
branches/plugin/bbp-includes/bbp-user-template.php
r3840 r3860 376 376 $user_id = bbp_get_user_id( $user_id ); 377 377 if ( empty( $user_id ) ) 378 return ;378 return false; 379 379 380 380 // Pretty permalinks … … 400 400 return apply_filters( 'bbp_get_user_edit_profile_url', $url, $user_id, $user_nicename ); 401 401 402 } 403 404 /** 405 * Output a user's main role for display 406 * 407 * @since bbPress (r3860) 408 * 409 * @param int $user_id 410 * @uses bbp_get_user_display_role To get the user display role 411 */ 412 function bbp_user_display_role( $user_id = 0 ) { 413 echo bbp_get_user_display_role( $user_id ); 414 } 415 /** 416 * Return a user's main role for display 417 * 418 * @since bbPress (r3860) 419 * 420 * @param int $user_id 421 * @uses bbp_get_user_role() To get the main user role 422 * @uses bbp_get_moderator_role() To get the moderator role 423 * @uses bbp_get_participant_role() To get the participant role 424 * @uses bbp_get_moderator_role() To get the moderator role 425 * @uses apply_filters() Calls 'bbp_get_user_display_role' with the 426 * display role, user id, and user role 427 * @return string 428 */ 429 function bbp_get_user_display_role( $user_id = 0 ) { 430 431 // Validate user id 432 $user_id = bbp_get_user_id( $user_id, false, false ); 433 $user_role = bbp_get_user_role( $user_id ); 434 435 // Capes earn Vinz Clortho status 436 if ( is_super_admin( $user_id ) ) { 437 $role = __( 'Key Master', 'bbpress' ); 438 439 // Not the keymaster of Gozer 440 } else { 441 442 // Get the user's main role for display 443 switch ( $user_role ) { 444 445 /** bbPress Roles *********************************************/ 446 447 // Anonymous 448 case bbp_get_anonymous_role() : 449 $role = __( 'Guest', 'bbpress' ); 450 break; 451 452 // Multisite Participant Role 453 case bbp_get_participant_role() : 454 $role = __( 'Member', 'bbpress' ); 455 break; 456 457 // Moderator 458 case bbp_get_moderator_role() : 459 $role = __( 'Moderator', 'bbpress' ); 460 break; 461 462 /** WordPress Core Roles **************************************/ 463 464 case 'administrator' : 465 case 'editor' : 466 case 'author' : 467 case 'contributor' : 468 case 'subscriber' : 469 default : // Any other role (plugins, etc...) 470 global $wp_roles; 471 472 // Load roles if not set 473 if ( !isset( $wp_roles ) ) 474 $wp_roles = new WP_Roles(); 475 476 // Get a translated role name 477 if ( !empty( $wp_roles->role_names[$user_role] ) ) 478 $role = translate_user_role( $wp_roles->role_names[$user_role] ); 479 480 // Fallback for registered user 481 else 482 $role = __( 'Member', 'bbpress' ); 483 484 break; 485 } 486 } 487 488 return apply_filters( 'bbp_get_user_display_role', $role, $user_id, $user_role ); 402 489 } 403 490 … … 1447 1534 /** 1448 1535 * Output a users topic count 1449 * 1536 * 1450 1537 * @since bbPress (r3632) 1451 1538 * 1452 1539 * @param int $user_id 1453 1540 * @uses bbp_get_user_topic_count() 1454 * @return string 1541 * @return string 1455 1542 */ 1456 1543 function bbp_user_topic_count( $user_id = 0 ) { … … 1459 1546 /** 1460 1547 * Return a users reply count 1461 * 1548 * 1462 1549 * @since bbPress (r3632) 1463 1550 * … … 1466 1553 * @uses get_user_meta() 1467 1554 * @uses apply_filters() 1468 * @return string 1555 * @return string 1469 1556 */ 1470 1557 function bbp_get_user_topic_count( $user_id = 0 ) { … … 1482 1569 /** 1483 1570 * Output a users reply count 1484 * 1571 * 1485 1572 * @since bbPress (r3632) 1486 1573 * 1487 1574 * @param int $user_id 1488 1575 * @uses bbp_get_user_reply_count() 1489 * @return string 1576 * @return string 1490 1577 */ 1491 1578 function bbp_user_reply_count( $user_id = 0 ) { … … 1494 1581 /** 1495 1582 * Return a users reply count 1496 * 1583 * 1497 1584 * @since bbPress (r3632) 1498 1585 * … … 1501 1588 * @uses get_user_meta() 1502 1589 * @uses apply_filters() 1503 * @return string 1590 * @return string 1504 1591 */ 1505 1592 function bbp_get_user_reply_count( $user_id = 0 ) { … … 1517 1604 /** 1518 1605 * Output a users total post count 1519 * 1606 * 1520 1607 * @since bbPress (r3632) 1521 1608 * 1522 1609 * @param int $user_id 1523 1610 * @uses bbp_get_user_post_count() 1524 * @return string 1611 * @return string 1525 1612 */ 1526 1613 function bbp_user_post_count( $user_id = 0 ) { … … 1529 1616 /** 1530 1617 * Return a users total post count 1531 * 1618 * 1532 1619 * @since bbPress (r3632) 1533 1620 * … … 1536 1623 * @uses get_user_meta() 1537 1624 * @uses apply_filters() 1538 * @return string 1625 * @return string 1539 1626 */ 1540 1627 function bbp_get_user_post_count( $user_id = 0 ) { 1541 1628 1542 1629 // Validate user id 1543 1630 $user_id = bbp_get_user_id( $user_id ); -
branches/plugin/bbp-theme-compat/css/bbpress.css
r3848 r3860 200 200 padding-right: 20px; 201 201 word-break: break-word; 202 } 203 204 li.bbp-body div.bbp-topic-author .bbp-author-role, 205 li.bbp-body div.bbp-reply-author .bbp-author-role { 206 font-size: 11px; 207 font-style: italic; 202 208 } 203 209 -
branches/plugin/bbp-themes/bbp-twentyten/css/bbpress.css
r3835 r3860 139 139 text-align: center; 140 140 vertical-align: top; 141 } 142 #content td.bbp-topic-author .bbp-author-role, 143 #content td.bbp-reply-author .bbp-author-role { 144 font-size: 11px; 145 font-style: italic; 141 146 } 142 147 .bbp-topic-title {
Note: See TracChangeset
for help on using the changeset viewer.