Changeset 6137
- Timestamp:
- 12/08/2016 03:43:15 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/replies/functions.php
r6136 r6137 1616 1616 } 1617 1617 1618 // What's the reply id? 1619 $reply_id = bbp_get_reply_id( (int) $_GET['reply_id'] ); 1620 1618 1621 // Get possible reply-handler toggles 1619 $ possible_actions = bbp_get_reply_toggles();1620 1621 // Bail if action s aren't meant for this function1622 if ( ! in_array( $action, $ possible_actions, true ) ) {1622 $toggles = bbp_get_reply_toggles( $reply_id ); 1623 1624 // Bail if action isn't meant for this function 1625 if ( ! in_array( $action, $toggles, true ) ) { 1623 1626 return; 1624 1627 } 1625 1626 $reply_id = (int) $_GET['reply_id']; // What's the reply id?1627 $post_data = array( 'ID' => $reply_id ); // Prelim array1628 1628 1629 1629 // Make sure reply exists … … 1634 1634 1635 1635 // What is the user doing here? 1636 if ( ! current_user_can( 'edit_reply', $reply ->ID ) || ( 'bbp_toggle_reply_trash' === $action && ! current_user_can( 'delete_reply', $reply->ID) ) ) {1636 if ( ! current_user_can( 'edit_reply', $reply_id ) || ( 'bbp_toggle_reply_trash' === $action && ! current_user_can( 'delete_reply', $reply_id ) ) ) { 1637 1637 bbp_add_error( 'bbp_toggle_reply_permission', __( '<strong>ERROR:</strong> You do not have the permission to do that!', 'bbpress' ) ); 1638 1638 return; 1639 1639 } 1640 1640 1641 // Sub action?1642 $sub_action = in_array( $_GET['sub_action'], array( 'trash', 'untrash', 'delete' ), true)1641 // Sub-action? 1642 $sub_action = ! empty( $_GET['sub_action'] ) 1643 1643 ? sanitize_key( $_GET['sub_action'] ) 1644 1644 : false; 1645 1646 // Preliminary array 1647 $post_data = array( 'ID' => $reply_id ); 1645 1648 1646 1649 // Do the reply toggling … … 1727 1730 case 'bbp_toggle_reply_trash' : 1728 1731 1729 // Bail if no subaction1730 if ( empty( $r['sub_action'] ) ) {1731 break;1732 }1733 1734 1732 // Which subaction? 1735 1733 switch ( $r['sub_action'] ) { … … 1797 1795 * @since 2.6.0 bbPress (r6133) 1798 1796 * 1797 * @param int $reply_id Optional. Reply id. 1798 * 1799 1799 * @return array 1800 1800 */ 1801 function bbp_get_reply_toggles( ) {1801 function bbp_get_reply_toggles( $reply_id = 0 ) { 1802 1802 return apply_filters( 'bbp_get_toggle_reply_actions', array( 1803 1803 'bbp_toggle_reply_spam', 1804 1804 'bbp_toggle_reply_trash', 1805 1805 'bbp_toggle_reply_approve' 1806 ) );1806 ), $reply_id ); 1807 1807 } 1808 1808
Note: See TracChangeset
for help on using the changeset viewer.