| @@ -43,15 +43,22 @@ | ||
| 43 | 43 | if ( $days < 1 ) { |
| 44 | 44 | return; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - $cutoff = date( 'Y-m-d H:i:s', strtotime( "-{$days} days" ) ); | |
| 47 | + // _bbp_last_active_time is stored in site-local time. | |
| 48 | + $cutoff = wp_date( 'Y-m-d H:i:s', time() - ( $days * DAY_IN_SECONDS ) ); | |
| 48 | 49 | |
| 50 | + // Stickies are skipped below; exclude them up front so they can't fill | |
| 51 | + // every batch and stop the rest from ever being closed. | |
| 52 | + $stickies = array_map( 'intval', array_merge( (array) bbp_get_super_stickies(), forumax_get_all_forum_stickies() ) ); | |
| 53 | + | |
| 49 | 54 | // Get open topics with no recent replies |
| 50 | 55 | $args = [ |
| 51 | 56 | 'post_type' => 'topic', |
| 52 | 57 | 'post_status' => 'publish', |
| 53 | - 'posts_per_page' => 50, // Batch to avoid timeouts | |
| 58 | + 'posts_per_page' => 100, // Batch to avoid timeouts | |
| 59 | + 'post__not_in' => $stickies, | |
| 60 | + 'no_found_rows' => true, | |
| 54 | 61 | 'meta_query' => [ |
| 55 | 62 | [ |
| 56 | 63 | 'key' => '_bbp_last_active_time', |
| 57 | 64 | 'value' => $cutoff, |