HEX
Server: Apache/2.4.46 (Ubuntu)
System: Linux localhost 5.11.0-49-generic #55-Ubuntu SMP Wed Jan 12 17:36:34 UTC 2022 x86_64
User: root (0)
PHP: 7.4.16
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/html/dooblo.cccinfotech.com/wp-content/plugins/backupwordpress/classes/class-schedules.php
<?php

namespace HM\BackUpWordPress;

/**
 * A simple class for loading schedules
 */
class Schedules {

	/**
	 * An array of schedules
	 *
	 * @var mixed
	 * @access private
	 */
	private $schedules;

	/**
	 *
	 */
	protected static $instance;

	public static function get_instance() {

		if ( ! ( self::$instance instanceof Schedules ) ) {
			self::$instance = new Schedules();
		}

		return self::$instance;

	}

	/**
	 * Load the schedules from wp_options and store in $this->schedules
	 *
	 */
	private function __construct() {
		$this->refresh_schedules();
	}

	public function refresh_schedules() {

		$schedules = get_transient( 'hmbkp_schedules' );

		if ( ! $schedules ) {

			global $wpdb;

			// Load all schedule options from the database.
			$schedules = $wpdb->get_col( "SELECT option_name from $wpdb->options WHERE option_name LIKE 'hmbkp\_schedule\_%'" );

			set_transient( 'hmbkp_schedules', $schedules, WEEK_IN_SECONDS );
		}

		// Instantiate each one as a Scheduled_Backup
		$this->schedules = array_map( array( $this, 'instantiate' ), array_filter( (array) $schedules ) );

	}

	/**
	 * Get an array of schedules
	 *
	 * @return Scheduled_Backup[]
	 */
	public function get_schedules() {
		return $this->schedules;
	}

	/**
	 * Get a schedule by ID
	 *
	 * @param $id
	 * @return Scheduled_Backup
	 */
	public function get_schedule( $id ) {

		foreach ( $this->schedules as $schedule ) {
			if ( $schedule->get_id() == $id ) {
				return $schedule;
			}
		}

		return null;
	}

	/**
	 * Instantiate the individual scheduled backup objects
	 *
	 * @access private
	 * @param string $id
	 * @return Scheduled_Backup
	 */
	private function instantiate( $id ) {
		return new Scheduled_Backup( str_replace( 'hmbkp_schedule_', '', $id ) );
	}
}