diff --git a/src/Actions/Convert/Replacer/PostAttachmentReplacer.php b/src/Actions/Convert/Replacer/PostAttachmentReplacer.php index 912f689..c49b3c9 100644 --- a/src/Actions/Convert/Replacer/PostAttachmentReplacer.php +++ b/src/Actions/Convert/Replacer/PostAttachmentReplacer.php @@ -1,7 +1,8 @@ getUrl() ); + if ($this->mcloudPostUrl == $post->getUrl()) { + throw new UrlDetectException( + sprintf(<<getUrl(), + $replacer->getUploadsDirBaseUrl() + ) + ); + } + $this->mcloudPostBaseUrl = trailingslashit( str_replace($this->post->getBasename(), '', $this->mcloudPostUrl) ); diff --git a/src/Actions/Convert/ReplacerService.php b/src/Actions/Convert/ReplacerService.php index 838b68e..f37b5f2 100644 --- a/src/Actions/Convert/ReplacerService.php +++ b/src/Actions/Convert/ReplacerService.php @@ -1,9 +1,9 @@ getId(), '_wp_attachment_metadata', $meta ); + $post->setAttachmentMetaData($meta); Counters::$processedImages++; } diff --git a/src/Exceptions/UrlDetectException.php b/src/Exceptions/UrlDetectException.php new file mode 100644 index 0000000..59d389b --- /dev/null +++ b/src/Exceptions/UrlDetectException.php @@ -0,0 +1,6 @@ +getUrl()); + return mb_basename($this->getUrl()); } public function getPostMimeType(): string @@ -57,7 +55,6 @@ class PostAttachment public function setAttachmentMetaData(array $meta) { - update_post_meta($this->getId(), self::META_KEY_ATTACHMENT_METADATA, $meta); } diff --git a/src/Support/helpers.php b/src/Support/helpers.php new file mode 100644 index 0000000..8dc186f --- /dev/null +++ b/src/Support/helpers.php @@ -0,0 +1,10 @@ + add_submenu_page( // // $ilabClassLoader = new Composer\Autoload\ClassLoader(); // $ilabLoader->unregister(); + include __DIR__ . '/src/Support/helpers.php'; $localVendorAutoloadPath = 'vendor/autoload.php'; $projectVendorAutoloadPath = ABSPATH . 'vendor/autoload.php';