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/Admin/Jobs/AbstractJob.php
<?php
declare( strict_types=1 );

namespace Hostinger\Admin\Jobs;

use Exception;

defined( 'ABSPATH' ) || exit;

abstract class AbstractJob implements JobInterface {

    protected ActionScheduler $action_scheduler;

    public function __construct( ActionScheduler $action_scheduler ) {
        $this->action_scheduler = $action_scheduler;
    }

    public function init(): void {
        add_action( $this->get_process_item_hook(), array( $this, 'handle_process_items_action' ) );
        add_action(
            $this->get_start_hook(),
            function ( $args ) {
                $this->schedule( $args );
            }
        );
    }

    public function can_schedule( $args = array() ): bool {
        return ! $this->is_running( $args );
    }

    public function handle_process_items_action( array $args = array() ): void {
        $this->process_items( $args );
    }

    public function get_process_item_hook(): string {
        return "{$this->get_hook_base_name()}process_item";
    }

    public function get_start_hook(): string {
        return $this->get_name();
    }

    protected function is_running( ?array $args = array() ): bool {
        return $this->action_scheduler->has_scheduled_action( $this->get_process_item_hook(), array( $args ) );
    }

    protected function get_hook_base_name(): string {
        return "{$this->action_scheduler->get_group()}/jobs/{$this->get_name()}/";
    }

    abstract public function get_name(): string;
    abstract protected function process_items( array $args );
}