Skip to:
Content

bbPress.org


Ignore:
Timestamp:
06/13/2011 07:21:03 PM (11 years ago)
Author:
johnjamesjacoby
Message:

Audit the usage of 'view=all' and create helper functions to handle frequent query arg checks and adjustments. Removes the need for passing $count_hidden between functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-reply-template.php

    r3324 r3325  
    8787
    8888        // What are the default allowed statuses (based on user caps)
    89         if ( !empty( $_GET['view'] ) && ( 'all' == $_GET['view'] && current_user_can( 'edit_others_replies' ) ) )
     89        if ( bbp_get_view_all( 'edit_others_replies' ) )
    9090            $default_status = join( ',', array( 'publish', $bbp->closed_status_id, $bbp->spam_status_id, 'trash' ) );
    9191    }
     
    162162            'next_text' => '→',
    163163            'mid_size'  => 1,
    164             'add_args'  => ( !empty( $_GET['view'] ) && 'all' == $_GET['view'] ) ? array( 'view' => 'all' ) : false
     164            'add_args'  => ( bbp_get_view_all() ) ? array( 'view' => 'all' ) : false
    165165        ) );
    166166
     
    344344     *
    345345     * @param int $reply_id Optional. Reply id
    346      * @param bool $count_hidden Optional. Count hidden (trashed/spammed)
    347      *                            replies? If $_GET['view'] == all, it is
    348      *                            automatically set to true. To override
    349      *                            this, set $count_hidden = (int) -1
    350346     * @param $string $redirect_to Optional. Pass a redirect value for use with
    351347     *                              shortcodes and other fun things.
     
    362358     * @return string Link to reply relative to paginated topic
    363359     */
    364     function bbp_get_reply_url( $reply_id = 0, $count_hidden = false, $redirect_to = '' ) {
     360    function bbp_get_reply_url( $reply_id = 0, $redirect_to = '' ) {
    365361        global $bbp, $wp_rewrite;
    366362
    367363        // Set needed variables
    368         $reply_id       = bbp_get_reply_id       ( $reply_id               );
    369         $topic_id       = bbp_get_reply_topic_id ( $reply_id               );
    370         $topic_url      = bbp_get_topic_permalink( $topic_id, $redirect_to );
    371         $reply_position = bbp_get_reply_position ( $reply_id, $topic_id    );
     364        $reply_id       = bbp_get_reply_id       ( $reply_id                           );
     365        $topic_id       = bbp_get_reply_topic_id ( $reply_id                           );
     366        $topic_url      = bbp_get_topic_permalink( $topic_id, $redirect_to             );
     367        $reply_position = bbp_get_reply_position ( $reply_id, $topic_id );
    372368
    373369        // Check if in query with pagination
     
    397393        }
    398394
    399         return apply_filters( 'bbp_get_reply_url', $url, $reply_id, $count_hidden );
     395        // Add topic view query arg back to end if it is set
     396        if ( bbp_get_view_all() )
     397            $url = bbp_add_view_all( $url );
     398
     399        return apply_filters( 'bbp_get_reply_url', $url, $reply_id, $redirect_to );
    400400    }
    401401
     
    11801180        if ( $reply_count = bbp_get_topic_reply_count( $topic_id ) ) {
    11811181
     1182            // Are we counting hidden replies too?
     1183            if ( bbp_get_view_all() )
     1184                $topic_replies = bbp_get_all_child_ids   ( $topic_id, bbp_get_reply_post_type() );
     1185            else
     1186                $topic_replies = bbp_get_public_child_ids( $topic_id, bbp_get_reply_post_type() );
     1187
    11821188            // Get reply id's
    1183             if ( $topic_replies = bbp_get_public_child_ids( $topic_id, bbp_get_reply_post_type() ) ) {
     1189            if ( !empty( $topic_replies ) ) {
    11841190
    11851191                // Reverse replies array and search for current reply position
Note: See TracChangeset for help on using the changeset viewer.