SchumacherFM / wordpress-to-hugo-exporter

Hugo is static site generator written in golang. Wordpress is a tool for remote access to your server ;-) ❗️Contributions welcome!
https://gohugo.io
GNU General Public License v3.0
692 stars 95 forks source link

`mkdir` fails for nested uploads #21

Closed ghost closed 8 years ago

ghost commented 8 years ago

I had some problems with nested upload dirs: uploads/YYYY/MM/$filename

wp_filesystem->mkdir doesn't recurse (like mkdir -p) so I changed the plugin like this:

diff --git a/hugo-export.php b/hugo-export.php
index 5bde326..5651fd6 100644
--- a/hugo-export.php
+++ b/hugo-export.php
@@ -474,7 +474,9 @@ class Hugo_Export

         // Make destination directory
         if (!is_dir($dest)) {
-            $wp_filesystem->mkdir($dest);
+            if (! wp_mkdir_p($dest)){
+                $wp_filesystem->mkdir($dest) or wp_die("Could not created $dest");
+            }
         }

         // Loop through the folder

To get it working

SchumacherFM commented 8 years ago

Good spot!

Would you please send me a Pull Request!?