src/WPametu/Service/Akismet.php
public static function is_spam( array $values = [] ){
		$query_string = self::make_request( $values );
		// If Akismet is not active, always return error
		if( !class_exists('Akismet') || ! \Akismet::get_api_key() ){
			return new \WP_Error(500, 'Akismet is not active.');
		}
		// Make request
		add_filter('akismet_ua', [static::class, 'get_ua'], 9);
		$response = \Akismet::http_post($query_string, 'comment-check');
		remove_filter('akismet_ua', [static::class, 'get_ua'], 9);
		// Parse result
		switch( $response[1] ){
			case 'true':
				return true; // This is spam.
				break;
			case 'false':
				return false; // This is not spam.
				break;
			default:
				// Something is wrong
				if( isset( $response[0]['x-akismet-debug-help'] ) && !empty($response[0]['x-akismet-debug-help']) ){
					$message = $response[0]['x-akismet-debug-help'];
				}else{
					$message = 'Akismet return the invalid result. Something is wrong.';
				}
				return new \WP_Error(500, $message);
				break;
		}
	}
public static function is_spam( array $values = [] ){
		$query_string = self::make_request( $values );
		// If Akismet is not active, always return error
		if( !class_exists('Akismet') || ! \Akismet::get_api_key() ){
			return new \WP_Error(500, 'Akismet is not active.');
		}
		// Make request
		add_filter('akismet_ua', [static::class, 'get_ua'], 9);
		$response = \Akismet::http_post($query_string, 'comment-check');
		remove_filter('akismet_ua', [static::class, 'get_ua'], 9);
		// Parse result
		switch( $response[1] ){
			case 'true':
				return true; // This is spam.
				break;
			case 'false':
				return false; // This is not spam.
				break;
			default:
				// Something is wrong
				if( isset( $response[0]['x-akismet-debug-help'] ) && !empty($response[0]['x-akismet-debug-help']) ){
					$message = $response[0]['x-akismet-debug-help'];
				}else{
					$message = 'Akismet return the invalid result. Something is wrong.';
				}
				return new \WP_Error(500, $message);
				break;
		}
	}
public static function is_spam ( array $ values = [ ] ) { $ query_string = self :: make_request ( $ values ) ; // If Akismet is not active, always return error if ( ! class_exists ( 'Akismet' ) || ! \ Akismet :: get_api_key ( ) ) { return new \ WP_Error ( 500 , 'Akismet is not active.' ) ; } // Make request add_filter ( 'akismet_ua' , [ static :: class , 'get_ua' ] , 9 ) ; $ response = \ Akismet :: http_post ( $ query_string , 'comment-check' ) ; remove_filter ( 'akismet_ua' , [ static :: class , 'get_ua' ] , 9 ) ; // Parse result switch ( $ response [ 1 ] ) { case 'true' : return true ; // This is spam. break ; case 'false' : return false ; // This is not spam. break ; default : // Something is wrong if ( isset ( $ response [ 0 ] [ 'x-akismet-debug-help' ] ) && ! empty ( $ response [ 0 ] [ 'x-akismet-debug-help' ] ) ) { $ message = $ response [ 0 ] [ 'x-akismet-debug-help' ] ; } else { $ message = 'Akismet return the invalid result. Something is wrong.' ; } return new \ WP_Error ( 500 , $ message ) ; break ; } }
Check if data is spam

@param array $values

@return bool|\WP_Error
Check if data is spam