HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux newsites.squeezer-software.com 6.8.0-90-generic #91-Ubuntu SMP PREEMPT_DYNAMIC Tue Nov 18 14:14:30 UTC 2025 x86_64
User: www-data (33)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /home/sites/ileskneiss/wp-content/plugins/learnpress/inc/Background/LPBackgroundTrigger.php
<?php
namespace LearnPress\Background;

use Exception;
use LearnPress;
use LP_Debug;
use LP_Helper;
use Throwable;

defined( 'ABSPATH' ) || exit;

/**
 * Class LPBackgroundTrigger
 * To handle a function that can be run in background
 * Via call class:method with params
 *
 * @since 4.2.8.7
 * @version 1.0.0
 */
class LPBackgroundTrigger extends LPAsyncRequest {
	protected $action = 'background_trigger';
	protected static $instance;

	/**
	 * Method async handle
	 */
	protected function handle() {
		ini_set( 'max_execution_time', 0 );
		try {
			$params = LP_Helper::sanitize_params_submitted( $_POST['params'] ?? false );
			$class  = LP_Helper::sanitize_params_submitted( $_POST['class'] ?? false );
			$method = LP_Helper::sanitize_params_submitted( $_POST['method'] ?? false );

			if ( ! $class || ! $params || ! $method ) {
				throw new Exception( 'Params send on background is invalid' );
			}

			// Security: check callback is registered.
			$allow_callbacks = apply_filters(
				'lp/background/allow_callback',
				[]
			);

			$callBackStr = $class . ':' . $method;
			if ( ! in_array( $callBackStr, $allow_callbacks ) ) {
				throw new Exception( 'Error: callback is not register!' );
			}

			// Check class and method is callable.
			if ( is_callable( [ $class, $method ] ) ) {
				call_user_func( [ $class, $method ], $params );
			} else {
				throw new Exception( 'Error: callback is not callable!' );
			}
		} catch ( Throwable $e ) {
			LP_Debug::error_log( $e );
		}

		ini_set( 'max_execution_time', LearnPress::$time_limit_default_of_sever );
		die;
	}

	/**
	 * @return LPBackgroundTrigger
	 */
	public static function instance(): self {
		if ( is_null( self::$instance ) ) {
			self::$instance = new self();
		}

		return self::$instance;
	}
}

// Must run instance to register ajax.
LPBackgroundTrigger::instance();