HEX
Server: Apache
System: Linux webd003.cluster128.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64
User: slyfwmm (169339)
PHP: 8.1.34
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/slyfwmm/foar/wp-content/plugins/defender-security/src/component/scheduler/class-scheduler.php
<?php
/**
 * Handles the scheduling of cron jobs within the WordPress environment.
 *
 * @package    WP_Defender\Component\Scheduler
 */

namespace WP_Defender\Component\Scheduler;

/**
 * Service layer to handle cron schedule.
 */
class Scheduler {

	/**
	 * Filter array cron schedules with matched cron keys.
	 *
	 * @param  array $cron_keys  Array of cron keys to fetch respective cron schedules.
	 *
	 * @return array Array of cron schedules.
	 */
	public function filter_cron_schedules( array $cron_keys ): array {
		return array_filter(
			wp_get_schedules(),
			function ( $v, $k ) use ( $cron_keys ): bool {
				return in_array(
					$k,
					$cron_keys,
					true
				);
			},
			ARRAY_FILTER_USE_BOTH
		);
	}

	/**
	 * Override existing schedule with new schedule.
	 *
	 * @param  string $hook  Schedule hook tag to execute/trigger.
	 * @param  string $recurrence  Schedule name.
	 */
	public function override_schedule( string $hook, string $recurrence ): void {
		$timestamp = (int) wp_next_scheduled( $hook );

		wp_clear_scheduled_hook( $hook );

		wp_reschedule_event( $timestamp, $recurrence, $hook );
	}
}