Skip to:
Content

bbPress.org

Changeset 4507


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

Extract:

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

Legend:

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

    r4428 r4507  
    6767    global $wp_rewrite;
    6868
     69    /** Defaults **************************************************************/
     70
    6971    // What are the default allowed statuses (based on user caps)
    7072    if ( bbp_get_view_all( 'edit_others_replies' ) ) {
     
    9193    );
    9294
    93     // Set up topic variables
    94     $bbp_r = bbp_parse_args( $args, $default, 'has_replies' );
    95 
    96     // Extract the query variables
    97     extract( $bbp_r );
     95    /** Setup *****************************************************************/
     96
     97    // Parse arguments with default values
     98    $r = bbp_parse_args( $args, $default, 'has_replies' );
    9899
    99100    // Get bbPress
     
    101102
    102103    // Call the query
    103     $bbp->reply_query = new WP_Query( $bbp_r );
     104    $bbp->reply_query = new WP_Query( $r );
    104105   
    105106    // Add pagination values to query object
    106     $bbp->reply_query->posts_per_page = $posts_per_page;
    107     $bbp->reply_query->paged          = $paged;
     107    $bbp->reply_query->posts_per_page = $r['posts_per_page'];
     108    $bbp->reply_query->paged          = $r['paged'];
    108109
    109110    // Never home, regardless of what parse_query says
     
    146147                'base'      => $base,
    147148                'format'    => '',
    148                 'total'     => ceil( (int) $bbp->reply_query->found_posts / (int) $posts_per_page ),
     149                'total'     => ceil( (int) $bbp->reply_query->found_posts / (int) $r['posts_per_page'] ),
    149150                'current'   => (int) $bbp->reply_query->paged,
    150151                'prev_text' => '←',
     
    10101011     */
    10111012    function bbp_get_reply_author_link( $args = '' ) {
    1012         $defaults = array (
     1013
     1014        // Parse arguments with default values
     1015        $r = bbp_parse_args( $args, array(
    10131016            'post_id'    => 0,
    10141017            'link_title' => '',
     
    10171020            'sep'        => ' ',
    10181021            'show_role'  => false
    1019         );
    1020         $r = bbp_parse_args( $args, $defaults, 'get_reply_author_link' );
    1021         extract( $r );
     1022        ), 'get_reply_author_link' );
    10221023
    10231024        // Used as reply_id
    1024         if ( is_numeric( $args ) )
     1025        if ( is_numeric( $args ) ) {
    10251026            $reply_id = bbp_get_reply_id( $args );
    1026         else
    1027             $reply_id = bbp_get_reply_id( $post_id );
     1027        } else {
     1028            $reply_id = bbp_get_reply_id( $r['post_id'] );
     1029        }
    10281030
    10291031        if ( !empty( $reply_id ) ) {
    1030             if ( empty( $link_title ) ) {
     1032            if ( empty( $$r['link_title'] ) ) {
    10311033                $link_title = sprintf( !bbp_is_reply_anonymous( $reply_id ) ? __( 'View %s\'s profile', 'bbpress' ) : __( 'Visit %s\'s website', 'bbpress' ), bbp_get_reply_author_display_name( $reply_id ) );
    10321034            }
    10331035
    1034             $link_title = !empty( $link_title ) ? ' title="' . $link_title . '"' : '';
     1036            $link_title = !empty( $r['link_title'] ) ? ' title="' . $r['link_title'] . '"' : '';
    10351037            $author_url = bbp_get_reply_author_url( $reply_id );
    10361038            $anonymous  = bbp_is_reply_anonymous( $reply_id );
    10371039
    10381040            // Get avatar
    1039             if ( 'avatar' == $type || 'both' == $type ) {
    1040                 $author_links['avatar'] = bbp_get_reply_author_avatar( $reply_id, $size );
     1041            if ( 'avatar' == $r['type'] || 'both' == $r['type'] ) {
     1042                $author_links['avatar'] = bbp_get_reply_author_avatar( $reply_id, $r['size'] );
    10411043            }
    10421044
    10431045            // Get display name
    1044             if ( 'name' == $type   || 'both' == $type ) {
     1046            if ( 'name' == $r['type']   || 'both' == $r['type'] ) {
    10451047                $author_links['name'] = bbp_get_reply_author_display_name( $reply_id );
    10461048            }
     
    10531055                }
    10541056
    1055                 if ( true === $show_role ) {
     1057                if ( true === $r['show_role'] ) {
    10561058                    $author_link[] = bbp_get_reply_author_role( array( 'reply_id' => $reply_id ) );
    10571059                }
    10581060
    1059                 $author_link = join( $sep, $author_link );
     1061                $author_link = join( $r['sep'], $author_link );
    10601062
    10611063            // No links if anonymous
    10621064            } else {
    1063                 $author_link = join( $sep, $author_links );
     1065                $author_link = join( $r['sep'], $author_links );
    10641066            }
    10651067
     
    10691071        }
    10701072
    1071         return apply_filters( 'bbp_get_reply_author_link', $author_link, $args );
     1073        return apply_filters( 'bbp_get_reply_author_link', $author_link, $r );
    10721074    }
    10731075
     
    11931195     */
    11941196    function bbp_get_reply_author_role( $args = array() ) {
    1195         $defaults = array(
     1197
     1198        // Parse arguments with default values
     1199        $r = bbp_parse_args( $args, array(
    11961200            'reply_id' => 0,
    11971201            'class'    => 'bbp-author-role',
    11981202            'before'   => '',
    11991203            'after'    => ''
    1200         );
    1201         $args = bbp_parse_args( $args, $defaults, 'get_reply_author_role' );
    1202         extract( $args, EXTR_SKIP );
    1203 
    1204         $reply_id    = bbp_get_reply_id( $reply_id );
     1204        ), 'get_reply_author_role' );
     1205
     1206        $reply_id    = bbp_get_reply_id( $r['reply_id'] );
    12051207        $role        = bbp_get_user_display_role( bbp_get_reply_author_id( $reply_id ) );
    1206         $author_role = sprintf( '%1$s<div class="%2$s">%3$s</div>%4$s', $before, $class, $role, $after );
     1208        $author_role = sprintf( '%1$s<div class="%2$s">%3$s</div>%4$s', $r['before'], $r['class'], $role, $r['after'] );
    12071209
    12081210        return apply_filters( 'bbp_get_reply_author_role', $author_role, $args );
     
    14251427    function bbp_get_reply_admin_links( $args = '' ) {
    14261428
    1427         $defaults = array (
     1429        // Parse arguments with default values
     1430        $r = bbp_parse_args( $args, array(
    14281431            'id'     => 0,
    14291432            'before' => '<span class="bbp-admin-links">',
     
    14311434            'sep'    => ' | ',
    14321435            'links'  => array()
    1433         );
    1434         $r = bbp_parse_args( $args, $defaults, 'get_reply_admin_links' );
     1436        ), 'get_reply_admin_links' );
    14351437
    14361438        $r['id'] = bbp_get_reply_id( (int) $r['id'] );
     
    14711473
    14721474            // Spam link shouldn't be visible on trashed topics
    1473             if ( $reply_status == bbp_get_trash_status_id() ) {
     1475            if ( bbp_get_trash_status_id() == $reply_status ) {
    14741476                unset( $r['links']['spam'] );
    14751477
     
    14841486        $retval = $r['before'] . $links . $r['after'];
    14851487
    1486         return apply_filters( 'bbp_get_reply_admin_links', $retval, $args );
     1488        return apply_filters( 'bbp_get_reply_admin_links', $retval, $r );
    14871489    }
    14881490
     
    15191521     */
    15201522    function bbp_get_reply_edit_link( $args = '' ) {
    1521         $defaults = array (
     1523
     1524        // Parse arguments with default values
     1525        $r = bbp_parse_args( $args, array(
    15221526            'id'           => 0,
    15231527            'link_before'  => '',
    15241528            'link_after'   => '',
    15251529            'edit_text'    => __( 'Edit', 'bbpress' )
    1526         );
    1527         $r = bbp_parse_args( $args, $defaults, 'get_reply_edit_link' );
    1528         extract( $r );
    1529 
    1530         $reply = bbp_get_reply( bbp_get_reply_id( (int) $id ) );
     1530        ), 'get_reply_edit_link' );
     1531
     1532        $reply = bbp_get_reply( bbp_get_reply_id( (int) $r['id'] ) );
    15311533
    15321534        // Bypass check if user has caps
     
    15341536
    15351537            // User cannot edit or it is past the lock time
    1536             if ( empty( $reply ) || !current_user_can( 'edit_reply', $reply->ID ) || bbp_past_edit_lock( $reply->post_date_gmt ) )
     1538            if ( empty( $reply ) || !current_user_can( 'edit_reply', $reply->ID ) || bbp_past_edit_lock( $reply->post_date_gmt ) ) {
    15371539                return;
     1540            }
    15381541        }
    15391542
    15401543        // Get uri
    1541         $uri = bbp_get_reply_edit_url( $id );
     1544        $uri = bbp_get_reply_edit_url( $r['id'] );
    15421545
    15431546        // Bail if no uri
     
    15451548            return;
    15461549
    1547         $retval = $link_before . '<a href="' . $uri . '">' . $edit_text . '</a>' . $link_after;
    1548 
    1549         return apply_filters( 'bbp_get_reply_edit_link', $retval, $args );
     1550        $retval = $r['link_before'] . '<a href="' . $uri . '">' . $r['edit_text'] . '</a>' . $r['link_after'];
     1551
     1552        return apply_filters( 'bbp_get_reply_edit_link', $retval, $r );
    15501553    }
    15511554
     
    16411644     */
    16421645    function bbp_get_reply_trash_link( $args = '' ) {
    1643         $defaults = array (
     1646
     1647        // Parse arguments with default values
     1648        $r = bbp_parse_args( $args, array(
    16441649            'id'           => 0,
    16451650            'link_before'  => '',
     
    16491654            'restore_text' => __( 'Restore', 'bbpress' ),
    16501655            'delete_text'  => __( 'Delete',  'bbpress' )
    1651         );
    1652         $r = bbp_parse_args( $args, $defaults, 'get_reply_trash_link' );
    1653         extract( $r );
     1656        ), 'get_reply_trash_link' );
    16541657
    16551658        $actions = array();
    1656         $reply   = bbp_get_reply( bbp_get_reply_id( (int) $id ) );
     1659        $reply   = bbp_get_reply( bbp_get_reply_id( (int) $r['id'] ) );
    16571660
    16581661        if ( empty( $reply ) || !current_user_can( 'delete_reply', $reply->ID ) ) {
     
    16611664
    16621665        if ( bbp_is_reply_trash( $reply->ID ) ) {
    1663             $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_reply_trash', 'sub_action' => 'untrash', 'reply_id' => $reply->ID ) ), 'untrash-' . $reply->post_type . '_' . $reply->ID ) ) . '">' . esc_html( $restore_text ) . '</a>';
     1666            $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_reply_trash', 'sub_action' => 'untrash', 'reply_id' => $reply->ID ) ), 'untrash-' . $reply->post_type . '_' . $reply->ID ) ) . '">' . esc_html( $r['restore_text'] ) . '</a>';
    16641667        } elseif ( EMPTY_TRASH_DAYS ) {
    1665             $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_reply_trash', 'sub_action' => 'trash', 'reply_id' => $reply->ID ) ), 'trash-' . $reply->post_type . '_' . $reply->ID ) ) . '">' . esc_html( $trash_text ) . '</a>';
     1668            $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_reply_trash', 'sub_action' => 'trash', 'reply_id' => $reply->ID ) ), 'trash-' . $reply->post_type . '_' . $reply->ID ) ) . '">' . esc_html( $r['trash_text'] ) . '</a>';
    16661669        }
    16671670
    16681671        if ( bbp_is_reply_trash( $reply->ID ) || !EMPTY_TRASH_DAYS ) {
    1669             $actions['delete']  = '<a title="' . esc_attr__( 'Delete this item permanently', 'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_reply_trash', 'sub_action' => 'delete', 'reply_id' => $reply->ID ) ), 'delete-' . $reply->post_type . '_' . $reply->ID ) ) . '" onclick="return confirm(\'' . esc_js( __( 'Are you sure you want to delete that permanently?', 'bbpress' ) ) . '\' );">' . esc_html( $delete_text ) . '</a>';
     1672            $actions['delete']  = '<a title="' . esc_attr__( 'Delete this item permanently', 'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_reply_trash', 'sub_action' => 'delete', 'reply_id' => $reply->ID ) ), 'delete-' . $reply->post_type . '_' . $reply->ID ) ) . '" onclick="return confirm(\'' . esc_js( __( 'Are you sure you want to delete that permanently?', 'bbpress' ) ) . '\' );">' . esc_html( $r['delete_text'] ) . '</a>';
    16701673        }
    16711674
    16721675        // Process the admin links
    1673         $retval = $link_before . implode( $sep, $actions ) . $link_after;
    1674 
    1675         return apply_filters( 'bbp_get_reply_trash_link', $retval, $args );
     1676        $retval = $r['link_before'] . implode( $r['sep'], $actions ) . $r['link_after'];
     1677
     1678        return apply_filters( 'bbp_get_reply_trash_link', $retval, $r );
    16761679    }
    16771680
     
    17131716     */
    17141717    function bbp_get_reply_spam_link( $args = '' ) {
    1715         $defaults = array (
     1718       
     1719        // Parse argmuments with default values
     1720        $r = bbp_parse_args( $args, array(
    17161721            'id'           => 0,
    17171722            'link_before'  => '',
     
    17191724            'spam_text'    => __( 'Spam',   'bbpress' ),
    17201725            'unspam_text'  => __( 'Unspam', 'bbpress' )
    1721         );
    1722         $r = bbp_parse_args( $args, $defaults, 'get_reply_spam_link' );
    1723         extract( $r );
    1724 
    1725         $reply = bbp_get_reply( bbp_get_reply_id( (int) $id ) );
     1726        ), 'get_reply_spam_link' );
     1727
     1728        $reply = bbp_get_reply( bbp_get_reply_id( (int) $r['id'] ) );
    17261729
    17271730        if ( empty( $reply ) || !current_user_can( 'moderate', $reply->ID ) )
    17281731            return;
    17291732
    1730         $display  = bbp_is_reply_spam( $reply->ID ) ? $unspam_text : $spam_text;
     1733        $display  = bbp_is_reply_spam( $reply->ID ) ? $r['unspam_text'] : $r['spam_text'];
    17311734        $uri      = add_query_arg( array( 'action' => 'bbp_toggle_reply_spam', 'reply_id' => $reply->ID ) );
    17321735        $uri      = esc_url( wp_nonce_url( $uri, 'spam-reply_' . $reply->ID ) );
    1733         $retval   = $link_before . '<a href="' . $uri . '">' . $display . '</a>' . $link_after;
    1734 
    1735         return apply_filters( 'bbp_get_reply_spam_link', $retval, $args );
     1736        $retval   = $r['link_before'] . '<a href="' . $uri . '">' . $display . '</a>' . $r['link_after'];
     1737
     1738        return apply_filters( 'bbp_get_reply_spam_link', $retval, $r );
    17361739    }
    17371740
     
    17771780     */
    17781781    function bbp_get_topic_split_link( $args = '' ) {
    1779         $defaults = array (
     1782
     1783        // Parse arguments with default values
     1784        $r = bbp_parse_args( $args, array(
    17801785            'id'          => 0,
    17811786            'link_before' => '',
     
    17831788            'split_text'  => __( 'Split',                           'bbpress' ),
    17841789            'split_title' => __( 'Split the topic from this reply', 'bbpress' )
    1785         );
    1786         $r = bbp_parse_args( $args, $defaults, 'get_topic_split_link' );
    1787         extract( $r );
    1788 
    1789         $reply_id = bbp_get_reply_id( $id );
     1790        ), 'get_topic_split_link' );
     1791
     1792        $reply_id = bbp_get_reply_id( $r['id'] );
    17901793        $topic_id = bbp_get_reply_topic_id( $reply_id );
    17911794
     
    18021805        ) );
    18031806
    1804         $retval = $link_before . '<a href="' . $uri . '" title="' . esc_attr( $split_title ) . '">' . $split_text . '</a>' . $link_after;
    1805 
    1806         return apply_filters( 'bbp_get_topic_split_link', $retval, $args );
     1807        $retval = $r['link_before'] . '<a href="' . $uri . '" title="' . esc_attr( $r['split_title'] ) . '">' . esc_html( $r['split_text'] ) . '</a>' . $r['link_after'];
     1808
     1809        return apply_filters( 'bbp_get_topic_split_link', $retval, $r );
    18071810    }
    18081811
     
    19651968
    19661969        // Get _POST data
    1967         if ( 'POST' == strtoupper( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_reply_content'] ) )
     1970        if ( 'POST' == strtoupper( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_reply_content'] ) ) {
    19681971            $reply_content = $_POST['bbp_reply_content'];
    19691972
    19701973        // Get edit data
    1971         elseif ( bbp_is_reply_edit() )
     1974        } elseif ( bbp_is_reply_edit() ) {
    19721975            $reply_content = bbp_get_global_post_field( 'post_content', 'raw' );
    19731976
    19741977        // No data
    1975         else
     1978        } else {
    19761979            $reply_content = '';
     1980        }
    19771981
    19781982        return apply_filters( 'bbp_get_form_reply_content', esc_textarea( $reply_content ) );
     
    20012005
    20022006        // Get _POST data
    2003         if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_log_reply_edit'] ) )
     2007        if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_log_reply_edit'] ) ) {
    20042008            $reply_revision = $_POST['bbp_log_reply_edit'];
    20052009
    20062010        // No data
    2007         else
     2011        } else {
    20082012            $reply_revision = 1;
     2013        }
    20092014
    20102015        return apply_filters( 'bbp_get_form_reply_log_edit', checked( $reply_revision, true, false ) );
     
    20332038
    20342039        // Get _POST data
    2035         if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_reply_edit_reason'] ) )
     2040        if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_reply_edit_reason'] ) ) {
    20362041            $reply_edit_reason = $_POST['bbp_reply_edit_reason'];
    20372042
    20382043        // No data
    2039         else
     2044        } else {
    20402045            $reply_edit_reason = '';
     2046        }
    20412047
    20422048        return apply_filters( 'bbp_get_form_reply_edit_reason', esc_attr( $reply_edit_reason ) );
Note: See TracChangeset for help on using the changeset viewer.