Skip to:
Content

bbPress.org

Ticket #1925: 1925.4.diff

File 1925.4.diff, 25.6 KB (added by thebrandonallen, 11 years ago)
  • includes/admin/converters/Vanilla.php

    diff --git includes/admin/converters/Vanilla.php includes/admin/converters/Vanilla.php
    index 01040aa..6db1b10 100644
    public function setup_globals() { 
    248248                );
    249249                $this->field_map[] = array(
    250250                        'from_tablename' => 'Discussion',
    251                         'from_fieldname' => 'DateUpdated',
     251                        'from_fieldname' => 'DateLastComment',
    252252                        'to_type'        => 'topic',
    253253                        'to_fieldname'   => 'post_modified'
    254254                );
    255255                $this->field_map[] = array(
    256256                        'from_tablename' => 'Discussion',
    257                         'from_fieldname' => 'DateUpdated',
     257                        'from_fieldname' => 'DateLastComment',
    258258                        'to_type'        => 'topic',
    259259                        'to_fieldname'   => 'post_modified_gmt'
    260260                );
    261261                $this->field_map[] = array(
    262262                        'from_tablename' => 'Discussion',
     263                        'from_fieldname' => 'DateUpdated',
     264                        'to_type'        => 'topic',
     265                        'to_fieldname'   => '_bbp_last_edit_time_gmt'
     266                );
     267
     268                $this->field_map[] = array(
     269                        'from_tablename' => 'Discussion',
    263270                        'from_fieldname' => 'DateLastComment',
    264271                        'to_type'        => 'topic',
    265272                        'to_fieldname'   => '_bbp_last_active_time'
  • includes/admin/converters/phpBB.php

    diff --git includes/admin/converters/phpBB.php includes/admin/converters/phpBB.php
    index bc8338f..9015c0a 100644
    public function setup_globals() { 
    278278                );
    279279                $this->field_map[] = array(
    280280                        'from_tablename'  => 'topics',
    281                         'from_fieldname'  => 'topic_time',
     281                        'from_fieldname'  => 'topic_last_post_time',
    282282                        'to_type'         => 'topic',
    283283                        'to_fieldname'    => 'post_modified',
    284284                        'callback_method' => 'callback_datetime'
    285285                );
    286286                $this->field_map[] = array(
    287287                        'from_tablename'  => 'topics',
    288                         'from_fieldname'  => 'topic_time',
     288                        'from_fieldname'  => 'topic_last_post_time',
    289289                        'to_type'         => 'topic',
    290290                        'to_fieldname'    => 'post_modified_gmt',
    291291                        'callback_method' => 'callback_datetime'
  • includes/admin/converters/vBulletin.php

    diff --git includes/admin/converters/vBulletin.php includes/admin/converters/vBulletin.php
    index 3903a75..8a66970 100644
    private function setup_globals() { 
    270270                );
    271271                $this->field_map[] = array(
    272272                        'from_tablename'  => 'thread',
    273                         'from_fieldname'  => 'dateline',
     273                        'from_fieldname'  => 'lastpost',
    274274                        'to_type'         => 'topic',
    275275                        'to_fieldname'    => 'post_modified',
    276276                        'callback_method' => 'callback_datetime'
    277277                );
    278278                $this->field_map[] = array(
    279279                        'from_tablename'  => 'thread',
    280                         'from_fieldname'  => 'dateline',
     280                        'from_fieldname'  => 'lastpost',
    281281                        'to_type'         => 'topic',
    282282                        'to_fieldname'    => 'post_modified_gmt',
    283283                        'callback_method' => 'callback_datetime'
  • includes/admin/converters/vBulletin3.php

    diff --git includes/admin/converters/vBulletin3.php includes/admin/converters/vBulletin3.php
    index 71dd7c6..5c64dbf 100644
    private function setup_globals() { 
    270270                );
    271271                $this->field_map[] = array(
    272272                        'from_tablename'  => 'thread',
    273                         'from_fieldname'  => 'dateline',
     273                        'from_fieldname'  => 'lastpost',
    274274                        'to_type'         => 'topic',
    275275                        'to_fieldname'    => 'post_modified',
    276276                        'callback_method' => 'callback_datetime'
    277277                );
    278278                $this->field_map[] = array(
    279279                        'from_tablename'  => 'thread',
    280                         'from_fieldname'  => 'dateline',
     280                        'from_fieldname'  => 'lastpost',
    281281                        'to_type'         => 'topic',
    282282                        'to_fieldname'    => 'post_modified_gmt',
    283283                        'callback_method' => 'callback_datetime'
  • includes/admin/forums.php

    diff --git includes/admin/forums.php includes/admin/forums.php
    index ce45039..7714e52 100644
    public function attributes_metabox_save( $forum_id ) { 
    303303                // Parent ID
    304304                $parent_id = ( !empty( $_POST['parent_id'] ) && is_numeric( $_POST['parent_id'] ) ) ? (int) $_POST['parent_id'] : 0;
    305305
     306                // Prevent infinite loop clash with last_active time updating
     307                remove_action( 'save_post', array( $this, 'attributes_metabox_save' ) );
     308
    306309                // Update the forum meta bidness
    307310                bbp_update_forum( array(
    308311                        'forum_id'    => $forum_id,
    309312                        'post_parent' => (int) $parent_id
    310313                ) );
    311314
     315                // Add save_post hook back, just in casies
     316                add_action( 'save_post', array( $this, 'attributes_metabox_save' ) );
     317
    312318                do_action( 'bbp_forum_attributes_metabox_save', $forum_id );
    313319
    314320                return $forum_id;
  • includes/admin/tools.php

    diff --git includes/admin/tools.php includes/admin/tools.php
    index 2ef2cdf..e182d39 100644
    function bbp_admin_repair_freshness() { 
    940940                        WHERE `reply`.`meta_id` IS NULL AND `topic`.`post_type` = '{$tpt}' );" ) ) )
    941941                return array( 9, sprintf( $statement, $result ) );
    942942
     943        // Also, update the post_modified and post_modified_gmt times
     944        if ( is_wp_error( $wpdb->query( "UPDATE `$wpdb->posts`,
     945                        ( SELECT `topic`.`ID` AS `ID`, MAX( `reply`.`post_date` ) AS `post_date`, MAX( `reply`.`post_date_gmt` ) AS `post_date_gmt`
     946                        FROM `$wpdb->posts` AS `topic` INNER JOIN `$wpdb->posts` AS `reply`
     947                        ON `topic`.`ID` = `reply`.`post_parent`
     948                        WHERE `reply`.`post_status` = '{$pps}' AND `topic`.`post_type` = '{$tpt}' AND `reply`.`post_type` = '{$rpt}'
     949                        GROUP BY `topic`.`ID` ) AS `update`
     950                        SET `$wpdb->posts`.`post_modified` = `update`.`post_date`, `$wpdb->posts`.`post_modified_gmt` = `update`.`post_date_gmt`
     951                        WHERE `$wpdb->posts`.`ID` = `update`.`ID`;" ) ) )
     952                return array( 10, sprintf( $statement, $result ) );
     953
    943954        // Forums need to know what their last active item is as well. Now it gets a bit more complex to do in the database.
    944955        $forums = $wpdb->get_col( "SELECT `ID` FROM `$wpdb->posts` WHERE `post_type` = '{$fpt}' and `post_status` != 'auto-draft';" );
    945956        if ( is_wp_error( $forums ) )
    946                 return array( 10, sprintf( $statement, $result ) );
     957                return array( 11, sprintf( $statement, $result ) );
    947958
    948959        // Loop through forums
    949960        foreach ( $forums as $forum_id ) {
  • includes/common/functions.php

    diff --git includes/common/functions.php includes/common/functions.php
    index f0248e6..0ef2bda 100644
    function bbp_fix_post_author( $data = array(), $postarr = array() ) { 
    364364}
    365365
    366366/**
     367 * Fix post modified times on post save for topics/forums
     368 *
     369 * When a forum or topic is updated, the post_modified and post_modified_gmt
     370 * fields are updated. Since these fields are used for freshness data, we
     371 * don't want to stomp out the current data. This keeps the post_modified(_gmt)
     372 * fields at their current status, and moves the last edit time (in GMT) to post
     373 * meta as '_bbp_last_edit_time_gmt'. This also solves the problem of not being
     374 * able to pass our own custom post_modified(_gmt) values
     375 *
     376 * @since bbPress (rXXXX)
     377 *
     378 * @param array $data Post data
     379 * @param array $postarr Original post array data
     380 * @uses bbp_get_topic_post_type() To get the topic post type
     381 * @uses bbp_get_reply_post_type() To get the reply post type
     382 * @uses bbp_is_post_request() To determine if we're in a POST request
     383 * @uses update_post_meta() To update the '_bbp_last_edit_time_gmt' post meta field
     384 * @return array Post data
     385 */
     386function bbp_fix_post_modified( $data = array(), $postarr = array() ) {
     387
     388        // Post is not being updated, return
     389        if ( empty( $postarr['ID'] ) ) {
     390                return $data;
     391        }
     392
     393        // We're not updating the last active time, return
     394        if ( empty( $postarr['post_modified'] ) && empty( $postarr['post_modified_gmt'] ) ) {
     395                return $data;
     396        }
     397
     398        // We're importing, return
     399        if ( ( !empty( $_POST['action'] ) && ( 'bbconverter_process' == $_POST['action'] ) ) ) {
     400                return $data;
     401        }
     402
     403        // Post is not a forum or topic, return
     404        if ( !in_array( $postarr['post_type'], array( bbp_get_forum_post_type(), bbp_get_topic_post_type() ) ) ) {
     405                return $data;
     406        }
     407
     408        // Are we editing?
     409        if ( bbp_is_post_request() && in_array( $_POST['action'], array( 'bbp-edit-forum', 'bbp-edit-topic', 'editpost' ) ) ) {
     410
     411                // Set the last edited time in post meta to the new post_modified_gmt
     412                update_post_meta( $postarr['ID'], '_bbp_last_edit_time_gmt', $data['post_modified_gmt'] );
     413
     414                // Reset post_modified and post_modified_gmt back to their original values
     415                $data['post_modified']     = $postarr['post_modified'];
     416                $data['post_modified_gmt'] = $postarr['post_modified_gmt'];
     417        }
     418
     419        return $data;
     420}
     421
     422/**
     423 * Fix revision post_(date/date_gmt/modified/modified_gmt) times
     424 *
     425 * When a revision is created, _wp_post_revision_fields() sets the post_date(_gmt)
     426 * fields to the post_modified time of the of the post being revised. Since we
     427 * are now using the post_modified(_gmt) fields for freshness times, these fields
     428 * are no longer accurate with respect to revisions. Here we reset the post_*
     429 * times to back their proper values
     430 *
     431 * @since bbPress (rXXXX)
     432 *
     433 * @param array $data Post data
     434 * @param array $postarr Original post array (includes post id)
     435 * @uses bbp_is_topic() To make sure the revision is of a topic
     436 * @uses get_post_meta() To get the '_bbp_last_edit_time_gmt' post meta field
     437 * @uses get_date_from_gmt() To get the localized date from a gmt date
     438 * @uses current_time() To get the current_time in mysql format
     439 * @return array Post data
     440 */
     441function bbp_fix_revision_times( $data = array(), $postarr = array() ) {
     442
     443        // Don't even bother. This is not a revision.
     444        if ( 'revision' !== $data['post_type'] ) {
     445                return $data;
     446        }
     447
     448        // Make sure we're working with a revision of a topic or forum
     449        if ( !bbp_is_topic( $data['post_parent'] ) && !bbp_is_forum( $data['post_parent'] ) ) {
     450                return $data;
     451        }
     452
     453        // We're importing, return
     454        if ( ( !empty( $_POST['action'] ) && ( 'bbconverter_process' == $_POST['action'] ) ) ) {
     455                return $data;
     456        }
     457
     458        // Get the true last edited time from post meta, bail otherwise
     459        $edit_time = get_post_meta( $data['post_parent'], '_bbp_last_edit_time_gmt', true );
     460        if ( empty( $edit_time ) ) {
     461                return $data;
     462        }
     463
     464        // Reset post_modified and post_modified_gmt back to their original values
     465        $data['post_date']         = get_date_from_gmt( $edit_time );
     466        $data['post_date_gmt']     = $edit_time;
     467        $data['post_modified']     = current_time( 'mysql' );
     468        $data['post_modified_gmt'] = current_time( 'mysql', 1 );
     469
     470        return $data;
     471}
     472
     473/**
    367474 * Check the date against the _bbp_edit_lock setting.
    368475 *
    369476 * @since bbPress (r3133)
  • includes/common/widgets.php

    diff --git includes/common/widgets.php includes/common/widgets.php
    index 3204dc7..9866888 100644
    public function widget( $args = array(), $instance = array() ) { 
    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'             => 'modified',
    748747                                        'order'               => 'DESC',
    749748                                );
    750749                                break;
  • includes/core/filters.php

    diff --git includes/core/filters.php includes/core/filters.php
    index 8dcd42c..d54a266 100644
     
    5151// Fix post author id for anonymous posts (set it back to 0) when the post status is changed
    5252add_filter( 'wp_insert_post_data', 'bbp_fix_post_author', 30, 2 );
    5353
     54// Fix post modified and post modified gmt time for forums and topics when the post is edited
     55add_filter( 'wp_insert_post_data', 'bbp_fix_post_modified', 32, 2 );
     56
     57// Fix post revision times
     58add_filter( 'wp_insert_post_data', 'bbp_fix_revision_times', 34, 2 );
     59
    5460// Force comments_status on bbPress post types
    5561add_filter( 'comments_open', 'bbp_force_comment_status' );
    5662
  • includes/core/update.php

    diff --git includes/core/update.php includes/core/update.php
    index 18141e3..ff0e44b 100644
    function bbp_version_updater() { 
    285285                // No changes
    286286        }
    287287
     288        /** 2.6 Branch ************************************************************/
     289
     290        // 2.6
     291        if ( $raw_db_version < 260 ) {
     292                global $wpdb;
     293
     294                // Give forums their last edit time
     295                $wpdb->query( "INSERT INTO `$wpdb->postmeta` (`post_id`, `meta_key`, `meta_value`)
     296                        ( SELECT `forum`.`ID`, '_bbp_last_edit_time_gmt', `forum`.`post_modified_gmt`
     297                        FROM `$wpdb->posts` AS `forum`
     298                        WHERE `forum`.`post_type` = '" . bbp_get_forum_post_type() . "'
     299                        GROUP BY `forum`.`ID` );"
     300                );
     301
     302                // Give topics their last edit time
     303                $wpdb->query( "INSERT INTO `$wpdb->postmeta` (`post_id`, `meta_key`, `meta_value`)
     304                        ( SELECT `topic`.`ID`, '_bbp_last_edit_time_gmt', `topic`.`post_modified_gmt`
     305                        FROM `$wpdb->posts` AS `topic`
     306                        WHERE `topic`.`post_type` = '" . bbp_get_topic_post_type() . "'
     307                        GROUP BY `topic`.`ID` );"
     308                );
     309
     310                // Update Forum/Topic Freshness to use post_modified_gmt
     311                bbp_admin_repair_freshness();
     312        }
     313
    288314        /** All done! *************************************************************/
    289315
    290316        // Bump the version
  • includes/forums/functions.php

    diff --git includes/forums/functions.php includes/forums/functions.php
    index 881f669..bdb8539 100644
    function bbp_update_forum_last_topic_id( $forum_id = 0, $topic_id = 0 ) { 
    11831183                $post_vars = array(
    11841184                        'post_parent' => $forum_id,
    11851185                        'post_type'   => bbp_get_topic_post_type(),
    1186                         'meta_key'    => '_bbp_last_active_time',
    1187                         'orderby'     => 'meta_value',
     1186                        'orderby'     => 'modified',
    11881187                        'numberposts' => 1
    11891188                );
    11901189
    function bbp_update_forum_last_active_id( $forum_id = 0, $active_id = 0 ) { 
    13381337}
    13391338
    13401339/**
    1341  * Update the forums last active date/time (aka freshness)
     1340 * Update the forum's last active date/time (aka freshness)
    13421341 *
    13431342 * @since bbPress (r2680)
    13441343 *
    1345  * @param int $forum_id Optional. Topic id
     1344 * @param int $forum_id Optional. Forum id
    13461345 * @param string $new_time Optional. New time in mysql format
    13471346 * @uses bbp_get_forum_id() To get the forum id
    13481347 * @uses bbp_get_forum_last_active_id() To get the forum's last post id
    1349  * @uses get_post_field() To get the post date of the forum's last post
    1350  * @uses update_post_meta() To update the forum last active time
     1348 * @uses get_post_field() To get the post_modified date of the forum
     1349 * @uses update_post_meta() To update the forum last active meta
     1350 * @uses post_type_supports() To check if the them supports revisions
     1351 * @uses remove_post_type_support() To remove support for revisions
     1352 * @uses wp_update_post() To update the post_modified date of the forum
     1353 * @uses add_post_type_support() To add support for revisions
    13511354 * @uses apply_filters() Calls 'bbp_update_forum_last_active' with the new time
    13521355 *                        and forum id
    13531356 * @return bool True on success, false on failure
    function bbp_update_forum_last_active_time( $forum_id = 0, $new_time = '' ) { 
    13601363                $new_time = get_post_field( 'post_date', bbp_get_forum_last_active_id( $forum_id ) );
    13611364
    13621365        // Update only if there is a time
    1363         if ( !empty( $new_time ) )
     1366        if ( !empty( $new_time ) ) {
     1367
     1368                // Update forum's meta - not used since 2.6
    13641369                update_post_meta( $forum_id, '_bbp_last_active_time', $new_time );
    13651370
     1371                // Toggle revisions to avoid duplicates
     1372                $revisions_removed = false;
     1373                if ( post_type_supports( bbp_get_forum_post_type(), 'revisions' ) ) {
     1374                        $revisions_removed = true;
     1375                        remove_post_type_support( bbp_get_forum_post_type(), 'revisions' );
     1376                }
     1377
     1378                // Update forum's post_modified date - since 2.6
     1379                wp_update_post( array(
     1380                        'ID'                => $forum_id,
     1381                        'post_modified'     => $new_time,
     1382                        'post_modified_gmt' => get_gmt_from_date( $new_time )
     1383                ) );
     1384
     1385                // Toggle revisions back on
     1386                if ( true === $revisions_removed ) {
     1387                        $revisions_removed = false;
     1388                        add_post_type_support( bbp_get_forum_post_type(), 'revisions' );
     1389                }
     1390        }
     1391
    13661392        return (int) apply_filters( 'bbp_update_forum_last_active', $new_time, $forum_id );
    13671393}
    13681394
    function bbp_forum_query_subforum_ids( $forum_id ) { 
    19181944 * @return Position change based on sort
    19191945 */
    19201946function _bbp_forum_query_usort_subforum_ids( $a = 0, $b = 0 ) {
    1921         $ta = get_post_meta( $a, '_bbp_last_active_time', true );
    1922         $tb = get_post_meta( $b, '_bbp_last_active_time', true );
     1947        $ta = get_post_field( 'post_modified', $a );
     1948        $tb = get_post_field( 'post_modified', $b );
    19231949        return ( $ta < $tb ) ? -1 : 1;
    19241950}
    19251951
  • includes/forums/template.php

    diff --git includes/forums/template.php includes/forums/template.php
    index f269288..b19cae2 100644
    function bbp_get_forum_content( $forum_id = 0 ) { 
    447447 * Allow forum rows to have adminstrative actions
    448448 *
    449449 * @since bbPress (r3653)
     450 *
    450451 * @uses do_action()
    451452 * @todo Links and filter
    452453 */
    function bbp_forum_last_active_time( $forum_id = 0 ) { 
    496497        echo bbp_get_forum_last_active_time( $forum_id );
    497498}
    498499        /**
    499          * Return the forums last update date/time (aka freshness)
     500         * Return the forum's last update date/time (aka freshness)
    500501         *
    501502         * @since bbPress (r2464)
    502503         *
    503504         * @param int $forum_id Optional. Forum id
    504505         * @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 of the forum
    511507         * @uses bbp_convert_date() To convert the date
    512508         * @uses bbp_get_time_since() To get time in since format
    513509         * @uses apply_filters() Calls 'bbp_get_forum_last_active' with last
    function bbp_forum_last_active_time( $forum_id = 0 ) { 
    516512         */
    517513        function bbp_get_forum_last_active_time( $forum_id = 0 ) {
    518514
    519                 // Verify forum and get last active meta
     515                // Verify forum and get last active time
    520516                $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                 }
     517                $last_active = get_post_field( 'post_modified', $forum_id );
    534518
     519                // Convert to time since format
    535520                $active_time = !empty( $last_active ) ? bbp_get_time_since( bbp_convert_date( $last_active ) ) : '';
    536521
     522                // Return the time since
    537523                return apply_filters( 'bbp_get_forum_last_active', $active_time, $forum_id );
    538524        }
    539525
    function bbp_get_form_forum_visibility() { 
    22262212
    22272213                return apply_filters( 'bbp_get_form_forum_visibility', esc_attr( $forum_visibility ) );
    22282214        }
    2229        
     2215
    22302216/**
    22312217 * Output checked value of forum subscription
    22322218 *
  • includes/topics/functions.php

    diff --git includes/topics/functions.php includes/topics/functions.php
    index 0376c7f..fbd953b 100644
    function bbp_update_topic_last_active_id( $topic_id = 0, $active_id = 0 ) { 
    24962496}
    24972497
    24982498/**
    2499  * Update the topics last active date/time (aka freshness)
     2499 * Update the topic's last active date/time (aka freshness)
    25002500 *
    25012501 * @since bbPress (r2680)
    25022502 *
    25032503 * @param int $topic_id Optional. Topic id
    25042504 * @param string $new_time Optional. New time in mysql format
    2505  * @uses bbp_get_topic_id() To get the topic id
     2505 * @uses bbp_is_reply() To check if the id passed is a reply
    25062506 * @uses bbp_get_reply_topic_id() To get the reply topic id
    2507  * @uses current_time() To get the current time
     2507 * @uses bbp_get_topic_id() To get the topic id
     2508 * @uses bbp_get_reply_post_type() To get the reply post type
     2509 * @uses bbp_get_public_child_last_id() To get the last public reply id
     2510 * @uses get_post_field() To get the post_modified date of the topic
    25082511 * @uses update_post_meta() To update the topic last active meta
     2512 * @uses bbp_get_reply_post_type() To get the topic post type
     2513 * @uses post_type_supports() To check if the them supports revisions
     2514 * @uses remove_post_type_support() To remove support for revisions
     2515 * @uses wp_update_post() To update the post_modified date of the topic
     2516 * @uses add_post_type_support() To add support for revisions
     2517 * @uses apply_filters() Calls 'bbp_update_topic_last_active' with the new time
     2518 *                        and topic id
    25092519 * @return bool True on success, false on failure
    25102520 */
    25112521function bbp_update_topic_last_active_time( $topic_id = 0, $new_time = '' ) {
    function bbp_update_topic_last_active_time( $topic_id = 0, $new_time = '' ) { 
    25242534
    25252535        // Update only if published
    25262536        if ( !empty( $new_time ) ) {
     2537
     2538                // Update topic's meta - not used since 2.6
    25272539                update_post_meta( $topic_id, '_bbp_last_active_time', $new_time );
     2540
     2541                // Toggle revisions to avoid duplicates
     2542                $revisions_removed = false;
     2543                if ( post_type_supports( bbp_get_topic_post_type(), 'revisions' ) ) {
     2544                        $revisions_removed = true;
     2545                        remove_post_type_support( bbp_get_topic_post_type(), 'revisions' );
     2546                }
     2547
     2548                // Update topic's post_modified date - since 2.6
     2549                wp_update_post( array(
     2550                        'ID'                => $topic_id,
     2551                        'post_modified'     => $new_time,
     2552                        'post_modified_gmt' => get_gmt_from_date( $new_time )
     2553                ) );
     2554
     2555                // Toggle revisions back on
     2556                if ( true === $revisions_removed ) {
     2557                        $revisions_removed = false;
     2558                        add_post_type_support( bbp_get_topic_post_type(), 'revisions' );
     2559                }
    25282560        }
    25292561
    25302562        return apply_filters( 'bbp_update_topic_last_active_time', $new_time, $topic_id );
    function bbp_display_topics_feed_rss2( $topics_query = array() ) { 
    34553487                                        <guid><?php bbp_topic_permalink(); ?></guid>
    34563488                                        <title><![CDATA[<?php bbp_topic_title(); ?>]]></title>
    34573489                                        <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>
     3490                                        <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_field( 'post_modified', bbp_get_topic_id() ) ); ?></pubDate>
    34593491                                        <dc:creator><?php the_author() ?></dc:creator>
    34603492
    34613493                                        <?php if ( !post_password_required() ) : ?>
  • includes/topics/template.php

    diff --git includes/topics/template.php includes/topics/template.php
    index ed1eff9..4d784e9 100644
    function bbp_get_topic_post_type_supports() { 
    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 */
    function bbp_has_topics( $args = '' ) { 
    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'        => 'modified',                // '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
    function bbp_has_topics( $args = '' ) { 
    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',
     282                                        'orderby'     => 'modified',
    284283                                        'order'       => 'DESC',
    285284                                        'include'     => $stickies
    286285                                );
    function bbp_topic_last_active_time( $topic_id = 0 ) { 
    17731772        echo bbp_get_topic_last_active_time( $topic_id );
    17741773}
    17751774        /**
    1776          * Return the topics last update date/time (aka freshness)
     1775         * Return the topic's last update date/time (aka freshness)
    17771776         *
    17781777         * @since bbPress (r2625)
    17791778         *
    17801779         * @param int $topic_id Optional. Topic id
    17811780         * @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
    1785          * @uses bbp_convert_date() To convert date
     1781         * @uses get_post_field() To get the post_modified of the topic
     1782         * @uses bbp_convert_date() To convert the date
    17861783         * @uses bbp_get_time_since() To get time in since format
    17871784         * @uses apply_filters() Calls 'bbp_get_topic_last_active' with topic
    17881785         *                        freshness and topic id
    17891786         * @return string Topic freshness
    17901787         */
    17911788        function bbp_get_topic_last_active_time( $topic_id = 0 ) {
    1792                 $topic_id = bbp_get_topic_id( $topic_id );
    17931789
    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                 }
     1790                // Verify forum and get last active time
     1791                $topic_id = bbp_get_topic_id( $topic_id );
     1792                $last_active = get_post_field( 'post_modified', $topic_id );
    18041793
    1805                 $last_active = !empty( $last_active ) ? bbp_get_time_since( bbp_convert_date( $last_active ) ) : '';
     1794                // Convert to time since format
     1795                $active_time = !empty( $last_active ) ? bbp_get_time_since( bbp_convert_date( $last_active ) ) : '';
    18061796
    18071797                // Return the time since
    1808                 return apply_filters( 'bbp_get_topic_last_active', $last_active, $topic_id );
     1798                return apply_filters( 'bbp_get_topic_last_active', $active_time, $topic_id );
    18091799        }
    18101800
    18111801/** Topic Subscriptions *******************************************************/