Skip to:
Content

BuddyPress.org

Ticket #7772: 7772.patch

File 7772.patch, 7.9 KB (added by imath, 7 years ago)
  • src/bp-templates/bp-nouveau/buddypress-functions.php

    diff --git src/bp-templates/bp-nouveau/buddypress-functions.php src/bp-templates/bp-nouveau/buddypress-functions.php
    index 5417f6b9c..48c1be2e7 100644
    class BP_Nouveau extends BP_Theme_Compat { 
    382382                        'unsaved_changes'     => __( 'Your profile has unsaved changes. If you leave the page, the changes will be lost.', 'buddypress' ),
    383383                        'view'                => __( 'View', 'buddypress' ),
    384384                        'object_nav_parent'   => '#buddypress',
    385                         'time_since'          => array(
    386                                 'sometime'    => _x( 'sometime', 'javascript time since', 'buddypress' ),
    387                                 'now'         => _x( 'right now', 'javascript time since', 'buddypress' ),
    388                                 'ago'         => _x( '% ago', 'javascript time since', 'buddypress' ),
    389                                 'separator'   => _x( ',', 'Separator in javascript time since', 'buddypress' ),
    390                                 'year'        => _x( '% year', 'javascript time since singular', 'buddypress' ),
    391                                 'years'       => _x( '% years', 'javascript time since plural', 'buddypress' ),
    392                                 'month'       => _x( '% month', 'javascript time since singular', 'buddypress' ),
    393                                 'months'      => _x( '% months', 'javascript time since plural', 'buddypress' ),
    394                                 'week'        => _x( '% week', 'javascript time since singular', 'buddypress' ),
    395                                 'weeks'       => _x( '% weeks', 'javascript time since plural', 'buddypress' ),
    396                                 'day'         => _x( '% day', 'javascript time since singular', 'buddypress' ),
    397                                 'days'        => _x( '% days', 'javascript time since plural', 'buddypress' ),
    398                                 'hour'        => _x( '% hour', 'javascript time since singular', 'buddypress' ),
    399                                 'hours'       => _x( '% hours', 'javascript time since plural', 'buddypress' ),
    400                                 'minute'      => _x( '% minute', 'javascript time since singular', 'buddypress' ),
    401                                 'minutes'     => _x( '% minutes', 'javascript time since plural', 'buddypress' ),
    402                                 'second'      => _x( '% second', 'javascript time since singular', 'buddypress' ),
    403                                 'seconds'     => _x( '% seconds', 'javascript time since plural', 'buddypress' ),
    404                                 'time_chunks' => array(
    405                                         'a_year'   => YEAR_IN_SECONDS,
    406                                         'b_month'  => 30 * DAY_IN_SECONDS,
    407                                         'c_week'   => WEEK_IN_SECONDS,
    408                                         'd_day'    => DAY_IN_SECONDS,
    409                                         'e_hour'   => HOUR_IN_SECONDS,
    410                                         'f_minute' => MINUTE_IN_SECONDS,
    411                                         'g_second' => 1,
    412                                 ),
    413                         ),
    414385                );
    415386
    416387                // If the Object/Item nav are in the sidebar
  • src/bp-templates/bp-nouveau/includes/activity/functions.php

    diff --git src/bp-templates/bp-nouveau/includes/activity/functions.php src/bp-templates/bp-nouveau/includes/activity/functions.php
    index 6b296f00e..529cb1a0c 100644
    function bp_nouveau_activity_scope_newest_class( $classes = '' ) { 
    427427        return $classes;
    428428}
    429429
    430 /**
    431  * @since 3.0.0
    432  */
    433 function bp_nouveau_activity_time_since( $time_since, $activity = null ) {
    434         if ( ! isset( $activity->date_recorded ) ) {
    435                 return $time_since;
    436         }
    437 
    438         return apply_filters(
    439                 'bp_nouveau_activity_time_since', sprintf(
    440                         '<time class="time-since" datetime="%1$s" data-bp-timestamp="%2$d">%3$s</time>',
    441                         esc_attr( $activity->date_recorded ),
    442                         esc_attr( strtotime( $activity->date_recorded ) ),
    443                         esc_attr( bp_core_time_since( $activity->date_recorded ) )
    444                 )
    445         );
    446 }
    447 
    448 /**
    449  * @since 3.0.0
    450  */
    451 function bp_nouveau_activity_allowed_tags( $activity_allowedtags = array() ) {
    452         $activity_allowedtags['time']                      = array();
    453         $activity_allowedtags['time']['class']             = array();
    454         $activity_allowedtags['time']['datetime']          = array();
    455         $activity_allowedtags['time']['data-bp-timestamp'] = array();
    456 
    457         return $activity_allowedtags;
    458 }
    459 
    460430/**
    461431 * Get the activity query args for the widget.
    462432 *
  • src/bp-templates/bp-nouveau/includes/activity/loader.php

    diff --git src/bp-templates/bp-nouveau/includes/activity/loader.php src/bp-templates/bp-nouveau/includes/activity/loader.php
    index 0f4ca255b..0bd59a0f1 100644
    class BP_Nouveau_Activity { 
    9696
    9797                add_filter( 'bp_get_activity_action_pre_meta', 'bp_nouveau_activity_secondary_avatars', 10, 2 );
    9898                add_filter( 'bp_get_activity_css_class', 'bp_nouveau_activity_scope_newest_class', 10, 1 );
    99                 add_filter( 'bp_activity_time_since', 'bp_nouveau_activity_time_since', 10, 2 );
    100                 add_filter( 'bp_activity_allowed_tags', 'bp_nouveau_activity_allowed_tags', 10, 1 );
    10199        }
    102100}
    103101
  • src/bp-templates/bp-nouveau/js/buddypress-activity.js

    diff --git src/bp-templates/bp-nouveau/js/buddypress-activity.js src/bp-templates/bp-nouveau/js/buddypress-activity.js
    index f5a07aeca..a2f3193b3 100644
    window.bp = window.bp || {}; 
    9595                        }
    9696
    9797                        $.extend( data, { bp_heartbeat: bp.Nouveau.getStorage( 'bp-activity' ) } );
    98 
    99                         // Update all displayed time
    100                         $.each( $( '#buddypress time' ), function( t, time ) {
    101                                 if ( $( time ).data( 'bp-timestamp' ) ) {
    102                                         $( time ).html( bp.Nouveau.updateTimeSince( Number( $( time ).data( 'bp-timestamp' ) ) ) );
    103                                 }
    104                         } );
    10598                },
    10699
    107100                /**
  • src/bp-templates/bp-nouveau/js/buddypress-nouveau.js

    diff --git src/bp-templates/bp-nouveau/js/buddypress-nouveau.js src/bp-templates/bp-nouveau/js/buddypress-nouveau.js
    index 422b8c41b..176816219 100644
    window.bp = window.bp || {}; 
    4848                        // Object Globals
    4949                        this.objects                = $.map( BP_Nouveau.objects, function( value ) { return value; } );
    5050                        this.objectNavParent        = BP_Nouveau.object_nav_parent;
    51                         this.time_since             = BP_Nouveau.time_since;
    5251
    5352                        // HeartBeat Global
    5453                        this.heartbeat              = wp.heartbeat || {};
    window.bp = window.bp || {}; 
    208207                        }
    209208                },
    210209
    211                 /**
    212                  * [updateTimeSince description]
    213                  * @param  {[type]} timestamp [description]
    214                  * @return {[type]}           [description]
    215                  */
    216                 updateTimeSince: function( timestamp ) {
    217                         var now = new Date( $.now() ), diff, count_1, chunk_1, count_2, chunk_2,
    218                                 time_since = [], time_chunks = $.extend( {}, this.time_since.time_chunks ), ms;
    219 
    220                         // Returns sometime
    221                         if ( undefined === timestamp ) {
    222                                 return this.time_since.sometime;
    223                         }
    224 
    225                         // Javascript timestamps are in ms.
    226                         timestamp = new Date( timestamp * 1000 );
    227 
    228                         // Calculate the diff
    229                         diff = now - timestamp;
    230 
    231                         // Returns right now
    232                         if ( 0 === diff ) {
    233                                 return this.time_since.now;
    234                         }
    235 
    236                         $.each( time_chunks, function( c, chunk ) {
    237                                 var milliseconds = chunk * 1000;
    238                                 var rounded_time = Math.floor( diff / milliseconds );
    239 
    240                                 if ( 0 !== rounded_time && ! chunk_1 ) {
    241                                         chunk_1 = c;
    242                                         count_1 = rounded_time;
    243                                         ms      = milliseconds;
    244                                 }
    245                         } );
    246 
    247                         // First chunk
    248                         chunk_1 = chunk_1.substr( 2 );
    249                         time_since.push( ( 1 === count_1 ) ? this.time_since[ chunk_1 ].replace( '%', count_1 ) : this.time_since[ chunk_1 + 's' ].replace( '%', count_1 ) );
    250 
    251                         // Remove Year from chunks
    252                         delete time_chunks.a_year;
    253 
    254                         $.each( time_chunks, function( c, chunk ) {
    255                                 var milliseconds = chunk * 1000;
    256                                 var rounded_time = Math.floor( ( diff - ( ms * count_1 ) ) / milliseconds );
    257 
    258                                 if ( 0 !== rounded_time && ! chunk_2 ) {
    259                                         chunk_2 = c;
    260                                         count_2 = rounded_time;
    261                                 }
    262                         } );
    263 
    264                         // Second chunk
    265                         if ( undefined !== chunk_2 ) {
    266                                 chunk_2 = chunk_2.substr( 2 );
    267                                 time_since.push( ( 1 === count_2 ) ? this.time_since[ chunk_2 ].replace( '%', count_2 ) : this.time_since[ chunk_2 + 's' ].replace( '%', count_2 ) );
    268                         }
    269 
    270                         // Returns x time, y time ago
    271                         if ( time_since.length >= 1 ) {
    272                                 return this.time_since.ago.replace( '%', time_since.join( this.time_since.separator + ' ' ) );
    273 
    274                         // Returns sometime
    275                         } else {
    276                                 return this.time_since.sometime;
    277                         }
    278                 },
    279 
    280210                /**
    281211                 * [objectRequest description]
    282212                 * @param  {[type]} data [description]