コード例 #1
0
 /**
  * @internal
  */
 public function _query($headers, FW_Backup_Helper_Database $db, $stmt)
 {
     $_translate_table_prefix = FW_Backup_Callable::make(array($this, '_translate_table_prefix'), $headers);
     $sql = preg_replace_callback('/^(CREATE TABLE|INSERT INTO) `(\\w+)`/m', $_translate_table_prefix, $stmt);
     $db->query($sql);
 }
コード例 #2
0
 public function do_backup_background_demo_install($post_id)
 {
     /**
      * @var FW_Extension_Backup_Storage_Local $storage_local
      */
     $backup_info = $this->backup()->get_backup_info($post_id);
     try {
         $name_prefix = sanitize_file_name(strtolower($backup_info->get_theme()));
         $storage_local = $this->backup()->get_storage('backup-storage-local');
         $storage = new FW_Backup_Storage_Local_With_Prefix($storage_local, $name_prefix);
         $exporter = new FW_Backup_Export_Demo_Install();
         $feedback = new FW_Backup_Feedback_Commit(FW_Backup_Callable::make(array($this->backup(), 'update_feedback'), $post_id));
         $process = new FW_Backup_Process_Backup($storage, $exporter, $feedback, $backup_info);
         $process->run();
     } catch (FW_Backup_Exception $exception) {
     }
     $this->backup()->update_backup_info($post_id, $backup_info);
     $this->backup()->delete_feedback($post_id);
     // Move demo-install to the trash, this will hides it from *All* tab
     $post = get_post($post_id);
     $post->post_title = __('Demo Install', 'fw');
     $post->post_status = 'trash';
     if (isset($exception)) {
         $post->post_content = $exception->getMessage();
     }
     wp_update_post($post);
     // Remove obsolete demo-install archives
     if ($backup_info->is_completed()) {
         array_map('wp_delete_post', array_diff($this->backup()->get_demo_install_list(), array($post_id)));
     } else {
         // Something went wrong with the *demo-install* process. Backup
         // archive has nothing in it.
         wp_delete_post($post_id);
     }
     wp_redirect($this->backup()->post_type()->get_url());
     exit;
 }