PluginProbe
bbPress / 2.6.19
bbPress v2.6.19
2.6.19 2.6.18 2.6.17 trunk 2.0 2.0-beta-1 2.0-beta-2b 2.0-beta-3 2.0-beta-3b 2.0-rc-2 2.0-rc-3 2.0-rc-4 2.0-rc-5 2.0.1 2.0.2 2.0.3 2.1 2.1-beta-1 2.1-rc1 2.1-rc2 2.1-rc3 2.1-rc4 2.1.1 2.1.2 2.1.3 All 74 releases
← All changes | includes/users/template.php +98 -61 2.6.18 → 2.6.19 View file →
@@ -14,9 +14,9 @@
14 14
15 15 /**
16 16 * Extension of WP_User_Query to allow easy looping
17 17 *
18 - * @since 2.6.0 bbPress (r6330)
18 + * @since 2.6.0 bbPress (r6332)
19 19 */
20 20 class BBP_User_Query extends WP_User_Query {
21 21
22 22 /**
@@ -21,9 +21,9 @@
21 21
22 22 /**
23 23 * The amount of users for the current query.
24 24 *
25 - * @since 2.6.0 bbPress (r6330)
25 + * @since 2.6.0 bbPress (r6332)
26 26 * @access public
27 27 * @var int
28 28 */
29 29 public $user_count = 0;
@@ -30,9 +30,9 @@
30 30
31 31 /**
32 32 * Index of the current item in the loop.
33 33 *
34 - * @since 2.6.0 bbPress (r6330)
34 + * @since 2.6.0 bbPress (r6332)
35 35 * @access public
36 36 * @var int
37 37 */
38 38 public $current_user = -1;
@@ -39,9 +39,9 @@
39 39
40 40 /**
41 41 * Whether the loop has started and the caller is in the loop.
42 42 *
43 - * @since 2.6.0 bbPress (r6330)
43 + * @since 2.6.0 bbPress (r6332)
44 44 * @access public
45 45 * @var bool
46 46 */
47 47 public $in_the_loop = false;
@@ -48,9 +48,9 @@
48 48
49 49 /**
50 50 * The current user.
51 51 *
52 - * @since 2.6.0 bbPress (r6330)
52 + * @since 2.6.0 bbPress (r6332)
53 53 * @access public
54 54 * @var WP_User
55 55 */
56 56 public $user;
@@ -57,9 +57,9 @@
57 57
58 58 /**
59 59 * PHP5 constructor.
60 60 *
61 - * @since 2.6.0 bbPress (r6330)
61 + * @since 2.6.0 bbPress (r6334)
62 62 * @access public
63 63 *
64 64 * @param null|string|array $query Optional. The query variables.
65 65 */
@@ -72,9 +72,9 @@
72 72
73 73 /**
74 74 * Set up the next user and iterate current user index.
75 75 *
76 - * @since 2.6.0 bbPress (r6330)
76 + * @since 2.6.0 bbPress (r6332)
77 77 * @access public
78 78 *
79 79 * @return WP_User Next user.
80 80 */
@@ -90,9 +90,9 @@
90 90 *
91 91 * Retrieves the next user, sets up the user, sets the 'in the loop'
92 92 * property to true.
93 93 *
94 - * @since 2.6.0 bbPress (r6330)
94 + * @since 2.6.0 bbPress (r6332)
95 95 * @access public
96 96 *
97 97 * @global WP_User $user
98 98 */
@@ -104,9 +104,9 @@
104 104
105 105 /**
106 106 * Fires once the loop is started.
107 107 *
108 - * @since 2.6.0 bbPress (r6330)
108 + * @since 2.6.0 bbPress (r6332)
109 109 *
110 110 * @param WP_Query &$this The WP_Query instance (passed by reference).
111 111 */
112 112 do_action_ref_array( 'loop_start', array( &$this ) );
@@ -119,9 +119,9 @@
119 119 * Determines whether there are more users available in the loop.
120 120 *
121 121 * Calls the {@see 'loop_end'} action when the loop is complete.
122 122 *
123 - * @since 2.6.0 bbPress (r6330)
123 + * @since 2.6.0 bbPress (r6332)
124 124 * @access public
125 125 *
126 126 * @return bool True if users are available, false if end of loop.
127 127 */
@@ -132,9 +132,9 @@
132 132
133 133 /**
134 134 * Fires once the loop has ended.
135 135 *
136 - * @since 2.6.0 bbPress (r6330)
136 + * @since 2.6.0 bbPress (r6332)
137 137 *
138 138 * @param WP_Query &$this The WP_Query instance (passed by reference).
139 139 */
140 140 do_action_ref_array( 'loop_end', array( &$this ) );
@@ -150,9 +150,9 @@
150 150
151 151 /**
152 152 * Rewind the users and reset user index.
153 153 *
154 - * @since 2.6.0 bbPress (r6330)
154 + * @since 2.6.0 bbPress (r6332)
155 155 * @access public
156 156 */
157 157 public function rewind_users() {
158 158 $this->current_user = -1;
@@ -165,9 +165,9 @@
165 165
166 166 /**
167 167 * The main user loop.
168 168 *
169 - * @since 2.6.0 bbPress (r6330)
169 + * @since 2.6.0 bbPress (r6332)
170 170 *
171 171 * @param array $args All the arguments supported by {@link WP_User_Query}
172 172 * @return object Multidimensional array of user information
173 173 */
@@ -196,9 +196,9 @@
196 196
197 197 /**
198 198 * Whether there are more users available in the loop
199 199 *
200 - * @since 2.6.0 bbPress (r2464)
200 + * @since 2.6.0 bbPress (r6332)
201 201 *
202 202 * @return object User information
203 203 */
204 204 function bbp_users() {
@@ -207,9 +207,9 @@
207 207
208 208 /**
209 209 * Loads up the current user in the loop
210 210 *
211 - * @since 2.6.0 bbPress (r2464)
211 + * @since 2.6.0 bbPress (r6332)
212 212 *
213 213 * @return object User information
214 214 */
215 215 function bbp_the_user() {
@@ -316,9 +316,9 @@
316 316 * This function relies on the $filter parameter to decide how to sanitize
317 317 * the field value that it finds. Since it uses the WP_User object's magic
318 318 * __get() method, it can also be used to get user_meta values.
319 319 *
320 - * @since 2.0.0 bbPress (r2688)
320 + * @since 2.1.0 bbPress (r3634)
321 321 *
322 322 * @param string $field Field to get
323 323 * @param string $filter How to filter the field value (null|raw|db|display|edit)
324 324 */
@@ -473,9 +473,9 @@
473 473
474 474 /**
475 475 * Output a users nicename to the screen
476 476 *
477 - * @since 2.3.0 bbPress (r4671)
477 + * @since 2.3.0 bbPress (r4672)
478 478 *
479 479 * @param int $user_id User ID whose nicename to get
480 480 * @param array $args before|after|user_id|force
481 481 */
@@ -484,9 +484,9 @@
484 484 }
485 485 /**
486 486 * Return a users nicename to the screen
487 487 *
488 - * @since 2.3.0 bbPress (r4671)
488 + * @since 2.3.0 bbPress (r4672)
489 489 *
490 490 * @param int $user_id User ID whose nicename to get
491 491 * @param array $args before|after|user_id|force
492 492 * @return string User nicename, maybe wrapped in before/after strings
@@ -849,9 +849,9 @@
849 849 *
850 850 * This might happen if a user was deleted but their content was retained, or
851 851 * if something went wrong during saving anonymous user data to the database.
852 852 *
853 - * @since 2.6.0 bbPress (r6561)
853 + * @since 2.6.0 bbPress (r6562)
854 854 *
855 855 * @param int $object_id For additional context only, usually a post ID
856 856 *
857 857 * @return string
@@ -869,9 +869,9 @@
869 869 * Convenience function to ensure proper template functions are called
870 870 * and correct filters are executed. Used primarily to display topic
871 871 * and reply author information in the anonymous form template-part.
872 872 *
873 - * @since 2.5.0 bbPress (r5119)
873 + * @since 2.5.0 bbPress (r5120)
874 874 *
875 875 * @param int $post_id
876 876 */
877 877 function bbp_author_display_name( $post_id = 0 ) {
@@ -884,9 +884,9 @@
884 884 * Convenience function to ensure proper template functions are called
885 885 * and correct filters are executed. Used primarily to display topic
886 886 * and reply author information in the anonymous form template-part.
887 887 *
888 - * @since 2.5.0 bbPress (r5119)
888 + * @since 2.5.0 bbPress (r5120)
889 889 *
890 890 * @param int $post_id
891 891 *
892 892 * @return string The name of the author
@@ -919,9 +919,9 @@
919 919 * Convenience function to ensure proper template functions are called
920 920 * and correct filters are executed. Used primarily to display topic
921 921 * and reply author information in the anonymous user form template-part.
922 922 *
923 - * @since 2.5.0 bbPress (r5119)
923 + * @since 2.5.0 bbPress (r5120)
924 924 *
925 925 * @param int $post_id
926 926 */
927 927 function bbp_author_email( $post_id = 0 ) {
@@ -934,9 +934,9 @@
934 934 * Convenience function to ensure proper template functions are called
935 935 * and correct filters are executed. Used primarily to display topic
936 936 * and reply author information in the anonymous user form template-part.
937 937 *
938 - * @since 2.5.0 bbPress (r5119)
938 + * @since 2.5.0 bbPress (r5120)
939 939 *
940 940 * @param int $post_id
941 941 *
942 942 * @return string The email of the author
@@ -969,9 +969,9 @@
969 969 * Convenience function to ensure proper template functions are called
970 970 * and correct filters are executed. Used primarily to display topic
971 971 * and reply author information in the anonymous user form template-part.
972 972 *
973 - * @since 2.5.0 bbPress (r5119)
973 + * @since 2.5.0 bbPress (r5120)
974 974 *
975 975 * @param int $post_id
976 976 */
977 977 function bbp_author_url( $post_id = 0 ) {
@@ -984,9 +984,9 @@
984 984 * Convenience function to ensure proper template functions are called
985 985 * and correct filters are executed. Used primarily to display topic
986 986 * and reply author information in the anonymous user form template-part.
987 987 *
988 - * @since 2.5.0 bbPress (r5119)
988 + * @since 2.5.0 bbPress (r5120)
989 989 *
990 990 * @param int $post_id
991 991 *
992 992 * @return string The url of the author
@@ -1017,9 +1017,9 @@
1017 1017
1018 1018 /**
1019 1019 * Output the link to the user's favorites page (profile page)
1020 1020 *
1021 - * @since 2.0.0 bbPress (r2652)
1021 + * @since 2.0.0 bbPress (r2660)
1022 1022 * @since 2.6.0 bbPress (r6308) Add pagination if in the loop
1023 1023 *
1024 1024 * @param int $user_id Optional. User id
1025 1025 */
@@ -1028,9 +1028,9 @@
1028 1028 }
1029 1029 /**
1030 1030 * Return the link to the user's favorites page (profile page)
1031 1031 *
1032 - * @since 2.0.0 bbPress (r2652)
1032 + * @since 2.0.0 bbPress (r2660)
1033 1033 * @since 2.6.0 bbPress (r6308) Add pagination if in the loop
1034 1034 *
1035 1035 * @param int $user_id Optional. User id
1036 1036 * @return string Permanent link to user profile page
@@ -1092,9 +1092,9 @@
1092 1092 /**
1093 1093 * Output the link to make a topic favorite/remove a topic from favorites
1094 1094 *
1095 1095 * @since 2.0.0 bbPress (r2652)
1096 - * @since 2.6.0 bbPress (r6308) Add 'redirect_to' support
1096 + * @since 2.6.0 bbPress (r6307) Add 'redirect_to' support
1097 1097 *
1098 1098 * @param array $args See {@link bbp_get_user_favorites_link()}
1099 1099 * @param int $user_id Optional. User id
1100 1100 * @param bool $wrap Optional. If you want to wrap the link in <span id="favorite-toggle">.
@@ -1108,9 +1108,9 @@
1108 1108 * Return the link to make a topic favorite/remove a topic from
1109 1109 * favorites
1110 1110 *
1111 1111 * @since 2.0.0 bbPress (r2652)
1112 - * @since 2.6.0 bbPress (r6308) Add 'redirect_to' support
1112 + * @since 2.6.0 bbPress (r6307) Add 'redirect_to' support
1113 1113 *
1114 1114 * @param array $args This function supports these arguments:
1115 1115 * - subscribe: Favorite text
1116 1116 * - unsubscribe: Unfavorite text
@@ -1162,10 +1162,10 @@
1162 1162 } else {
1163 1163 $object_id = absint( $r['object_id'] );
1164 1164 }
1165 1165
1166 - // Bail if empty
1167 - if ( empty( $user_id ) || empty( $object_id ) || empty( $object_type ) ) {
1166 + // Validate the object before checking its favorite state
1167 + if ( empty( $user_id ) || empty( $object_id ) || ! bbp_current_user_can_toggle_engagement( $object_id, $object_type, 'favorite', 'remove' ) ) {
1168 1168 return false;
1169 1169 }
1170 1170
1171 1171 // No link if you can't edit yourself
@@ -1174,8 +1174,13 @@
1174 1174 }
1175 1175
1176 1176 // Decide which link to show
1177 1177 $is_fav = bbp_is_user_favorite( $user_id, $object_id );
1178 + $toggle_action = ! empty( $is_fav ) ? 'remove' : 'add';
1179 + if ( ! bbp_current_user_can_toggle_engagement( $object_id, $object_type, 'favorite', $toggle_action ) ) {
1180 + return false;
1181 + }
1182 +
1178 1183 if ( ! empty( $is_fav ) ) {
1179 1184 $text = $r['favorited'];
1180 1185 $q_args = array(
1181 1186 'action' => 'bbp_favorite_remove',
@@ -1297,9 +1302,9 @@
1297 1302 /**
1298 1303 * Output the link to subscribe/unsubscribe from a topic
1299 1304 *
1300 1305 * @since 2.0.0 bbPress (r2668)
1301 - * @since 2.6.0 bbPress (r6308) Add 'redirect_to' support
1306 + * @since 2.6.0 bbPress (r6307) Add 'redirect_to' support
1302 1307 *
1303 1308 * @param array $args See {@link bbp_get_user_subscribe_link()}
1304 1309 * @param int $user_id Optional. User id
1305 1310 * @param bool $wrap Optional. If you want to wrap the link in <span id="subscription-toggle">.
@@ -1310,9 +1315,9 @@
1310 1315 /**
1311 1316 * Return the link to subscribe/unsubscribe from a forum or topic
1312 1317 *
1313 1318 * @since 2.0.0 bbPress (r2668)
1314 - * @since 2.6.0 bbPress (r6308) Add 'redirect_to' support
1319 + * @since 2.6.0 bbPress (r6307) Add 'redirect_to' support
1315 1320 *
1316 1321 * @param array $args This function supports these arguments:
1317 1322 * - subscribe: Subscribe text
1318 1323 * - unsubscribe: Unsubscribe text
@@ -1364,10 +1369,10 @@
1364 1369 } else {
1365 1370 $object_id = absint( $r['object_id'] );
1366 1371 }
1367 1372
1368 - // Bail if anything is missing
1369 - if ( empty( $user_id ) || empty( $object_id ) || empty( $object_type ) ) {
1373 + // Validate the object before checking its subscription state
1374 + if ( empty( $user_id ) || empty( $object_id ) || ! bbp_current_user_can_toggle_engagement( $object_id, $object_type, 'subscription', 'remove' ) ) {
1370 1375 return false;
1371 1376 }
1372 1377
1373 1378 // No link if you can't edit yourself
@@ -1375,9 +1380,14 @@
1375 1380 return false;
1376 1381 }
1377 1382
1378 1383 // Decide which link to show
1379 - $is_subscribed = bbp_is_user_subscribed( $user_id, $object_id );
1384 + $is_subscribed = bbp_is_user_subscribed( $user_id, $object_id, $object_type );
1385 + $toggle_action = ! empty( $is_subscribed ) ? 'remove' : 'add';
1386 + if ( ! bbp_current_user_can_toggle_engagement( $object_id, $object_type, 'subscription', $toggle_action ) ) {
1387 + return false;
1388 + }
1389 +
1380 1390 if ( ! empty( $is_subscribed ) ) {
1381 1391 $text = $r['unsubscribe'];
1382 1392 $q_args = array(
1383 1393 'action' => 'bbp_unsubscribe',
@@ -1398,11 +1408,11 @@
1398 1408 $q_args['redirect_to'] = urlencode( $r['redirect_to'] );
1399 1409 }
1400 1410
1401 1411 // URL
1402 - $url = esc_url( wp_nonce_url( add_query_arg( $q_args ), 'toggle-subscription_' . $object_id ) );
1412 + $url = esc_url( wp_nonce_url( add_query_arg( $q_args ), 'toggle-subscription_post_' . $object_id ) );
1403 1413 $sub = $is_subscribed ? ' class="is-subscribed"' : '';
1404 - $html = sprintf( '%s<span id="subscribe-%d" %s><a href="%s" class="subscription-toggle" data-bbp-object-id="%d" data-bbp-object-type="%d" data-bbp-nonce="%s">%s</a></span>%s', $r['before'], $object_id, $sub, $url, $object_id, $object_type, wp_create_nonce( 'toggle-subscription_' . $object_id ), $text, $r['after'] );
1414 + $html = sprintf( '%s<span id="subscribe-%d" %s><a href="%s" class="subscription-toggle" data-bbp-object-id="%d" data-bbp-object-type="%s" data-bbp-nonce="%s">%s</a></span>%s', $r['before'], $object_id, $sub, $url, $object_id, $object_type, wp_create_nonce( 'toggle-subscription_post_' . $object_id ), $text, $r['after'] );
1405 1415
1406 1416 // Initial output is wrapped in a span, ajax output is hooked to this
1407 1417 if ( ! empty( $wrap ) ) {
1408 1418 $html = '<span id="subscription-toggle">' . $html . '</span>';
@@ -1442,9 +1452,9 @@
1442 1452
1443 1453 /**
1444 1454 * Display pending email change notice on user edit page
1445 1455 *
1446 - * @since 2.6.0 bbPress (r5660)
1456 + * @since 2.6.0 bbPress (r5661)
1447 1457 */
1448 1458 function bbp_notice_edit_user_pending_email() {
1449 1459
1450 1460 // Bail if not on users own profile
@@ -1545,9 +1555,9 @@
1545 1555 <select name="display_name" id="display_name">
1546 1556
1547 1557 <?php foreach ( $public_display as $id => $item ) : ?>
1548 1558
1549 - <option id="<?php echo $id; ?>" value="<?php echo esc_attr( $item ); ?>"<?php selected( $bbp->displayed_user->display_name, $item ); ?>><?php echo $item; ?></option>
1559 + <option id="<?php echo esc_attr( $id ); ?>" value="<?php echo esc_attr( $item ); ?>"<?php selected( $bbp->displayed_user->display_name, $item ); ?>><?php echo esc_html( $item ); ?></option>
1550 1560
1551 1561 <?php endforeach; ?>
1552 1562
1553 1563 </select>
@@ -1557,9 +1567,9 @@
1557 1567
1558 1568 /**
1559 1569 * Output blog role selector (for user edit)
1560 1570 *
1561 - * @since 2.0.0 bbPress (r2688)
1571 + * @since 2.2.0 bbPress (r4288)
1562 1572 */
1563 1573 function bbp_edit_user_blog_role() {
1564 1574
1565 1575 // Bail if no user is being edited
@@ -1589,9 +1599,9 @@
1589 1599
1590 1600 /**
1591 1601 * Output forum role selector (for user edit)
1592 1602 *
1593 - * @since 2.2.0 bbPress (r4284)
1603 + * @since 2.2.0 bbPress (r4288)
1594 1604 */
1595 1605 function bbp_edit_user_forums_role() {
1596 1606
1597 1607 // Bail if no user is being edited
@@ -1621,9 +1631,9 @@
1621 1631
1622 1632 /**
1623 1633 * Filter whether password fields are displayed on a bbPress user profile.
1624 1634 *
1625 - * @since 2.6.17
1635 + * @since 2.6.17 bbPress (r7514)
1626 1636 *
1627 1637 * @param bool $show Whether to show the password fields.
1628 1638 * @param WP_User $profile_user User being edited.
1629 1639 * @return bool Whether to show the password fields.
@@ -1653,9 +1663,9 @@
1653 1663
1654 1664 /**
1655 1665 * Output the language chooser (for user edit)
1656 1666 *
1657 - * @since 2.6.0 bbPress (r6488)
1667 + * @since 2.6.0 bbPress (r6489)
1658 1668 *
1659 1669 * @param array $args See wp_dropdown_languages()
1660 1670 * @return string
1661 1671 */
@@ -1677,9 +1687,9 @@
1677 1687 *
1678 1688 * Used to avoid cross-site request forgeries when checking posted user profile
1679 1689 * form content.
1680 1690 *
1681 - * @since 2.6.15 bbPress (r7397)
1691 + * @since 2.6.15 bbPress (r7398)
1682 1692 *
1683 1693 * @param int $user_id
1684 1694 *
1685 1695 * @return bool True if this is a user profile post request with valid nonce
@@ -1716,9 +1726,9 @@
1716 1726
1717 1727 /**
1718 1728 * Output the link to the user's topics
1719 1729 *
1720 - * @since 2.2.0 bbPress (r4225)
1730 + * @since 2.2.0 bbPress (r4228)
1721 1731 *
1722 1732 * @param int $user_id Optional. User id
1723 1733 */
1724 1734 function bbp_user_topics_created_url( $user_id = 0 ) {
@@ -1726,9 +1736,9 @@
1726 1736 }
1727 1737 /**
1728 1738 * Return the link to the user's topics
1729 1739 *
1730 - * @since 2.2.0 bbPress (r4225)
1740 + * @since 2.2.0 bbPress (r4228)
1731 1741 *
1732 1742 * @param int $user_id Optional. User id
1733 1743 * @return string Permanent link to user profile page
1734 1744 */
@@ -1772,9 +1782,9 @@
1772 1782
1773 1783 /**
1774 1784 * Output the link to the user's replies
1775 1785 *
1776 - * @since 2.2.0 bbPress (r4225)
1786 + * @since 2.2.0 bbPress (r4228)
1777 1787 *
1778 1788 * @param int $user_id Optional. User id
1779 1789 */
1780 1790 function bbp_user_replies_created_url( $user_id = 0 ) {
@@ -1782,9 +1792,9 @@
1782 1792 }
1783 1793 /**
1784 1794 * Return the link to the user's replies
1785 1795 *
1786 - * @since 2.2.0 bbPress (r4225)
1796 + * @since 2.2.0 bbPress (r4228)
1787 1797 *
1788 1798 * @param int $user_id Optional. User id
1789 1799 * @return string Permanent link to user profile page
1790 1800 */
@@ -1884,9 +1894,9 @@
1884 1894
1885 1895 /**
1886 1896 * Output the select element used to save a user's language
1887 1897 *
1888 - * @since 2.6.0 bbPress (r6488)
1898 + * @since 2.6.0 bbPress (r6489)
1889 1899 *
1890 1900 * @param array $args See wp_dropdown_languages()
1891 1901 */
1892 1902 function bbp_user_languages_dropdown( $args = array() ) {
@@ -1895,9 +1905,9 @@
1895 1905
1896 1906 /**
1897 1907 * Return the select element used to save a user's language.
1898 1908 *
1899 - * @since 2.6.0 bbPress (r6488)
1909 + * @since 2.6.0 bbPress (r6489)
1900 1910 *
1901 1911 * @param array $args See wp_dropdown_languages()
1902 1912 * @return string
1903 1913 */
@@ -2083,9 +2093,9 @@
2083 2093
2084 2094 /**
2085 2095 * Output the author link of a post
2086 2096 *
2087 - * @since 2.0.0 bbPress (r2875)
2097 + * @since 2.0.0 bbPress (r2874)
2088 2098 *
2089 2099 * @param array $args Optional. If it is an integer, it is used as post id.
2090 2100 */
2091 2101 function bbp_author_link( $args = array() ) {
@@ -2093,9 +2103,9 @@
2093 2103 }
2094 2104 /**
2095 2105 * Return the author link of the post
2096 2106 *
2097 - * @since 2.0.0 bbPress (r2875)
2107 + * @since 2.0.0 bbPress (r2874)
2098 2108 *
2099 2109 * @param array $args Optional. If an integer, it is used as reply id.
2100 2110 * @return string Author link of reply
2101 2111 */
@@ -2115,8 +2125,13 @@
2115 2125 ),
2116 2126 'get_author_link'
2117 2127 );
2118 2128
2129 + // An explicitly empty post ID must not fall back to the current loop post
2130 + if ( ( is_numeric( $args ) || ( is_array( $args ) && array_key_exists( 'post_id', $args ) ) ) && empty( $r['post_id'] ) ) {
2131 + return apply_filters( 'bbp_get_author_link', '-', $r, $args );
2132 + }
2133 +
2119 2134 // Confirmed topic
2120 2135 if ( bbp_is_topic( $r['post_id'] ) ) {
2121 2136 return bbp_get_topic_author_link( $r );
2122 2137
@@ -2198,9 +2213,10 @@
2198 2213
2199 2214 /**
2200 2215 * Check if the user can access a specific forum
2201 2216 *
2202 - * @since 2.0.0 bbPress (r3127)
2217 + * @since 2.0.0 bbPress (r3057)
2218 + * @since 2.6.19 bbPress (r7676) Check forum ancestors by default.
2203 2219 *
2204 2220 * @return bool
2205 2221 */
2206 2222 function bbp_user_can_view_forum( $args = array() ) {
@@ -2210,9 +2226,9 @@
2210 2226 $args,
2211 2227 array(
2212 2228 'user_id' => bbp_get_current_user_id(),
2213 2229 'forum_id' => bbp_get_forum_id(),
2214 - 'check_ancestors' => false
2230 + 'check_ancestors' => true
2215 2231 ),
2216 2232 'user_can_view_forum'
2217 2233 );
2218 2234
@@ -2244,9 +2260,9 @@
2244 2260
2245 2261 /**
2246 2262 * Check if the current user can publish topics
2247 2263 *
2248 - * @since 2.0.0 bbPress (r3127)
2264 + * @since 2.0.0 bbPress (r3366)
2249 2265 *
2250 2266 * @return bool
2251 2267 */
2252 2268 function bbp_current_user_can_publish_topics() {
@@ -2298,9 +2314,9 @@
2298 2314
2299 2315 /**
2300 2316 * Check if the current user can publish replies
2301 2317 *
2302 - * @since 2.0.0 bbPress (r3127)
2318 + * @since 2.0.0 bbPress (r3366)
2303 2319 *
2304 2320 * @return bool
2305 2321 */
2306 2322 function bbp_current_user_can_publish_replies() {
@@ -2428,9 +2444,9 @@
2428 2444
2429 2445 /**
2430 2446 * Performs a series of checks to ensure the current user can create replies.
2431 2447 *
2432 - * @since 2.0.0 bbPress (r3127)
2448 + * @since 2.0.0 bbPress (r3366)
2433 2449 *
2434 2450 * @return bool
2435 2451 */
2436 2452 function bbp_current_user_can_access_create_reply_form() {
@@ -2459,12 +2475,33 @@
2459 2475 return (bool) apply_filters( 'bbp_current_user_can_access_create_reply_form', (bool) $retval );
2460 2476 }
2461 2477
2462 2478 /**
2479 + * Check if the current user can access structural topic moderation actions.
2480 + *
2481 + * This covers topic merges, topic splits, and reply moves. Their handlers
2482 + * perform the same capability checks independently when processing a request.
2483 + *
2484 + * @since 2.6.19 bbPress (r7618)
2485 + *
2486 + * @param int $topic_id Optional. Topic ID.
2487 + * @return bool True if the current user can moderate and edit the topic.
2488 + */
2489 +function bbp_current_user_can_access_topic_moderation( $topic_id = 0 ) {
2490 + $topic_id = bbp_get_topic_id( $topic_id );
2491 + $retval = ! empty( $topic_id )
2492 + && current_user_can( 'moderate', $topic_id )
2493 + && current_user_can( 'edit_topic', $topic_id );
2494 +
2495 + // Filter & return
2496 + return (bool) apply_filters( 'bbp_current_user_can_access_topic_moderation', $retval, $topic_id );
2497 +}
2498 +
2499 +/**
2463 2500 * Performs a series of checks to ensure the current user should see the
2464 2501 * anonymous user form fields.
2465 2502 *
2466 - * @since 2.5.0 bbPress (r5119)
2503 + * @since 2.5.0 bbPress (r5120)
2467 2504 *
2468 2505 * @return bool
2469 2506 */
2470 2507 function bbp_current_user_can_access_anonymous_user_form() {
@@ -2493,9 +2530,9 @@
2493 2530
2494 2531 /**
2495 2532 * Output the moderators of a forum
2496 2533 *
2497 - * @since 2.6.0 bbPress
2534 + * @since 2.6.0 bbPress (r6056)
2498 2535 *
2499 2536 * @param int $forum_id Optional. Topic id
2500 2537 * @param array $args See {@link bbp_get_moderator_list()}
2501 2538 */
@@ -2505,9 +2542,9 @@
2505 2542
2506 2543 /**
2507 2544 * Return the moderators for an object
2508 2545 *
2509 - * @since 2.6.0 bbPress
2546 + * @since 2.6.0 bbPress (r6056)
2510 2547 *
2511 2548 * @param int $object_id Optional. Object id
2512 2549 * @param array $args This function supports these arguments:
2513 2550 * - before: Before the tag list