diff --git a/plugins/quant/src/Client.php b/plugins/quant/src/Client.php index 7f90f5c..e127b40 100755 --- a/plugins/quant/src/Client.php +++ b/plugins/quant/src/Client.php @@ -217,11 +217,6 @@ public function sendAttachments($media) { // Strip query params. $file = $url = strtok($url, '?'); - // Strip the site path from the front of the URL. - if (isset($site->path)) { - $file = preg_replace("#^{$site->path}#", '/', $file); - } - if (isset($item['existing_md5'])) { // Skip file: MD5 matches. if (file_exists(ABSPATH . $file) && md5_file(ABSPATH . $file) == $item['existing_md5']) { @@ -229,9 +224,17 @@ public function sendAttachments($media) { } } - if (file_exists(ABSPATH . $file)) { + $uploadDir = wp_get_upload_dir(); + + // Strip the site path from the front of the URL. + if (isset($uploadDir['baseurl'])) { + $basePath = parse_url($uploadDir['baseurl'], PHP_URL_PATH); + $file = preg_replace("#^{$basePath}#", '/', $file); + } + + if (file_exists($uploadDir['basedir'] . $file)) { $attachments[] = [ - 'file' => $file, + 'file' => $uploadDir['basedir'] . $file, 'url' => $url, ]; } @@ -256,7 +259,7 @@ public function multipleFiles($files) { foreach ($files as $file) { $headers['Quant-File-Url'] = $file['url']; - $path = ABSPATH . $file['file']; + $path = $file['file']; $requests[] = [ 'url' => $this->endpoint . '/file-upload?path=' . $path,