Plugin Directory

Changeset 2584331


Ignore:
Timestamp:
08/17/2021 04:25:55 PM (5 years ago)
Author:
winrid
Message:

3.9.5 - Improved comment date accuracy on reverse sync + switching to WordPress built in mechanisms for HTTP requests.

Location:
fastcomments
Files:
34 added
4 edited

Legend:

Unmodified
Added
Removed
  • fastcomments/trunk/README.txt

    r2583733 r2584331  
    44Requires at least: 4.6
    55Tested up to: 5.8
    6 Stable tag: 3.9.4
     6Stable tag: 3.9.5
    77Requires PHP: 5.2.4
    88License: GPLv2 or later
     
    8585== Changelog ==
    8686
     87= 3.9.5 =
     88* Improved comment date accuracy on reverse sync + switching to WordPress built in mechanisms for HTTP requests.
     89
    8790= 3.9.4 =
    8891* Support for custom integrations to pass custom values for "comment thread ids" while retaining the WordPress Post and User IDs on sync.
  • fastcomments/trunk/core/FastCommentsWordPressIntegration.php

    r2583733 r2584331  
    143143
    144144    public function makeHTTPRequest($method, $url, $body) {
    145         $curl = curl_init();
    146 
    147         curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
    148         switch ($method) {
    149             case "POST":
    150                 if ($body) {
    151                     curl_setopt($curl, CURLOPT_POSTFIELDS, $body);
    152                     curl_setopt($curl, CURLOPT_HTTPHEADER, array(
    153                         'Content-Type: application/json',
    154                         'Content-Length: ' . strlen($body)
    155                     ));
    156                 }
    157                 break;
    158             default:
    159                 if ($body) {
    160                     $url = sprintf("%s?%s", $url, http_build_query($body));
    161                 }
    162         }
    163 
    164         curl_setopt($curl, CURLOPT_URL, $url);
    165         curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    166 //        curl_setopt($curl, CURLOPT_VERBOSE, true);
    167         curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    168         curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
    169 
    170         $rawResult = curl_exec($curl);
     145        $rawResult = wp_remote_request($url, array(
     146            'method' => $method,
     147            'body' => $body,
     148            'timeout' => 20,
     149            'headers' => array('Content-Type' => 'application/json; charset=utf-8'),
     150            'data_format' => $body ? 'body' : 'query'
     151        ));
    171152
    172153        $result = new stdClass();
    173         $result->responseStatusCode = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
    174         $result->responseBody = $rawResult;
     154        if ($rawResult instanceof WP_Error) {
     155            $this->log('error', "Request for $url errored out.");
     156            $result->responseStatusCode = 500;
     157            $result->responseBody = null;
     158        } else {
     159            $result->responseStatusCode = $rawResult['response']['code'];
     160            $result->responseBody = $rawResult['body'];
     161        }
    175162
    176163//        echo "Response URL " . $method . " " . $url . "\n";
    177164//        echo "Response Code " . $result->responseStatusCode . "\n";
    178165//        echo "Response Body " . $result->responseBody . "\n";
    179 
    180         curl_close($curl);
    181166
    182167        return $result;
     
    217202        // wordpress timestamp format is Y-m-d H:i:s (mysql date column type)
    218203        $timestamp = strtotime($fc_comment->date);
    219         $date_formatted = date('Y-m-d H:i:s', $timestamp);
    220 
     204        $date_formatted_gmt = date('Y-m-d H:i:s', $timestamp);
     205        $date_formatted = get_date_from_gmt($date_formatted_gmt);
     206
     207        $this->log('debug', "Dates: got $date_formatted_gmt -> $date_formatted from $fc_comment->date -> $timestamp");
    221208
    222209        $wp_id = $this->getWPCommentId($fc_comment->_id);
     
    247234        $wp_comment['comment_author_email'] = $fc_comment->commenterEmail;
    248235        $wp_comment['comment_date'] = $date_formatted;
    249         $wp_comment['comment_date_gmt'] = $date_formatted;
     236        $wp_comment['comment_date_gmt'] = $date_formatted_gmt;
    250237        $wp_comment['comment_content'] = $fc_comment->comment;
    251238        $wp_comment['comment_karma'] = $fc_comment->votes;
  • fastcomments/trunk/fastcomments-wordpress-plugin.php

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

    r2583733 r2584331  
    7474            'readonly' => 'open' != $post->comment_status,
    7575            'sso' => $isSSOEnabled ? FastCommentsPublic::getSSOConfig($ssoKey, $wp_user) : null,
     76            'apiHost' => null, // For local builds, the CI system will replace this with localhost. This mechanism prevents us from having to read files etc at run time for production sites.
    7677            'commentMeta' => array(
    7778                'wpPostId' => $post->ID,
Note: See TracChangeset for help on using the changeset viewer.