Changeset 4059
- Timestamp:
- 07/05/2012 05:32:33 AM (12 years ago)
- Location:
- branches/plugin/bbp-includes
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-includes/bbp-common-functions.php
r4034 r4059 1471 1471 'key' => '_bbp_forum_id', 1472 1472 'value' => $forum_id, 1473 'type' => 'numeric', 1473 1474 'compare' => '=' 1474 1475 ) ); … … 1501 1502 'feed' => true, 1502 1503 'post_type' => bbp_get_topic_post_type(), 1503 'post_parent' => 'any',1504 'post_parent' => $forum_id, 1504 1505 'post_status' => join( ',', array( bbp_get_public_status_id(), bbp_get_closed_status_id() ) ), 1505 1506 'posts_per_page' => bbp_get_topics_per_rss_page(), 1506 'order' => 'DESC', 1507 'meta_query' => $meta_query 1507 'order' => 'DESC' 1508 1508 ); 1509 1509 … … 1550 1550 1551 1551 // Output the feed 1552 bbp_display_replies_feed_rss2( );1552 bbp_display_replies_feed_rss2( array( 'feed' => true ) ); 1553 1553 1554 1554 // All topics -
branches/plugin/bbp-includes/bbp-core-filters.php
r3966 r4059 201 201 add_filter( 'bbp_pre_anonymous_post_author_website', 'wp_filter_kses', 10 ); 202 202 203 // Queries 204 add_filter( 'posts_where', '_bbp_has_replies_where', 10, 2 ); 205 203 206 /** Functions *****************************************************************/ 204 207 -
branches/plugin/bbp-includes/bbp-core-shortcodes.php
r4048 r4059 377 377 } 378 378 379 // Filter the query380 if ( ! bbp_is_single_topic() ) {381 add_filter( 'bbp_before_has_replies_parse_args', array( $this, 'display_topic_query' ) );382 }383 384 379 // Start output buffer 385 380 $this->start( 'bbp_single_topic' ); … … 749 744 $args['show_stickies'] = true; 750 745 $args['order'] = 'DESC'; 751 return $args;752 }753 754 /**755 * Filter the query for the topic index756 *757 * @since bbPress (r3637)758 *759 * @param array $args760 * @return array761 */762 public function display_topic_query( $args = array() ) {763 $args['meta_query'] = array( array(764 'key' => '_bbp_topic_id',765 'value' => bbpress()->current_topic_id,766 'compare' => '='767 ) );768 769 746 return $args; 770 747 } -
branches/plugin/bbp-includes/bbp-forum-functions.php
r4042 r4059 1569 1569 1570 1570 // Setup arrays 1571 $retval = $private = $hidden = $meta_query = $forum_ids = array(); 1572 1571 $private = $hidden = $meta_query = $forum_ids = array(); 1572 1573 // Default return value 1574 switch ( $type ) { 1575 case 'string' : 1576 $retval = ''; 1577 break; 1578 1579 case 'array' : 1580 $retval = array(); 1581 break; 1582 1583 case 'meta_query' : 1584 $retval = array( array() ) ; 1585 break; 1586 } 1587 1573 1588 // Exclude for everyone but super admins 1574 1589 if ( !is_super_admin() ) { … … 1605 1620 'key' => '_bbp_forum_id', 1606 1621 'value' => implode( ',', $forum_ids ), 1622 'type' => 'numeric', 1607 1623 'compare' => ( 1 < count( $forum_ids ) ) ? 'NOT IN' : '!=' 1608 1624 ); … … 1949 1965 // Validate forum ID 1950 1966 $forum_id = bbp_get_forum_id( $forum_id ); 1951 1952 1967 if ( empty( $forum_id ) ) 1953 1968 return; … … 1956 1971 if ( bbp_has_topics( array( 1957 1972 'post_type' => bbp_get_topic_post_type(), 1973 'post_parent' => $forum_id, 1958 1974 'post_status' => 'any', 1959 'posts_per_page' => -1, 1960 'meta_query' => array( array( 1961 'key' => '_bbp_forum_id', 1962 'value' => $forum_id, 1963 'compare' => '=' 1964 ) ) 1975 'posts_per_page' => -1 1965 1976 ) ) ) { 1966 1977 while ( bbp_topics() ) { … … 1993 2004 // Validate forum ID 1994 2005 $forum_id = bbp_get_forum_id( $forum_id ); 1995 1996 2006 if ( empty( $forum_id ) ) 1997 2007 return; … … 2007 2017 if ( bbp_has_topics( array( 2008 2018 'post_type' => bbp_get_topic_post_type(), 2019 'post_parent' => $forum_id, 2009 2020 'post_status' => $post_stati, 2010 'posts_per_page' => -1, 2011 'meta_query' => array( array( 2012 'key' => '_bbp_forum_id', 2013 'value' => $forum_id, 2014 'compare' => '=' 2015 ) ) 2021 'posts_per_page' => -1 2016 2022 ) ) ) { 2017 2023 -
branches/plugin/bbp-includes/bbp-reply-functions.php
r4042 r4059 1366 1366 } 1367 1367 1368 /** Filters *******************************************************************/ 1369 1370 /** 1371 * Used by bbp_has_replies() to add the topic to the posts 1372 * 1373 * This function filters the 'post_where' of the WP_Query, and changes the query 1374 * to include both the topic AND its children in the same loop. 1375 * 1376 * @since bbPress (r4058) 1377 * 1378 * @param string $where 1379 * @return string 1380 */ 1381 function _bbp_has_replies_where( $where, $query ) { 1382 1383 // Bail if no post_parent to replace 1384 if ( ! is_numeric( $query->get( 'post_parent' ) ) ) 1385 return $where; 1386 1387 // Bail if not a topic and reply query 1388 if ( array( bbp_get_topic_post_type(), bbp_get_reply_post_type() ) != $query->get( 'post_type' ) ) 1389 return $where; 1390 1391 // Get the topic ID 1392 $topic_id = bbp_get_topic_id(); 1393 1394 // The text we're searching for 1395 $search = 'wp_posts.post_parent = ' . $topic_id ; 1396 1397 // The text to replace it with 1398 $replace = '(wp_posts.ID = ' . $topic_id . ' OR wp_posts.post_parent = ' . $topic_id . ')'; 1399 1400 // Try to replace the search text with the replacement 1401 if ( $new_where = str_replace( $search, $replace, $where ) ) 1402 $where = $new_where; 1403 1404 return $where; 1405 } 1406 1368 1407 /** Feeds *********************************************************************/ 1369 1408 -
branches/plugin/bbp-includes/bbp-reply-template.php
r4042 r4059 67 67 global $wp_rewrite; 68 68 69 // Default status70 $default_status = join( ',', array( bbp_get_public_status_id(), bbp_get_closed_status_id() ) );71 72 // Skip topic_id if in the replies widget query73 $parent_args['meta_query'] = array( array(74 'key' => '_bbp_topic_id',75 'value' => bbp_get_topic_id(),76 'compare' => '='77 ) );78 79 69 // What are the default allowed statuses (based on user caps) 80 70 if ( bbp_get_view_all( 'edit_others_replies' ) ) 81 $default_status = join( ',', array( bbp_get_public_status_id(), bbp_get_closed_status_id(), bbp_get_spam_status_id(), bbp_get_trash_status_id() ) ); 71 $default_post_status = join( ',', array( bbp_get_public_status_id(), bbp_get_closed_status_id(), bbp_get_spam_status_id(), bbp_get_trash_status_id() ) ); 72 else 73 $default_post_status = join( ',', array( bbp_get_public_status_id(), bbp_get_closed_status_id() ) ); 74 75 // Maybe Search 76 $default_reply_search = !empty( $_REQUEST['rs'] ) ? $_REQUEST['rs'] : false; 77 $default_post_parent = ( bbp_is_single_topic() ) ? bbp_get_topic_id() : 'any'; 78 $default_post_type = ( bbp_is_single_topic() && bbp_show_lead_topic() ) ? bbp_get_reply_post_type() : array( bbp_get_topic_post_type(), bbp_get_reply_post_type() ); 82 79 83 80 // Default query args 84 81 $default = array( 85 'post_type' => bbp_show_lead_topic() ? bbp_get_reply_post_type() : array( bbp_get_topic_post_type(), bbp_get_reply_post_type() ), 86 'orderby' => 'date', // 'author', 'date', 'title', 'modified', 'parent', rand', 87 'order' => 'ASC', // 'ASC', 'DESC' 88 'posts_per_page' => bbp_get_replies_per_page(), // Max number 89 'paged' => bbp_get_paged(), // Page Number 90 's' => !empty( $_REQUEST['rs'] ) ? $_REQUEST['rs'] : '', // Reply Search 91 'post_status' => $default_status // Post Status 82 'post_type' => $default_post_type, // Only replies 83 'post_parent' => $default_post_parent, // Of this topic 84 'post_status' => $default_post_status, // Of this status 85 'posts_per_page' => bbp_get_replies_per_page(), // This many 86 'paged' => bbp_get_paged(), // On this page 87 'orderby' => 'date', // Sorted by date 88 'order' => 'ASC', // Oldest to newest 89 's' => $default_reply_search, // Maybe search 92 90 ); 93 94 // Merge the default args and parent args together95 if ( !empty( $parent_args ) )96 $default = array_merge( $parent_args, $default );97 91 98 92 // Set up topic variables -
branches/plugin/bbp-includes/bbp-topic-functions.php
r4042 r4059 2831 2831 2832 2832 // Topic is being permanently deleted, so its replies gotta go too 2833 // @todo remove meta query 2833 2834 if ( bbp_has_replies( array( 2834 2835 'post_type' => bbp_get_reply_post_type(), … … 2838 2839 'key' => '_bbp_topic_id', 2839 2840 'value' => $topic_id, 2841 'type' => 'numeric', 2840 2842 'compare' => '=' 2841 2843 ) ) … … 2875 2877 2876 2878 // Topic is being trashed, so its replies are trashed too 2879 // @todo remove meta query 2877 2880 if ( bbp_has_replies( array( 2878 2881 'post_type' => bbp_get_reply_post_type(), … … 2882 2885 'key' => '_bbp_topic_id', 2883 2886 'value' => $topic_id, 2887 'type' => 'numeric', 2884 2888 'compare' => '=' 2885 2889 ) )
Note: See TracChangeset
for help on using the changeset viewer.