Changeset 13881
- Timestamp:
- 07/05/2024 09:23:23 AM (5 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/profiles.wordpress.org/public_html/wp-content/plugins/wporg-profiles-activity-handler/wporg-profiles-activity-handler.php
r13364 r13881 264 264 } elseif ( false === $activity_id || intval( $activity_id ) <= 0 ) { 265 265 throw new Exception( '-1 Unable to save activity' ); 266 } else { 267 $this->maybe_update_last_activity(); 266 268 } 267 269 … … 275 277 276 278 die( $response ); 279 } 280 281 /** 282 * 283 * Adds/Updates user meta to track last activity. 284 * 285 */ 286 public static function maybe_update_last_activity() { 287 288 $user = self::get_user( $_POST['user'] ); 289 290 if ( ! $user ) { 291 return; 292 } 293 294 $user_activity_cache_key = 'wporg-user-activity-logger-' . $user->ID; 295 296 // Adds some caching to avoid unnecessary updates since we only store day. 297 $user_activity_cache = wp_cache_get( $user_activity_cache_key ); 298 299 if ( $user_activity_cache ) { 300 return; 301 } 302 303 // Only store date since we aim to cache for a day. 304 update_user_meta( $user->ID, 'last_activity_tracker', date( 'Y-m-d 00:00:00' ) ); 305 wp_cache_set( $user_activity_cache_key, '1', '', DAY_IN_SECONDS ); 306 307 return; 308 277 309 } 278 310
Note: See TracChangeset
for help on using the changeset viewer.