Ticket #1925: 1925.2.patch
File 1925.2.patch, 10.2 KB (added by , 11 years ago) |
---|
-
includes/common/widgets.php
743 743 'post_status' => array( bbp_get_public_status_id(), bbp_get_closed_status_id() ), 744 744 'ignore_sticky_posts' => true, 745 745 'no_found_rows' => true, 746 'meta_key' => '_bbp_last_active_time', 747 'orderby' => 'meta_value', 746 'orderby' => 'modified', 748 747 'order' => 'DESC', 749 748 ); 750 749 break; -
includes/forums/functions.php
1167 1167 } 1168 1168 } 1169 1169 1170 // Setup recent topic query vars1171 $ post_vars =array(1170 // Get the most recent topic in this forum_id 1171 $recent_topic = get_posts( array( 1172 1172 'post_parent' => $forum_id, 1173 1173 'post_type' => bbp_get_topic_post_type(), 1174 ' meta_key' => '_bbp_last_active_time',1175 'order by' => 'meta_value',1174 'orderby' => 'modified', 1175 'order' => 'DESC', 1176 1176 'numberposts' => 1 1177 ) ;1177 ) ); 1178 1178 1179 // Get the most recent topic in this forum_id1180 $recent_topic = get_posts( $post_vars );1181 1179 if ( !empty( $recent_topic ) ) { 1182 1180 $topic_id = $recent_topic[0]->ID; 1183 1181 } … … 1347 1345 if ( empty( $new_time ) ) 1348 1346 $new_time = get_post_field( 'post_date', bbp_get_forum_last_active_id( $forum_id ) ); 1349 1347 1350 // Update only if there is a time 1351 if ( !empty( $new_time ) ) 1348 // Update only if published 1349 if ( !empty( $new_time ) ) { 1350 1351 // Update forum's meta - not used since 2.6 1352 1352 update_post_meta( $forum_id, '_bbp_last_active_time', $new_time ); 1353 1353 1354 // Update forum's post_modified date - since 2.6 1355 wp_update_post( array( 1356 'ID' => $forum_id, 1357 'post_modified' => $new_time, 1358 'post_modified_gmt' => get_gmt_from_date( $new_time ) 1359 ) ); 1360 } 1361 1354 1362 return (int) apply_filters( 'bbp_update_forum_last_active', $new_time, $forum_id ); 1355 1363 } 1356 1364 … … 1906 1914 * @return Position change based on sort 1907 1915 */ 1908 1916 function _bbp_forum_query_usort_subforum_ids( $a = 0, $b = 0 ) { 1909 $ta = get_post_ meta( $a, '_bbp_last_active_time', true);1910 $tb = get_post_ meta( $b, '_bbp_last_active_time', true);1917 $ta = get_post_field( 'post_modified', $a ); 1918 $tb = get_post_field( 'post_modified', $b ); 1911 1919 return ( $ta < $tb ) ? -1 : 1; 1912 1920 } 1913 1921 -
includes/forums/template.php
447 447 * Allow forum rows to have adminstrative actions 448 448 * 449 449 * @since bbPress (r3653) 450 * 450 451 * @uses do_action() 451 452 * @todo Links and filter 452 453 */ … … 502 503 * 503 504 * @param int $forum_id Optional. Forum id 504 505 * @uses bbp_get_forum_id() To get the forum id 505 * @uses get_post_meta() To retrieve forum last active meta 506 * @uses bbp_get_forum_last_reply_id() To get forum's last reply id 507 * @uses get_post_field() To get the post date of the reply 508 * @uses bbp_get_forum_last_topic_id() To get forum's last topic id 509 * @uses bbp_get_topic_last_active_time() To get time when the topic was 510 * last active 506 * @uses get_post_field() To get the post modified date of the forum 511 507 * @uses bbp_convert_date() To convert the date 512 508 * @uses bbp_get_time_since() To get time in since format 513 509 * @uses apply_filters() Calls 'bbp_get_forum_last_active' with last … … 515 511 * @return string Forum last update date/time (freshness) 516 512 */ 517 513 function bbp_get_forum_last_active_time( $forum_id = 0 ) { 514 $forum_id = bbp_get_forum_id( $forum_id ); 515 $post_modified = get_post_field( 'post_modified', $forum_id ); 516 $last_active = bbp_get_time_since( bbp_convert_date( $post_modified ) ); 518 517 519 // Verify forum and get last active meta 520 $forum_id = bbp_get_forum_id( $forum_id ); 521 $last_active = get_post_meta( $forum_id, '_bbp_last_active_time', true ); 522 523 if ( empty( $last_active ) ) { 524 $reply_id = bbp_get_forum_last_reply_id( $forum_id ); 525 if ( !empty( $reply_id ) ) { 526 $last_active = get_post_field( 'post_date', $reply_id ); 527 } else { 528 $topic_id = bbp_get_forum_last_topic_id( $forum_id ); 529 if ( !empty( $topic_id ) ) { 530 $last_active = bbp_get_topic_last_active_time( $topic_id ); 531 } 532 } 533 } 534 535 $active_time = !empty( $last_active ) ? bbp_get_time_since( bbp_convert_date( $last_active ) ) : ''; 536 537 return apply_filters( 'bbp_get_forum_last_active', $active_time, $forum_id ); 518 return apply_filters( 'bbp_get_forum_last_active', $last_active, $forum_id ); 538 519 } 539 520 540 521 /** … … 2226 2207 2227 2208 return apply_filters( 'bbp_get_form_forum_visibility', esc_attr( $forum_visibility ) ); 2228 2209 } 2229 2210 2230 2211 /** 2231 2212 * Output checked value of forum subscription 2232 2213 * -
includes/search/template.php
50 50 'post_type' => $default_post_type, // Forums, topics, and replies 51 51 'posts_per_page' => bbp_get_replies_per_page(), // This many 52 52 'paged' => bbp_get_paged(), // On this page 53 'orderby' => ' date', // Sorted by date53 'orderby' => 'modified', // Sorted by date 54 54 'order' => 'DESC', // Most recent first 55 55 'ignore_sticky_posts' => true, // Stickies not supported 56 56 's' => bbp_get_search_terms(), // This is a search … … 141 141 'prev_text' => is_rtl() ? '→' : '←', 142 142 'next_text' => is_rtl() ? '←' : '→', 143 143 'mid_size' => 1, 144 'add_args' => $add_args, 144 'add_args' => $add_args, 145 145 ) ) 146 146 ); 147 147 -
includes/topics/functions.php
2524 2524 2525 2525 // Update only if published 2526 2526 if ( !empty( $new_time ) ) { 2527 2528 // Update topic's meta - not used since 2.6 2527 2529 update_post_meta( $topic_id, '_bbp_last_active_time', $new_time ); 2530 2531 // Update topic's post_modified date - since 2.6 2532 wp_update_post( array( 2533 'ID' => $topic_id, 2534 'post_modified' => $new_time 2535 ) ); 2528 2536 } 2529 2537 2530 2538 return apply_filters( 'bbp_update_topic_last_active_time', $new_time, $topic_id ); … … 3455 3463 <guid><?php bbp_topic_permalink(); ?></guid> 3456 3464 <title><![CDATA[<?php bbp_topic_title(); ?>]]></title> 3457 3465 <link><?php bbp_topic_permalink(); ?></link> 3458 <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_ meta( bbp_get_topic_id(), '_bbp_last_active_time', true) ); ?></pubDate>3466 <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_field( 'post_modified', bbp_get_topic_id() ) ); ?></pubDate> 3459 3467 <dc:creator><?php the_author() ?></dc:creator> 3460 3468 3461 3469 <?php if ( !post_password_required() ) : ?> -
includes/topics/template.php
97 97 * - New Style: Topics appear as "lead" posts, ahead of replies 98 98 * 99 99 * @since bbPress (r2954) 100 * 100 101 * @param $show_lead Optional. Default false 101 102 * @return bool Yes if the topic appears as a lead, otherwise false 102 103 */ … … 151 152 $default = array( 152 153 'post_type' => bbp_get_topic_post_type(), // Narrow query down to bbPress topics 153 154 'post_parent' => $default_post_parent, // Forum ID 154 'meta_key' => '_bbp_last_active_time', // Make sure topic has some last activity time 155 'orderby' => 'meta_value', // 'meta_value', 'author', 'date', 'title', 'modified', 'parent', rand', 155 'orderby' => 'modified', // 'meta_value', 'author', 'date', 'title', 'modified', 'parent', rand', 156 156 'order' => 'DESC', // 'ASC', 'DESC' 157 157 'posts_per_page' => bbp_get_topics_per_page(), // Topics per page 158 158 'paged' => bbp_get_paged(), // Page Number … … 279 279 $sticky_query = array( 280 280 'post_type' => bbp_get_topic_post_type(), 281 281 'post_parent' => 'any', 282 'meta_key' => '_bbp_last_active_time', 283 'orderby' => 'meta_value', 282 'orderby' => 'modified', 284 283 'order' => 'DESC', 285 284 'include' => $stickies 286 285 ); … … 1778 1777 * @since bbPress (r2625) 1779 1778 * 1780 1779 * @param int $topic_id Optional. Topic id 1781 * @uses bbp_get_topic_id() To get topic id 1782 * @uses get_post_meta() To get the topic lst active meta 1783 * @uses bbp_get_topic_last_reply_id() To get topic last reply id 1784 * @uses get_post_field() To get the post date of topic/reply 1780 * @uses bbp_get_topic_id() To verify the topic id 1781 * @uses get_post_field() To get the post date of topic 1785 1782 * @uses bbp_convert_date() To convert date 1786 1783 * @uses bbp_get_time_since() To get time in since format 1787 1784 * @uses apply_filters() Calls 'bbp_get_topic_last_active' with topic … … 1789 1786 * @return string Topic freshness 1790 1787 */ 1791 1788 function bbp_get_topic_last_active_time( $topic_id = 0 ) { 1792 $topic_id = bbp_get_topic_id( $topic_id ); 1789 $topic_id = bbp_get_topic_id( $topic_id ); 1790 $post_modified = get_post_field( 'post_modified', $topic_id ); 1791 $last_active = bbp_get_time_since( bbp_convert_date( $post_modified ) ); 1793 1792 1794 // Try to get the most accurate freshness time possible1795 $last_active = get_post_meta( $topic_id, '_bbp_last_active_time', true );1796 if ( empty( $last_active ) ) {1797 $reply_id = bbp_get_topic_last_reply_id( $topic_id );1798 if ( !empty( $reply_id ) ) {1799 $last_active = get_post_field( 'post_date', $reply_id );1800 } else {1801 $last_active = get_post_field( 'post_date', $topic_id );1802 }1803 }1804 1805 $last_active = !empty( $last_active ) ? bbp_get_time_since( bbp_convert_date( $last_active ) ) : '';1806 1807 1793 // Return the time since 1808 1794 return apply_filters( 'bbp_get_topic_last_active', $last_active, $topic_id ); 1809 1795 }