alleyinteractive / alleyinteractive/logger

Add Flexibility to AI_Logger_Garbage_Collector via Filters

未關閉
#133 0 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
PHP
星號
30
分支
3
PR 合併指標
30 天內沒有已合併 PR

描述

### Description

I would like to see additional values passed through WordPress filters in the AI_Logger_Garbage_Collector class so that I can fine tune when our logs are garbage collected, and how logs are queried during the garbage collection process.

Specifically, I would like to see a filter around the `$recurrence` parameter of the `wp_schedule_event` function, like so:

`apply_filters( 'ai_logger_garbage_collector_cron_interval', 'every_three_hours' )`

I would also like to see the return of the filter for the `$throttle` variable within the `run_cleanup` method:

`$throttle = boolval( apply_filters( 'ai_logger_garbage_collector_throttle', $throttle ) );`

Finally, I would like to see the post args array that is passed to the `get_posts` function passed through a filter:

`$post_args = apply_filters(
'ai_logger_garbage_collector_post_args',
[
'fields' => 'ids',
'ignore_sticky_posts' => true,
'post_type' => 'ai_log',
'posts_per_page' => $throttle ? 100 : 1000,
'suppress_filters' => false,
'update_post_meta_cache' => false,
'update_post_term_cache' => false,
'date_query' => [
[
'before' => "-{$max_age} days",
'column' => 'post_date',
],
],
]
);`

...

`$logs_to_delete = get_posts( // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.get_posts_get_posts
$post_args
);`

This last point is motivated by the fact that currently, all of our logs have a `post_status` value of `draft`. By default, if `post_status` is not included in the post args array, `get_posts` will only query for posts that have a `post_status` of `publish`. Therefore, none of our logs are being garbage collected.

### Use Case

Users will have a greater degree of freedom in determining how frequently their logs are garbage collected and how the logs to be garbage collected are queried.

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。