From bac7b9629c8a0df9d0d1106510fe198aaf39dc14 Mon Sep 17 00:00:00 2001 From: Sujan Date: Wed, 25 Sep 2019 16:12:04 +1000 Subject: [PATCH] Allowing option to change custom identifier for pages via Wordpress custom field. --- disqus/public/class-disqus-public.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/disqus/public/class-disqus-public.php b/disqus/public/class-disqus-public.php index 38456b7..70f2d55 100755 --- a/disqus/public/class-disqus-public.php +++ b/disqus/public/class-disqus-public.php @@ -23,13 +23,20 @@ class Disqus_Public { /** * Returns the Disqus identifier for a given post. + * If custom field is defined for the page with + * key 'dsq_cusom_identifier' then the custom identifier is returned. * * @since 3.0 * @param WP_Post $post The WordPress post to create the title for. * @return string The formatted identifier to be passed to Disqus. */ public static function dsq_identifier_for_post( $post ) { - return $post->ID . ' ' . $post->guid; + $dsq_custom_identifier = get_post_meta($post->ID, 'dsq_custom_identifier', true); + if (!empty($dsq_custom_identifier )) { + return $disqus_custom_identifier_meta . ' ' . get_the_guid($disqus_custom_identifier_meta); + } else { + return $post->ID . ' ' . $post->guid; + } } /**