Skip to:
Content

bbPress.org

Changeset 5675


Ignore:
Timestamp:
04/15/2015 02:16:32 AM (11 years ago)
Author:
johnjamesjacoby
Message:

Replies: Normalize admin links:

  • Remove superfluous (int) type casts
  • Pass $args into filters
  • Use bbp_get_edit_rewrite_id() where applicable
  • Whitespace beside ! operators
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/replies/template.php

    r5588 r5675  
    16841684
    16851685        // Get the reply to use it's ID and post_parent
    1686         $reply = bbp_get_reply( bbp_get_reply_id( (int) $r['id'] ) );
     1686        $reply = bbp_get_reply( bbp_get_reply_id( $r['id'] ) );
    16871687
    16881688        // Bail if no reply or user cannot reply
     
    18801880        ), 'get_reply_admin_links' );
    18811881
    1882         $r['id'] = bbp_get_reply_id( (int) $r['id'] );
     1882        $r['id'] = bbp_get_reply_id( $r['id'] );
    18831883
    18841884        // If post is a topic, return the topic admin links instead
     
    18881888
    18891889        // If post is not a reply, return
    1890         if ( !bbp_is_reply( $r['id'] ) ) {
     1890        if ( ! bbp_is_reply( $r['id'] ) ) {
    18911891            return;
    18921892        }
     
    19721972        ), 'get_reply_edit_link' );
    19731973
    1974         $reply = bbp_get_reply( bbp_get_reply_id( (int) $r['id'] ) );
     1974        $reply = bbp_get_reply( bbp_get_reply_id( $r['id'] ) );
    19751975
    19761976        // Bypass check if user has caps
    1977         if ( !current_user_can( 'edit_others_replies' ) ) {
     1977        if ( ! current_user_can( 'edit_others_replies' ) ) {
    19781978
    19791979            // User cannot edit or it is past the lock time
    1980             if ( empty( $reply ) || !current_user_can( 'edit_reply', $reply->ID ) || bbp_past_edit_lock( $reply->post_date_gmt ) ) {
     1980            if ( empty( $reply ) || ! current_user_can( 'edit_reply', $reply->ID ) || bbp_past_edit_lock( $reply->post_date_gmt ) ) {
    19811981                return;
    19821982            }
     
    19931993        $retval = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" class="bbp-reply-edit-link">' . $r['edit_text'] . '</a>' . $r['link_after'];
    19941994
    1995         return apply_filters( 'bbp_get_reply_edit_link', $retval, $r );
     1995        return apply_filters( 'bbp_get_reply_edit_link', $retval, $r, $args );
    19961996    }
    19971997
     
    20242024        global $wp_rewrite;
    20252025
    2026         $bbp   = bbpress();
    20272026        $reply = bbp_get_reply( bbp_get_reply_id( $reply_id ) );
    20282027        if ( empty( $reply ) ) {
     
    20342033        // Pretty permalinks
    20352034        if ( $wp_rewrite->using_permalinks() ) {
    2036             $url = trailingslashit( $reply_link ) . $bbp->edit_id;
     2035            $url = trailingslashit( $reply_link ) . bbp_get_edit_rewrite_id();
    20372036            $url = trailingslashit( $url );
    20382037
    20392038        // Unpretty permalinks
    20402039        } else {
    2041             $url = add_query_arg( array( bbp_get_reply_post_type() => $reply->post_name, $bbp->edit_id => '1' ), $reply_link );
     2040            $url = add_query_arg( array( bbp_get_reply_post_type() => $reply->post_name, bbp_get_edit_rewrite_id() => '1' ), $reply_link );
    20422041        }
    20432042
     
    21002099        ), 'get_reply_trash_link' );
    21012100
     2101        $reply = bbp_get_reply( bbp_get_reply_id( $r['id'] ) );
     2102
     2103        if ( empty( $reply ) || ! current_user_can( 'delete_reply', $reply->ID ) ) {
     2104            return;
     2105        }
     2106
    21022107        $actions = array();
    2103         $reply   = bbp_get_reply( bbp_get_reply_id( (int) $r['id'] ) );
    2104 
    2105         if ( empty( $reply ) || !current_user_can( 'delete_reply', $reply->ID ) ) {
    2106             return;
    2107         }
    21082108
    21092109        if ( bbp_is_reply_trash( $reply->ID ) ) {
     
    21202120        $retval = $r['link_before'] . implode( $r['sep'], $actions ) . $r['link_after'];
    21212121
    2122         return apply_filters( 'bbp_get_reply_trash_link', $retval, $r );
     2122        return apply_filters( 'bbp_get_reply_trash_link', $retval, $r, $args );
    21232123    }
    21242124
     
    21702170        ), 'get_reply_spam_link' );
    21712171
    2172         $reply = bbp_get_reply( bbp_get_reply_id( (int) $r['id'] ) );
    2173 
    2174         if ( empty( $reply ) || !current_user_can( 'moderate', $reply->ID ) ) {
     2172        $reply = bbp_get_reply( bbp_get_reply_id( $r['id'] ) );
     2173
     2174        if ( empty( $reply ) || ! current_user_can( 'moderate', $reply->ID ) ) {
    21752175            return;
    21762176        }
    21772177
    2178         $display  = bbp_is_reply_spam( $reply->ID ) ? $r['unspam_text'] : $r['spam_text'];
    2179         $uri      = add_query_arg( array( 'action' => 'bbp_toggle_reply_spam', 'reply_id' => $reply->ID ) );
    2180         $uri      = wp_nonce_url( $uri, 'spam-reply_' . $reply->ID );
    2181         $retval   = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" class="bbp-reply-spam-link">' . $display . '</a>' . $r['link_after'];
    2182 
    2183         return apply_filters( 'bbp_get_reply_spam_link', $retval, $r );
     2178        $display = bbp_is_reply_spam( $reply->ID ) ? $r['unspam_text'] : $r['spam_text'];
     2179        $uri     = add_query_arg( array( 'action' => 'bbp_toggle_reply_spam', 'reply_id' => $reply->ID ) );
     2180        $uri     = wp_nonce_url( $uri, 'spam-reply_' . $reply->ID );
     2181        $retval  = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" class="bbp-reply-spam-link">' . $display . '</a>' . $r['link_after'];
     2182
     2183        return apply_filters( 'bbp_get_reply_spam_link', $retval, $r, $args );
    21842184    }
    21852185
     
    22382238        $topic_id = bbp_get_reply_topic_id( $reply_id );
    22392239
    2240         if ( empty( $reply_id ) || !current_user_can( 'moderate', $topic_id ) ) {
     2240        if ( empty( $reply_id ) || ! current_user_can( 'moderate', $topic_id ) ) {
    22412241            return;
    22422242        }
     
    22492249        $retval = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" title="' . $r['split_title'] . '" class="bbp-reply-move-link">' . $r['split_text'] . '</a>' . $r['link_after'];
    22502250
    2251         return apply_filters( 'bbp_get_reply_move_link', $retval, $r );
     2251        return apply_filters( 'bbp_get_reply_move_link', $retval, $r, $args );
    22522252    }
    22532253
     
    23062306        $topic_id = bbp_get_reply_topic_id( $reply_id );
    23072307
    2308         if ( empty( $reply_id ) || !current_user_can( 'moderate', $topic_id ) ) {
     2308        if ( empty( $reply_id ) || ! current_user_can( 'moderate', $topic_id ) ) {
    23092309            return;
    23102310        }
    23112311
    2312         $uri =  add_query_arg( array(
     2312        $uri = add_query_arg( array(
    23132313            'action'   => 'split',
    23142314            'reply_id' => $reply_id
     
    23172317        $retval = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" title="' . $r['split_title'] . '" class="bbp-topic-split-link">' . $r['split_text'] . '</a>' . $r['link_after'];
    23182318
    2319         return apply_filters( 'bbp_get_topic_split_link', $retval, $r );
     2319        return apply_filters( 'bbp_get_topic_split_link', $retval, $r, $args );
    23202320    }
    23212321
     
    23672367        ), 'get_reply_approve_link' );
    23682368
    2369         $reply = bbp_get_reply( bbp_get_reply_id( (int) $r['id'] ) );
    2370 
    2371         if ( empty( $reply ) || !current_user_can( 'moderate', $reply->ID ) ) {
     2369        $reply = bbp_get_reply( bbp_get_reply_id( $r['id'] ) );
     2370
     2371        if ( empty( $reply ) || ! current_user_can( 'moderate', $reply->ID ) ) {
    23722372            return;
    23732373        }
     
    23782378        $retval  = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" class="bbp-reply-approve-link">' . $display . '</a>' . $r['link_after'];
    23792379
    2380         return apply_filters( 'bbp_get_reply_approve_link', $retval, $r );
     2380        return apply_filters( 'bbp_get_reply_approve_link', $retval, $r, $args );
    23812381    }
    23822382
Note: See TracChangeset for help on using the changeset viewer.