Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Not every WordPress host (example: Pantheon) allows writes to the fil… #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions Exporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ class Exporter

public function __construct()
{
$this->filename = 'statamic_' . date('Ymd_His') . '.json';
$this->file = ABSPATH . '/' . static::PREFIX . '/' . $this->filename;
$this->upload_dir = wp_upload_dir();
$this->filename = 'statamic_' . date('Ymd_His') . '.json';
$this->directory = trailingslashit( $this->upload_dir['basedir'] ) . trailingslashit( static::PREFIX );
$this->file = $this->directory . $this->filename;
}

public function content($types)
Expand Down Expand Up @@ -169,11 +171,11 @@ public function download()

private function createExportDirectory()
{
if (file_exists(ABSPATH . static::PREFIX)) {
if (file_exists( $this->directory )) {
return;
}

mkdir(ABSPATH . static::PREFIX, 0777, true);
mkdir( $this->directory, 0777, true );
}

private function metadata($type, $post)
Expand Down