From 6da0a19746882e2da8e308bc82a820d88a8c0baa Mon Sep 17 00:00:00 2001 From: Alex Tolar <> Date: Mon, 4 Jun 2018 17:18:34 +0200 Subject: [PATCH] on thumb removal: delete thumbnail_meta postmeta --- wds-multisite-aggregate.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/wds-multisite-aggregate.php b/wds-multisite-aggregate.php index b6bb737..94711fd 100644 --- a/wds-multisite-aggregate.php +++ b/wds-multisite-aggregate.php @@ -466,6 +466,19 @@ public function save_meta_fields( $post_id, $post, $meta_to_sync ) { $this->set_thumbnail_by_url( $meta_to_sync[ 'thumbnail_url' ], $post_id ); unset( $meta_to_sync[ 'thumbnail_url' ]); } + + // remove 'thumbnail_html*' meta for aggregated post if thumbnail removed on original post + $thumbs_meta = array_filter($meta_to_sync,function($k){ + return strpos($k,'thumbnail_html') === 0; + }); + if(!count($thumbs_meta)) { + foreach (get_post_meta($post_id) as $k => $value) { + if( strpos($k,'thumbnail_html') === 0 ) { + delete_post_meta($post_id,$k ); + } + } + } + foreach ( (array) $meta_to_sync as $key => $value ) { if ( $value ) { $updated[ $key ] = add_post_meta( $post_id, $key, $value );