Implement log cleanup cron job (woocommerce_cleanup_logs)
This commit is contained in:
parent
d40b704cba
commit
e8f3bac6c8
|
@ -352,6 +352,7 @@ class WC_Install {
|
|||
wp_clear_scheduled_hook( 'woocommerce_cancel_unpaid_orders' );
|
||||
wp_clear_scheduled_hook( 'woocommerce_cleanup_sessions' );
|
||||
wp_clear_scheduled_hook( 'woocommerce_cleanup_orders' );
|
||||
wp_clear_scheduled_hook( 'woocommerce_cleanup_logs' );
|
||||
wp_clear_scheduled_hook( 'woocommerce_geoip_updater' );
|
||||
wp_clear_scheduled_hook( 'woocommerce_tracker_send_event' );
|
||||
|
||||
|
@ -366,7 +367,8 @@ class WC_Install {
|
|||
}
|
||||
|
||||
wp_schedule_event( time(), 'daily', 'woocommerce_cleanup_orders' );
|
||||
wp_schedule_event( time(), 'twicedaily', 'woocommerce_cleanup_sessions' );
|
||||
wp_schedule_event( time() + ( 3 * HOUR_IN_SECONDS ), 'daily', 'woocommerce_cleanup_logs' );
|
||||
wp_schedule_event( time() + ( 6 * HOUR_IN_SECONDS ), 'twicedaily', 'woocommerce_cleanup_sessions' );
|
||||
wp_schedule_event( strtotime( 'first tuesday of next month' ), 'monthly', 'woocommerce_geoip_updater' );
|
||||
wp_schedule_event( time() + 10, apply_filters( 'woocommerce_tracker_event_recurrence', 'daily' ), 'woocommerce_tracker_send_event' );
|
||||
|
||||
|
|
|
@ -1660,6 +1660,20 @@ function wc_get_logger() {
|
|||
return $logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger logging cleanup using the logging class.
|
||||
*
|
||||
* @since 3.4.0
|
||||
*/
|
||||
function wc_cleanup_logs() {
|
||||
$logger = wc_get_logger();
|
||||
|
||||
if ( is_callable( array( $logger, 'clear_expired_logs' ) ) ) {
|
||||
$logger->clear_expired_logs();
|
||||
}
|
||||
}
|
||||
add_action( 'woocommerce_cleanup_logs', 'wc_cleanup_logs' );
|
||||
|
||||
/**
|
||||
* Prints human-readable information about a variable.
|
||||
*
|
||||
|
|
|
@ -16,6 +16,7 @@ wp_clear_scheduled_hook( 'woocommerce_scheduled_sales' );
|
|||
wp_clear_scheduled_hook( 'woocommerce_cancel_unpaid_orders' );
|
||||
wp_clear_scheduled_hook( 'woocommerce_cleanup_sessions' );
|
||||
wp_clear_scheduled_hook( 'woocommerce_cleanup_orders' );
|
||||
wp_clear_scheduled_hook( 'woocommerce_cleanup_logs' );
|
||||
wp_clear_scheduled_hook( 'woocommerce_geoip_updater' );
|
||||
wp_clear_scheduled_hook( 'woocommerce_tracker_send_event' );
|
||||
|
||||
|
|
Loading…
Reference in New Issue