From 6044aa2fc2fa15868088719156ee25de475e60a8 Mon Sep 17 00:00:00 2001 From: Vinicius Barros Date: Fri, 14 Jul 2017 14:09:55 +0100 Subject: [PATCH] Fixing issue when deploying post thumbnail --- classes/db/class-postmeta-dao.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/classes/db/class-postmeta-dao.php b/classes/db/class-postmeta-dao.php index ec040d1..efbc37c 100644 --- a/classes/db/class-postmeta-dao.php +++ b/classes/db/class-postmeta-dao.php @@ -209,7 +209,15 @@ public function update_postmeta_by_post( $post_id, array $stage_records ) { unset( $prod_records[$prod_key] ); } else { foreach ( $stage_records as $stage_key => $stage_record ) { - if ( $stage_record['meta_key'] == $prod_record['meta_key'] ) { + /** + * Fixing issue with thumbnails that don't get deployed + * as value come as an array, instead of string + */ + if( $stage_record['meta_key'] == '_thumbnail_id' && isset($stage_record['meta_value'][0]) ){ + $stage_record['meta_value'] = $stage_record['meta_value'][0]; + } + + if ( $stage_record['meta_key'] == $prod_record['meta_key'] ) { $stage_record['meta_id'] = $prod_record['meta_id']; $update[] = $stage_record; unset( $stage_records[$stage_key] ); @@ -300,4 +308,4 @@ private function filter_input( $postmeta ) { ); } -} \ No newline at end of file +}