/** * Setup the schedule object * Loads the options from the database and populates properties * * @param string $id * * @throws Exception */ public function __construct($id) { // Verify the schedule id if (!is_string($id) || !trim($id)) { throw new \Exception('Argument 1 for ' . __METHOD__ . ' must be a non empty string'); } // Store id for later $this->id = $id; // Load the options $this->options = array_filter((array) get_option('hmbkp_schedule_' . $this->get_id())); // Setup The Backup class $this->backup = new Backup(); // Set the archive filename to site name + schedule slug + date $this->backup->set_archive_filename(implode('-', array(sanitize_title(str_ireplace(array('http://', 'https://', 'www'), '', home_url())), $this->get_id(), $this->get_type(), current_time('Y-m-d-H-i-s'))) . '.zip'); $this->backup->set_database_dump_filename(implode('-', array('database', sanitize_title(str_ireplace(array('http://', 'https://', 'www'), '', home_url())), $this->get_id())) . '.sql'); $this->backup->set_type($this->get_type()); $this->backup->set_excludes($this->backup->default_excludes(), true); $this->backup->set_excludes($this->get_excludes()); $this->backup->set_action_callback(array($this, 'do_action')); if (defined('HMBKP_SCHEDULE_START_TIME') && strtotime('HMBKP_SCHEDULE_START_TIME')) { $this->set_schedule_start_time(strtotime('HMBKP_SCHEDULE_START_TIME')); } // Setup the schedule if it isn't set if (!$this->is_cron_scheduled() && $this->get_reoccurrence() !== 'manually') { $this->schedule(); } }