Пример #1
0
 /**
  * Hook into the actions fired in the Backup class and set the status
  *
  * @param $action
  */
 public function do_action($action, Backup $backup)
 {
     // Pass the actions to all the services
     // Todo should be decoupled into the service class
     foreach (Services::get_services($this) as $service) {
         $service->action($action, $backup);
     }
     switch ($action) {
         case 'hmbkp_backup_started':
         case 'hmbkp_mysqldump_finished':
         case 'hmbkp_archive_finished':
             break;
         case 'hmbkp_mysqldump_started':
             $this->set_status(sprintf(__('Dumping Database %s', 'backupwordpress'), '(<code>' . $this->backup->get_mysqldump_method() . '</code>)'));
             break;
         case 'hmbkp_mysqldump_verify_started':
             $this->set_status(sprintf(__('Verifying Database Dump %s', 'backupwordpress'), '(<code>' . $this->backup->get_mysqldump_method() . '</code>)'));
             break;
         case 'hmbkp_archive_started':
             $this->set_status(sprintf(__('Creating zip archive %s', 'backupwordpress'), '(<code>' . $this->backup->get_archive_method() . '</code>)'));
             break;
         case 'hmbkp_archive_verify_started':
             $this->set_status(sprintf(__('Verifying Zip Archive %s', 'backupwordpress'), '(<code>' . $this->backup->get_archive_method() . '</code>)'));
             break;
         case 'hmbkp_backup_complete':
             $this->set_status(__('Finishing Backup', 'backupwordpress'));
             $this->update_average_schedule_run_time($this->get_schedule_running_start_time(), time());
             break;
         case 'hmbkp_error':
             if ($this->backup->get_errors()) {
                 $file = $this->get_path() . '/.backup_errors';
                 if (file_exists($file)) {
                     @unlink($file);
                 }
                 if (!($handle = @fopen($file, 'w'))) {
                     return;
                 }
                 fwrite($handle, json_encode($this->backup->get_errors()));
                 fclose($handle);
             }
             break;
         case 'hmbkp_warning':
             if ($this->backup->get_warnings()) {
                 $file = $this->get_path() . '/.backup_warnings';
                 if (file_exists($file)) {
                     @unlink($file);
                 }
                 if (!($handle = @fopen($file, 'w'))) {
                     return;
                 }
                 fwrite($handle, json_encode($this->backup->get_warnings()));
                 fclose($handle);
             }
             break;
         default:
             return new \WP_Error('unexpected-error', __('An unexpected error occured', 'backupwordpress'));
     }
 }
    }
    /**
     * The words to append to the main schedule sentence
     *
     * @return string The words that will be appended to the main schedule sentence
     */
    public function display()
    {
        if ($this->is_service_active()) {
            return __($this->name, 'backupwordpress');
        }
    }
    /**
     * Used to determine if the service is in use or not
     *
     * @return bool True if service is active
     */
    public function is_service_active()
    {
        return (bool) $this->get_field_value($this->name);
    }
    public static function intercom_data()
    {
        return array();
    }
    public static function intercom_data_html()
    {
    }
}
Services::register(__FILE__, 'HM\\BackUpWordPress\\S3BackUpService');