Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -913,4 +913,19 @@ public function set_active_page( $page_slug ) {
$this->active_page = $page_slug;
}
}

/**
* Checks if auto sync feature is enabled.
*
* @return bool
*/
public function is_auto_sync_enabled() {
$settings = $this->get_config();

if ( ! empty( $settings['sync_media']['auto_sync'] ) && 'on' === $settings['sync_media']['auto_sync'] ) {
return true;
}

return false;
Comment on lines +925 to +929
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also be:

Suggested change
if ( ! empty( $settings['sync_media']['auto_sync'] ) && 'on' === $settings['sync_media']['auto_sync'] ) {
return true;
}
return false;
return ! empty( $settings['sync_media']['auto_sync'] ) && 'on' === $settings['sync_media']['auto_sync'];

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function is_synced( $post_id ) {
return true;
}

if ( apply_filters( 'cloudinary_flag_sync', '__return_false' ) && ! get_post_meta( $post_id, Sync::META_KEYS['downloading'], true ) ) {
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 ) ) {
update_post_meta( $post_id, Sync::META_KEYS['syncing'], true );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public function handle_bulk_actions( $location, $action, $post_ids ) {
* @return bool
*/
public function auto_sync_enabled( $enabled, $post_id ) {
if ( isset( $this->plugin->config['settings']['sync_media']['auto_sync'] ) && 'on' === $this->plugin->config['settings']['sync_media']['auto_sync'] ) {
if ( $this->plugin->components['settings']->is_auto_sync_enabled() ) {
$enabled = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
* @package Cloudinary
*/

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