PluginProbe
Media Cloud Sync / 1.4.2
Media Cloud Sync v1.4.2
1.4.2 1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 All 36 releases
← All changes | includes/base/services/cloudflare-r2.php +14 -2 1.3.12 → 1.4.2 View file →
@@ -608,9 +608,9 @@
608 608 /**
609 609 * Upload Single
610 610 * @since 1.0.0
611 611 */
612 - public function uploadSingle($absolute_source_path, $relative_source_path, $prefix='') {
612 + public function uploadSingle($absolute_source_path, $relative_source_path, $prefix='', $is_private = false) {
613 613 if (
614 614 isset($absolute_source_path) && !empty($absolute_source_path) &&
615 615 isset($relative_source_path) && !empty($relative_source_path)
616 616 ) {
@@ -615,9 +615,16 @@
615 615 isset($relative_source_path) && !empty($relative_source_path)
616 616 ) {
617 617 $file_name = wp_basename( $relative_source_path );
618 618 if ($file_name) {
619 - $upload_path = Utils::generate_object_key($relative_source_path, $prefix);
619 + $upload_path = Utils::generate_object_key($relative_source_path, $prefix, $is_private);
620 + if ($upload_path === false) {
621 + return [
622 + 'success' => false,
623 + 'code' => 200,
624 + 'message' => esc_html__('This file is marked private, but the private-media add-on is not currently active — reupload skipped to avoid exposing it.', 'media-cloud-sync')
625 + ];
626 + }
620 627 return $this->execute_upload($absolute_source_path, $upload_path);
621 628 }
622 629 }
623 630
@@ -1061,6 +1068,11 @@
1061 1068 return "https://{$account_id}.r2.cloudflarestorage.com";
1062 1069 }
1063 1070 // fallback
1064 1071 return "https://r2.cloudflarestorage.com";
1072 + }
1073 +
1074 + /** Exposes the already-constructed SDK client for StreamWrapper's registration — avoids reconstructing one from credentials. */
1075 + public function get_client() {
1076 + return $this->cloudflareClient;
1065 1077 }
1066 1078 }