Skip to:
Content

bbPress.org

Changeset 4506


Ignore:
Timestamp:
11/24/2012 08:10:34 PM (13 years ago)
Author:
johnjamesjacoby
Message:

Extract:

  • Remove extract() usages from /topics/template-tags.php.
  • See #2056.
File:
1 edited

Legend:

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

    r4363 r4506  
    8585    global $wp_rewrite;
    8686
     87    /** Defaults **************************************************************/
     88
    8789    // What are the default allowed statuses (based on user caps)
    8890    if ( bbp_get_view_all() ) {
     
    117119        $default['taxonomy'] = bbp_get_topic_tag_tax_id();
    118120    }
    119     $bbp_t = bbp_parse_args( $args, $default, 'has_topics' );
    120 
    121     // Extract the query variables
    122     extract( $bbp_t );
     121
     122    /** Setup *****************************************************************/
     123
     124    // Parse arguments with default values
     125    $r = bbp_parse_args( $args, $default, 'has_topics' );
    123126
    124127    // Get bbPress
     
    126129
    127130    // Call the query
    128     $bbp->topic_query = new WP_Query( $bbp_t );
     131    $bbp->topic_query = new WP_Query( $r );
    129132
    130133    // Set post_parent back to 0 if originally set to 'any'
    131     if ( 'any' == $bbp_t['post_parent'] )
    132         $bbp_t['post_parent'] = $post_parent = 0;
     134    if ( 'any' == $r['post_parent'] )
     135        $r['post_parent'] = $post_parent = 0;
    133136
    134137    // Limited the number of pages shown
    135     if ( !empty( $max_num_pages ) )
    136         $bbp->topic_query->max_num_pages = $max_num_pages;
     138    if ( !empty( $r['max_num_pages'] ) )
     139        $bbp->topic_query->max_num_pages = $r['max_num_pages'];
     140
     141    /** Stickies **************************************************************/
    137142
    138143    // Put sticky posts at the top of the posts array
    139     if ( !empty( $show_stickies ) && $paged <= 1 ) {
     144    if ( !empty( $r['show_stickies'] ) && $r['paged'] <= 1 ) {
    140145
    141146        // Get super stickies and stickies in this forum
    142147        $stickies = bbp_get_super_stickies();
    143         $stickies = !empty( $post_parent ) ? array_merge( $stickies, bbp_get_stickies( $post_parent ) ) : $stickies;
     148        $stickies = !empty( $r['post_parent'] ) ? array_merge( $stickies, bbp_get_stickies( $r['post_parent'] ) ) : $stickies;
    144149        $stickies = array_unique( $stickies );
    145150
     
    175180
    176181            // If any posts have been excluded specifically, Ignore those that are sticky.
    177             if ( !empty( $stickies ) && !empty( $post__not_in ) ) {
    178                 $stickies = array_diff( $stickies, $post__not_in );
     182            if ( !empty( $stickies ) && !empty( $r['post__not_in'] ) ) {
     183                $stickies = array_diff( $stickies, $r['post__not_in'] );
    179184            }
    180185
     
    223228
    224229    // If no limit to posts per page, set it to the current post_count
    225     if ( -1 == $posts_per_page )
    226         $posts_per_page = $bbp->topic_query->post_count;
     230    if ( -1 == $r['posts_per_page'] )
     231        $r['posts_per_page'] = $bbp->topic_query->post_count;
    227232
    228233    // Add pagination values to query object
    229     $bbp->topic_query->posts_per_page = $posts_per_page;
    230     $bbp->topic_query->paged          = $paged;
     234    $bbp->topic_query->posts_per_page = $r['posts_per_page'];
     235    $bbp->topic_query->paged          = $r['paged'];
    231236
    232237    // Only add pagination if query returned results
     
    234239
    235240        // Limit the number of topics shown based on maximum allowed pages
    236         if ( ( !empty( $max_num_pages ) ) && $bbp->topic_query->found_posts > $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count )
     241        if ( ( !empty( $r['max_num_pages'] ) ) && $bbp->topic_query->found_posts > $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count )
    237242            $bbp->topic_query->found_posts = $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count;
    238243
     
    289294            'base'      => $base,
    290295            'format'    => '',
    291             'total'     => $posts_per_page == $bbp->topic_query->found_posts ? 1 : ceil( (int) $bbp->topic_query->found_posts / (int) $posts_per_page ),
     296            'total'     => $r['posts_per_page'] == $bbp->topic_query->found_posts ? 1 : ceil( (int) $bbp->topic_query->found_posts / (int) $r['posts_per_page'] ),
    292297            'current'   => (int) $bbp->topic_query->paged,
    293298            'prev_text' => '&larr;',
     
    297302
    298303        // Add pagination to query object
    299         $bbp->topic_query->pagination_links = paginate_links ( $bbp_topic_pagination );
     304        $bbp->topic_query->pagination_links = paginate_links( $bbp_topic_pagination );
    300305
    301306        // Remove first page from pagination
     
    730735        global $wp_rewrite;
    731736
    732         $defaults = array(
     737        $r = bbp_parse_args( $args, array(
    733738            'topic_id' => bbp_get_topic_id(),
    734739            'before'   => '<span class="bbp-topic-pagination">',
    735740            'after'    => '</span>',
    736         );
    737         $r = bbp_parse_args( $args, $defaults, 'get_topic_pagination' );
    738         extract( $r );
     741        ), 'get_topic_pagination' );
    739742
    740743        // If pretty permalinks are enabled, make our pagination pretty
    741         if ( $wp_rewrite->using_permalinks() )
    742             $base = trailingslashit( get_permalink( $topic_id ) ) . user_trailingslashit( $wp_rewrite->pagination_base . '/%#%/' );
    743         else
    744             $base = add_query_arg( 'paged', '%#%', get_permalink( $topic_id ) );
     744        if ( $wp_rewrite->using_permalinks() ) {
     745            $base = trailingslashit( get_permalink( $r['topic_id'] ) ) . user_trailingslashit( $wp_rewrite->pagination_base . '/%#%/' );
     746        } else {
     747            $base = add_query_arg( 'paged', '%#%', get_permalink( $r['topic_id'] ) );
     748        }
    745749
    746750        // Get total and add 1 if topic is included in the reply loop
    747         $total = bbp_get_topic_reply_count( $topic_id, true );
     751        $total = bbp_get_topic_reply_count( $r['topic_id'], true );
    748752
    749753        // Bump if topic is in loop
     
    775779
    776780            // Add before and after to pagination links
    777             $pagination_links = $before . $pagination_links . $after;
     781            $pagination_links = $r['before'] . $pagination_links . $r['after'];
    778782        }
    779783
     
    13151319     */
    13161320    function bbp_get_topic_author_link( $args = '' ) {
    1317         $defaults = array (
     1321
     1322        // Parse arguments against default values
     1323        $r = bbp_parse_args( $args, array(
    13181324            'post_id'    => 0,
    13191325            'link_title' => '',
     
    13221328            'sep'        => '&nbsp;',
    13231329            'show_role'  => false
    1324         );
    1325         $r = bbp_parse_args( $args, $defaults, 'get_topic_author_link' );
    1326         extract( $r );
     1330        ), 'get_topic_author_link' );
    13271331
    13281332        // Used as topic_id
     
    13301334            $topic_id = bbp_get_topic_id( $args );
    13311335        } else {
    1332             $topic_id = bbp_get_topic_id( $post_id );
     1336            $topic_id = bbp_get_topic_id( $r['post_id'] );
    13331337        }
    13341338
     
    13371341
    13381342            // Tweak link title if empty
    1339             if ( empty( $link_title ) ) {
     1343            if ( empty( $r['link_title'] ) ) {
    13401344                $link_title = sprintf( !bbp_is_topic_anonymous( $topic_id ) ? __( 'View %s\'s profile', 'bbpress' ) : __( 'Visit %s\'s website', 'bbpress' ), bbp_get_topic_author_display_name( $topic_id ) );
    13411345            }
    13421346
    1343             $link_title   = !empty( $link_title ) ? ' title="' . $link_title . '"' : '';
    1344             $author_url   = bbp_get_topic_author_url( $topic_id );
    1345             $anonymous    = bbp_is_topic_anonymous( $topic_id );
    1346             $author_links = array();
     1347            $r['link_title'] = !empty( $r['link_title'] ) ? ' title="' . $r['link_title'] . '"' : '';
     1348            $author_url      = bbp_get_topic_author_url( $topic_id );
     1349            $anonymous       = bbp_is_topic_anonymous( $topic_id );
     1350            $author_links    = array();
    13471351
    13481352            // Get avatar
    1349             if ( 'avatar' == $type || 'both' == $type ) {
    1350                 $author_links['avatar'] = bbp_get_topic_author_avatar( $topic_id, $size );
     1353            if ( 'avatar' == $r['type'] || 'both' == $r['type'] ) {
     1354                $author_links['avatar'] = bbp_get_topic_author_avatar( $topic_id, $r['size'] );
    13511355            }
    13521356
    13531357            // Get display name
    1354             if ( 'name' == $type   || 'both' == $type ) {
     1358            if ( 'name' == $r['type'] || 'both' == $r['type'] ) {
    13551359                $author_links['name'] = bbp_get_topic_author_display_name( $topic_id );
    13561360            }
    13571361
    13581362            // Link class
    1359             $link_class = ' class="bbp-author-' . $type . '"';
     1363            $link_class = ' class="bbp-author-' . $r['type'] . '"';
    13601364
    13611365            // Add links if not anonymous
     
    13681372                }
    13691373
    1370                 if ( true === $show_role ) {
     1374                if ( true === $r['show_role'] ) {
    13711375                    $author_link[] = bbp_get_topic_author_role( array( 'topic_id' => $topic_id ) );
    13721376                }
    13731377
    1374                 $author_link = join( $sep, $author_link );
     1378                $author_link = join( $r['sep'], $author_link );
    13751379
    13761380            // No links if anonymous
    13771381            } else {
    1378                 $author_link = join( $sep, $author_links );
     1382                $author_link = join( $r['sep'], $author_links );
    13791383            }
    13801384
     
    15101514     */
    15111515    function bbp_get_topic_author_role( $args = array() ) {
    1512         $defaults = array(
     1516
     1517        // Parse arguments against default values
     1518        $r = bbp_parse_args( $args, array(
    15131519            'topic_id' => 0,
    15141520            'class'    => 'bbp-author-role',
    15151521            'before'   => '',
    15161522            'after'    => ''
    1517         );
    1518         $args = bbp_parse_args( $args, $defaults, 'get_topic_author_role' );
    1519         extract( $args, EXTR_SKIP );
     1523        ), 'get_topic_author_role' );
    15201524
    15211525        $topic_id    = bbp_get_topic_id( $topic_id );
    15221526        $role        = bbp_get_user_display_role( bbp_get_topic_author_id( $topic_id ) );
    1523         $author_role = sprintf( '%1$s<div class="%2$s">%3$s</div>%4$s', $before, $class, $role, $after );
    1524 
    1525         return apply_filters( 'bbp_get_topic_author_role', $author_role, $args );
     1527        $author_role = sprintf( '%1$s<div class="%2$s">%3$s</div>%4$s', $r['before'], $r['class'], $role, $r['after'] );
     1528
     1529        return apply_filters( 'bbp_get_topic_author_role', $author_role, $r );
    15261530    }
    15271531
     
    20572061            return;
    20582062
    2059         $defaults = array(
     2063        // Parse arguments against default values
     2064        $r = bbp_parse_args( $args, array(
    20602065            'before' => '<div class="bbp-topic-tags"><p>' . __( 'Tagged:', 'bbpress' ) . '&nbsp;',
    20612066            'sep'    => ', ',
    20622067            'after'  => '</p></div>'
    2063         );
    2064         $r = bbp_parse_args( $args, $defaults, 'get_topic_tag_list' );
    2065         extract( $r );
     2068        ), 'get_topic_tag_list' );
    20662069
    20672070        $topic_id = bbp_get_topic_id( $topic_id );
     
    20752078            // If terms exist, explode them and compile the return value
    20762079            if ( !empty( $terms ) ) {
    2077                 $terms  = implode( $sep, $terms );
    2078                 $retval = $before . $terms . $after;
     2080                $terms  = implode( $r['sep'], $terms );
     2081                $retval = $r['before'] . $terms . $r['after'];
    20792082
    20802083            // No terms so return emty string
     
    20852088        // Topic is not spam so display a clickable term list
    20862089        } else {
    2087             $retval = get_the_term_list( $topic_id, bbp_get_topic_tag_tax_id(), $before, $sep, $after );
     2090            $retval = get_the_term_list( $topic_id, bbp_get_topic_tag_tax_id(), $r['before'], $r['sep'], $r['after'] );
    20882091        }
    20892092
     
    22552258     */
    22562259    function bbp_get_topic_edit_link( $args = '' ) {
    2257         $defaults = array (
     2260       
     2261        // Parse arguments against default values
     2262        $r = bbp_parse_args( $args, array(
    22582263            'id'           => 0,
    22592264            'link_before'  => '',
    22602265            'link_after'   => '',
    22612266            'edit_text'    => __( 'Edit', 'bbpress' )
    2262         );
    2263         $r = bbp_parse_args( $args, $defaults, 'get_topic_edit_link' );
    2264         extract( $r );
    2265 
    2266         $topic = bbp_get_topic( bbp_get_topic_id( (int) $id ) );
     2267        ), 'get_topic_edit_link' );
     2268
     2269        $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) );
    22672270
    22682271        // Bypass check if user has caps
     
    22762279
    22772280        // Get uri
    2278         $uri = bbp_get_topic_edit_url( $id );
     2281        $uri = bbp_get_topic_edit_url( $r['id'] );
    22792282
    22802283        // Bail if no uri
     
    22822285            return;
    22832286
    2284         $retval = $link_before . '<a href="' . $uri . '">' . $edit_text . '</a>' . $link_after;
    2285 
    2286         return apply_filters( 'bbp_get_topic_edit_link', $retval, $args );
     2287        $retval = $r['link_before'] . '<a href="' . $uri . '">' . $r['edit_text'] . '</a>' . $r['link_after'];
     2288
     2289        return apply_filters( 'bbp_get_topic_edit_link', $retval, $r );
    22872290    }
    22882291
     
    23792382    function bbp_get_topic_trash_link( $args = '' ) {
    23802383
    2381         $defaults = array (
     2384        // Parse arguments against default values
     2385        $r = bbp_parse_args( $args, array(
    23822386            'id'           => 0,
    23832387            'link_before'  => '',
     
    23872391            'restore_text' => __( 'Restore', 'bbpress' ),
    23882392            'delete_text'  => __( 'Delete',  'bbpress' )
    2389         );
    2390         $r = bbp_parse_args( $args, $defaults, 'get_topic_trash_link' );
    2391         extract( $r );
     2393        ), 'get_topic_trash_link' );
    23922394
    23932395        $actions = array();
    2394         $topic   = bbp_get_topic( bbp_get_topic_id( (int) $id ) );
     2396        $topic   = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) );
    23952397
    23962398        if ( empty( $topic ) || !current_user_can( 'delete_topic', $topic->ID ) ) {
     
    23992401
    24002402        if ( bbp_is_topic_trash( $topic->ID ) ) {
    2401             $actions['untrash'] = '<a title="' . esc_attr__( 'Restore this item from the Trash', 'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_topic_trash', 'sub_action' => 'untrash', 'topic_id' => $topic->ID ) ), 'untrash-' . $topic->post_type . '_' . $topic->ID ) ) . '">' . esc_html( $restore_text ) . '</a>';
     2403            $actions['untrash'] = '<a title="' . esc_attr__( 'Restore this item from the Trash', 'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_topic_trash', 'sub_action' => 'untrash', 'topic_id' => $topic->ID ) ), 'untrash-' . $topic->post_type . '_' . $topic->ID ) ) . '">' . esc_html( $r['restore_text'] ) . '</a>';
    24022404        } elseif ( EMPTY_TRASH_DAYS ) {
    2403             $actions['trash']   = '<a title="' . esc_attr__( 'Move this item to the Trash', 'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_topic_trash', 'sub_action' => 'trash', 'topic_id' => $topic->ID ) ), 'trash-' . $topic->post_type . '_' . $topic->ID ) ) . '">' . esc_html( $trash_text ) . '</a>';
     2405            $actions['trash']   = '<a title="' . esc_attr__( 'Move this item to the Trash', 'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_topic_trash', 'sub_action' => 'trash', 'topic_id' => $topic->ID ) ), 'trash-' . $topic->post_type . '_' . $topic->ID ) ) . '">' . esc_html( $r['trash_text'] ) . '</a>';
    24042406        }
    24052407
    24062408        if ( bbp_is_topic_trash( $topic->ID ) || !EMPTY_TRASH_DAYS ) {
    2407             $actions['delete']  = '<a title="' . esc_attr__( 'Delete this item permanently', 'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_topic_trash', 'sub_action' => 'delete', 'topic_id' => $topic->ID ) ), 'delete-' . $topic->post_type . '_' . $topic->ID ) ) . '" onclick="return confirm(\'' . esc_js( __( 'Are you sure you want to delete that permanently?', 'bbpress' ) ) . '\' );">' . esc_html( $delete_text ) . '</a>';
     2409            $actions['delete']  = '<a title="' . esc_attr__( 'Delete this item permanently', 'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_topic_trash', 'sub_action' => 'delete', 'topic_id' => $topic->ID ) ), 'delete-' . $topic->post_type . '_' . $topic->ID ) ) . '" onclick="return confirm(\'' . esc_js( __( 'Are you sure you want to delete that permanently?', 'bbpress' ) ) . '\' );">' . esc_html( $r['delete_text'] ) . '</a>';
    24082410        }
    24092411
    24102412        // Process the admin links
    2411         $retval = $link_before . implode( $sep, $actions ) . $link_after;
    2412 
    2413         return apply_filters( 'bbp_get_topic_trash_link', $retval, $args );
     2413        $retval = $r['link_before'] . implode( $r['sep'], $actions ) . $r['link_after'];
     2414
     2415        return apply_filters( 'bbp_get_topic_trash_link', $retval, $r );
    24142416    }
    24152417
     
    24492451     */
    24502452    function bbp_get_topic_close_link( $args = '' ) {
    2451         $defaults = array (
     2453
     2454        // Parse arguments against default values
     2455        $r = bbp_parse_args( $args, array(
    24522456            'id'          => 0,
    24532457            'link_before' => '',
     
    24562460            'close_text'  => _x( 'Close', 'Topic Status', 'bbpress' ),
    24572461            'open_text'   => _x( 'Open',  'Topic Status', 'bbpress' )
    2458         );
    2459         $r = bbp_parse_args( $args, $defaults, 'get_topic_close_link' );
    2460         extract( $r );
    2461 
    2462         $topic = bbp_get_topic( bbp_get_topic_id( (int) $id ) );
     2462        ), 'get_topic_close_link' );
     2463
     2464        $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) );
    24632465
    24642466        if ( empty( $topic ) || !current_user_can( 'moderate', $topic->ID ) )
    24652467            return;
    24662468
    2467         $display = bbp_is_topic_open( $topic->ID ) ? $close_text : $open_text;
     2469        $display = bbp_is_topic_open( $topic->ID ) ? $r['close_text'] : $r['open_text'];
    24682470        $uri     = add_query_arg( array( 'action' => 'bbp_toggle_topic_close', 'topic_id' => $topic->ID ) );
    24692471        $uri     = esc_url( wp_nonce_url( $uri, 'close-topic_' . $topic->ID ) );
    2470         $retval  = $link_before . '<a href="' . $uri . '">' . $display . '</a>' . $link_after;
    2471 
    2472         return apply_filters( 'bbp_get_topic_close_link', $retval, $args );
     2472        $retval  = $r['link_before'] . '<a href="' . $uri . '">' . $display . '</a>' . $r['link_after'];
     2473
     2474        return apply_filters( 'bbp_get_topic_close_link', $retval, $r );
    24732475    }
    24742476
     
    25102512     */
    25112513    function bbp_get_topic_stick_link( $args = '' ) {
    2512         $defaults = array (
     2514
     2515        // Parse argmuntes against default values
     2516        $r = bbp_parse_args( $args, array(
    25132517            'id'           => 0,
    25142518            'link_before'  => '',
     
    25172521            'unstick_text' => __( 'Unstick',  'bbpress' ),
    25182522            'super_text'   => __( 'to front', 'bbpress' ),
    2519         );
    2520         $r = bbp_parse_args( $args, $defaults, 'get_topic_stick_link' );
    2521         extract( $r );
    2522 
    2523         $topic = bbp_get_topic( bbp_get_topic_id( (int) $id ) );
     2523        ), 'get_topic_stick_link' );
     2524
     2525        $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) );
    25242526
    25252527        if ( empty( $topic ) || !current_user_can( 'moderate', $topic->ID ) )
     
    25312533        $stick_uri = esc_url( wp_nonce_url( $stick_uri, 'stick-topic_' . $topic->ID ) );
    25322534
    2533         $stick_display = true == $is_sticky ? $unstick_text : $stick_text;
     2535        $stick_display = true == $is_sticky ? $r['unstick_text'] : $r['stick_text'];
    25342536        $stick_display = '<a href="' . $stick_uri . '">' . $stick_display . '</a>';
    25352537
     
    25382540            $super_uri = esc_url( wp_nonce_url( $super_uri, 'stick-topic_' . $topic->ID ) );
    25392541
    2540             $super_display = ' (<a href="' . $super_uri . '">' . $super_text . '</a>)';
     2542            $super_display = ' (<a href="' . $super_uri . '">' . $r['super_text'] . '</a>)';
    25412543        } else {
    25422544            $super_display = '';
     
    25442546
    25452547        // Combine the HTML into 1 string
    2546         $retval = $link_before . $stick_display . $super_display . $link_after;
    2547 
    2548         return apply_filters( 'bbp_get_topic_stick_link', $retval, $args );
     2548        $retval = $r['link_before'] . $stick_display . $super_display . $r['link_after'];
     2549
     2550        return apply_filters( 'bbp_get_topic_stick_link', $retval, $r );
    25492551    }
    25502552
     
    25812583     */
    25822584    function bbp_get_topic_merge_link( $args = '' ) {
    2583         $defaults = array (
     2585
     2586        // Parse arguments against default values
     2587        $r = bbp_parse_args( $args, array(
    25842588            'id'           => 0,
    25852589            'link_before'  => '',
    25862590            'link_after'   => '',
    25872591            'merge_text'   => __( 'Merge', 'bbpress' ),
    2588         );
    2589         $r = bbp_parse_args( $args, $defaults, 'get_topic_merge_link' );
    2590         extract( $r );
    2591 
    2592         $topic = bbp_get_topic( bbp_get_topic_id( (int) $id ) );
     2592        ), 'get_topic_merge_link' );
     2593
     2594        $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) );
    25932595
    25942596        if ( empty( $topic ) || !current_user_can( 'moderate', $topic->ID ) )
     
    25962598
    25972599        $uri    = esc_url( add_query_arg( array( 'action' => 'merge' ), bbp_get_topic_edit_url( $topic->ID ) ) );
    2598         $retval = $link_before . '<a href="' . $uri . '">' . $merge_text . '</a>' . $link_after;
     2600        $retval = $r['link_before'] . '<a href="' . $uri . '">' . $r['merge_text'] . '</a>' . $r['link_after'];
    25992601
    26002602        return apply_filters( 'bbp_get_topic_merge_link', $retval, $args );
     
    26362638     */
    26372639    function bbp_get_topic_spam_link( $args = '' ) {
    2638         $defaults = array (
     2640
     2641        // Parse arguments against default values
     2642        $r = bbp_parse_args( $args, array(
    26392643            'id'           => 0,
    26402644            'link_before'  => '',
     
    26432647            'spam_text'    => __( 'Spam',   'bbpress' ),
    26442648            'unspam_text'  => __( 'Unspam', 'bbpress' )
    2645         );
    2646         $r = bbp_parse_args( $args, $defaults, 'get_topic_spam_link' );
    2647         extract( $r );
    2648 
    2649         $topic = bbp_get_topic( bbp_get_topic_id( (int) $id ) );
     2649        ), 'get_topic_spam_link' );
     2650
     2651        $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) );
    26502652
    26512653        if ( empty( $topic ) || !current_user_can( 'moderate', $topic->ID ) )
    26522654            return;
    26532655
    2654         $display = bbp_is_topic_spam( $topic->ID ) ? $unspam_text : $spam_text;
     2656        $display = bbp_is_topic_spam( $topic->ID ) ? $r['unspam_text'] : $r['spam_text'];
    26552657        $uri     = add_query_arg( array( 'action' => 'bbp_toggle_topic_spam', 'topic_id' => $topic->ID ) );
    26562658        $uri     = esc_url( wp_nonce_url( $uri, 'spam-topic_' . $topic->ID ) );
    2657         $retval  = $link_before . '<a href="' . $uri . '">' . $display . '</a>' . $link_after;
    2658 
    2659         return apply_filters( 'bbp_get_topic_spam_link', $retval, $args );
     2659        $retval  = $r['link_before'] . '<a href="' . $uri . '">' . $display . '</a>' . $r['link_after'];
     2660
     2661        return apply_filters( 'bbp_get_topic_spam_link', $retval, $r );
    26602662    }
    26612663
     
    28032805function bbp_topic_type_select( $args = '' ) {
    28042806
    2805     $defaults = array (
     2807    // Parse arguments against default values
     2808    $r = bbp_parse_args( $args, array(
    28062809        'unstick_text' => __( 'Normal',       'bbpress' ),
    28072810        'stick_text'   => __( 'Sticky',       'bbpress' ),
     
    28102813        'tab'          => bbp_get_tab_index(),
    28112814        'topic_id'     => 0
    2812     );
    2813     $r = bbp_parse_args( $args, $defaults, 'topic_type_select' );
    2814     extract( $r );
     2815    ), 'topic_type_select' );
    28152816
    28162817    // Edit topic
     
    28212822
    28222823        // Post value is passed
    2823         if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST[$select_id] ) ) {
    2824             $sticky_current = $_POST[$select_id];
     2824        if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST[ $r['select_id'] ] ) ) {
     2825            $sticky_current = $_POST[ $r['select_id'] ];
    28252826
    28262827        // Topic is super sticky
     
    28372838
    28382839        // Post value is passed
    2839         if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST[$select_id] ) ) {
    2840             $sticky_current = $_POST[$select_id];
     2840        if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST[ $r['select_id'] ] ) ) {
     2841            $sticky_current = $_POST[ $r['select_id'] ];
    28412842
    28422843        // Default to unstick
     
    28482849    // Used variables
    28492850    $tab             = !empty( $tab ) ? ' tabindex="' . $tab . '"' : '';
    2850     $select_id       = esc_attr( $select_id );
     2851    $select_id       = esc_attr( $r['select_id'] );
    28512852    $sticky_statuses = array (
    2852         'unstick' => $unstick_text,
    2853         'stick'   => $stick_text,
    2854         'super'   => $super_text,
     2853        'unstick' => $r['unstick_text'],
     2854        'stick'   => $r['stick_text'],
     2855        'super'   => $r['super_text'],
    28552856    ); ?>
    28562857
     
    28592860        <?php foreach ( $sticky_statuses as $sticky_status => $label ) : ?>
    28602861
    2861             <option value="<?php echo $sticky_status; ?>"<?php selected( $sticky_current, $sticky_status ); ?>><?php echo $label; ?></option>
     2862            <option value="<?php echo esc_attr( $sticky_status ); ?>"<?php selected( $sticky_current, $sticky_status ); ?>><?php echo esc_html( $label ); ?></option>
    28622863
    28632864        <?php endforeach; ?>
     
    29052906    function bbp_get_single_topic_description( $args = '' ) {
    29062907
    2907         // Default arguments
    2908         $defaults = array (
     2908        // Parse argmuents against default values
     2909        $r = bbp_parse_args( $args, array(
    29092910            'topic_id'  => 0,
    29102911            'before'    => '<div class="bbp-template-notice info"><p class="bbp-topic-description">',
    29112912            'after'     => '</p></div>',
    29122913            'size'      => 14
    2913         );
    2914         $r = bbp_parse_args( $args, $defaults, 'get_single_topic_description' );
    2915         extract( $r );
     2914        ), 'get_single_topic_description' );
    29162915
    29172916        // Validate topic_id
    2918         $topic_id = bbp_get_topic_id( $topic_id );
     2917        $topic_id = bbp_get_topic_id( $r['topic_id'] );
    29192918
    29202919        // Unhook the 'view all' query var adder
     
    29222921
    29232922        // Build the topic description
    2924         $voice_count = bbp_get_topic_voice_count   ( $topic_id );
    2925         $reply_count = bbp_get_topic_replies_link  ( $topic_id );
    2926         $time_since  = bbp_get_topic_freshness_link( $topic_id );
     2923        $vc_int      = bbp_get_topic_voice_count   ( $topic_id, true  );
     2924        $voice_count = bbp_get_topic_voice_count   ( $topic_id, false );
     2925        $reply_count = bbp_get_topic_replies_link  ( $topic_id        );
     2926        $time_since  = bbp_get_topic_freshness_link( $topic_id        );
    29272927
    29282928        // Singular/Plural
    2929         $voice_count = sprintf( _n( '%s voice', '%s voices', $voice_count, 'bbpress' ), $voice_count );
     2929        $voice_count = sprintf( _n( '%s voice', '%s voices', $vc_int, 'bbpress' ), $voice_count );
    29302930
    29312931        // Topic has replies
    29322932        $last_reply = bbp_get_topic_last_active_id( $topic_id );
    29332933        if ( !empty( $last_reply ) ) {
    2934             $last_updated_by = bbp_get_author_link( array( 'post_id' => $last_reply, 'size' => $size ) );
     2934            $last_updated_by = bbp_get_author_link( array( 'post_id' => $last_reply, 'size' => $r['size'] ) );
    29352935            $retstr          = sprintf( __( 'This topic contains %1$s, has %2$s, and was last updated by %3$s %4$s.', 'bbpress' ), $reply_count, $voice_count, $last_updated_by, $time_since );
    29362936
     
    29482948
    29492949        // Combine the elements together
    2950         $retstr = $before . $retstr . $after;
     2950        $retstr = $r['before'] . $retstr . $r['after'];
    29512951
    29522952        // Return filtered result
    2953         return apply_filters( 'bbp_get_single_topic_description', $retstr, $args );
     2953        return apply_filters( 'bbp_get_single_topic_description', $retstr, $r );
    29542954    }
    29552955
     
    32343234    function bbp_get_topic_tag_description( $args = array() ) {
    32353235
    3236         $defaults = array(
     3236        // Parse arguments against default values
     3237        $r = bbp_parse_args( $args, array(
    32373238            'before' => '<div class="bbp-topic-tag-description"><p>',
    32383239            'after'  => '</p></div>',
    32393240            'tag'    => ''
    3240         );
    3241         $r = bbp_parse_args( $args, $defaults, 'get_topic_tag_description' );
    3242         extract( $r );
     3241        ), 'get_topic_tag_description' );
    32433242
    32443243        // Get the term
    3245         if ( ! empty( $tag ) ) {
    3246             $term = get_term_by( 'slug', $tag, bbp_get_topic_tag_tax_id() );
     3244        if ( ! empty( $r['tag'] ) ) {
     3245            $term = get_term_by( 'slug', $r['tag'], bbp_get_topic_tag_tax_id() );
    32473246        } else {
    3248             $tag         = get_query_var( 'term' );
    3249             $args['tag'] = $tag;
    3250             $term        = get_queried_object();
     3247            $tag      = get_query_var( 'term' );
     3248            $r['tag'] = $tag;
     3249            $term     = get_queried_object();
    32513250        }
    32523251
    32533252        // Add before and after if description exists
    32543253        if ( !empty( $term->description ) ) {
    3255             $retval = $before . $term->description . $after;
     3254            $retval = $r['before'] . $term->description . $r['after'];
    32563255
    32573256        // No description, no HTML
     
    32603259        }
    32613260
    3262         return apply_filters( 'bbp_get_topic_tag_description', $retval, $args );
     3261        return apply_filters( 'bbp_get_topic_tag_description', $retval, $r );
    32633262    }
    32643263
     
    32873286
    32883287        // Get _POST data
    3289         if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_topic_title'] ) )
     3288        if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_topic_title'] ) ) {
    32903289            $topic_title = $_POST['bbp_topic_title'];
    32913290
    32923291        // Get edit data
    3293         elseif ( bbp_is_topic_edit() )
     3292        } elseif ( bbp_is_topic_edit() ) {
    32943293            $topic_title = bbp_get_global_post_field( 'post_title', 'raw' );
    32953294
    32963295        // No data
    3297         else
     3296        } else {
    32983297            $topic_title = '';
     3298        }
    32993299
    33003300        return apply_filters( 'bbp_get_form_topic_title', esc_attr( $topic_title ) );
     
    33233323
    33243324        // Get _POST data
    3325         if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_topic_content'] ) )
     3325        if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_topic_content'] ) ) {
    33263326            $topic_content = $_POST['bbp_topic_content'];
    33273327
    33283328        // Get edit data
    3329         elseif ( bbp_is_topic_edit() )
     3329        } elseif ( bbp_is_topic_edit() ) {
    33303330            $topic_content = bbp_get_global_post_field( 'post_content', 'raw' );
    33313331
    33323332        // No data
    3333         else
     3333        } else {
    33343334            $topic_content = '';
     3335        }
    33353336
    33363337        return apply_filters( 'bbp_get_form_topic_content', esc_textarea( $topic_content ) );
     
    34523453
    34533454        // Get _POST data
    3454         if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_forum_id'] ) )
     3455        if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_forum_id'] ) ) {
    34553456            $topic_forum = $_POST['bbp_forum_id'];
    34563457
    34573458        // Get edit data
    3458         elseif ( bbp_is_topic_edit() )
     3459        } elseif ( bbp_is_topic_edit() ) {
    34593460            $topic_forum = bbp_get_topic_forum_id();
    34603461
    34613462        // No data
    3462         else
     3463        } else {
    34633464            $topic_forum = 0;
     3465        }
    34643466
    34653467        return apply_filters( 'bbp_get_form_topic_forum', esc_attr( $topic_forum ) );
     
    35463548
    35473549        // Get _POST data
    3548         if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_log_topic_edit'] ) )
     3550        if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_log_topic_edit'] ) ) {
    35493551            $topic_revision = $_POST['bbp_log_topic_edit'];
    35503552
    35513553        // No data
    3552         else
     3554        } else {
    35533555            $topic_revision = 1;
     3556        }
    35543557
    35553558        return apply_filters( 'bbp_get_form_topic_log_edit', checked( $topic_revision, true, false ) );
     
    35783581
    35793582        // Get _POST data
    3580         if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_topic_edit_reason'] ) )
     3583        if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_topic_edit_reason'] ) ) {
    35813584            $topic_edit_reason = $_POST['bbp_topic_edit_reason'];
    35823585
    35833586        // No data
    3584         else
     3587        } else {
    35853588            $topic_edit_reason = '';
     3589        }
    35863590
    35873591        return apply_filters( 'bbp_get_form_topic_edit_reason', esc_attr( $topic_edit_reason ) );
Note: See TracChangeset for help on using the changeset viewer.