Changeset 5683
- Timestamp:
- 04/15/2015 03:00:15 PM (11 years ago)
- File:
-
- 1 edited
-
trunk/src/includes/forums/template.php (modified) (51 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/forums/template.php
r5676 r5683 218 218 219 219 // Easy empty checking 220 if ( ! empty( $forum_id ) && is_numeric( $forum_id ) ) {220 if ( ! empty( $forum_id ) && is_numeric( $forum_id ) ) { 221 221 $bbp_forum_id = $forum_id; 222 222 223 223 // Currently inside a forum loop 224 } elseif ( ! empty( $bbp->forum_query->in_the_loop ) && isset( $bbp->forum_query->post->ID ) ) {224 } elseif ( ! empty( $bbp->forum_query->in_the_loop ) && isset( $bbp->forum_query->post->ID ) ) { 225 225 $bbp_forum_id = $bbp->forum_query->post->ID; 226 226 227 227 // Currently inside a search loop 228 } elseif ( ! empty( $bbp->search_query->in_the_loop ) && isset( $bbp->search_query->post->ID ) && bbp_is_forum( $bbp->search_query->post->ID ) ) {228 } elseif ( ! empty( $bbp->search_query->in_the_loop ) && isset( $bbp->search_query->post->ID ) && bbp_is_forum( $bbp->search_query->post->ID ) ) { 229 229 $bbp_forum_id = $bbp->search_query->post->ID; 230 230 231 231 // Currently viewing a forum 232 } elseif ( ( bbp_is_single_forum() || bbp_is_forum_edit() ) && ! empty( $bbp->current_forum_id ) ) {232 } elseif ( ( bbp_is_single_forum() || bbp_is_forum_edit() ) && ! empty( $bbp->current_forum_id ) ) { 233 233 $bbp_forum_id = $bbp->current_forum_id; 234 234 … … 328 328 329 329 // Use the redirect address 330 if ( ! empty( $redirect_to ) ) {330 if ( ! empty( $redirect_to ) ) { 331 331 $forum_permalink = esc_url_raw( $redirect_to ); 332 332 … … 401 401 // Set root text to page title 402 402 $page = bbp_get_page_by_path( bbp_get_root_slug() ); 403 if ( ! empty( $page ) ) {403 if ( ! empty( $page ) ) { 404 404 $title = get_the_title( $page->ID ); 405 405 … … 532 532 if ( empty( $last_active ) ) { 533 533 $reply_id = bbp_get_forum_last_reply_id( $forum_id ); 534 if ( ! empty( $reply_id ) ) {534 if ( ! empty( $reply_id ) ) { 535 535 $last_active = get_post_field( 'post_date', $reply_id ); 536 536 } else { 537 537 $topic_id = bbp_get_forum_last_topic_id( $forum_id ); 538 if ( ! empty( $topic_id ) ) {538 if ( ! empty( $topic_id ) ) { 539 539 $last_active = bbp_get_topic_last_active_time( $topic_id ); 540 540 } … … 542 542 } 543 543 544 $active_time = ! empty( $last_active ) ? bbp_get_time_since( bbp_convert_date( $last_active ) ) : '';544 $active_time = ! empty( $last_active ) ? bbp_get_time_since( bbp_convert_date( $last_active ) ) : ''; 545 545 546 546 return apply_filters( 'bbp_get_forum_last_active', $active_time, $forum_id ); … … 607 607 $time_since = bbp_get_forum_last_active_time( $forum_id ); 608 608 609 if ( ! empty( $time_since ) && !empty( $link_url ) ) {609 if ( ! empty( $time_since ) && ! empty( $link_url ) ) { 610 610 $anchor = '<a href="' . esc_url( $link_url ) . '" title="' . esc_attr( $title ) . '">' . esc_html( $time_since ) . '</a>'; 611 611 } else { … … 662 662 $forum = bbp_get_forum( $forum_id ); 663 663 664 if ( ! empty( $forum ) ) {664 if ( ! empty( $forum ) ) { 665 665 while ( 0 !== (int) $forum->post_parent ) { 666 666 $ancestors[] = $forum->post_parent; … … 731 731 732 732 // No forum passed 733 $sub_forums = ! empty( $r['post_parent'] ) ? $get_posts->query( $r ) : array();734 735 return (array) apply_filters( 'bbp_forum_get_subforums', $sub_forums, $r );733 $sub_forums = ! empty( $r['post_parent'] ) ? $get_posts->query( $r ) : array(); 734 735 return (array) apply_filters( 'bbp_forum_get_subforums', $sub_forums, $r, $args ); 736 736 } 737 737 … … 779 779 // Loop through forums and create a list 780 780 $sub_forums = bbp_forum_get_subforums( $r['forum_id'] ); 781 if ( ! empty( $sub_forums ) ) {781 if ( ! empty( $sub_forums ) ) { 782 782 783 783 // Total count (for separator) … … 793 793 794 794 // Show topic count 795 if ( ! empty( $r['show_topic_count'] ) && !bbp_is_forum_category( $sub_forum->ID ) ) {795 if ( ! empty( $r['show_topic_count'] ) && ! bbp_is_forum_category( $sub_forum->ID ) ) { 796 796 $count['topic'] = bbp_get_forum_topic_count( $sub_forum->ID ); 797 797 } 798 798 799 799 // Show reply count 800 if ( ! empty( $r['show_reply_count'] ) && !bbp_is_forum_category( $sub_forum->ID ) ) {800 if ( ! empty( $r['show_reply_count'] ) && ! bbp_is_forum_category( $sub_forum->ID ) ) { 801 801 $count['reply'] = bbp_get_forum_reply_count( $sub_forum->ID ); 802 802 } 803 803 804 804 // Counts to show 805 if ( ! empty( $count ) ) {805 if ( ! empty( $count ) ) { 806 806 $counts = $r['count_before'] . implode( $r['count_sep'], $count ) . $r['count_after']; 807 807 } … … 812 812 813 813 // Output the list 814 echo apply_filters( 'bbp_list_forums', $r['before'] . $output . $r['after'], $r );814 echo apply_filters( 'bbp_list_forums', $r['before'] . $output . $r['after'], $r, $args ); 815 815 } 816 816 } … … 851 851 'before' => '', 852 852 'after' => '', 853 'subscribe' => __( 'Subscribe', 'bbpress' ),854 'unsubscribe' => __( 'Unsubscribe', 'bbpress' )853 'subscribe' => esc_html__( 'Subscribe', 'bbpress' ), 854 'unsubscribe' => esc_html__( 'Unsubscribe', 'bbpress' ) 855 855 ), 'get_forum_subscribe_link' ); 856 856 … … 861 861 } 862 862 863 return apply_filters( 'bbp_get_forum_subscribe_link', $retval, $r );863 return apply_filters( 'bbp_get_forum_subscribe_link', $retval, $r, $args ); 864 864 } 865 865 … … 923 923 $forum_id = bbp_get_forum_id( $forum_id ); 924 924 $topic_id = bbp_get_forum_last_topic_id( $forum_id ); 925 $title = ! empty( $topic_id ) ? bbp_get_topic_title( $topic_id ) : '';925 $title = ! empty( $topic_id ) ? bbp_get_topic_title( $topic_id ) : ''; 926 926 927 927 return apply_filters( 'bbp_get_forum_last_topic_title', $title, $forum_id ); … … 955 955 function bbp_get_forum_last_topic_permalink( $forum_id = 0 ) { 956 956 $forum_id = bbp_get_forum_id( $forum_id ); 957 return apply_filters( 'bbp_get_forum_last_topic_permalink', bbp_get_topic_permalink( bbp_get_forum_last_topic_id( $forum_id ) ), $forum_id ); 957 $topic_id = bbp_get_forum_last_topic_id( $forum_id ); 958 $link = bbp_get_topic_permalink( $topic_id ); 959 960 return apply_filters( 'bbp_get_forum_last_topic_permalink', $link, $forum_id, $topic_id ); 958 961 } 959 962 … … 973 976 function bbp_get_forum_last_topic_author_id( $forum_id = 0 ) { 974 977 $forum_id = bbp_get_forum_id( $forum_id ); 975 $author_id = bbp_get_topic_author_id( bbp_get_forum_last_topic_id( $forum_id ) ); 976 return (int) apply_filters( 'bbp_get_forum_last_topic_author_id', (int) $author_id, $forum_id ); 978 $topic_id = bbp_get_forum_last_topic_id( $forum_id ); 979 $author_id = bbp_get_topic_author_id( $topic_id ); 980 981 return (int) apply_filters( 'bbp_get_forum_last_topic_author_id', (int) $author_id, $forum_id, $topic_id ); 977 982 } 978 983 … … 1007 1012 $author_id = bbp_get_forum_last_topic_author_id( $forum_id ); 1008 1013 $author_link = bbp_get_user_profile_link( $author_id ); 1014 1009 1015 return apply_filters( 'bbp_get_forum_last_topic_author_link', $author_link, $forum_id ); 1010 1016 } … … 1069 1075 function bbp_get_forum_last_reply_title( $forum_id = 0 ) { 1070 1076 $forum_id = bbp_get_forum_id( $forum_id ); 1071 return apply_filters( 'bbp_get_forum_last_reply_title', bbp_get_reply_title( bbp_get_forum_last_reply_id( $forum_id ) ), $forum_id ); 1077 $reply_id = bbp_get_forum_last_reply_id( $forum_id ); 1078 $title = bbp_get_reply_title( $reply_id ); 1079 1080 return apply_filters( 'bbp_get_forum_last_reply_title', $title, $forum_id, $reply_id ); 1072 1081 } 1073 1082 … … 1098 1107 function bbp_get_forum_last_reply_permalink( $forum_id = 0 ) { 1099 1108 $forum_id = bbp_get_forum_id( $forum_id ); 1100 return apply_filters( 'bbp_get_forum_last_reply_permalink', bbp_get_reply_permalink( bbp_get_forum_last_reply_id( $forum_id ) ), $forum_id ); 1109 $reply_id = bbp_get_forum_last_reply_id( $forum_id ); 1110 $link = bbp_get_reply_permalink( $reply_id ); 1111 1112 return apply_filters( 'bbp_get_forum_last_reply_permalink', $link, $forum_id, $reply_id ); 1101 1113 } 1102 1114 … … 1132 1144 // If forum has replies, get the last reply and use its url 1133 1145 $reply_id = bbp_get_forum_last_reply_id( $forum_id ); 1134 if ( ! empty( $reply_id ) ) {1146 if ( ! empty( $reply_id ) ) { 1135 1147 $reply_url = bbp_get_reply_url( $reply_id ); 1136 1148 … … 1146 1158 1147 1159 // Filter and return 1148 return apply_filters( 'bbp_get_forum_last_reply_url', $reply_url, $forum_id );1160 return apply_filters( 'bbp_get_forum_last_reply_url', $reply_url, $forum_id, $reply_id ); 1149 1161 } 1150 1162 … … 1177 1189 function bbp_get_forum_last_reply_author_id( $forum_id = 0 ) { 1178 1190 $forum_id = bbp_get_forum_id( $forum_id ); 1179 $author_id = bbp_get_reply_author_id( bbp_get_forum_last_reply_id( $forum_id ) ); 1180 return apply_filters( 'bbp_get_forum_last_reply_author_id', $author_id, $forum_id ); 1191 $reply_id = bbp_get_forum_last_reply_id( $forum_id ); 1192 $author_id = bbp_get_reply_author_id( $reply_id ); 1193 1194 return apply_filters( 'bbp_get_forum_last_reply_author_id', $author_id, $forum_id, $reply_id ); 1181 1195 } 1182 1196 … … 1212 1226 $author_id = bbp_get_forum_last_reply_author_id( $forum_id ); 1213 1227 $author_link = bbp_get_user_profile_link( $author_id ); 1214 return apply_filters( 'bbp_get_forum_last_reply_author_link', $author_link, $forum_id ); 1228 1229 return apply_filters( 'bbp_get_forum_last_reply_author_link', $author_link, $forum_id, $author_id ); 1215 1230 } 1216 1231 … … 1265 1280 1266 1281 // This forum has hidden topics 1267 if ( ! empty( $deleted ) && current_user_can( 'edit_others_topics' ) ) {1282 if ( ! empty( $deleted ) && current_user_can( 'edit_others_topics' ) ) { 1268 1283 1269 1284 // Extra text … … 1490 1505 $forum_id = bbp_get_forum_id( $forum_id ); 1491 1506 $status = get_post_meta( $forum_id, '_bbp_status', true ); 1507 1492 1508 if ( empty( $status ) ) { 1493 1509 $status = 'open'; … … 1515 1531 * @param int $forum_id Optional. Forum id 1516 1532 * @uses bbp_get_forum_id() To get the forum id 1517 * @uses get_post_ visibility() To get the forum's visibility1533 * @uses get_post_status() To get the forum's status 1518 1534 * @uses apply_filters() Calls 'bbp_get_forum_visibility' with the visibility 1519 1535 * and forum id … … 1521 1537 */ 1522 1538 function bbp_get_forum_visibility( $forum_id = 0 ) { 1523 $forum_id = bbp_get_forum_id( $forum_id ); 1524 1525 return apply_filters( 'bbp_get_forum_visibility', get_post_status( $forum_id ), $forum_id ); 1539 $forum_id = bbp_get_forum_id( $forum_id ); 1540 $visibility = get_post_status( $forum_id ); 1541 1542 return apply_filters( 'bbp_get_forum_visibility', $visibility, $forum_id ); 1526 1543 } 1527 1544 … … 1549 1566 $forum_id = bbp_get_forum_id( $forum_id ); 1550 1567 $retval = get_post_meta( $forum_id, '_bbp_forum_type', true ); 1568 1551 1569 if ( empty( $retval ) ) { 1552 1570 $retval = 'forum'; … … 1568 1586 $forum_id = bbp_get_forum_id( $forum_id ); 1569 1587 $type = bbp_get_forum_type( $forum_id ); 1570 $retval = ( ! empty( $type ) && 'category' === $type );1588 $retval = ( ! empty( $type ) && 'category' === $type ); 1571 1589 1572 1590 return (bool) apply_filters( 'bbp_is_forum_category', (bool) $retval, $forum_id ); … … 1585 1603 */ 1586 1604 function bbp_is_forum_open( $forum_id = 0, $check_ancestors = true ) { 1587 return ! bbp_is_forum_closed( $forum_id, $check_ancestors );1605 return ! bbp_is_forum_closed( $forum_id, $check_ancestors ); 1588 1606 } 1589 1607 … … 1779 1797 1780 1798 // Quickly compare visibility of first forum ID 1781 if ( $status_name === $visibility ) {1799 if ( $status_name === $visibility ) { 1782 1800 $retval = true; 1783 1801 $count++; … … 1788 1806 1789 1807 // Adjust the ancestor check based on the count 1790 switch ( $operator ) {1808 switch ( $operator ) { 1791 1809 1792 1810 // Adjust the ancestor check based on the count … … 1828 1846 return (bool) apply_filters( 'bbp_is_forum_visibility', $retval, $count, $forum_id, $status_name, $check_ancestors, $operator ); 1829 1847 } 1848 1849 /** 1850 * Output the author ID of the forum 1851 * 1852 * @since bbPress (r3675) 1853 * 1854 * @param int $forum_id Optional. Forum id 1855 * @uses bbp_get_forum_author_id() To get the forum author id 1856 */ 1857 function bbp_forum_author_id( $forum_id = 0 ) { 1858 echo bbp_get_forum_author_id( $forum_id ); 1859 } 1860 /** 1861 * Return the author ID of the forum 1862 * 1863 * @since bbPress (r3675) 1864 * 1865 * @param int $forum_id Optional. Forum id 1866 * @uses bbp_get_forum_id() To get the forum id 1867 * @uses get_post_field() To get the forum author id 1868 * @uses apply_filters() Calls 'bbp_get_forum_author_id' with the author 1869 * id and forum id 1870 * @return string Author of forum 1871 */ 1872 function bbp_get_forum_author_id( $forum_id = 0 ) { 1873 $forum_id = bbp_get_forum_id( $forum_id ); 1874 $author_id = get_post_field( 'post_author', $forum_id ); 1875 1876 return (int) apply_filters( 'bbp_get_forum_author_id', (int) $author_id, $forum_id ); 1877 } 1830 1878 1831 1879 /** … … 1854 1902 */ 1855 1903 function bbp_get_forum_author_display_name( $forum_id = 0 ) { 1856 $forum_id = bbp_get_forum_id( $forum_id );1857 $author = get_the_author_meta( 'display_name', bbp_get_forum_author_id( $forum_id ) );1858 1859 return apply_filters( 'bbp_get_forum_author_display_name', $author, $forum_id );1860 }1861 1862 /**1863 * Output the author ID of the forum1864 *1865 * @since bbPress (r3675)1866 *1867 * @param int $forum_id Optional. Forum id1868 * @uses bbp_get_forum_author_id() To get the forum author id1869 */1870 function bbp_forum_author_id( $forum_id = 0 ) {1871 echo bbp_get_forum_author_id( $forum_id );1872 }1873 /**1874 * Return the author ID of the forum1875 *1876 * @since bbPress (r3675)1877 *1878 * @param int $forum_id Optional. Forum id1879 * @uses bbp_get_forum_id() To get the forum id1880 * @uses get_post_field() To get the forum author id1881 * @uses apply_filters() Calls 'bbp_get_forum_author_id' with the author1882 * id and forum id1883 * @return string Author of forum1884 */1885 function bbp_get_forum_author_id( $forum_id = 0 ) {1886 1904 $forum_id = bbp_get_forum_id( $forum_id ); 1887 $author_id = get_post_field( 'post_author', $forum_id ); 1888 1889 return (int) apply_filters( 'bbp_get_forum_author_id', (int) $author_id, $forum_id ); 1905 $author_id = bbp_get_forum_author_id( $forum_id ); 1906 $author = get_the_author_meta( 'display_name', $author_id ); 1907 1908 return apply_filters( 'bbp_get_forum_author_display_name', $author, $forum_id, $author_id ); 1890 1909 } 1891 1910 … … 1904 1923 */ 1905 1924 function bbp_suppress_private_forum_meta( $retval, $forum_id ) { 1906 if ( bbp_is_forum_private( $forum_id, false ) && ! current_user_can( 'read_private_forums' ) ) {1925 if ( bbp_is_forum_private( $forum_id, false ) && ! current_user_can( 'read_private_forums' ) ) { 1907 1926 $retval = '-'; 1908 1927 } … … 1935 1954 1936 1955 // Show the normal author link 1937 if ( ! empty( $args['post_id'] ) && !current_user_can( 'read_private_forums' ) ) {1956 if ( ! empty( $args['post_id'] ) && ! current_user_can( 'read_private_forums' ) ) { 1938 1957 1939 1958 // What post type are we looking at? … … 2086 2105 2087 2106 // Has replies 2088 if ( ! empty( $reply_count ) ) {2107 if ( ! empty( $reply_count ) ) { 2089 2108 $reply_text = sprintf( _n( '%s reply', '%s replies', $rc_int, 'bbpress' ), $reply_count ); 2090 2109 } 2091 2110 2092 2111 // Forum has active data 2093 if ( ! empty( $last_active ) ) {2112 if ( ! empty( $last_active ) ) { 2094 2113 $topic_text = bbp_get_forum_topics_link( $forum_id ); 2095 2114 $time_since = bbp_get_forum_freshness_link( $forum_id ); … … 2102 2121 2103 2122 // Forum has active data 2104 if ( ! empty( $last_active ) ) {2105 2106 if ( ! empty( $reply_count ) ) {2123 if ( ! empty( $last_active ) ) { 2124 2125 if ( ! empty( $reply_count ) ) { 2107 2126 2108 2127 if ( bbp_is_forum_category( $forum_id ) ) { … … 2124 2143 } else { 2125 2144 2126 if ( ! empty( $reply_count ) ) {2145 if ( ! empty( $reply_count ) ) { 2127 2146 2128 2147 if ( bbp_is_forum_category( $forum_id ) ) { … … 2134 2153 } else { 2135 2154 2136 if ( ! empty( $topic_count ) ) {2155 if ( ! empty( $topic_count ) ) { 2137 2156 2138 2157 if ( bbp_is_forum_category( $forum_id ) ) { … … 2149 2168 2150 2169 // Add feeds 2151 //$feed_links = ( ! empty( $r['feed'] ) ) ? bbp_get_forum_topics_feed_link ( $forum_id ) . bbp_get_forum_replies_feed_link( $forum_id ) : '';2170 //$feed_links = ( ! empty( $r['feed'] ) ) ? bbp_get_forum_topics_feed_link ( $forum_id ) . bbp_get_forum_replies_feed_link( $forum_id ) : ''; 2152 2171 2153 2172 // Add the 'view all' filter back … … 2158 2177 2159 2178 // Return filtered result 2160 return apply_filters( 'bbp_get_single_forum_description', $retstr, $r );2179 return apply_filters( 'bbp_get_single_forum_description', $retstr, $r, $args ); 2161 2180 } 2162 2181 … … 2186 2205 // Get _POST data 2187 2206 if ( bbp_is_forum_form_post_request() && isset( $_POST['bbp_forum_title'] ) ) { 2188 $forum_title = $_POST['bbp_forum_title'];2207 $forum_title = wp_unslash( $_POST['bbp_forum_title'] ); 2189 2208 2190 2209 // Get edit data … … 2197 2216 } 2198 2217 2199 return apply_filters( 'bbp_get_form_forum_title', esc_attr( $forum_title ));2218 return apply_filters( 'bbp_get_form_forum_title', $forum_title ); 2200 2219 } 2201 2220 … … 2310 2329 } 2311 2330 2312 return apply_filters( 'bbp_get_form_forum_type', esc_attr( $forum_type ));2331 return apply_filters( 'bbp_get_form_forum_type', $forum_type ); 2313 2332 } 2314 2333 … … 2348 2367 } 2349 2368 2350 return apply_filters( 'bbp_get_form_forum_visibility', esc_attr( $forum_visibility ));2369 return apply_filters( 'bbp_get_form_forum_visibility', $forum_visibility ); 2351 2370 } 2352 2371 … … 2502 2521 2503 2522 // Return the results 2504 return apply_filters( 'bbp_get_form_forum_type_dropdown', ob_get_clean(), $r );2523 return apply_filters( 'bbp_get_form_forum_type_dropdown', ob_get_clean(), $r, $args ); 2505 2524 } 2506 2525 … … 2594 2613 2595 2614 // Return the results 2596 return apply_filters( 'bbp_get_form_forum_status_dropdown', ob_get_clean(), $r );2615 return apply_filters( 'bbp_get_form_forum_status_dropdown', ob_get_clean(), $r, $args ); 2597 2616 } 2598 2617 … … 2686 2705 2687 2706 // Return the results 2688 return apply_filters( 'bbp_get_form_forum_type_dropdown', ob_get_clean(), $r );2707 return apply_filters( 'bbp_get_form_forum_type_dropdown', ob_get_clean(), $r, $args ); 2689 2708 } 2690 2709 … … 2758 2777 2759 2778 // Forum is valid 2760 if ( ! empty( $forum_id ) ) {2779 if ( ! empty( $forum_id ) ) { 2761 2780 2762 2781 // Define local variable(s) … … 2820 2839 2821 2840 // Forum is valid 2822 if ( ! empty( $forum_id ) ) {2841 if ( ! empty( $forum_id ) ) { 2823 2842 2824 2843 // Define local variable(s)
Note: See TracChangeset
for help on using the changeset viewer.