Skip to content

Commit a4812af

Browse files
authored
Merge pull request #131 from cloudinary/hotfix/sync-status
Fix syncing status
2 parents 6faac36 + b7a7ac6 commit a4812af

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-settings-page.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,4 +913,19 @@ public function set_active_page( $page_slug ) {
913913
$this->active_page = $page_slug;
914914
}
915915
}
916+
917+
/**
918+
* Checks if auto sync feature is enabled.
919+
*
920+
* @return bool
921+
*/
922+
public function is_auto_sync_enabled() {
923+
$settings = $this->get_config();
924+
925+
if ( ! empty( $settings['sync_media']['auto_sync'] ) && 'on' === $settings['sync_media']['auto_sync'] ) {
926+
return true;
927+
}
928+
929+
return false;
930+
}
916931
}

cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function is_synced( $post_id ) {
109109
return true;
110110
}
111111

112-
if ( apply_filters( 'cloudinary_flag_sync', '__return_false' ) && ! get_post_meta( $post_id, Sync::META_KEYS['downloading'], true ) ) {
112+
if ( $this->plugin->components['settings']->is_auto_sync_enabled() && apply_filters( 'cloudinary_flag_sync', '__return_false' ) && ! get_post_meta( $post_id, Sync::META_KEYS['downloading'], true ) ) {
113113
update_post_meta( $post_id, Sync::META_KEYS['syncing'], true );
114114
}
115115

cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-sync.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public function handle_bulk_actions( $location, $action, $post_ids ) {
167167
* @return bool
168168
*/
169169
public function auto_sync_enabled( $enabled, $post_id ) {
170-
if ( isset( $this->plugin->config['settings']['sync_media']['auto_sync'] ) && 'on' === $this->plugin->config['settings']['sync_media']['auto_sync'] ) {
170+
if ( $this->plugin->components['settings']->is_auto_sync_enabled() ) {
171171
$enabled = true;
172172
}
173173

cloudinary-image-management-and-manipulation-in-the-cloud-cdn/ui-definitions/tabs/sync-media-content.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
* @package Cloudinary
66
*/
77

8-
$autosync = false;
9-
if ( isset( $this->plugin->config['settings']['sync_media']['auto_sync'] ) && 'on' === $this->plugin->config['settings']['sync_media']['auto_sync'] ) {
10-
$autosync = true;
11-
}
8+
$autosync = $this->plugin->components['settings']->is_auto_sync_enabled();
129
?>
1310
<?php if ( ! empty( $this->plugin->config['connect'] ) ) : ?>
1411
<div class="settings-tab-section-card">

0 commit comments

Comments
 (0)