Changeset 5622
- Timestamp:
- 01/07/2012 05:23:24 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-akismet.php
r5621 r5622 464 464 remove_filter( 'akismet_ua', array( $this, 'buddypress_ua' ) ); 465 465 466 // Get the response 466 467 $activity_data['bp_as_result'] = $response[1]; 467 468 469 // Perform a daily tidy up 470 if ( ! wp_next_scheduled( 'bp_activity_akismet_delete_old_metadata' ) ) 471 wp_schedule_event( time(), 'daily', 'bp_activity_akismet_delete_old_metadata' ); 472 468 473 return $activity_data; 469 474 } … … 473 478 * 474 479 * @param string $user_agent 475 * @since 1. 0480 * @since 1.6 476 481 */ 477 482 public function buddypress_ua( $user_agent ) { … … 515 520 } 516 521 } 522 523 /** 524 * Deletes old spam activity meta data, as _bp_akismet_submission meta can be large. 525 * 526 * @global object $bp BuddyPress global settings 527 * @global wpdb $wpdb WordPress database object 528 * @since 1.6 529 */ 530 function bp_activity_akismet_delete_old_metadata() { 531 global $bp, $wpdb; 532 533 $interval = apply_filters( 'bp_activity_akismet_delete_meta_interval', 15 ); 534 535 // Enforce a minimum of 1 day 536 $interval = max( 1, absint( $interval ) ); 537 538 // _bp_akismet_submission meta values are large, so expire them after $interval days regardless of the activity status 539 $sql = $wpdb->prepare( "SELECT a.id FROM {$bp->activity->table_name} a LEFT JOIN {$bp->activity->table_name_meta} m ON a.id = m.activity_id WHERE m.meta_key = %s AND DATE_SUB(%s, INTERVAL {$interval} DAY) > a.date_recorded LIMIT 10000", '_bp_akismet_submission', current_time( 'mysql', 1 ) ); 540 $activity_ids = $wpdb->get_col( $sql ); 541 542 if ( ! empty( $activity_ids ) ) { 543 foreach ( $activity_ids as $activity_id ) 544 bp_activity_delete_meta( $activity_id, '_bp_akismet_submission' ); 545 } 546 } 517 547 ?>
Note: See TracChangeset
for help on using the changeset viewer.