Skip to content

Instantly share code, notes, and snippets.

@jrick1229
Last active November 29, 2018 17:18
Show Gist options
  • Save jrick1229/7fdb46f73db01b0e3547a67474771997 to your computer and use it in GitHub Desktop.
Save jrick1229/7fdb46f73db01b0e3547a67474771997 to your computer and use it in GitHub Desktop.
Disable 'Reports' cache updates for higher volume sites (Subscriptions)
<?php
function wcs_disable_report_cache_update() {
$cached_report_classes = array(
'WC_Report_Subscription_Events_By_Date',
'WC_Report_Upcoming_Recurring_Revenue',
'WC_Report_Subscription_By_Product',
'WC_Report_Subscription_By_Customer',
);
foreach ( $cached_report_classes as $report_class ) {
wp_clear_scheduled_hook( 'wcs_report_update_cache', array( 'report_class' => $report_class ) );
}
}
add_action( 'shutdown', 'wcs_disable_report_cache_update', 11 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment