Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/10/2016 12:55:49 PM (4 years ago)
Author:
djpaul
Message:

Fix inaccurate timestamps caused by page caching.

If any template with a timestamp is statically cached, then the timestamps quickly become inaccurate.
The change adds livestamp.js and moment.js to dynamically update timestamps with the real relative time.

A consequence is that the labels surrounding the timestamps, notably in our widgets, have slightly changed.
We're going to keep an eye on this for the remainder of the 2.7 development cycle, and may make further adjustments as testing proves necessary.

Fixes #5757

Props r-a-y, imath, DJPaul

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/bp-groups-widgets.php

    r10652 r11008  
    6666                    <div class="item-title"><a href="<?php bp_group_permalink() ?>" title="<?php bp_group_name() ?>"><?php bp_group_name() ?></a></div>
    6767                    <div class="item-meta">
    68                         <span class="activity">
    69                             <?php
    70                             if ( 'newest-groups' == $_POST['filter'] ) {
    71                                 printf( __( 'created %s', 'buddypress' ), bp_get_group_date_created() );
    72                             } elseif ( 'recently-active-groups' == $_POST['filter'] ) {
    73                                 printf( __( 'active %s', 'buddypress' ), bp_get_group_last_active() );
    74                             } elseif ( 'popular-groups' == $_POST['filter'] ) {
    75                                 bp_group_member_count();
    76                             }
    77                             ?>
    78                         </span>
     68                        <?php if ( 'newest-groups' === $_POST['filter'] ) : ?>
     69                            <span class="activity" data-livestamp="<?php bp_core_iso8601_date( bp_get_group_date_created( 0, array( 'relative' => false ) ) ); ?>"><?php printf( __( 'created %s', 'buddypress' ), bp_get_group_date_created() ); ?></span>
     70                        <?php elseif ( 'recently-active-groups' === $_POST['filter'] ) : ?>
     71                            <span class="activity" data-livestamp="<?php bp_core_iso8601_date( bp_get_group_last_active( 0, array( 'relative' => false ) ) ); ?>"><?php printf( __( 'active %s', 'buddypress' ), bp_get_group_last_active() ); ?></span>
     72                        <?php else : ?>
     73                            <span class="activity"><?php bp_group_member_count(); ?></span>
     74                        <?php endif; ?>
    7975                    </div>
    8076                </div>
Note: See TracChangeset for help on using the changeset viewer.