Changeset 6583 for trunk/src/includes/forums/functions.php
- Timestamp:
- 06/19/2017 04:29:43 AM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/includes/forums/functions.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/forums/functions.php
r6573 r6583 963 963 // Query for private forums 964 964 $private_forums = new WP_Query( array( 965 'fields' => 'ids', 965 966 'suppress_filters' => true, 966 'nopaging' => true,967 'no_found_rows' => true,968 967 'post_type' => bbp_get_forum_post_type(), 969 968 'post_status' => bbp_get_private_status_id(), 970 'fields' => 'ids' 969 'posts_per_page' => -1, 970 971 // Performance 972 'ignore_sticky_posts' => true, 973 'no_found_rows' => true, 974 'nopaging' => true, 975 'update_post_term_cache' => false, 976 'update_post_meta_cache' => false 971 977 ) ); 972 978 973 979 // Query for hidden forums 974 980 $hidden_forums = new WP_Query( array( 981 'fields' => 'ids', 975 982 'suppress_filters' => true, 976 'nopaging' => true,977 'no_found_rows' => true,978 983 'post_type' => bbp_get_forum_post_type(), 979 984 'post_status' => bbp_get_hidden_status_id(), 980 'fields' => 'ids' 985 'posts_per_page' => -1, 986 987 // Performance 988 'ignore_sticky_posts' => true, 989 'no_found_rows' => true, 990 'nopaging' => true, 991 'update_post_term_cache' => false, 992 'update_post_meta_cache' => false 981 993 ) ); 982 994 … … 1650 1662 if ( empty( $topic_count ) ) { 1651 1663 $query = new WP_Query( array( 1652 'fields' => 'ids', 1653 'post_parent' => $forum_id, 1654 'post_status' => array( bbp_get_trash_status_id(), bbp_get_spam_status_id(), bbp_get_pending_status_id() ), 1655 'post_type' => bbp_get_topic_post_type(), 1656 1657 // Maybe change these later 1658 'posts_per_page' => -1, 1664 'fields' => 'ids', 1665 'suppress_filters' => true, 1666 'post_parent' => $forum_id, 1667 'post_status' => array( bbp_get_trash_status_id(), bbp_get_spam_status_id(), bbp_get_pending_status_id() ), 1668 'post_type' => bbp_get_topic_post_type(), 1669 'posts_per_page' => -1, 1670 1671 // Performance 1659 1672 'update_post_term_cache' => false, 1660 1673 'update_post_meta_cache' => false, 1661 1674 'ignore_sticky_posts' => true, 1662 'no_found_rows' => true 1675 'no_found_rows' => true, 1676 'nopaging' => true 1663 1677 ) ); 1664 1678 $topic_count = $query->post_count; … … 1706 1720 if ( ! empty( $topic_ids ) ) { 1707 1721 $query = new WP_Query( array( 1708 'fields' => 'ids', 1709 'post_parent__in' => $topic_ids, 1710 'post_status' => bbp_get_public_status_id(), 1711 'post_type' => bbp_get_reply_post_type(), 1712 1713 // Maybe change these later 1714 'posts_per_page' => -1, 1722 'fields' => 'ids', 1723 'suppress_filters' => true, 1724 'post_parent__in' => $topic_ids, 1725 'post_status' => bbp_get_public_status_id(), 1726 'post_type' => bbp_get_reply_post_type(), 1727 'posts_per_page' => -1, 1728 1729 // Performance 1715 1730 'update_post_term_cache' => false, 1716 1731 'update_post_meta_cache' => false, 1717 1732 'ignore_sticky_posts' => true, 1718 'no_found_rows' => true 1733 'no_found_rows' => true, 1734 'nopaging' => true 1719 1735 ) ); 1720 1736 $reply_count = ! empty( $query->posts ) ? count( $query->posts ) : 0; … … 2106 2122 2107 2123 $query = new WP_Query( array( 2108 'fields' => 'ids', 2109 'post_parent__in' => $topic_ids, 2110 'post_status' => bbp_get_public_status_id(), 2111 'post_type' => bbp_get_reply_post_type(), 2112 'orderby' => array( 2124 'fields' => 'ids', 2125 'suppress_filters' => true, 2126 'post_parent__in' => $topic_ids, 2127 'post_status' => bbp_get_public_status_id(), 2128 'post_type' => bbp_get_reply_post_type(), 2129 'posts_per_page' => 1, 2130 'orderby' => array( 2113 2131 'post_date' => 'DESC', 2114 2132 'ID' => 'DESC' 2115 2133 ), 2116 2134 2117 // Maybe change these later 2118 'posts_per_page' => 1, 2135 // Performance 2119 2136 'update_post_term_cache' => false, 2120 2137 'update_post_meta_cache' => false, 2121 2138 'ignore_sticky_posts' => true, 2122 'no_found_rows' => true 2139 'no_found_rows' => true, 2140 'nopaging' => true 2123 2141 ) ); 2124 2142 $reply_id = array_shift( $query->posts ); … … 2144 2162 } 2145 2163 2146 global $wp_query; 2147 2148 // Define local variable 2164 // Define local variables 2149 2165 $forum_id = 0; 2166 $wp_query = bbp_get_wp_query(); 2150 2167 2151 2168 // Check post type … … 2170 2187 // If forum is explicitly hidden and user not capable, set 404 2171 2188 if ( ! empty( $forum_id ) && bbp_is_forum_hidden( $forum_id ) && ! current_user_can( 'read_forum', $forum_id ) ) { 2172 bbp_set_404( );2189 bbp_set_404( $wp_query ); 2173 2190 } 2174 2191 } … … 2187 2204 } 2188 2205 2189 global $wp_query; 2190 2191 // Define local variable 2206 // Define local variables 2192 2207 $forum_id = 0; 2208 $wp_query = bbp_get_wp_query(); 2193 2209 2194 2210 // Check post type … … 2214 2230 // If forum is explicitly hidden and user not capable, set 404 2215 2231 if ( ! empty( $forum_id ) && bbp_is_forum_private( $forum_id ) && ! current_user_can( 'read_forum', $forum_id ) ) { 2216 bbp_set_404( );2232 bbp_set_404( $wp_query ); 2217 2233 } 2218 2234 } … … 2257 2273 // Note that we get all post statuses here 2258 2274 $topics = new WP_Query( array( 2275 'fields' => 'id=>parent', 2259 2276 'suppress_filters' => true, 2277 2278 // What and how 2260 2279 'post_type' => bbp_get_topic_post_type(), 2261 2280 'post_parent' => $forum_id, 2262 2281 'post_status' => array_keys( get_post_stati() ), 2263 2282 'posts_per_page' => -1, 2264 'nopaging' => true, 2265 'no_found_rows' => true, 2266 'fields' => 'id=>parent' 2283 2284 // Performance 2285 'ignore_sticky_posts' => true, 2286 'no_found_rows' => true, 2287 'nopaging' => true, 2288 'update_post_term_cache' => false, 2289 'update_post_meta_cache' => false 2267 2290 ) ); 2268 2291 … … 2305 2328 ); 2306 2329 2307 // Forum is being trashed, so its topics and repliesare trashed too2330 // Forum is being trashed, so its topics (and replies) are trashed too 2308 2331 $topics = new WP_Query( array( 2332 'fields' => 'id=>parent', 2309 2333 'suppress_filters' => true, 2310 2334 'post_type' => bbp_get_topic_post_type(), … … 2312 2336 'post_status' => $post_stati, 2313 2337 'posts_per_page' => -1, 2314 'nopaging' => true, 2315 'no_found_rows' => true, 2316 'fields' => 'id=>parent' 2338 2339 // Performance 2340 'ignore_sticky_posts' => true, 2341 'no_found_rows' => true, 2342 'nopaging' => true, 2343 'update_post_term_cache' => false, 2344 'update_post_meta_cache' => false 2317 2345 ) ); 2318 2346
Note: See TracChangeset
for help on using the changeset viewer.