Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/hostinge.../includes/Admin/Jobs
File: AbstractBatchedJob.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Hostinger\Admin\Jobs;
[2] Fix | Delete
[3] Fix | Delete
use Hostinger\LlmsTxtGenerator\LlmsTxtParser;
[4] Fix | Delete
[5] Fix | Delete
defined( 'ABSPATH' ) || exit;
[6] Fix | Delete
[7] Fix | Delete
abstract class AbstractBatchedJob extends AbstractJob {
[8] Fix | Delete
[9] Fix | Delete
public function init(): void {
[10] Fix | Delete
add_action( $this->get_create_batch_hook(), array( $this, 'handle_create_batch_action' ), 10, 2 );
[11] Fix | Delete
parent::init();
[12] Fix | Delete
}
[13] Fix | Delete
[14] Fix | Delete
protected function get_create_batch_hook(): string {
[15] Fix | Delete
return "{$this->get_hook_base_name()}create_batch";
[16] Fix | Delete
}
[17] Fix | Delete
[18] Fix | Delete
public function schedule( array $args = array() ): void {
[19] Fix | Delete
$this->schedule_create_batch_action( 1, $args );
[20] Fix | Delete
}
[21] Fix | Delete
[22] Fix | Delete
public function handle_create_batch_action( int $batch_number, array $args ): void {
[23] Fix | Delete
$items = $this->get_batch( $batch_number, $args );
[24] Fix | Delete
[25] Fix | Delete
if ( empty( $items ) ) {
[26] Fix | Delete
$this->handle_complete( $batch_number, $args );
[27] Fix | Delete
} else {
[28] Fix | Delete
$this->schedule_process_action( $items, $args );
[29] Fix | Delete
$this->schedule_create_batch_action( $batch_number + 1, $args );
[30] Fix | Delete
}
[31] Fix | Delete
}
[32] Fix | Delete
[33] Fix | Delete
protected function get_batch_size(): int {
[34] Fix | Delete
return apply_filters( 'hostinger_batch_item_limit', LlmsTxtParser::DEFAULT_LIMIT );
[35] Fix | Delete
}
[36] Fix | Delete
[37] Fix | Delete
protected function get_query_offset( int $batch_number ): int {
[38] Fix | Delete
return $this->get_batch_size() * ( $batch_number - 1 );
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
protected function schedule_create_batch_action( int $batch_number, array $args ): void {
[42] Fix | Delete
if ( $this->can_schedule( array( $batch_number ) ) ) {
[43] Fix | Delete
$this->action_scheduler->schedule_immediate(
[44] Fix | Delete
$this->get_create_batch_hook(),
[45] Fix | Delete
array(
[46] Fix | Delete
$batch_number,
[47] Fix | Delete
$args,
[48] Fix | Delete
)
[49] Fix | Delete
);
[50] Fix | Delete
}
[51] Fix | Delete
}
[52] Fix | Delete
[53] Fix | Delete
protected function schedule_process_action( array $items = array(), array $args = array() ): void {
[54] Fix | Delete
$job_data = array(
[55] Fix | Delete
'items' => $items,
[56] Fix | Delete
'args' => $args,
[57] Fix | Delete
);
[58] Fix | Delete
if ( ! $this->is_processing( $job_data ) ) {
[59] Fix | Delete
$this->action_scheduler->schedule_immediate( $this->get_process_item_hook(), array( $job_data ) );
[60] Fix | Delete
}
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
protected function is_processing( array $args = array() ): bool {
[64] Fix | Delete
return $this->action_scheduler->has_scheduled_action( $this->get_process_item_hook(), array( $args ) );
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
protected function handle_complete( int $final_batch_number, array $args ): void {
[68] Fix | Delete
return;
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
abstract protected function get_batch( int $batch_number, array $args ): array;
[72] Fix | Delete
}
[73] Fix | Delete
[74] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function