• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WordPress a2z

WordPress a2z

WordPress Dynamic API Reference

  • Home
  • Plugins
  • Themes
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / Akismet::delete_old_comments_meta() – Determines how many days a comment will be left in the Spam queue before being deleted.

You appear to be a bot. Output may be restricted

Description

Determines how many days a comment will be left in the Spam queue before being deleted.

Usage

Akismet::delete_old_comments_meta();

Parameters

Returns

void

Source

File name: akismet/class.akismet.php
Lines:

1 to 29 of 29
  public static function delete_old_comments_meta() {
    global $wpdb;

    $interval = apply_filters( 'akismet_delete_commentmeta_interval', 15 );

    # enforce a minimum of 1 day
    $interval = absint( $interval );
    if ( $interval < 1 )
      $interval = 1;

    // akismet_as_submitted meta values are large, so expire them
    // after $interval days regardless of the comment status
    while ( $comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT m.comment_id FROM {$wpdb->commentmeta} as m INNER JOIN {$wpdb->comments} as c USING(comment_id) WHERE m.meta_key = 'akismet_as_submitted' AND DATE_SUB(NOW(), INTERVAL %d DAY) > c.comment_date_gmt LIMIT 10000", $interval ) ) ) {
      if ( empty( $comment_ids ) )
        return;

      $wpdb->queries = array();

      foreach ( $comment_ids as $comment_id ) {
        delete_comment_meta( $comment_id, 'akismet_as_submitted' );
        do_action( 'akismet_batch_delete_count', __FUNCTION__ );
      }

      do_action( 'akismet_delete_commentmeta_batch', count( $comment_ids ) );
    }

    if ( apply_filters( 'akismet_optimize_table', ( mt_rand(1, 5000) == 11), $wpdb->commentmeta ) ) // lucky number
      $wpdb->query("OPTIMIZE TABLE {$wpdb->commentmeta}");
  }
 

 View on GitHub View on Trac

Published: 19th December 2019 | Last updated: 19th December 2019

Primary Sidebar

Information

Function name: Akismet::delete_old_comments_meta
Class ref: Akismet
Plugin ref: Akismet
Version: 5.0.1
Sourcefile: class.akismet.php
File ref: class.akismet.php
Deprecated?: No
API Letters: A,C,D,M,O

Footer

WordPress a2z
WordPress a2z
WordPress Dynamic API Reference
WordPress 6.1.1. PHP: 8.0.28
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:  wp-a2z.org
© Copyright WordPress a2z 2014-2023. All rights reserved.


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

  • Home
  • Blog
  • Sitemap
  • Sites