Skip to content
Snippets Groups Projects
Commit cc4f0812 authored by Mohammad Jangda's avatar Mohammad Jangda
Browse files

Better handling for thumbnails and multiple sites

The way we were preventing repetitive syndication on every update was
also breaking syndicating the thumbnail to multiple sites. This stores
each thumbnail syndication alongside the site ID so that one site result
cannot stomp on another.

Also updates the meta key to make it more specific.

fixes #36
parent 4ab51808
Branches
No related tags found
No related merge requests found
...@@ -44,8 +44,13 @@ class Syndication_WP_XMLRPC_Client extends WP_HTTP_IXR_Client implements Syndica ...@@ -44,8 +44,13 @@ class Syndication_WP_XMLRPC_Client extends WP_HTTP_IXR_Client implements Syndica
foreach ( $thumbnail_meta_keys as $thumbnail_meta ) { foreach ( $thumbnail_meta_keys as $thumbnail_meta ) {
$thumbnail_id = get_post_meta( $post_id, $thumbnail_meta, true ); $thumbnail_id = get_post_meta( $post_id, $thumbnail_meta, true );
$syn_local_meta_key = '_syn_push_syndicated_' . $thumbnail_meta; $syn_local_meta_key = '_syn_push_thumb_' . $thumbnail_meta;
$syndicated_thumbnail_id = get_post_meta( $post_id, $syn_local_meta_key, true ); $syndicated_thumbnails_by_site = get_post_meta( $post_id, $syn_local_meta_key, true );
if ( ! is_array( $syndicated_thumbnails_by_site ) )
$syndicated_thumbnails_by_site = array();
$syndicated_thumbnail_id = isset( $syndicated_thumbnails_by_site[ $this->site_ID ] ) ? $syndicated_thumbnails_by_site[ $this->site_ID ] : false;
if ( ! $thumbnail_id ) { if ( ! $thumbnail_id ) {
if ( $syndicated_thumbnail_id ) { if ( $syndicated_thumbnail_id ) {
...@@ -58,7 +63,8 @@ class Syndication_WP_XMLRPC_Client extends WP_HTTP_IXR_Client implements Syndica ...@@ -58,7 +63,8 @@ class Syndication_WP_XMLRPC_Client extends WP_HTTP_IXR_Client implements Syndica
$thumbnail_meta $thumbnail_meta
); );
delete_post_meta( $post_id, $syn_local_meta_key ); unset( $syndicated_thumbnails_by_site[ $this->site_ID ] );
update_post_meta( $post_id, $syn_local_meta_key, $syndicated_thumbnails_by_site );
} }
continue; continue;
...@@ -80,7 +86,8 @@ class Syndication_WP_XMLRPC_Client extends WP_HTTP_IXR_Client implements Syndica ...@@ -80,7 +86,8 @@ class Syndication_WP_XMLRPC_Client extends WP_HTTP_IXR_Client implements Syndica
); );
if ( $result ) { if ( $result ) {
update_post_meta( $post_id, $syn_local_meta_key, $thumbnail_id ); $syndicated_thumbnails_by_site[ $this->site_ID ] = $thumbnail_id;
update_post_meta( $post_id, $syn_local_meta_key, $syndicated_thumbnails_by_site );
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment