diff --git a/plugins/bbpress/includes/common/widgets.php b/plugins/bbpress/includes/common/widgets.php
index 3204dc7..9866888 100644
|
a
|
b
|
|
| 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; |
diff --git a/plugins/bbpress/includes/forums/functions.php b/plugins/bbpress/includes/forums/functions.php
index 050791d..37eea24 100644
|
a
|
b
|
|
| 1167 | 1167 | } |
| 1168 | 1168 | } |
| 1169 | 1169 | |
| 1170 | | // Setup recent topic query vars |
| 1171 | | $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 | | 'orderby' => '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_id |
| 1180 | | $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 | |
| | 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 | } |
| 1353 | 1361 | |
| 1354 | 1362 | return (int) apply_filters( 'bbp_update_forum_last_active', $new_time, $forum_id ); |
| 1355 | 1363 | } |
| … |
… |
|
| 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 | |
diff --git a/plugins/bbpress/includes/forums/template.php b/plugins/bbpress/includes/forums/template.php
index 890dbe0..3ea300b 100644
|
a
|
b
|
|
| 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 | 506 | * @uses bbp_get_forum_last_reply_id() To get forum's last reply id |
| 507 | 507 | * @uses get_post_field() To get the post date of the reply |
| 508 | 508 | * @uses bbp_get_forum_last_topic_id() To get forum's last topic id |
| … |
… |
|
| 515 | 515 | * @return string Forum last update date/time (freshness) |
| 516 | 516 | */ |
| 517 | 517 | function bbp_get_forum_last_active_time( $forum_id = 0 ) { |
| | 518 | $forum_id = bbp_get_forum_id( $forum_id ); |
| | 519 | $post_modified = get_post_field( 'post_modified', $forum_id ); |
| | 520 | $last_active = bbp_get_time_since( bbp_convert_date( $post_modified ) ); |
| 518 | 521 | |
| 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 ); |
| | 522 | return apply_filters( 'bbp_get_forum_last_active', $last_active, $forum_id ); |
| 538 | 523 | } |
| 539 | 524 | |
| 540 | 525 | /** |
diff --git a/plugins/bbpress/includes/search/template.php b/plugins/bbpress/includes/search/template.php
index c22b887..212717f 100644
|
a
|
b
|
|
| 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 date |
| | 53 | '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 |
diff --git a/plugins/bbpress/includes/topics/functions.php b/plugins/bbpress/includes/topics/functions.php
index d097d22..df38911 100644
|
a
|
b
|
|
| 798 | 798 | * @uses bbp_get_current_user_id() To get the current user id |
| 799 | 799 | * @yses bbp_get_topic_forum_id() To get the topic forum id |
| 800 | 800 | * @uses update_post_meta() To update the topic metas |
| 801 | | * @uses get_post_field() To get the topic's last active time |
| 802 | 801 | * @uses set_transient() To update the flood check transient for the ip |
| 803 | 802 | * @uses bbp_update_user_last_posted() To update the users last posted time |
| 804 | 803 | * @uses bbp_is_subscriptions_active() To check if the subscriptions feature is |
| … |
… |
|
| 888 | 887 | update_post_meta( $topic_id, '_bbp_author_ip', bbp_current_author_ip(), false ); |
| 889 | 888 | |
| 890 | 889 | // Last active time |
| 891 | | $last_active = current_time( 'mysql' ); |
| | 890 | $last_active = get_post_field( 'post_date', $topic_id ); |
| 892 | 891 | |
| 893 | 892 | // Reply topic meta |
| 894 | 893 | bbp_update_topic_last_reply_id ( $topic_id, 0 ); |
| … |
… |
|
| 2525 | 2524 | |
| 2526 | 2525 | // Update only if published |
| 2527 | 2526 | if ( !empty( $new_time ) ) { |
| | 2527 | |
| | 2528 | // Update topic's meta - not used since 2.6 |
| 2528 | 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 | 'post_modified_gmt' => get_gmt_from_date( $new_time ) |
| | 2536 | ) ); |
| 2529 | 2537 | } |
| 2530 | 2538 | |
| 2531 | 2539 | return apply_filters( 'bbp_update_topic_last_active_time', $new_time, $topic_id ); |
| … |
… |
|
| 3456 | 3464 | <guid><?php bbp_topic_permalink(); ?></guid> |
| 3457 | 3465 | <title><![CDATA[<?php bbp_topic_title(); ?>]]></title> |
| 3458 | 3466 | <link><?php bbp_topic_permalink(); ?></link> |
| 3459 | | <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> |
| | 3467 | <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_field( 'post_modified', bbp_get_topic_id() ) ); ?></pubDate> |
| 3460 | 3468 | <dc:creator><?php the_author() ?></dc:creator> |
| 3461 | 3469 | |
| 3462 | 3470 | <?php if ( !post_password_required() ) : ?> |
diff --git a/plugins/bbpress/includes/topics/template.php b/plugins/bbpress/includes/topics/template.php
index 98fe48d..bb97266 100644
|
a
|
b
|
|
| 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 ); |
| 1793 | | |
| 1794 | | // Try to get the most accurate freshness time possible |
| 1795 | | $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 ) ) : ''; |
| | 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 ) ); |
| 1806 | 1792 | |
| 1807 | 1793 | // Return the time since |
| 1808 | 1794 | return apply_filters( 'bbp_get_topic_last_active', $last_active, $topic_id ); |