• 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::submit_nonspam_comment() –

You appear to be a bot. Output may be restricted

Description

Usage

Akismet::submit_nonspam_comment( $comment_id );

Parameters

$comment_id
( mixed ) required –

Returns

void

Source

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

1 to 57 of 57
  public static function submit_nonspam_comment( $comment_id ) {
    global $wpdb, $current_user, $current_site;

    $comment_id = (int) $comment_id;

    $comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->comments} WHERE comment_ID = %d", $comment_id ) );
    if ( !$comment ) // it was deleted
      return;

    self::update_comment_history( $comment_id, '', 'report-ham' );

    // If the user hasn't configured Akismet, there's nothing else to do at this point.
    if ( ! self::get_api_key() ) {
      return;
    }

    // use the original version stored in comment_meta if available
    $as_submitted = self::sanitize_comment_as_submitted( get_comment_meta( $comment_id, 'akismet_as_submitted', true ) );

    if ( $as_submitted && is_array($as_submitted) && isset($as_submitted['comment_content']) )
      $comment = (object) array_merge( (array)$comment, $as_submitted );

    $comment->blog         = get_option( 'home' );
    $comment->blog_lang    = get_locale();
    $comment->blog_charset = get_option('blog_charset');
    $comment->permalink    = get_permalink( $comment->comment_post_ID );
    $comment->user_role    = '';

    if ( is_object($current_user) )
      $comment->reporter = $current_user->user_login;

    if ( is_object($current_site) )
      $comment->site_domain = $current_site->domain;

    if ( ! empty( $comment->user_ID ) ) {
      $comment->user_role = Akismet::get_user_roles( $comment->user_ID );
    }

    if ( Akismet::is_test_mode() )
      $comment->is_test = 'true';

    $post = get_post( $comment->comment_post_ID );

    if ( ! is_null( $post ) ) {
      $comment->comment_post_modified_gmt = $post->post_modified_gmt;
    }

    $response = self::http_post( Akismet::build_query( $comment ), 'submit-ham' );

    update_comment_meta( $comment_id, 'akismet_user_result', 'false' );

    if ( $comment->reporter ) {
      update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );
    }

    do_action('akismet_submit_nonspam_comment', $comment_id, $response[1]);
  }
 

 View on GitHub View on Trac

Published: 19th December 2019 | Last updated: 3rd April 2020

Primary Sidebar

Information

Function name: Akismet::submit_nonspam_comment
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,N,S

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