diff --git a/php/class-sync.php b/php/class-sync.php index 4ec29f34..53173f0a 100644 --- a/php/class-sync.php +++ b/php/class-sync.php @@ -51,7 +51,7 @@ class Sync implements Setup, Assets { * * @var array */ - protected $sync_types; + protected $sync_types = array(); /** * Holds a list of unsynced images to push on end. @@ -372,10 +372,13 @@ public function get_signature( $attachment_id, $cached = true ) { $signature = array(); } - // Remove any old or outdated signature items. against the expected. - $signature = array_intersect_key( $signature, $this->sync_types ); $signatures[ $attachment_id ] = $return; - $return = wp_parse_args( $signature, $this->sync_types ); + + // Remove any old or outdated signature items. against the expected. + if ( ! empty( $this->sync_types ) ) { + $signature = array_intersect_key( $signature, $this->sync_types ); + $return = wp_parse_args( $signature, $this->sync_types ); + } } /** @@ -789,9 +792,12 @@ public function sync_base( $attachment_id ) { $return = array(); $asset_state = $this->get_asset_state( $attachment_id ); - foreach ( array_keys( $this->sync_types ) as $type ) { - if ( $asset_state >= $this->sync_base_struct[ $type ]['asset_state'] ) { - $return[ $type ] = $this->generate_type_signature( $type, $attachment_id ); + + if ( ! empty( $this->sync_types ) ) { + foreach ( array_keys( $this->sync_types ) as $type ) { + if ( $asset_state >= $this->sync_base_struct[ $type ]['asset_state'] ) { + $return[ $type ] = $this->generate_type_signature( $type, $attachment_id ); + } } } @@ -844,7 +850,7 @@ public function get_sync_type( $attachment_id, $cached = true ) { $required_signature = $this->generate_signature( $attachment_id, $cached ); $attachment_signature = $this->get_signature( $attachment_id, $cached ); $attachment_signature = array_intersect_key( $attachment_signature, $required_signature ); - if ( is_array( $required_signature ) ) { + if ( is_array( $required_signature ) && ! empty( $this->sync_types ) ) { $sync_items = array_filter( $attachment_signature, function ( $item, $key ) use ( $required_signature ) { @@ -1108,8 +1114,8 @@ public function maybe_cleanup_errored() { wp_redirect( add_query_arg( array( - 'page' => 'cloudinary', - 'action' => 'cleaned_up', + 'page' => 'cloudinary', + 'action' => 'cleaned_up', ), admin_url( 'admin.php' ) )