Ticket #1925: 1925.05.diff
File 1925.05.diff, 17.9 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' => 'date', 748 747 'order' => 'DESC', 749 748 ); 750 749 break; -
includes/forums/functions.php
584 584 * Handle the saving of core forum metadata (Status, Visibility, and Type) 585 585 * 586 586 * @since bbPress (r3678) 587 * 587 588 * @param int $forum_id 588 589 * @uses bbp_is_forum_closed() To check if forum is closed 589 590 * @uses bbp_close_forum() To close forum … … 666 667 * @since bbPress (r2746) 667 668 * 668 669 * @param int $forum_id forum id 670 * @uses bbp_get_forum_id() To verify the forum id 669 671 * @uses do_action() Calls 'bbp_close_forum' with the forum id 670 672 * @uses update_post_meta() To add the previous status to a meta 671 * @uses do_action() Calls 'bbp_ opened_forum' with the forum id673 * @uses do_action() Calls 'bbp_closed_forum' with the forum id 672 674 * @return mixed False or {@link WP_Error} on failure, forum id on success 673 675 */ 674 676 function bbp_close_forum( $forum_id = 0 ) { … … 690 692 * @since bbPress (r2746) 691 693 * 692 694 * @param int $forum_id forum id 695 * @uses bbp_get_forum_id() To verify the forum id 693 696 * @uses do_action() Calls 'bbp_open_forum' with the forum id 694 * @uses get_post_meta() To get the previous status695 697 * @uses update_post_meta() To delete the previous status meta 696 698 * @uses do_action() Calls 'bbp_opened_forum' with the forum id 697 699 * @return mixed False or {@link WP_Error} on failure, forum id on success … … 715 717 * @since bbPress (r2746) 716 718 * 717 719 * @param int $forum_id Optional. Forum id 720 * @uses bbp_get_forum_id() To verify the forum id 721 * @uses do_action() Calls 'bbp_categorize_forum' with the forum id 718 722 * @uses update_post_meta() To update the forum category meta 723 * @uses do_action() Calls 'bbp_categorized_forum' with the forum id 719 724 * @return bool False on failure, true on success 720 725 */ 721 726 function bbp_categorize_forum( $forum_id = 0 ) { … … 737 742 * @since bbPress (r2746) 738 743 * 739 744 * @param int $forum_id Optional. Forum id 740 * @uses delete_post_meta() To delete the forum category meta 745 * @uses bbp_get_forum_id() To verify the forum id 746 * @uses do_action() Calls 'bbp_normalize_forum' with the forum id 747 * @uses update_post_meta() To delete the forum category meta 748 * @uses do_action() Calls 'bbp_normalized_forum' with the forum id 741 749 * @return bool False on failure, true on success 742 750 */ 743 751 function bbp_normalize_forum( $forum_id = 0 ) { … … 758 766 * 759 767 * @since bbPress (r2746) 760 768 * 769 * @global WPDB $wpdb 761 770 * @param int $forum_id Optional. Forum id 762 * @uses update_post_meta() To update the forum private meta 771 * @uses bbp_get_forum_id() To verify the forum id 772 * @uses do_action() Calls 'bbp_publicize_forum' with the forum id 773 * @uses bbp_get_private_forum_ids() To get private forum id's 774 * @uses bbp_get_hidden_forum_ids() To get hidden forum id's 775 * @uses bbp_get_public_status_id() To get public status id 776 * @uses update_option() To update the private and hidden post ID pointers 777 * @uses do_action() Calls 'bbp_publicized_forum' with the forum id 763 778 * @return bool False on failure, true on success 764 779 */ 765 780 function bbp_publicize_forum( $forum_id = 0, $current_visibility = '' ) { … … 818 833 * 819 834 * @since bbPress (r2746) 820 835 * 836 * @global WPDB $wpdb 821 837 * @param int $forum_id Optional. Forum id 822 * @uses update_post_meta() To update the forum private meta 838 * @uses bbp_get_forum_id() To verify the forum id 839 * @uses do_action() Calls 'bbp_privatize_forum' with the forum id 840 * @uses bbp_get_private_status_id() To get private status id 841 * @uses bbp_get_hidden_forum_ids() To get hidden forum id's 842 * @uses bbp_get_private_forum_ids() To get private forum id's 843 * @uses update_option() To update the private and hidden post ID pointers 844 * @uses do_action() Calls 'bbp_privatized_forum' with the forum id 823 845 * @return bool False on failure, true on success 824 846 */ 825 847 function bbp_privatize_forum( $forum_id = 0, $current_visibility = '' ) { … … 868 890 * 869 891 * @since bbPress (r2996) 870 892 * 893 * @global WPDB $wpdb 871 894 * @param int $forum_id Optional. Forum id 872 * @uses update_post_meta() To update the forum private meta 895 * @uses bbp_get_forum_id() To verify the forum id 896 * @uses do_action() Calls 'bbp_hide_forum' with the forum id 897 * @uses bbp_get_hidden_status_id() To get hidden status id 898 * @uses bbp_get_private_forum_ids() To get private forum id's 899 * @uses bbp_get_hidden_forum_ids() To get hidden forum id's 900 * @uses update_option() To update the private and hidden post ID pointers 901 * @uses do_action() Calls 'bbp_hid_forum' with the forum id 873 902 * @return bool False on failure, true on success 874 903 */ 875 904 function bbp_hide_forum( $forum_id = 0, $current_visibility = '' ) { … … 1144 1173 * @uses bbp_forum_query_subforum_ids() To get the subforum ids 1145 1174 * @uses bbp_update_forum_last_topic_id() To update the last topic id of child 1146 1175 * forums 1176 * @uses bbp_get_topic_post_type() To set the topic post type query variable 1147 1177 * @uses get_posts() To get the most recent topic in the forum 1178 * @uses bbp_is_topic_published() To check if the topic is already published 1148 1179 * @uses update_post_meta() To update the forum's last active id meta 1149 1180 * @uses apply_filters() Calls 'bbp_update_forum_last_topic_id' with the last 1150 1181 * reply id and forum id … … 1171 1202 $post_vars = array( 1172 1203 'post_parent' => $forum_id, 1173 1204 'post_type' => bbp_get_topic_post_type(), 1174 ' meta_key' => '_bbp_last_active_time',1175 'order by' => 'meta_value',1205 'orderby' => 'date', 1206 'order' => 'DESC', 1176 1207 'numberposts' => 1 1177 1208 ); 1178 1209 … … 1348 1379 $new_time = get_post_field( 'post_date', bbp_get_forum_last_active_id( $forum_id ) ); 1349 1380 1350 1381 // Update only if there is a time 1351 if ( !empty( $new_time ) ) 1382 if ( !empty( $new_time ) ) { 1352 1383 update_post_meta( $forum_id, '_bbp_last_active_time', $new_time ); 1384 } 1353 1385 1354 1386 return (int) apply_filters( 'bbp_update_forum_last_active', $new_time, $forum_id ); 1355 1387 } … … 1901 1933 * Callback to sort forum ID's based on last active time 1902 1934 * 1903 1935 * @since bbPress (r3789) 1936 * 1904 1937 * @param int $a First forum ID to compare 1905 1938 * @param int $b Second forum ID to compare 1906 1939 * @return Position change based on sort 1907 1940 */ 1908 1941 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);1942 $ta = get_post_field( 'post_modified', $a ); 1943 $tb = get_post_field( 'post_modified', $b ); 1911 1944 return ( $ta < $tb ) ? -1 : 1; 1912 1945 } 1913 1946 … … 2247 2280 * a forum that is being deleted. 2248 2281 * 2249 2282 * @since bbPress (r3668) 2283 * 2250 2284 * @uses bbp_get_forum_id() To get the forum id 2251 2285 * @uses bbp_is_forum() To check if the passed id is a forum 2252 2286 * @uses do_action() Calls 'bbp_delete_forum' with the forum id … … 2268 2302 * a forum that is being trashed. 2269 2303 * 2270 2304 * @since bbPress (r3668) 2305 * 2271 2306 * @uses bbp_get_forum_id() To get the forum id 2272 2307 * @uses bbp_is_forum() To check if the passed id is a forum 2273 2308 * @uses do_action() Calls 'bbp_trash_forum' with the forum id … … 2285 2320 * Called before untrashing a forum 2286 2321 * 2287 2322 * @since bbPress (r3668) 2323 * 2288 2324 * @uses bbp_get_forum_id() To get the forum id 2289 2325 * @uses bbp_is_forum() To check if the passed id is a forum 2290 2326 * @uses do_action() Calls 'bbp_untrash_forum' with the forum id … … 2304 2340 * Called after deleting a forum 2305 2341 * 2306 2342 * @since bbPress (r3668) 2343 * 2307 2344 * @uses bbp_get_forum_id() To get the forum id 2308 2345 * @uses bbp_is_forum() To check if the passed id is a forum 2309 2346 * @uses do_action() Calls 'bbp_deleted_forum' with the forum id … … 2321 2358 * Called after trashing a forum 2322 2359 * 2323 2360 * @since bbPress (r3668) 2361 * 2324 2362 * @uses bbp_get_forum_id() To get the forum id 2325 2363 * @uses bbp_is_forum() To check if the passed id is a forum 2326 2364 * @uses do_action() Calls 'bbp_trashed_forum' with the forum id … … 2338 2376 * Called after untrashing a forum 2339 2377 * 2340 2378 * @since bbPress (r3668) 2379 * 2341 2380 * @uses bbp_get_forum_id() To get the forum id 2342 2381 * @uses bbp_is_forum() To check if the passed id is a forum 2343 2382 * @uses do_action() Calls 'bbp_untrashed_forum' with the forum id -
includes/forums/template.php
16 16 * Output the unique id of the custom post type for forums 17 17 * 18 18 * @since bbPress (r2857) 19 * 19 20 * @uses bbp_get_forum_post_type() To get the forum post type 20 21 */ 21 22 function bbp_forum_post_type() { … … 447 448 * Allow forum rows to have adminstrative actions 448 449 * 449 450 * @since bbPress (r3653) 451 * 450 452 * @uses do_action() 451 453 * @todo Links and filter 452 454 */ … … 502 504 * 503 505 * @param int $forum_id Optional. Forum id 504 506 * @uses bbp_get_forum_id() To get the forum id 505 * @uses get_post_meta() To retrieve forum last active meta506 507 * @uses bbp_get_forum_last_reply_id() To get forum's last reply id 507 508 * @uses get_post_field() To get the post date of the reply 508 509 * @uses bbp_get_forum_last_topic_id() To get forum's last topic id … … 516 517 */ 517 518 function bbp_get_forum_last_active_time( $forum_id = 0 ) { 518 519 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 ); 520 // Verify forum id 521 $forum_id = bbp_get_forum_id( $forum_id ); 522 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 } 523 // Check the forum for the last reply id and use this time stamp 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 528 // No reply's, lets try the last topic and use that time stamp 529 } else { 530 $topic_id = bbp_get_forum_last_topic_id( $forum_id ); 531 if ( !empty( $topic_id ) ) { 532 $last_active = bbp_get_topic_last_active_time( $topic_id ); 532 533 } 533 534 } 534 535 … … 1559 1560 * Is the forum open? 1560 1561 * 1561 1562 * @since bbPress (r2746) 1563 * 1562 1564 * @param int $forum_id Optional. Forum id 1563 1565 * 1564 1566 * @param int $forum_id Optional. Forum id … … 2226 2228 2227 2229 return apply_filters( 'bbp_get_form_forum_visibility', esc_attr( $forum_visibility ) ); 2228 2230 } 2229 2231 2230 2232 /** 2231 2233 * Output checked value of forum subscription 2232 2234 * -
includes/replies/functions.php
866 866 update_post_meta( $reply_id, '_bbp_author_ip', bbp_current_author_ip(), false ); 867 867 868 868 // Last active time 869 $last_active_time = current_time( 'mysql');869 $last_active_time = get_post_field( 'post_date', $reply_id ); 870 870 871 871 // Walk up ancestors and do the dirty work 872 872 bbp_update_reply_walker( $reply_id, $last_active_time, $forum_id, $topic_id, false ); … … 1395 1395 bbp_update_reply_to( $child->ID, $parent ); 1396 1396 1397 1397 // Remove reply_to from moved reply 1398 delete_post_meta( $move_reply->ID, '_bbp_reply_to' ); 1398 delete_post_meta( $move_reply->ID, '_bbp_reply_to' ); 1399 1399 1400 1400 // It is a new topic and we need to set some default metas to make 1401 1401 // the topic display in bbp_has_topics() list … … 1867 1867 * Check if autoembeds are enabled and hook them in if so 1868 1868 * 1869 1869 * @since bbPress (r3752) 1870 * 1870 1871 * @global WP_Embed $wp_embed 1871 1872 */ 1872 1873 function bbp_reply_content_autoembed() { -
includes/topics/functions.php
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 801 802 * @uses set_transient() To update the flood check transient for the ip 802 803 * @uses bbp_update_user_last_posted() To update the users last posted time 803 804 * @uses bbp_is_subscriptions_active() To check if the subscriptions feature is … … 887 888 update_post_meta( $topic_id, '_bbp_author_ip', bbp_current_author_ip(), false ); 888 889 889 890 // Last active time 890 $last_active = current_time( 'mysql');891 $last_active = get_post_field( 'post_date', $topic_id ); 891 892 892 893 // Reply topic meta 893 894 bbp_update_topic_last_reply_id ( $topic_id, 0 ); … … 909 910 * function can be costly to run but is necessary to keep everything accurate. 910 911 * 911 912 * @since bbPress (r2800) 913 * 912 914 * @param int $topic_id Topic id 913 915 * @param string $last_active_time Optional. Last active time 914 916 * @param int $forum_id Optional. Forum id … … 965 967 'last_topic_id' => $topic_id, 966 968 'last_reply_id' => $reply_id, 967 969 'last_active_id' => $active_id, 968 'last_active_time' => 0,970 'last_active_time' => $last_active_time, 969 971 'last_active_status' => $topic_status 970 972 ) ); 971 973 } … … 3374 3376 * Check if autoembeds are enabled and hook them in if so 3375 3377 * 3376 3378 * @since bbPress (r3752) 3379 * 3377 3380 * @global WP_Embed $wp_embed 3378 3381 */ 3379 3382 function bbp_topic_content_autoembed() { … … 3455 3458 <guid><?php bbp_topic_permalink(); ?></guid> 3456 3459 <title><![CDATA[<?php bbp_topic_title(); ?>]]></title> 3457 3460 <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>3461 <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_field( 'post_date', bbp_get_topic_id() ) ); ?></pubDate> 3459 3462 <dc:creator><?php the_author() ?></dc:creator> 3460 3463 3461 3464 <?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' => 'date', // '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', 284 'order' => 'DESC', 282 'orderby' => 'date', 283 'order' => 'ASC', 285 284 'include' => $stickies 286 285 ); 287 286 … … 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 1780 * @uses bbp_get_topic_id() To verify the topic id 1783 1781 * @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 1782 * @uses get_post_field() To get the post date of topic 1783 * @uses get_post_field() To get the post date of reply 1785 1784 * @uses bbp_convert_date() To convert date 1786 1785 * @uses bbp_get_time_since() To get time in since format 1787 1786 * @uses apply_filters() Calls 'bbp_get_topic_last_active' with topic … … 1791 1790 function bbp_get_topic_last_active_time( $topic_id = 0 ) { 1792 1791 $topic_id = bbp_get_topic_id( $topic_id ); 1793 1792 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 } 1793 // Check the topic for the last reply id 1794 $reply_id = bbp_get_topic_last_reply_id( $topic_id ); 1795 1796 // If we have a reply use that timestamp, if not use the topic timestamp 1797 if ( !empty( $reply_id ) ) { 1798 $last_active = get_post_field( 'post_date', $reply_id ); 1799 } else { 1800 $last_active = get_post_field( 'post_date', $topic_id ); 1803 1801 } 1804 1802 1805 1803 $last_active = !empty( $last_active ) ? bbp_get_time_since( bbp_convert_date( $last_active ) ) : ''; … … 3756 3754 * Allow topic rows to have adminstrative actions 3757 3755 * 3758 3756 * @since bbPress (r3653) 3757 * 3759 3758 * @uses do_action() 3760 3759 * @todo Links and filter 3761 3760 */ … … 3767 3766 * Output value of topic tags field 3768 3767 * 3769 3768 * @since bbPress (r2976) 3769 * 3770 3770 * @uses bbp_get_form_topic_tags() To get the value of topic tags field 3771 3771 */ 3772 3772 function bbp_form_topic_tags() {