• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Easy Digital Downloads a2z

Easy Digital Downloads a2z

Easy Digital Downloads a2z

  • Home
  • Plugins
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / edd_cleanup_stats_transients() – Deletes edd_stats_ transients that have expired to prevent database clogs

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')"  );

  }

}
 

 View on GitHub View on Trac

Published: 26th November 2019 | Last updated: 8th April 2020

Primary Sidebar

Information

Function name: edd_cleanup_stats_transients
Plugin ref: Easy Digital Downloads
Version: 2.9.23
Sourcefile: includes/payments/actions.php
File ref: includes/payments/actions.php
Deprecated?: No
API Letters: C,E,S,T

Footer

Easy Digital Downloads a2z
Easy Digital Downloads a2z
Easy Digital Downloads a2z
WordPress 5.6
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  edd.wp-a2z.org
© Copyright Easy Digital Downloads a2z 2014-2021. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites