- Timestamp:
- 04/29/2024 06:50:42 PM (19 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-templates/bp-legacy/buddypress-functions.php
r13709 r13822 512 512 $class = did_action( 'admin_bar_menu' ) ? 'admin-bar-on' : 'admin-bar-off'; 513 513 514 echo '<div id="sitewide-notice" class="' . $class. '">';514 echo '<div id="sitewide-notice" class="' . esc_attr( $class ) . '">'; 515 515 bp_message_get_notices(); 516 516 echo '</div>'; … … 985 985 check_admin_referer( 'post_update', '_wpnonce_post_update' ); 986 986 987 if ( ! is_user_logged_in() ) 987 if ( ! is_user_logged_in() ) { 988 988 exit( '-1' ); 989 990 if ( empty( $_POST['content'] ) ) 991 exit( '-1<div id="message" class="error bp-ajax-message"><p>' . __( 'Please enter some content to post.', 'buddypress' ) . '</p></div>' ); 989 } 990 991 if ( empty( $_POST['content'] ) ) { 992 exit( '-1<div id="message" class="error bp-ajax-message"><p>' . esc_html__( 'Please enter some content to post.', 'buddypress' ) . '</p></div>' ); 993 } 992 994 993 995 $activity_id = 0; … … 1025 1027 1026 1028 if ( false === $activity_id ) { 1027 exit( '-1<div id="message" class="error bp-ajax-message"><p>' . __( 'There was a problem posting your update. Please try again.', 'buddypress' ) . '</p></div>' );1029 exit( '-1<div id="message" class="error bp-ajax-message"><p>' . esc_html__( 'There was a problem posting your update. Please try again.', 'buddypress' ) . '</p></div>' ); 1028 1030 } elseif ( is_wp_error( $activity_id ) && $activity_id->get_error_code() ) { 1029 exit( '-1<div id="message" class="error bp-ajax-message"><p>' . $activity_id->get_error_message() . '</p></div>' );1031 exit( '-1<div id="message" class="error bp-ajax-message"><p>' . esc_html( $activity_id->get_error_message() ) . '</p></div>' ); 1030 1032 } 1031 1033 … … 1146 1148 check_admin_referer( 'bp_activity_delete_link' ); 1147 1149 1148 if ( ! is_user_logged_in() ) 1150 if ( ! is_user_logged_in() ) { 1149 1151 exit( '-1' ); 1150 1151 if ( empty( $_POST['id'] ) || ! is_numeric( $_POST['id'] ) ) 1152 } 1153 1154 if ( empty( $_POST['id'] ) || ! is_numeric( $_POST['id'] ) ) { 1152 1155 exit( '-1' ); 1156 } 1153 1157 1154 1158 $activity = new BP_Activity_Activity( (int) $_POST['id'] ); 1155 1159 1156 1160 // Check access. 1157 if ( ! bp_activity_user_can_delete( $activity ) ) 1161 if ( ! bp_activity_user_can_delete( $activity ) ) { 1158 1162 exit( '-1' ); 1163 } 1159 1164 1160 1165 /** This action is documented in bp-activity/bp-activity-actions.php */ 1161 1166 do_action( 'bp_activity_before_action_delete_activity', $activity->id, $activity->user_id ); 1162 1167 1163 if ( ! bp_activity_delete( array( 'id' => $activity->id, 'user_id' => $activity->user_id ) ) ) 1164 exit( '-1<div id="message" class="error bp-ajax-message"><p>' . __( 'There was a problem when deleting. Please try again.', 'buddypress' ) . '</p></div>' ); 1168 if ( ! bp_activity_delete( array( 'id' => $activity->id, 'user_id' => $activity->user_id ) ) ) { 1169 exit( '-1<div id="message" class="error bp-ajax-message"><p>' . esc_html__( 'There was a problem when deleting. Please try again.', 'buddypress' ) . '</p></div>' ); 1170 } 1165 1171 1166 1172 /** This action is documented in bp-activity/bp-activity-actions.php */ … … 1195 1201 1196 1202 // Check access. 1197 if ( ! bp_current_user_can( 'bp_moderate' ) && $comment->user_id != bp_loggedin_user_id() ) 1203 if ( ! bp_current_user_can( 'bp_moderate' ) && $comment->user_id != bp_loggedin_user_id() ) { 1198 1204 exit( '-1' ); 1205 } 1199 1206 1200 1207 /** This action is documented in bp-activity/bp-activity-actions.php */ 1201 1208 do_action( 'bp_activity_before_action_delete_activity', $_POST['id'], $comment->user_id ); 1202 1209 1203 if ( ! bp_activity_delete_comment( $comment->item_id, $comment->id ) ) 1204 exit( '-1<div id="message" class="error bp-ajax-message"><p>' . __( 'There was a problem when deleting. Please try again.', 'buddypress' ) . '</p></div>' ); 1210 if ( ! bp_activity_delete_comment( $comment->item_id, $comment->id ) ) { 1211 exit( '-1<div id="message" class="error bp-ajax-message"><p>' . esc_html__( 'There was a problem when deleting. Please try again.', 'buddypress' ) . '</p></div>' ); 1212 } 1205 1213 1206 1214 /** This action is documented in bp-activity/bp-activity-actions.php */ … … 1224 1232 1225 1233 // Check that user is logged in, Activity Streams are enabled, and Akismet is present. 1226 if ( ! is_user_logged_in() || ! bp_is_active( 'activity' ) || empty( $bp->activity->akismet ) ) 1234 if ( ! is_user_logged_in() || ! bp_is_active( 'activity' ) || empty( $bp->activity->akismet ) ) { 1227 1235 exit( '-1' ); 1236 } 1228 1237 1229 1238 // Check an item ID was passed. 1230 if ( empty( $_POST['id'] ) || ! is_numeric( $_POST['id'] ) ) 1239 if ( empty( $_POST['id'] ) || ! is_numeric( $_POST['id'] ) ) { 1231 1240 exit( '-1' ); 1241 } 1232 1242 1233 1243 // Is the current user allowed to spam items? 1234 if ( ! bp_activity_user_can_mark_spam() ) 1244 if ( ! bp_activity_user_can_mark_spam() ) { 1235 1245 exit( '-1' ); 1246 } 1236 1247 1237 1248 // Load up the activity item. 1238 1249 $activity = new BP_Activity_Activity( (int) $_POST['id'] ); 1239 if ( empty( $activity->component ) ) 1250 if ( empty( $activity->component ) ) { 1240 1251 exit( '-1' ); 1252 } 1241 1253 1242 1254 // Check nonce. … … 1346 1358 $activity = ! empty( $activity_array['activities'][0] ) ? $activity_array['activities'][0] : false; 1347 1359 1348 if ( empty( $activity ) ) 1360 if ( empty( $activity ) ) { 1349 1361 exit; // @todo: error? 1362 } 1350 1363 1351 1364 /** … … 1364 1377 $content = apply_filters_ref_array( 'bp_get_activity_content_body', array( $activity->content, &$activity ) ); 1365 1378 1379 // phpcs:ignore WordPress.Security.EscapeOutput 1366 1380 exit( $content ); 1367 1381 } … … 1381 1395 check_ajax_referer( 'groups_invite_uninvite_user' ); 1382 1396 1383 if ( ! $_POST['friend_id'] || ! $_POST['friend_action'] || ! $_POST['group_id'] ) 1384 return; 1385 1386 if ( ! bp_groups_user_can_send_invites( $_POST['group_id'] ) ) 1387 return; 1397 if ( ! $_POST['friend_id'] || ! $_POST['friend_action'] || ! $_POST['group_id'] ) { 1398 return; 1399 } 1400 1401 if ( ! bp_groups_user_can_send_invites( $_POST['group_id'] ) ) { 1402 return; 1403 } 1388 1404 1389 1405 $group_id = (int) $_POST['group_id']; … … 1424 1440 } 1425 1441 1442 // phpcs:disable WordPress.Security.EscapeOutput 1426 1443 echo '<li id="uid-' . esc_attr( $user->id ) . '">'; 1427 1444 echo $user->avatar_thumb; … … 1429 1446 echo '<span class="activity">' . esc_attr( $user->last_active ) . '</span>'; 1430 1447 echo '<div class="action"> 1431 <a class="button remove" href="' . wp_nonce_url( $uninvite_url, 'groups_invite_uninvite_user' ) . '" id="uid-' . esc_attr( $user->id ) . '">' .__( 'Remove Invite', 'buddypress' ) . '</a>1448 <a class="button remove" href="' . esc_url( wp_nonce_url( $uninvite_url, 'groups_invite_uninvite_user' ) ) . '" id="uid-' . esc_attr( $user->id ) . '">' . esc_html__( 'Remove Invite', 'buddypress' ) . '</a> 1432 1449 </div>'; 1433 1450 1434 1451 if ( 'is_pending' == $user_status ) { 1435 1452 /* translators: %s: user link */ 1436 echo '<p class="description">' . sprintf( __( '%s has previously requested to join this group. Sending an invitation will automatically add the member to the group.', 'buddypress' ), $user->user_link ) . '</p>';1453 echo '<p class="description">' . sprintf( esc_html__( '%s has previously requested to join this group. Sending an invitation will automatically add the member to the group.', 'buddypress' ), $user->user_link ) . '</p>'; 1437 1454 } 1438 1455 1439 1456 echo '</li>'; 1457 // phpcs:enable 1440 1458 exit; 1441 1459 … … 1476 1494 $user = get_user_by( 'id', $friend_id ); 1477 1495 if ( ! $user ) { 1478 die( __( 'No member found by that ID.', 'buddypress' ) );1496 die( esc_html__( 'No member found by that ID.', 'buddypress' ) ); 1479 1497 } 1480 1498 … … 1484 1502 1485 1503 if ( ! friends_remove_friend( bp_loggedin_user_id(), $friend_id ) ) { 1486 e cho __( 'Friendship could not be canceled.', 'buddypress' );1504 esc_html_e( 'Friendship could not be canceled.', 'buddypress' ); 1487 1505 } else { 1488 1506 $url = bp_loggedin_user_url( bp_members_get_path_chunks( array( bp_get_friends_slug(), 'add-friend', array( $friend_id ) ) ) ); 1489 echo '<a id="friend-' . esc_attr( $friend_id ) . '" class="friendship-button not_friends add" rel="add" href="' . wp_nonce_url( $url, 'friends_add_friend' ) . '">' .__( 'Add Friend', 'buddypress' ) . '</a>';1507 echo '<a id="friend-' . esc_attr( $friend_id ) . '" class="friendship-button not_friends add" rel="add" href="' . esc_url( wp_nonce_url( $url, 'friends_add_friend' ) ) . '">' . esc_html__( 'Add Friend', 'buddypress' ) . '</a>'; 1490 1508 } 1491 1509 … … 1495 1513 1496 1514 if ( ! friends_add_friend( bp_loggedin_user_id(), $friend_id ) ) { 1497 e cho __(' Friendship could not be requested.', 'buddypress' );1515 esc_html_e(' Friendship could not be requested.', 'buddypress' ); 1498 1516 } else { 1499 1517 $url = bp_loggedin_user_url( bp_members_get_path_chunks( array( bp_get_friends_slug(), 'requests', array( 'cancel', $friend_id ) ) ) ); 1500 echo '<a id="friend-' . esc_attr( $friend_id ) . '" class="remove friendship-button pending_friend requested" rel="remove" href="' . wp_nonce_url( $url, 'friends_withdraw_friendship' ) . '" class="requested">' .__( 'Cancel Friendship Request', 'buddypress' ) . '</a>';1518 echo '<a id="friend-' . esc_attr( $friend_id ) . '" class="remove friendship-button pending_friend requested" rel="remove" href="' . esc_url( wp_nonce_url( $url, 'friends_withdraw_friendship' ) ) . '" class="requested">' . esc_html__( 'Cancel Friendship Request', 'buddypress' ) . '</a>'; 1501 1519 } 1502 1520 … … 1507 1525 if ( friends_withdraw_friendship( bp_loggedin_user_id(), $friend_id ) ) { 1508 1526 $url = bp_loggedin_user_url( bp_members_get_path_chunks( array( bp_get_friends_slug(), 'add-friend', array( $friend_id ) ) ) ); 1509 echo '<a id="friend-' . esc_attr( $friend_id ) . '" class="friendship-button not_friends add" rel="add" href="' . wp_nonce_url( $url, 'friends_add_friend' ) . '">' .__( 'Add Friend', 'buddypress' ) . '</a>';1527 echo '<a id="friend-' . esc_attr( $friend_id ) . '" class="friendship-button not_friends add" rel="add" href="' . esc_url( wp_nonce_url( $url, 'friends_add_friend' ) ) . '">' . esc_html__( 'Add Friend', 'buddypress' ) . '</a>'; 1510 1528 } else { 1511 e cho __("Friendship request could not be cancelled.", 'buddypress');1529 esc_html_e("Friendship request could not be cancelled.", 'buddypress'); 1512 1530 } 1513 1531 1514 1532 // Request already pending. 1515 1533 } else { 1516 e cho __( 'Request Pending', 'buddypress' );1534 esc_html_e( 'Request Pending', 'buddypress' ); 1517 1535 } 1518 1536 … … 1535 1553 1536 1554 if ( ! friends_accept_friendship( (int) $_POST['id'] ) ) 1537 echo "-1<div id='message' class='error'><p>" . __( 'There was a problem accepting that request. Please try again.', 'buddypress' ) . '</p></div>';1555 echo "-1<div id='message' class='error'><p>" . esc_html__( 'There was a problem accepting that request. Please try again.', 'buddypress' ) . '</p></div>'; 1538 1556 1539 1557 exit; … … 1555 1573 1556 1574 if ( ! friends_reject_friendship( (int) $_POST['id'] ) ) 1557 echo "-1<div id='message' class='error'><p>" . __( 'There was a problem rejecting that request. Please try again.', 'buddypress' ) . '</p></div>';1575 echo "-1<div id='message' class='error'><p>" . esc_html__( 'There was a problem rejecting that request. Please try again.', 'buddypress' ) . '</p></div>'; 1558 1576 1559 1577 exit; … … 1610 1628 1611 1629 if ( ! groups_join_group( $group->id ) ) { 1612 _e( 'Error joining group', 'buddypress' );1630 esc_html_e( 'Error joining group', 'buddypress' ); 1613 1631 } else { 1614 1632 $leave_url = wp_nonce_url( … … 1619 1637 'groups_leave_group' 1620 1638 ); 1621 echo '<a id="group-' . esc_attr( $group->id ) . '" class="group-button leave-group" rel="leave" href="' . esc_url( $leave_url ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';1639 echo '<a id="group-' . esc_attr( $group->id ) . '" class="group-button leave-group" rel="leave" href="' . esc_url( $leave_url ) . '">' . esc_html__( 'Leave Group', 'buddypress' ) . '</a>'; 1622 1640 } 1623 1641 break; … … 1631 1649 1632 1650 if ( ! groups_accept_invite( bp_loggedin_user_id(), $group->id ) ) { 1633 _e( 'Error requesting membership', 'buddypress' );1651 esc_html_e( 'Error requesting membership', 'buddypress' ); 1634 1652 } else { 1635 1653 $leave_url = wp_nonce_url( … … 1640 1658 'groups_leave_group' 1641 1659 ); 1642 echo '<a id="group-' . esc_attr( $group->id ) . '" class="group-button leave-group" rel="leave" href="' . esc_url( $leave_url ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';1660 echo '<a id="group-' . esc_attr( $group->id ) . '" class="group-button leave-group" rel="leave" href="' . esc_url( $leave_url ) . '">' . esc_html__( 'Leave Group', 'buddypress' ) . '</a>'; 1643 1661 } 1644 1662 break; … … 1648 1666 1649 1667 if ( ! groups_send_membership_request( [ 'user_id' => bp_loggedin_user_id(), 'group_id' => $group->id ] ) ) { 1650 _e( 'Error requesting membership', 'buddypress' );1668 esc_html_e( 'Error requesting membership', 'buddypress' ); 1651 1669 } else { 1652 echo '<a id="group-' . esc_attr( $group->id ) . '" class="group-button disabled pending membership-requested" rel="membership-requested" href="' . esc_url( bp_get_group_url( $group ) ) . '">' . __( 'Request Sent', 'buddypress' ) . '</a>';1670 echo '<a id="group-' . esc_attr( $group->id ) . '" class="group-button disabled pending membership-requested" rel="membership-requested" href="' . esc_url( bp_get_group_url( $group ) ) . '">' . esc_html__( 'Request Sent', 'buddypress' ) . '</a>'; 1653 1671 } 1654 1672 break; … … 1658 1676 1659 1677 if ( ! groups_leave_group( $group->id ) ) { 1660 _e( 'Error leaving group', 'buddypress' );1678 esc_html_e( 'Error leaving group', 'buddypress' ); 1661 1679 } elseif ( 'public' === $group->status ) { 1662 1680 $join_url = wp_nonce_url( … … 1667 1685 'groups_join_group' 1668 1686 ); 1669 echo '<a id="group-' . esc_attr( $group->id ) . '" class="group-button join-group" rel="join" href="' . esc_url( $join_url ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>';1687 echo '<a id="group-' . esc_attr( $group->id ) . '" class="group-button join-group" rel="join" href="' . esc_url( $join_url ) . '">' . esc_html__( 'Join Group', 'buddypress' ) . '</a>'; 1670 1688 } else { 1671 1689 $request_url = wp_nonce_url( … … 1676 1694 'groups_request_membership' 1677 1695 ); 1678 echo '<a id="group-' . esc_attr( $group->id ) . '" class="group-button request-membership" rel="join" href="' . esc_url( $request_url ) . '">' . __( 'Request Membership', 'buddypress' ) . '</a>';1696 echo '<a id="group-' . esc_attr( $group->id ) . '" class="group-button request-membership" rel="join" href="' . esc_url( $request_url ) . '">' . esc_html__( 'Request Membership', 'buddypress' ) . '</a>'; 1679 1697 } 1680 1698 break; … … 1699 1717 1700 1718 if ( ! $nonce_check || ! isset( $_POST['notice_id'] ) ) { 1701 echo "-1<div id='message' class='error'><p>" . __( 'There was a problem closing the notice.', 'buddypress' ) . '</p></div>';1719 echo "-1<div id='message' class='error'><p>" . esc_html__( 'There was a problem closing the notice.', 'buddypress' ) . '</p></div>'; 1702 1720 1703 1721 } else { … … 1726 1744 // Cannot respond to a thread you're not already a recipient on. 1727 1745 if ( ! bp_current_user_can( 'bp_moderate' ) && ( ! messages_is_valid_thread( $thread_id ) || ! messages_check_thread_access( $thread_id ) ) ) { 1728 echo "-1<div id='message' class='error'><p>" . __( 'There was a problem sending that reply. Please try again.', 'buddypress' ) . '</p></div>';1746 echo "-1<div id='message' class='error'><p>" . esc_html__( 'There was a problem sending that reply. Please try again.', 'buddypress' ) . '</p></div>'; 1729 1747 die; 1730 1748 } … … 1732 1750 $result = messages_new_message( array( 'thread_id' => $thread_id, 'content' => $_REQUEST['content'] ) ); 1733 1751 1734 if ( ! empty( $result ) ) {1752 if ( ! empty( $result ) ) { 1735 1753 1736 1754 // Pretend we're in the message loop. … … 1766 1784 1767 1785 } else { 1768 echo "-1<div id='message' class='error'><p>" . __( 'There was a problem sending that reply. Please try again.', 'buddypress' ) . '</p></div>';1786 echo "-1<div id='message' class='error'><p>" . esc_html__( 'There was a problem sending that reply. Please try again.', 'buddypress' ) . '</p></div>'; 1769 1787 } 1770 1788 … … 2097 2115 if ( $message ) { 2098 2116 // Surround the message with `<p>` tags. 2099 echo wpautop( $message ); 2117 $message = wpautop( $message ); 2118 2119 echo wp_kses( 2120 $message, 2121 array( 2122 'p' => true, 2123 'a' => array( 2124 'href' => true, 2125 ), 2126 ) 2127 ); 2100 2128 } 2101 2129 } … … 2114 2142 if ( $message ) { 2115 2143 // Surround the message with `<p>` tags. 2116 echo wpautop( $message ); 2144 $message = wpautop( $message ); 2145 2146 echo wp_kses( 2147 $message, 2148 array( 2149 'p' => true, 2150 'a' => array( 2151 'href' => true, 2152 ), 2153 ) 2154 ); 2117 2155 } 2118 2156 }
Note: See TracChangeset
for help on using the changeset viewer.