/** * 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'); } // Setup HM Backup parent::__construct(); // Store id for later $this->id = $id; // Load the options $this->options = array_filter((array) get_option('hmbkp_schedule_' . $this->get_id())); // Some properties can be overridden with defines if (defined('HMBKP_ROOT') && HMBKP_ROOT) { $this->set_root(HMBKP_ROOT); } if (defined('HMBKP_PATH') && HMBKP_PATH) { $this->set_path(HMBKP_PATH); } if (defined('HMBKP_EXCLUDE') && HMBKP_EXCLUDE) { parent::set_excludes(HMBKP_EXCLUDE, true); } parent::set_excludes($this->default_excludes(), true); if (defined('HMBKP_MYSQLDUMP_PATH')) { $this->set_mysqldump_command_path(HMBKP_MYSQLDUMP_PATH); } if (defined('HMBKP_ZIP_PATH')) { $this->set_zip_command_path(HMBKP_ZIP_PATH); } if (defined('HMBKP_ZIP_PATH') && HMBKP_ZIP_PATH === 'PclZip' && ($this->skip_zip_archive = true)) { $this->set_zip_command_path(false); } if (defined('HMBKP_SCHEDULE_START_TIME') && strtotime('HMBKP_SCHEDULE_START_TIME')) { $this->set_schedule_start_time(strtotime('HMBKP_SCHEDULE_START_TIME')); } // Set the path - TODO remove external function dependancy $this->set_path(hmbkp_path()); // Set the archive filename to site name + schedule slug + date $this->set_archive_filename(implode('-', array(sanitize_title(str_ireplace(array('http://', 'https://', 'www'), '', home_url())), $this->get_id(), $this->get_type(), date('Y-m-d-H-i-s', current_time('timestamp')))) . '.zip'); $this->set_database_dump_filename(implode('-', array(sanitize_title(str_ireplace(array('http://', 'https://', 'www'), '', home_url())), $this->get_id(), $this->get_type(), date('Y-m-d-H-i-s', current_time('timestamp')))) . '.sql'); // Setup the schedule if it isn't set if (!$this->is_cron_scheduled() && $this->get_reoccurrence() !== 'manually') { $this->schedule(); } }