Skip to:
Content

bbPress.org

Changeset 7104


Ignore:
Timestamp:
06/05/2020 08:56:16 PM (6 years ago)
Author:
johnjamesjacoby
Message:

Users: Correctly calculate offset in User Profile > Last Activity.

Previous to this, Last Activity was being saved with time() but then using the site offset on display. For negative timezones, this would cause "sometime ago" type output in screens like User Profiles.

Also correctly update Last Activity when posting new Topics and Replies, and add expiration to transients for anonymous users to prevent them from being autoloaded while also never expiring.

In branches/2.6, for 2.6.6.

See #3378.

Location:
branches/2.6/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2.6/src/includes/replies/functions.php

    r7097 r7104  
    820820        // Set transient for throttle check (only on new, not edit)
    821821        if ( empty( $is_edit ) ) {
    822             set_transient( '_bbp_' . bbp_current_author_ip() . '_last_posted', time() );
    823         }
    824 
    825     } else {
    826         if ( empty( $is_edit ) && ! current_user_can( 'throttle' ) ) {
    827             bbp_update_user_last_posted( $author_id );
     822            set_transient( '_bbp_' . bbp_current_author_ip() . '_last_posted', time(), HOUR_IN_SECONDS );
    828823        }
    829824    }
     
    858853    if ( empty( $is_edit ) ) {
    859854
    860         // Update poster IP if not editing
     855        // Update poster activity time
     856        bbp_update_user_last_posted( $author_id );
     857
     858        // Update poster IP
    861859        update_post_meta( $reply_id, '_bbp_author_ip', bbp_current_author_ip(), false );
    862860
  • branches/2.6/src/includes/topics/functions.php

    r7097 r7104  
    787787        // Set transient for throttle check (only on new, not edit)
    788788        if ( empty( $is_edit ) ) {
    789             set_transient( '_bbp_' . bbp_current_author_ip() . '_last_posted', time() );
    790         }
    791 
    792     } else {
    793         if ( empty( $is_edit ) && ! current_user_can( 'throttle' ) ) {
    794             bbp_update_user_last_posted( $author_id );
     789            set_transient( '_bbp_' . bbp_current_author_ip() . '_last_posted', time(), HOUR_IN_SECONDS );
    795790        }
    796791    }
     
    820815    if ( empty( $is_edit ) ) {
    821816
    822         // Update poster IP if not editing
     817        // Update poster activity time
     818        bbp_update_user_last_posted( $author_id );
     819
     820        // Update poster IP
    823821        update_post_meta( $topic_id, '_bbp_author_ip', bbp_current_author_ip(), false );
    824822
  • branches/2.6/src/templates/default/bbpress/user-profile.php

    r6592 r7104  
    3636        <?php if ( bbp_get_user_last_posted() ) : ?>
    3737
    38             <p class="bbp-user-topic-count"><?php printf( esc_html__( 'Last Activity: %s',  'bbpress' ), bbp_get_time_since( bbp_get_user_last_posted() ) ); ?></p>
     38            <p class="bbp-user-topic-count"><?php printf( esc_html__( 'Last Activity: %s',  'bbpress' ), bbp_get_time_since( bbp_get_user_last_posted(), false, true ) ); ?></p>
    3939
    4040        <?php endif; ?>
Note: See TracChangeset for help on using the changeset viewer.