@@ -97,24 +97,31 @@ private function register_hooks() {
9797 * @return array
9898 */
9999 function add_inline_action ( $ actions , $ post ) {
100- if ( ! $ this ->plugin ->components ['sync ' ]->is_synced ( $ post ->ID ) ) {
101- if ( current_user_can ( 'delete_post ' , $ post ->ID ) ) {
102- $ action_url = add_query_arg (
103- array (
104- 'action ' => 'cloudinary-push ' ,
105- 'media[] ' => $ post ->ID ,
106- '_wpnonce ' => wp_create_nonce ( 'bulk-media ' ),
107- ),
108- 'upload.php '
109- );
110-
100+ if ( current_user_can ( 'delete_post ' , $ post ->ID ) ) {
101+ $ action_url = add_query_arg (
102+ array (
103+ 'action ' => 'cloudinary-push ' ,
104+ 'media[] ' => $ post ->ID ,
105+ '_wpnonce ' => wp_create_nonce ( 'bulk-media ' ),
106+ ),
107+ 'upload.php '
108+ );
109+ if ( ! $ this ->plugin ->components ['sync ' ]->is_synced ( $ post ->ID ) ) {
111110 $ actions ['cloudinary-push ' ] = sprintf (
112111 '<a href="%s" aria-label="%s">%s</a> ' ,
113112 $ action_url ,
114113 /* translators: %s: Attachment title. */
115114 esc_attr ( sprintf ( __ ( 'Push to Cloudinary “%s” ' ), 'asd ' ) ),
116115 __ ( 'Push to Cloudinary ' , 'cloudinary ' )
117116 );
117+ } else {
118+ $ actions ['cloudinary-push ' ] = sprintf (
119+ '<a href="%s" aria-label="%s">%s</a> ' ,
120+ $ action_url ,
121+ /* translators: %s: Attachment title. */
122+ esc_attr ( sprintf ( __ ( 'Push to Cloudinary “%s” ' ), 'asd ' ) ),
123+ __ ( 'Re-sync to Cloudinary ' , 'cloudinary ' )
124+ );
118125 }
119126 }
120127
@@ -135,9 +142,12 @@ public function handle_bulk_actions( $location, $action, $post_ids ) {
135142 switch ( $ action ) {
136143 case 'cloudinary-push ' :
137144 foreach ( $ post_ids as $ post_id ) {
138- if ( ! $ this ->plugin ->components ['sync ' ]->is_synced ( $ post_id ) ) {
139- $ this ->prep_upload ( $ post_id );
140- }
145+ delete_post_meta ( $ post_id , Sync::META_KEYS ['sync_error ' ] );
146+ delete_post_meta ( $ post_id , Sync::META_KEYS ['public_id ' ] );
147+ delete_post_meta ( $ post_id , Sync::META_KEYS ['pending ' ] );
148+ $ file = get_attached_file ( $ post_id );
149+ wp_generate_attachment_metadata ( $ post_id , $ file );
150+ $ this ->prep_upload ( $ post_id );
141151 }
142152 break ;
143153 }
0 commit comments