Skip to:
Content

bbPress.org


Ignore:
Timestamp:
06/11/2013 04:42:26 AM (12 years ago)
Author:
johnjamesjacoby
Message:

Remove capability pre-check from admin links functions. Remove duplicate trash-removal logic that's done inside the respective trash-link generating functions. Fixes inconsistent nested capability checks within admin link functions. See #2348.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/replies/template-tags.php

    r4973 r4985  
    16851685 * @since bbPress (r2667)
    16861686 *
    1687  * @param mixed $args See {@link bbp_get_reply_admin_links()}
     1687 * @param array $args See {@link bbp_get_reply_admin_links()}
    16881688 * @uses bbp_get_reply_admin_links() To get the reply admin links
    16891689 */
    1690 function bbp_reply_admin_links( $args = '' ) {
     1690function bbp_reply_admin_links( $args = array() ) {
    16911691    echo bbp_get_reply_admin_links( $args );
    16921692}
     
    16961696     * @since bbPress (r2667)
    16971697     *
    1698      * @param mixed $args This function supports these arguments:
     1698     * @param array $args This function supports these arguments:
    16991699     *  - id: Optional. Reply id
    17001700     *  - before: HTML before the links. Defaults to
     
    17181718     * @return string Reply admin links
    17191719     */
    1720     function bbp_get_reply_admin_links( $args = '' ) {
     1720    function bbp_get_reply_admin_links( $args = array() ) {
    17211721
    17221722        // Parse arguments against default values
     
    17321732
    17331733        // If post is a topic, return the topic admin links instead
    1734         if ( bbp_is_topic( $r['id'] ) )
     1734        if ( bbp_is_topic( $r['id'] ) ) {
    17351735            return bbp_get_topic_admin_links( $args );
     1736        }
    17361737
    17371738        // If post is not a reply, return
    1738         if ( !bbp_is_reply( $r['id'] ) )
     1739        if ( !bbp_is_reply( $r['id'] ) ) {
    17391740            return;
    1740 
    1741         // Make sure user can edit this reply
    1742         if ( !current_user_can( 'edit_reply', $r['id'] ) )
     1741        }
     1742
     1743        // If topic is trashed, do not show admin links
     1744        if ( bbp_is_topic_trash( bbp_get_reply_topic_id( $r['id'] ) ) ) {
    17431745            return;
    1744 
    1745         // If topic is trashed, do not show admin links
    1746         if ( bbp_is_topic_trash( bbp_get_reply_topic_id( $r['id'] ) ) )
    1747             return;
     1746        }
    17481747
    17491748        // If no links were passed, default to the standard
     
    17591758        }
    17601759
    1761         // Check caps for trashing the topic
    1762         if ( !current_user_can( 'delete_reply', $r['id'] ) && !empty( $r['links']['trash'] ) )
    1763             unset( $r['links']['trash'] );
    1764 
    17651760        // See if links need to be unset
    17661761        $reply_status = bbp_get_reply_status( $r['id'] );
     
    17681763
    17691764            // Spam link shouldn't be visible on trashed topics
    1770             if ( bbp_get_trash_status_id() == $reply_status ) {
     1765            if ( bbp_get_trash_status_id() === $reply_status ) {
    17711766                unset( $r['links']['spam'] );
    17721767
    17731768            // Trash link shouldn't be visible on spam topics
    1774             } elseif ( isset( $r['links']['trash'] ) && ( bbp_get_spam_status_id() == $reply_status ) ) {
     1769            } elseif ( bbp_get_spam_status_id() === $reply_status ) {
    17751770                unset( $r['links']['trash'] );
    17761771            }
     
    17811776        $retval = $r['before'] . $links . $r['after'];
    17821777
    1783         return apply_filters( 'bbp_get_reply_admin_links', $retval, $r );
     1778        return apply_filters( 'bbp_get_reply_admin_links', $retval, $r, $args );
    17841779    }
    17851780
Note: See TracChangeset for help on using the changeset viewer.