You appear to be a bot. Output may be restricted
Description
Deletes edd_stats_ transients that have expired to prevent database clogs
Usage
$void = edd_cleanup_stats_transients();
Parameters
Returns
void
Source
File name: easy-digital-downloads/includes/payments/actions.php
Lines:
1 to 35 of 35
function edd_cleanup_stats_transients() { global $wpdb; if ( defined( 'WP_SETUP_CONFIG' ) ) { return; } if ( defined( 'WP_INSTALLING' ) ) { return; } $now = current_time( 'timestamp' ); $transients = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE option_name LIKE '%\_transient_timeout\_edd\_stats\_%' AND option_value+0 < $now LIMIT 0, 200;" ); $to_delete = array(); if( ! empty( $transients ) ) { foreach( $transients as $transient ) { $to_delete[] = $transient->option_name; $to_delete[] = str_replace( '_timeout', '', $transient->option_name ); } } if ( ! empty( $to_delete ) ) { $option_names = implode( "','", $to_delete ); $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name IN ('$option_names')" ); } }