HEX
Server: Apache/2
System: Linux server1c 2.6.32-042stab145.3 #1 SMP Thu Jun 11 14:05:04 MSK 2020 x86_64
User: jandjware (1008)
PHP: 8.2.23
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/jandjware/public_html/wp-content/plugins/hostinger/includes/Mcp/Handlers/EventHandler.php
<?php

namespace Hostinger\Mcp\Handlers;

use Hostinger\Admin\Proxy;
use Hostinger\Mcp\EventHandlerFactory;

defined( 'ABSPATH' ) || exit;

abstract class EventHandler {

    public Proxy $proxy;

    public function __construct( Proxy $proxy ) {
        $this->proxy = $proxy;
    }

    protected function send_to_proxy( array $args = array() ): bool {
        if ( ! $this->can_send( $args ) ) {
            $this->debug_mcp( 'Event failed: User is not opted in' . ' -- ' . print_r( $args, true ) );
            return false;
        }

        $event   = $args['event'];
        $request = $this->proxy->trigger_event( $event, $args );
        if ( is_wp_error( $request ) ) {
            $this->debug_mcp( 'Event failed: ' . $event . $request->get_error_message() . ' -- ' . print_r( $args, true ) );
            return false;
        }

        $response_code = wp_remote_retrieve_response_code( $request );
        if ( $response_code < 300 ) {
            $this->debug_mcp( 'Event sent: ' . $event . ' -- ' . print_r( $args, true ) );
            return true;
        }

        $this->debug_mcp( 'Event failed: ' . $event . ' --' . $response_code . ' -- ' . print_r( $args, true ) );
        return false;
    }

    public function can_send( array $args = array() ): bool {
        return isset( $args['event'] ) && ( $this->is_optin_event( $args['event'] ) || $this->is_opted_in() );
    }

    private function is_opted_in(): bool {
        $settings = get_option( HOSTINGER_PLUGIN_SETTINGS_OPTION, array() );
        return $settings['optin_mcp'] ?? false;
    }

    private function is_optin_event( $event ): bool {
        return $event === EventHandlerFactory::MCP_EVENT_OPTIN_TOGGLED;
    }

    private function debug_mcp( string $msg ): void {
        if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
            error_log( 'Hostinger Tools MCP: ' . $msg . PHP_EOL, 3, WP_CONTENT_DIR . '/mcp.log' );
        }
    }

    abstract public function send( array $args = array() ): void;
}