PluginProbe
Media Cloud Sync / 1.4.1
Media Cloud Sync v1.4.1
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 1.2.9 All 35 releases
← All changes | includes/compatbility/compatibility.php +14 -4 1.3.101.4.1 View file →
@@ -38,8 +38,12 @@
38 38
39 39 }
40 40
41 41 public function init() {
42 + if(!Utils::is_service_enabled()) {
43 + return;
44 + }
45 +
42 46 /*
43 47 * Image Editor Handler
44 48 * /wp-admin/includes/image-edit.php
45 49 */
@@ -372,9 +376,9 @@
372 376 *
373 377 * @return int|null
374 378 */
375 379 public function customizer_background_image($post_id, $url) {
376 - if (!is_null($post_id)) {
380 + if (!empty($post_id)) {
377 381 return $post_id;
378 382 }
379 383
380 384 // There seems to be a bug in the WP Customizer whereby sometimes it puts the attachment ID on the URL.
@@ -387,9 +391,9 @@
387 391 }
388 392 } else {
389 393 $path = Utils::get_attachment_source_path($url);
390 394 if (!Utils::is_empty($path)) {
391 - $item = Item::instance()->get_items_by_paths($path);
395 + $item = Item::instance()->get_items_by_paths( $path, true, true );
392 396 if (!Utils::is_empty($item)) {
393 397 // If we found an offloaded Media Library item for that path, job's a good'n'.
394 398 $post_id = $item['source_id'];
395 399 }
@@ -464,15 +468,21 @@
464 468 * the attachment's file should be.
465 469 *
466 470 * @return string|bool File if downloaded, false on failure
467 471 */
468 - private function copy_provider_file_to_server($attachment_id, $file) {
472 + public function copy_provider_file_to_server($attachment_id, $file) {
469 473 // Download files
470 474 if (!Item::instance()->moveToServerBySourcePath($attachment_id, $file, 'media_library')) {
471 475 return false;
472 - }
476 + }
473 477
474 478 $this->restored_files[] = $file;
479 +
480 + // Shared with woocommerce.php — feeds the same pre_update_item pipeline as
481 + // below when a save happens this request, with a shutdown fallback for the
482 + // other three callers here (image editor, legacy copy-back, Regenerate
483 + // Thumbnails pre-v3), which otherwise have no cleanup at all.
484 + Item::instance()->track_restored_for_cleanup( [ $file ] );
475 485
476 486 return $file;
477 487 }
478 488