• 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_CLI::check() – Checks one or more comments against the Akismet API.

You appear to be a bot. Output may be restricted

Description

Checks one or more comments against the Akismet API.

OPTIONS

<comment_id>… : The ID(s) of the comment(s) to check. [–noaction] : Don't change the status of the comment. Just report what Akismet thinks it is.

EXAMPLES

  • wp akismet check 12345

Usage

Akismet_CLI::check( $args, $assoc_args );

Parameters

$args
( mixed ) required –
$assoc_args
( mixed ) required –

Returns

void

Source

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

1 to 26 of 26
  public function check( $args, $assoc_args ) {
    foreach ( $args as $comment_id ) {
      if ( isset( $assoc_args['noaction'] ) ) {
        // Check the comment, but don't reclassify it.
        $api_response = Akismet::check_db_comment( $comment_id, 'wp-cli' );
      }
      else {
        $api_response = Akismet::recheck_comment( $comment_id, 'wp-cli' );
      }
      
      if ( 'true' === $api_response ) {
        WP_CLI::line( sprintf( __( "Comment #%d is spam.", 'akismet' ), $comment_id ) );
      }
      else if ( 'false' === $api_response ) {
        WP_CLI::line( sprintf( __( "Comment #%d is not spam.", 'akismet' ), $comment_id ) );
      }
      else {
        if ( false === $api_response ) {
          WP_CLI::error( __( "Failed to connect to Akismet.", 'akismet' ) );
        }
        else if ( is_wp_error( $api_response ) ) {
          WP_CLI::warning( sprintf( __( "Comment #%d could not be checked.", 'akismet' ), $comment_id ) );
        }
      }
    }
  }
 

 View on GitHub View on Trac

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

Primary Sidebar

Information

Function name: Akismet_CLI::check
Class ref: Akismet_CLI
Plugin ref: Akismet
Version: 5.0.1
Sourcefile: class.akismet-cli.php
File ref: class.akismet-cli.php
Deprecated?: No
API Letters: A,C

Footer

WordPress a2z
WordPress a2z
WordPress Dynamic API Reference
WordPress 6.1.1. PHP: 8.0.27
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