From 39b1b6f2f76f98f8382e5b08614856537a74071a Mon Sep 17 00:00:00 2001 From: Tung Du Date: Thu, 8 Jul 2021 10:13:00 +0700 Subject: [PATCH] fix: adding isCanonical lately after removing falsy items --- includes/functions/content-sync.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/includes/functions/content-sync.php b/includes/functions/content-sync.php index 4476de25..e9aa65e0 100644 --- a/includes/functions/content-sync.php +++ b/includes/functions/content-sync.php @@ -174,17 +174,13 @@ function get_post_data( $post ) { 'tags' => Utils\get_post_tags( $post ), 'url' => get_permalink( $post ), 'type' => Utils\get_post_content_type( $post ), - 'isCanonical' => untrailingslashit( $canonical_url ) === untrailingslashit( get_permalink( $post ) ), 'promoImageUri' => get_the_post_thumbnail_url( $post, 'full' ), ]; - // Remove empty key, not false ones. - $data = array_filter( - $data, - function( $item ) { - return '' !== $item; - } - ); + $data = array_filter( $data ); + + // Add canonical after filtering the falsy items. + $data['isCanonical'] = untrailingslashit( $canonical_url ) === untrailingslashit( get_permalink( $post ) ); /** * Filter post data for content sync events (aka "CMS updates" in Sophi.io terms) sent to Sophi Collector. This allows control over data before it is sent to Collector in case it needs to be modified for unique site needs. Note that if you add, change, or remove any fields with this that those changes will need to be coordinated with the Sophi.io team to ensure content is appropriately received by Collector.