HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
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: //var/www/lipovac/wp-content/plugins/the-events-calendar/src/Tribe/Event_Cleaner.php
<?php

/**
 * Class Event_Cleaner
 *
 * @since 4.6.13
 */
class Tribe__Events__Event_Cleaner {

	/**
	 * @var $scheduler
	 */
	private $scheduler;

	/**
	 * The option name to move old events to trash.
	 *
	 * @var $key_trash_events
	 *
	 * @since 4.6.13
	 */
	public $key_trash_events = 'trash-past-events';

	/**
	 * The option name to permanently delete old events.
	 *
	 * @var $key_delete_events
	 *
	 * @since 4.6.13
	 */
	public $key_delete_events = 'delete-past-events';

	public function __construct( Tribe__Events__Event_Cleaner_Scheduler $scheduler = null ) {
		$this->scheduler = $scheduler ? $scheduler : new Tribe__Events__Event_Cleaner_Scheduler();
	}

	/**
	 * Receives the existing value and the new value (modified by user) for the $key_trash_events option,
	 * compares them and runs the scheduler if the conditions are satisfied.
	 *
	 * @param array $old_value
	 * @param array $new_value
	 *
	 * @since 4.6.13
	 */
	public function move_old_events_to_trash( array $old_value, array $new_value ) {
		$old_value = empty( $old_value[ $this->key_trash_events ] ) ? null : $old_value[ $this->key_trash_events ];
		$new_value = empty( $new_value[ $this->key_trash_events ] ) ? null : $new_value[ $this->key_trash_events ];

		if ( $new_value == $old_value ) {
			return;
		}

		if ( null === $new_value ) {
			$this->scheduler->trash_clear_scheduled_task();

			return;
		}

		$this->scheduler->set_trash_new_date( $new_value );
		$this->scheduler->move_old_events_to_trash();
	}

	/**
	 * Receives the existing value and the new value (modified by user) for the $key_delete_events option,
	 * compares them and runs the scheduler if the conditions are satisfied.
	 *
	 * @param array $old_value
	 * @param array $new_value
	 *
	 * @since 4.6.13
	 */
	public function permanently_delete_old_events( array $old_value, array $new_value ) {
		$old_value = empty( $old_value[ $this->key_delete_events ] ) ? null : $old_value[ $this->key_delete_events ];
		$new_value = empty( $new_value[ $this->key_delete_events ] ) ? null : $new_value[ $this->key_delete_events ];

		if ( $new_value == $old_value ) {
			return;
		}

		if ( null === $new_value ) {
			$this->scheduler->delete_clear_scheduled_task();

			return;
		}

		$this->scheduler->set_delete_new_date( $new_value );
		$this->scheduler->permanently_delete_old_events();
	}
}