HEX
Server: Apache
System: Linux efa57bbe-abb1-400d-2985-3b056fbc2701.secureserver.net 6.1.147-1.el9.elrepo.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jul 24 12:33:32 EDT 2025 x86_64
User: root (0)
PHP: 8.0.30.4
Disabled: NONE
Upload Files
File: //var/www/wp-content/mu-plugins/vendor/wpsec/wp-captcha-plugin/src/handlers/EventHandler.php
<?php

namespace Wpsec\captcha\handlers;

use WP_Error;
use Wpsec\captcha\service\CaptchaService;
use Wpsec\captcha\utils\Logger;

/**
 * Handles WP hooks
 *
 * @since      1.0.0
 * @package    Wpsec
 * @subpackage Wpsec/Handlers
 */
abstract class EventHandler {

	/**
	 * Captcha trigger point from comment.
	 */
	const COMMENT_TRIGGER_POINT = 'comment';

	/**
	 * Captcha trigger point from login.
	 */
	const WP_LOGIN_TRIGGER_POINT = 'wp_login';

	/**
	 * Captcha Service
	 *
	 * @since    1.0.0
	 * @access   private
	 * @var      CaptchaService captcha_service
	 */
	public $captcha_service;

	public function __construct() {
		$this->captcha_service = new CaptchaService();
	}

	/**
	 * Send event type with meta data to the API
	 *
	 * @param   string  $event_type
	 * @param   array   $client_ips
	 * @param   array   $event_meta
	 *
	 * @return array|WP_Error
	 *
	 * @since   1.0.0
	 */
	public function send_event( $event_type, $client_ips, $event_meta = array() ) {
		Logger::log(
			'Send event to API' . ':' . $event_type,
			array(
				'event_type' => $event_type,
				'event_meta' => $event_meta,
				'client_ips' => $client_ips,
			)
		);
		$response = $this->captcha_service->send_event_to_api( $event_type, $client_ips, $event_meta );

		Logger::log(
			'Send event to API Response' . ':' . $event_type,
			array(
				'response' => $response,
			)
		);

		return $response;
	}

	/**
	 * Send event type with meta data to the API
	 *
	 * @since   1.0.0
	 */
	public function show_captcha( $trigger = null ) {
		$this->captcha_service->render_captcha_html_wrapper( $trigger );
	}
}