diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-sync.php
index 11377b172..cd9272c2d 100644
--- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-sync.php
+++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-sync.php
@@ -97,17 +97,16 @@ private function register_hooks() {
* @return array
*/
function add_inline_action( $actions, $post ) {
- if ( ! $this->plugin->components['sync']->is_synced( $post->ID ) ) {
- if ( current_user_can( 'delete_post', $post->ID ) ) {
- $action_url = add_query_arg(
- array(
- 'action' => 'cloudinary-push',
- 'media[]' => $post->ID,
- '_wpnonce' => wp_create_nonce( 'bulk-media' ),
- ),
- 'upload.php'
- );
-
+ if ( current_user_can( 'delete_post', $post->ID ) ) {
+ $action_url = add_query_arg(
+ array(
+ 'action' => 'cloudinary-push',
+ 'media[]' => $post->ID,
+ '_wpnonce' => wp_create_nonce( 'bulk-media' ),
+ ),
+ 'upload.php'
+ );
+ if ( ! $this->plugin->components['sync']->is_synced( $post->ID ) ) {
$actions['cloudinary-push'] = sprintf(
'%s',
$action_url,
@@ -115,6 +114,14 @@ function add_inline_action( $actions, $post ) {
esc_attr( sprintf( __( 'Push to Cloudinary “%s”' ), 'asd' ) ),
__( 'Push to Cloudinary', 'cloudinary' )
);
+ } else {
+ $actions['cloudinary-push'] = sprintf(
+ '%s',
+ $action_url,
+ /* translators: %s: Attachment title. */
+ esc_attr( sprintf( __( 'Push to Cloudinary “%s”' ), 'asd' ) ),
+ __( 'Re-sync to Cloudinary', 'cloudinary' )
+ );
}
}
@@ -135,9 +142,12 @@ public function handle_bulk_actions( $location, $action, $post_ids ) {
switch ( $action ) {
case 'cloudinary-push' :
foreach ( $post_ids as $post_id ) {
- if ( ! $this->plugin->components['sync']->is_synced( $post_id ) ) {
- $this->prep_upload( $post_id );
- }
+ delete_post_meta( $post_id, Sync::META_KEYS['sync_error'] );
+ delete_post_meta( $post_id, Sync::META_KEYS['public_id'] );
+ delete_post_meta( $post_id, Sync::META_KEYS['pending'] );
+ $file = get_attached_file( $post_id );
+ wp_generate_attachment_metadata( $post_id, $file );
+ $this->prep_upload( $post_id );
}
break;
}