Skip to:
Content

bbPress.org

Ticket #1925: 1925.05.diff

File 1925.05.diff, 17.9 KB (added by netweb, 11 years ago)
  • includes/common/widgets.php

     
    743743                                        'post_status'         => array( bbp_get_public_status_id(), bbp_get_closed_status_id() ),
    744744                                        'ignore_sticky_posts' => true,
    745745                                        'no_found_rows'       => true,
    746                                         'meta_key'            => '_bbp_last_active_time',
    747                                         'orderby'             => 'meta_value',
     746                                        'orderby'             => 'date',
    748747                                        'order'               => 'DESC',
    749748                                );
    750749                                break;
  • includes/forums/functions.php

     
    584584 * Handle the saving of core forum metadata (Status, Visibility, and Type)
    585585 *
    586586 * @since bbPress (r3678)
     587 *
    587588 * @param int $forum_id
    588589 * @uses bbp_is_forum_closed() To check if forum is closed
    589590 * @uses bbp_close_forum() To close forum
     
    666667 * @since bbPress (r2746)
    667668 *
    668669 * @param int $forum_id forum id
     670 * @uses bbp_get_forum_id() To verify the forum id
    669671 * @uses do_action() Calls 'bbp_close_forum' with the forum id
    670672 * @uses update_post_meta() To add the previous status to a meta
    671  * @uses do_action() Calls 'bbp_opened_forum' with the forum id
     673 * @uses do_action() Calls 'bbp_closed_forum' with the forum id
    672674 * @return mixed False or {@link WP_Error} on failure, forum id on success
    673675 */
    674676function bbp_close_forum( $forum_id = 0 ) {
     
    690692 * @since bbPress (r2746)
    691693 *
    692694 * @param int $forum_id forum id
     695 * @uses bbp_get_forum_id() To verify the forum id
    693696 * @uses do_action() Calls 'bbp_open_forum' with the forum id
    694  * @uses get_post_meta() To get the previous status
    695697 * @uses update_post_meta() To delete the previous status meta
    696698 * @uses do_action() Calls 'bbp_opened_forum' with the forum id
    697699 * @return mixed False or {@link WP_Error} on failure, forum id on success
     
    715717 * @since bbPress (r2746)
    716718 *
    717719 * @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
    718722 * @uses update_post_meta() To update the forum category meta
     723 * @uses do_action() Calls 'bbp_categorized_forum' with the forum id
    719724 * @return bool False on failure, true on success
    720725 */
    721726function bbp_categorize_forum( $forum_id = 0 ) {
     
    737742 * @since bbPress (r2746)
    738743 *
    739744 * @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
    741749 * @return bool False on failure, true on success
    742750 */
    743751function bbp_normalize_forum( $forum_id = 0 ) {
     
    758766 *
    759767 * @since bbPress (r2746)
    760768 *
     769 * @global WPDB $wpdb
    761770 * @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
    763778 * @return bool False on failure, true on success
    764779 */
    765780function bbp_publicize_forum( $forum_id = 0, $current_visibility = '' ) {
     
    818833 *
    819834 * @since bbPress (r2746)
    820835 *
     836 * @global WPDB $wpdb
    821837 * @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
    823845 * @return bool False on failure, true on success
    824846 */
    825847function bbp_privatize_forum( $forum_id = 0, $current_visibility = '' ) {
     
    868890 *
    869891 * @since bbPress (r2996)
    870892 *
     893 * @global WPDB $wpdb
    871894 * @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
    873902 * @return bool False on failure, true on success
    874903 */
    875904function bbp_hide_forum( $forum_id = 0, $current_visibility = '' ) {
     
    11441173 * @uses bbp_forum_query_subforum_ids() To get the subforum ids
    11451174 * @uses bbp_update_forum_last_topic_id() To update the last topic id of child
    11461175 *                                         forums
     1176 * @uses bbp_get_topic_post_type() To set the topic post type query variable
    11471177 * @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
    11481179 * @uses update_post_meta() To update the forum's last active id meta
    11491180 * @uses apply_filters() Calls 'bbp_update_forum_last_topic_id' with the last
    11501181 *                        reply id and forum id
     
    11711202                $post_vars = array(
    11721203                        'post_parent' => $forum_id,
    11731204                        'post_type'   => bbp_get_topic_post_type(),
    1174                         'meta_key'    => '_bbp_last_active_time',
    1175                         'orderby'     => 'meta_value',
     1205                        'orderby'     => 'date',
     1206                        'order'       => 'DESC',
    11761207                        'numberposts' => 1
    11771208                );
    11781209
     
    13481379                $new_time = get_post_field( 'post_date', bbp_get_forum_last_active_id( $forum_id ) );
    13491380
    13501381        // Update only if there is a time
    1351         if ( !empty( $new_time ) )
     1382        if ( !empty( $new_time ) ) {
    13521383                update_post_meta( $forum_id, '_bbp_last_active_time', $new_time );
     1384        }
    13531385
    13541386        return (int) apply_filters( 'bbp_update_forum_last_active', $new_time, $forum_id );
    13551387}
     
    19011933 * Callback to sort forum ID's based on last active time
    19021934 *
    19031935 * @since bbPress (r3789)
     1936 *
    19041937 * @param int $a First forum ID to compare
    19051938 * @param int $b Second forum ID to compare
    19061939 * @return Position change based on sort
    19071940 */
    19081941function _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 );
    19111944        return ( $ta < $tb ) ? -1 : 1;
    19121945}
    19131946
     
    22472280 * a forum that is being deleted.
    22482281 *
    22492282 * @since bbPress (r3668)
     2283 *
    22502284 * @uses bbp_get_forum_id() To get the forum id
    22512285 * @uses bbp_is_forum() To check if the passed id is a forum
    22522286 * @uses do_action() Calls 'bbp_delete_forum' with the forum id
     
    22682302 * a forum that is being trashed.
    22692303 *
    22702304 * @since bbPress (r3668)
     2305 *
    22712306 * @uses bbp_get_forum_id() To get the forum id
    22722307 * @uses bbp_is_forum() To check if the passed id is a forum
    22732308 * @uses do_action() Calls 'bbp_trash_forum' with the forum id
     
    22852320 * Called before untrashing a forum
    22862321 *
    22872322 * @since bbPress (r3668)
     2323 *
    22882324 * @uses bbp_get_forum_id() To get the forum id
    22892325 * @uses bbp_is_forum() To check if the passed id is a forum
    22902326 * @uses do_action() Calls 'bbp_untrash_forum' with the forum id
     
    23042340 * Called after deleting a forum
    23052341 *
    23062342 * @since bbPress (r3668)
     2343 *
    23072344 * @uses bbp_get_forum_id() To get the forum id
    23082345 * @uses bbp_is_forum() To check if the passed id is a forum
    23092346 * @uses do_action() Calls 'bbp_deleted_forum' with the forum id
     
    23212358 * Called after trashing a forum
    23222359 *
    23232360 * @since bbPress (r3668)
     2361 *
    23242362 * @uses bbp_get_forum_id() To get the forum id
    23252363 * @uses bbp_is_forum() To check if the passed id is a forum
    23262364 * @uses do_action() Calls 'bbp_trashed_forum' with the forum id
     
    23382376 * Called after untrashing a forum
    23392377 *
    23402378 * @since bbPress (r3668)
     2379 *
    23412380 * @uses bbp_get_forum_id() To get the forum id
    23422381 * @uses bbp_is_forum() To check if the passed id is a forum
    23432382 * @uses do_action() Calls 'bbp_untrashed_forum' with the forum id
  • includes/forums/template.php

     
    1616 * Output the unique id of the custom post type for forums
    1717 *
    1818 * @since bbPress (r2857)
     19 *
    1920 * @uses bbp_get_forum_post_type() To get the forum post type
    2021 */
    2122function bbp_forum_post_type() {
     
    447448 * Allow forum rows to have adminstrative actions
    448449 *
    449450 * @since bbPress (r3653)
     451 *
    450452 * @uses do_action()
    451453 * @todo Links and filter
    452454 */
     
    502504         *
    503505         * @param int $forum_id Optional. Forum id
    504506         * @uses bbp_get_forum_id() To get the forum id
    505          * @uses get_post_meta() To retrieve forum last active meta
    506507         * @uses bbp_get_forum_last_reply_id() To get forum's last reply id
    507508         * @uses get_post_field() To get the post date of the reply
    508509         * @uses bbp_get_forum_last_topic_id() To get forum's last topic id
     
    516517         */
    517518        function bbp_get_forum_last_active_time( $forum_id = 0 ) {
    518519
    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 );
    522522
    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 );
    532533                        }
    533534                }
    534535
     
    15591560 * Is the forum open?
    15601561 *
    15611562 * @since bbPress (r2746)
     1563 *
    15621564 * @param int $forum_id Optional. Forum id
    15631565 *
    15641566 * @param int $forum_id Optional. Forum id
     
    22262228
    22272229                return apply_filters( 'bbp_get_form_forum_visibility', esc_attr( $forum_visibility ) );
    22282230        }
    2229        
     2231
    22302232/**
    22312233 * Output checked value of forum subscription
    22322234 *
  • includes/replies/functions.php

     
    866866                update_post_meta( $reply_id, '_bbp_author_ip', bbp_current_author_ip(), false );
    867867
    868868                // Last active time
    869                 $last_active_time = current_time( 'mysql' );
     869                $last_active_time = get_post_field( 'post_date', $reply_id );
    870870
    871871                // Walk up ancestors and do the dirty work
    872872                bbp_update_reply_walker( $reply_id, $last_active_time, $forum_id, $topic_id, false );
     
    13951395                bbp_update_reply_to( $child->ID, $parent );
    13961396
    13971397        // 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' );
    13991399
    14001400        // It is a new topic and we need to set some default metas to make
    14011401        // the topic display in bbp_has_topics() list
     
    18671867 * Check if autoembeds are enabled and hook them in if so
    18681868 *
    18691869 * @since bbPress (r3752)
     1870 *
    18701871 * @global WP_Embed $wp_embed
    18711872 */
    18721873function bbp_reply_content_autoembed() {
  • includes/topics/functions.php

     
    798798 * @uses bbp_get_current_user_id() To get the current user id
    799799 * @yses bbp_get_topic_forum_id() To get the topic forum id
    800800 * @uses update_post_meta() To update the topic metas
     801 * @uses get_post_field() To get the topic's last active time
    801802 * @uses set_transient() To update the flood check transient for the ip
    802803 * @uses bbp_update_user_last_posted() To update the users last posted time
    803804 * @uses bbp_is_subscriptions_active() To check if the subscriptions feature is
     
    887888                update_post_meta( $topic_id, '_bbp_author_ip', bbp_current_author_ip(), false );
    888889
    889890                // Last active time
    890                 $last_active = current_time( 'mysql' );
     891                $last_active = get_post_field( 'post_date', $topic_id );
    891892
    892893                // Reply topic meta
    893894                bbp_update_topic_last_reply_id      ( $topic_id, 0            );
     
    909910 * function can be costly to run but is necessary to keep everything accurate.
    910911 *
    911912 * @since bbPress (r2800)
     913 *
    912914 * @param int $topic_id Topic id
    913915 * @param string $last_active_time Optional. Last active time
    914916 * @param int $forum_id Optional. Forum id
     
    965967                                        'last_topic_id'      => $topic_id,
    966968                                        'last_reply_id'      => $reply_id,
    967969                                        'last_active_id'     => $active_id,
    968                                         'last_active_time'   => 0,
     970                                        'last_active_time'   => $last_active_time,
    969971                                        'last_active_status' => $topic_status
    970972                                ) );
    971973                        }
     
    33743376 * Check if autoembeds are enabled and hook them in if so
    33753377 *
    33763378 * @since bbPress (r3752)
     3379 *
    33773380 * @global WP_Embed $wp_embed
    33783381 */
    33793382function bbp_topic_content_autoembed() {
     
    34553458                                        <guid><?php bbp_topic_permalink(); ?></guid>
    34563459                                        <title><![CDATA[<?php bbp_topic_title(); ?>]]></title>
    34573460                                        <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>
    34593462                                        <dc:creator><?php the_author() ?></dc:creator>
    34603463
    34613464                                        <?php if ( !post_password_required() ) : ?>
  • includes/topics/template.php

     
    9797 * - New Style: Topics appear as "lead" posts, ahead of replies
    9898 *
    9999 * @since bbPress (r2954)
     100 *
    100101 * @param $show_lead Optional. Default false
    101102 * @return bool Yes if the topic appears as a lead, otherwise false
    102103 */
     
    151152        $default = array(
    152153                'post_type'      => bbp_get_topic_post_type(), // Narrow query down to bbPress topics
    153154                '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',
    156156                'order'          => 'DESC',                    // 'ASC', 'DESC'
    157157                'posts_per_page' => bbp_get_topics_per_page(), // Topics per page
    158158                'paged'          => bbp_get_paged(),           // Page Number
     
    279279                                $sticky_query = array(
    280280                                        'post_type'   => bbp_get_topic_post_type(),
    281281                                        'post_parent' => 'any',
    282                                         'meta_key'    => '_bbp_last_active_time',
    283                                         'orderby'     => 'meta_value',
    284                                         'order'       => 'DESC',
     282                                        'orderby'     => 'date',
     283                                        'order'       => 'ASC',
    285284                                        'include'     => $stickies
    286285                                );
    287286
     
    17781777         * @since bbPress (r2625)
    17791778         *
    17801779         * @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
    17831781         * @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
    17851784         * @uses bbp_convert_date() To convert date
    17861785         * @uses bbp_get_time_since() To get time in since format
    17871786         * @uses apply_filters() Calls 'bbp_get_topic_last_active' with topic
     
    17911790        function bbp_get_topic_last_active_time( $topic_id = 0 ) {
    17921791                $topic_id = bbp_get_topic_id( $topic_id );
    17931792
    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 );
    18031801                }
    18041802
    18051803                $last_active = !empty( $last_active ) ? bbp_get_time_since( bbp_convert_date( $last_active ) ) : '';
     
    37563754 * Allow topic rows to have adminstrative actions
    37573755 *
    37583756 * @since bbPress (r3653)
     3757 *
    37593758 * @uses do_action()
    37603759 * @todo Links and filter
    37613760 */
     
    37673766 * Output value of topic tags field
    37683767 *
    37693768 * @since bbPress (r2976)
     3769 *
    37703770 * @uses bbp_get_form_topic_tags() To get the value of topic tags field
    37713771 */
    37723772function bbp_form_topic_tags() {