From c28b5bce2364fe212b73d20965ec729a8d9ec3cc Mon Sep 17 00:00:00 2001 From: Tracy Rotton Date: Wed, 8 May 2019 17:00:37 -0400 Subject: [PATCH] Not every WordPress host (example: Pantheon) allows writes to the filesystem outside of the WP_CONTENT/uploads directory. --- Exporter.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Exporter.php b/Exporter.php index b15095c..2d2ebad 100644 --- a/Exporter.php +++ b/Exporter.php @@ -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) @@ -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)