get_col( $wpdb->prepare( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = %s AND post_id > %d ORDER BY post_id ASC LIMIT 100", Store::META, $cursor ) ) ); update_option( 'mapp_retention_cursor', count( $ids ) < 100 ? 0 : end( $ids ), false ); foreach ( $ids as $id ) { foreach ( Store::files_for( $id ) as $file_id => $file ) { if ( (int) $file['uploaded'] < $cutoff ) { Store::delete( $id, $file_id ); Access::log( $id, 'retention_delete', $file['name'], 'system:' . $days . 'd' ); } } if ( ! Store::files_for( $id ) ) { delete_post_meta( $id, Store::META ); } } } }