Plugin Directory

Changeset 2583733


Ignore:
Timestamp:
08/16/2021 07:32:14 PM (5 years ago)
Author:
winrid
Message:

3.9.4 - Support for custom integrations to pass custom values for "comment thread ids" while retaining the WordPress Post and User IDs on sync.

Location:
fastcomments
Files:
34 added
4 edited

Legend:

Unmodified
Added
Removed
  • fastcomments/trunk/README.txt

    r2577475 r2583733  
    44Requires at least: 4.6
    55Tested up to: 5.8
    6 Stable tag: 3.9.3
     6Stable tag: 3.9.4
    77Requires PHP: 5.2.4
    88License: GPLv2 or later
     
    8585== Changelog ==
    8686
     87= 3.9.4 =
     88* Support for custom integrations to pass custom values for "comment thread ids" while retaining the WordPress Post and User IDs on sync.
     89
    8790= 3.9.3 =
    8891* Stability improvements and sync-related bugfixes.
  • fastcomments/trunk/core/FastCommentsWordPressIntegration.php

    r2577475 r2583733  
    223223        $wp_parent_id = isset($fc_comment->parentId) && $fc_comment->parentId ? $this->getWPCommentId($fc_comment->parentId) : 0;
    224224
     225        $post_id = null;
     226        $user_id = null;
     227
     228        if (isset($fc_comment->meta)) {
     229            if (isset($fc_comment->meta->wpPostId)) {
     230                $post_id = $fc_comment->meta->wpPostId;
     231            }
     232            if (isset($fc_comment->meta->wpUserId)) {
     233                $user_id = $fc_comment->meta->wpUserId;
     234            }
     235        } else {
     236            $post_id = (int) $fc_comment->urlId;
     237        }
     238
    225239        $wp_comment['comment_ID'] = is_numeric($wp_id) ? $wp_id : null;
    226         $wp_comment['comment_post_ID'] = (int)$fc_comment->urlId;
    227         $finalpostId = $wp_comment['comment_post_ID'];
     240        $wp_comment['comment_post_ID'] = $post_id;
    228241        $wp_comment['comment_post_url'] = $fc_comment->url;
    229         // TODO fix user ids potentially getting lost via 1. Create comment in WP 2. Sync to FC 3. Update Comment Text in FC 4. Sync back to WP.
    230 //        $wp_comment['comment_user_ID'] = 0;
     242        // Isset check to prevent user ids potentially getting lost if integration is custom and doesn't define meta->wpUserId.
     243        if (isset($user_id)) {
     244            $wp_comment['comment_user_ID'] = $user_id;
     245        }
    231246        $wp_comment['comment_author'] = $fc_comment->commenterName;
    232247        $wp_comment['comment_author_email'] = $fc_comment->commenterEmail;
  • fastcomments/trunk/fastcomments-wordpress-plugin.php

    r2577475 r2583733  
    44Plugin URI: https://fastcomments.com
    55Description: Live Comments, Fast. A comment system that will delight your users and developers.
    6 Version: 3.9.3
     6Version: 3.9.4
    77Author: winrid @ FastComments
    88License: GPL-2.0+
     
    1414}
    1515
    16 $FASTCOMMENTS_VERSION = 3.93;
     16$FASTCOMMENTS_VERSION = 3.94;
    1717
    1818require_once plugin_dir_path(__FILE__) . 'admin/fastcomments-admin.php';
  • fastcomments/trunk/public/fastcomments-public.php

    r2577451 r2583733  
    6666        $ssoKey = get_option('fastcomments_sso_key');
    6767        $isSSOEnabled = $ssoKey && get_option('fastcomments_sso_enabled');
     68        $userId = null;
     69        $wp_user = wp_get_current_user();
    6870        return array(
    6971            'tenantId' => get_option('fastcomments_tenant_id') ? get_option('fastcomments_tenant_id') : 'demo',
     
    7173            'url' => get_permalink($post),
    7274            'readonly' => 'open' != $post->comment_status,
    73             'sso' => $isSSOEnabled ? FastCommentsPublic::getSSOConfig($ssoKey) : null
     75            'sso' => $isSSOEnabled ? FastCommentsPublic::getSSOConfig($ssoKey, $wp_user) : null,
     76            'commentMeta' => array(
     77                'wpPostId' => $post->ID,
     78                'wpUserId' => $wp_user ? $wp_user->ID : null
     79            )
    7480        );
    7581    }
    7682
    77     private static function getSSOConfig($ssoKey) {
     83    private static function getSSOConfig($ssoKey, $wp_user) {
    7884        $timestamp = time() * 1000;
    7985
     
    8288
    8389        $sso_user = array();
    84         $wp_user = wp_get_current_user();
    8590        if ($wp_user) {
    8691            $sso_user['id'] = $wp_user->ID;
Note: See TracChangeset for help on using the changeset viewer.