Changeset 4507
- Timestamp:
- 11/24/2012 08:27:31 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/replies/template-tags.php
r4428 r4507 67 67 global $wp_rewrite; 68 68 69 /** Defaults **************************************************************/ 70 69 71 // What are the default allowed statuses (based on user caps) 70 72 if ( bbp_get_view_all( 'edit_others_replies' ) ) { … … 91 93 ); 92 94 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' ); 98 99 99 100 // Get bbPress … … 101 102 102 103 // Call the query 103 $bbp->reply_query = new WP_Query( $ bbp_r );104 $bbp->reply_query = new WP_Query( $r ); 104 105 105 106 // 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']; 108 109 109 110 // Never home, regardless of what parse_query says … … 146 147 'base' => $base, 147 148 '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'] ), 149 150 'current' => (int) $bbp->reply_query->paged, 150 151 'prev_text' => '←', … … 1010 1011 */ 1011 1012 function bbp_get_reply_author_link( $args = '' ) { 1012 $defaults = array ( 1013 1014 // Parse arguments with default values 1015 $r = bbp_parse_args( $args, array( 1013 1016 'post_id' => 0, 1014 1017 'link_title' => '', … … 1017 1020 'sep' => ' ', 1018 1021 'show_role' => false 1019 ); 1020 $r = bbp_parse_args( $args, $defaults, 'get_reply_author_link' ); 1021 extract( $r ); 1022 ), 'get_reply_author_link' ); 1022 1023 1023 1024 // Used as reply_id 1024 if ( is_numeric( $args ) ) 1025 if ( is_numeric( $args ) ) { 1025 1026 $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 } 1028 1030 1029 1031 if ( !empty( $reply_id ) ) { 1030 if ( empty( $ link_title) ) {1032 if ( empty( $$r['link_title'] ) ) { 1031 1033 $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 ) ); 1032 1034 } 1033 1035 1034 $link_title = !empty( $ link_title ) ? ' title="' . $link_title. '"' : '';1036 $link_title = !empty( $r['link_title'] ) ? ' title="' . $r['link_title'] . '"' : ''; 1035 1037 $author_url = bbp_get_reply_author_url( $reply_id ); 1036 1038 $anonymous = bbp_is_reply_anonymous( $reply_id ); 1037 1039 1038 1040 // 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'] ); 1041 1043 } 1042 1044 1043 1045 // Get display name 1044 if ( 'name' == $ type || 'both' == $type) {1046 if ( 'name' == $r['type'] || 'both' == $r['type'] ) { 1045 1047 $author_links['name'] = bbp_get_reply_author_display_name( $reply_id ); 1046 1048 } … … 1053 1055 } 1054 1056 1055 if ( true === $ show_role) {1057 if ( true === $r['show_role'] ) { 1056 1058 $author_link[] = bbp_get_reply_author_role( array( 'reply_id' => $reply_id ) ); 1057 1059 } 1058 1060 1059 $author_link = join( $ sep, $author_link );1061 $author_link = join( $r['sep'], $author_link ); 1060 1062 1061 1063 // No links if anonymous 1062 1064 } else { 1063 $author_link = join( $ sep, $author_links );1065 $author_link = join( $r['sep'], $author_links ); 1064 1066 } 1065 1067 … … 1069 1071 } 1070 1072 1071 return apply_filters( 'bbp_get_reply_author_link', $author_link, $ args);1073 return apply_filters( 'bbp_get_reply_author_link', $author_link, $r ); 1072 1074 } 1073 1075 … … 1193 1195 */ 1194 1196 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( 1196 1200 'reply_id' => 0, 1197 1201 'class' => 'bbp-author-role', 1198 1202 'before' => '', 1199 1203 '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'] ); 1205 1207 $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'] ); 1207 1209 1208 1210 return apply_filters( 'bbp_get_reply_author_role', $author_role, $args ); … … 1425 1427 function bbp_get_reply_admin_links( $args = '' ) { 1426 1428 1427 $defaults = array ( 1429 // Parse arguments with default values 1430 $r = bbp_parse_args( $args, array( 1428 1431 'id' => 0, 1429 1432 'before' => '<span class="bbp-admin-links">', … … 1431 1434 'sep' => ' | ', 1432 1435 'links' => array() 1433 ); 1434 $r = bbp_parse_args( $args, $defaults, 'get_reply_admin_links' ); 1436 ), 'get_reply_admin_links' ); 1435 1437 1436 1438 $r['id'] = bbp_get_reply_id( (int) $r['id'] ); … … 1471 1473 1472 1474 // 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 ) { 1474 1476 unset( $r['links']['spam'] ); 1475 1477 … … 1484 1486 $retval = $r['before'] . $links . $r['after']; 1485 1487 1486 return apply_filters( 'bbp_get_reply_admin_links', $retval, $ args);1488 return apply_filters( 'bbp_get_reply_admin_links', $retval, $r ); 1487 1489 } 1488 1490 … … 1519 1521 */ 1520 1522 function bbp_get_reply_edit_link( $args = '' ) { 1521 $defaults = array ( 1523 1524 // Parse arguments with default values 1525 $r = bbp_parse_args( $args, array( 1522 1526 'id' => 0, 1523 1527 'link_before' => '', 1524 1528 'link_after' => '', 1525 1529 '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'] ) ); 1531 1533 1532 1534 // Bypass check if user has caps … … 1534 1536 1535 1537 // 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 ) ) { 1537 1539 return; 1540 } 1538 1541 } 1539 1542 1540 1543 // Get uri 1541 $uri = bbp_get_reply_edit_url( $ id);1544 $uri = bbp_get_reply_edit_url( $r['id'] ); 1542 1545 1543 1546 // Bail if no uri … … 1545 1548 return; 1546 1549 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 ); 1550 1553 } 1551 1554 … … 1641 1644 */ 1642 1645 function bbp_get_reply_trash_link( $args = '' ) { 1643 $defaults = array ( 1646 1647 // Parse arguments with default values 1648 $r = bbp_parse_args( $args, array( 1644 1649 'id' => 0, 1645 1650 'link_before' => '', … … 1649 1654 'restore_text' => __( 'Restore', 'bbpress' ), 1650 1655 'delete_text' => __( 'Delete', 'bbpress' ) 1651 ); 1652 $r = bbp_parse_args( $args, $defaults, 'get_reply_trash_link' ); 1653 extract( $r ); 1656 ), 'get_reply_trash_link' ); 1654 1657 1655 1658 $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'] ) ); 1657 1660 1658 1661 if ( empty( $reply ) || !current_user_can( 'delete_reply', $reply->ID ) ) { … … 1661 1664 1662 1665 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( $r estore_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>'; 1664 1667 } 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>'; 1666 1669 } 1667 1670 1668 1671 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>'; 1670 1673 } 1671 1674 1672 1675 // 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 ); 1676 1679 } 1677 1680 … … 1713 1716 */ 1714 1717 function bbp_get_reply_spam_link( $args = '' ) { 1715 $defaults = array ( 1718 1719 // Parse argmuments with default values 1720 $r = bbp_parse_args( $args, array( 1716 1721 'id' => 0, 1717 1722 'link_before' => '', … … 1719 1724 'spam_text' => __( 'Spam', 'bbpress' ), 1720 1725 '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'] ) ); 1726 1729 1727 1730 if ( empty( $reply ) || !current_user_can( 'moderate', $reply->ID ) ) 1728 1731 return; 1729 1732 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']; 1731 1734 $uri = add_query_arg( array( 'action' => 'bbp_toggle_reply_spam', 'reply_id' => $reply->ID ) ); 1732 1735 $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 ); 1736 1739 } 1737 1740 … … 1777 1780 */ 1778 1781 function bbp_get_topic_split_link( $args = '' ) { 1779 $defaults = array ( 1782 1783 // Parse arguments with default values 1784 $r = bbp_parse_args( $args, array( 1780 1785 'id' => 0, 1781 1786 'link_before' => '', … … 1783 1788 'split_text' => __( 'Split', 'bbpress' ), 1784 1789 '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'] ); 1790 1793 $topic_id = bbp_get_reply_topic_id( $reply_id ); 1791 1794 … … 1802 1805 ) ); 1803 1806 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 ); 1807 1810 } 1808 1811 … … 1965 1968 1966 1969 // 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'] ) ) { 1968 1971 $reply_content = $_POST['bbp_reply_content']; 1969 1972 1970 1973 // Get edit data 1971 elseif ( bbp_is_reply_edit() )1974 } elseif ( bbp_is_reply_edit() ) { 1972 1975 $reply_content = bbp_get_global_post_field( 'post_content', 'raw' ); 1973 1976 1974 1977 // No data 1975 else1978 } else { 1976 1979 $reply_content = ''; 1980 } 1977 1981 1978 1982 return apply_filters( 'bbp_get_form_reply_content', esc_textarea( $reply_content ) ); … … 2001 2005 2002 2006 // 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'] ) ) { 2004 2008 $reply_revision = $_POST['bbp_log_reply_edit']; 2005 2009 2006 2010 // No data 2007 else2011 } else { 2008 2012 $reply_revision = 1; 2013 } 2009 2014 2010 2015 return apply_filters( 'bbp_get_form_reply_log_edit', checked( $reply_revision, true, false ) ); … … 2033 2038 2034 2039 // 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'] ) ) { 2036 2041 $reply_edit_reason = $_POST['bbp_reply_edit_reason']; 2037 2042 2038 2043 // No data 2039 else2044 } else { 2040 2045 $reply_edit_reason = ''; 2046 } 2041 2047 2042 2048 return apply_filters( 'bbp_get_form_reply_edit_reason', esc_attr( $reply_edit_reason ) );
Note: See TracChangeset
for help on using the changeset viewer.