Plugin Directory

Changeset 1881615


Ignore:
Timestamp:
05/25/2018 06:24:44 PM (8 years ago)
Author:
ryanv12
Message:

Preparing for 3.0.16 release

Location:
disqus-comment-system/trunk
Files:
4 added
3 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • disqus-comment-system/trunk/README.txt

    r1832582 r1881615  
    44Requires at least: 4.4
    55Tested up to: 4.9.4
    6 Stable tag: 3.0.15
     6Stable tag: 3.0.16
    77Requires PHP: 5.4
    88
     
    9797
    9898**NOTE: It is recommended that you [backup your database](http://codex.wordpress.org/Backing_Up_Your_Database) before installing the plugin.**
     99
     100https://www.youtube.com/watch?v=a4JBJXyuaFk
    99101
    100102= Syncing comments to WordPress =
     
    123125== Changelog ==
    124126
     127= 3.0.16 =
     128
     129* Add a manual syncing option that allows retroactive syncing within a selected date range
     130* Fixed bug where SSO avatar URLs were malformed (Thanks to [klaufel](https://github.com/disqus/disqus-wordpress-plugin/pull/49))
     131
    125132= 3.0.15 =
    126133
  • disqus-comment-system/trunk/disqus.php

    r1832582 r1881615  
    1616 * Plugin URI:        https://disqus.com/
    1717 * Description:       Disqus helps publishers increase engagement and build loyal audiences. Supports syncing comments to your database for easy backup.
    18  * Version:           3.0.15
     18 * Version:           3.0.16
    1919 * Author:            Disqus
    2020 * Author URI:        https://disqus.com/
     
    2525 */
    2626
    27 $DISQUSVERSION = '3.0.15';
     27$DISQUSVERSION = '3.0.16';
    2828
    2929// If this file is called directly, abort.
  • disqus-comment-system/trunk/public/class-disqus-public.php

    r1831152 r1881615  
    5959            $payload_user['id'] = $user->ID;
    6060            $payload_user['username'] = $user->display_name;
    61             $payload_user['avatar'] = get_avatar( $user->ID, 92 );
     61            $payload_user['avatar'] = get_avatar_url( $user->ID, 92 );
    6262            $payload_user['email'] = $user->user_email;
    6363            $payload_user['url'] = $user->user_url;
     
    302302        }
    303303
     304        // Don't load embed when comments are closed on a post. These lines can solve a conflict with plugin Public Post Preview.
     305        if ( ! comments_open() ) {
     306            return false;
     307        }
     308
    304309        // Don't load embed if it's not a single post page.
    305310        if ( ! is_singular() ) {
  • disqus-comment-system/trunk/rest-api/class-disqus-rest-api.php

    r1831152 r1881615  
    118118        ) );
    119119
     120        // Alias route for `sync/webhook` to get around plugins/services disabling "abused" routes.
     121        register_rest_route( Disqus_Rest_Api::REST_NAMESPACE, 'sync/comment', array(
     122            'methods' => 'POST',
     123            'callback' => array( $this, 'rest_sync_webhook' ),
     124            'permission_callback' => array( $this, 'rest_admin_only_permission_callback' ),
     125        ) );
     126
    120127        register_rest_route( Disqus_Rest_Api::REST_NAMESPACE, 'settings', array(
    121128            array(
     
    224231        try {
    225232            switch ( $json_data['verb'] ) {
     233                case 'force_sync':
     234                    $comment_id = $this->create_or_update_comment_from_post( $json_data['transformed_data'] );
     235                    $this->log_sync_message( 'Manually synced comment "' . $json_data['transformed_data']['id'] . '" from Disqus' );
     236                    return new WP_REST_Response( (string) $comment_id, 200 );
    226237                case 'create':
    227                     $new_comment_id = $this->create_comment_from_post( $json_data['transformed_data'] );
     238                    $new_comment_id = $this->create_or_update_comment_from_post( $json_data['transformed_data'] );
    228239                    $this->log_sync_message( 'Synced new comment "' . $json_data['transformed_data']['id'] . '" from Disqus' );
    229240                    return new WP_REST_Response( (string) $new_comment_id, 201 );
    230241                case 'update':
    231                     $updated_comment_id = $this->update_comment_from_post( $json_data['transformed_data'] );
     242                    $updated_comment_id = $this->create_or_update_comment_from_post( $json_data['transformed_data'] );
    232243                    $this->log_sync_message( 'Updated synced comment "' . $json_data['transformed_data']['id'] . '" from Disqus' );
    233244                    return new WP_REST_Response( (string) $updated_comment_id, 200 );
     
    621632
    622633    /**
    623      * Creates a comment in the WordPress database given a Disqus post.
    624      *
    625      * @since    3.0
     634     * Queries the WordPress database for existing comment by dsq_post_id. Creates or updates if comment found
     635     * in the WordPress database given a Disqus post.
     636     *
     637     * @since    3.0.16
    626638     * @param    array $post    The Disqus post object.
    627      * @return   int            The newly created comment ID.
     639     * @return   int            The created or updated comment ID.
    628640     * @throws   Exception      An exception if comment can't be saved from post data.
    629641     */
    630     private function create_comment_from_post( $post ) {
     642    private function create_or_update_comment_from_post( $post ) {
    631643        $this->validate_disqus_post_data( $post );
    632644
    633         // Check to make sure we haven't synced this comment yet.
     645        // Check for existing comment.
    634646        $comment_query = new WP_Comment_Query( array(
    635647            'meta_key' => 'dsq_post_id',
     
    638650        ) );
    639651
    640         if ( ! empty( $comment_query->comments ) ) {
    641             $this->log_sync_message( 'Error syncing new comment "' . $post['id'] . '" from Disqus. Comment with this dsq_post_id already in the local database' );
    642             return 0;
    643         }
    644 
    645         $comment_data = $this->comment_data_from_post( $post );
    646 
    647         $new_comment_id = wp_insert_comment( $comment_data );
    648 
    649         return $new_comment_id;
    650     }
    651 
    652     /**
    653      * Updates a comment in the WordPress database given a Disqus post.
     652        $comments = $comment_query->comments;
     653        if ( ! empty( $comments ) ) {
     654            return $this->update_comment_from_post( $post, $comments );
     655        }
     656
     657        return $this->create_comment_from_post( $post );
     658    }
     659
     660    /**
     661     * Creates a comment in the WordPress database given a Disqus post.
    654662     *
    655663     * @since    3.0
     
    658666     * @throws   Exception      An exception if comment can't be saved from post data.
    659667     */
    660     private function update_comment_from_post( $post ) {
    661         $this->validate_disqus_post_data( $post );
    662 
    663         // Check to make sure we have synced this comment already.
    664         $comment_query = new WP_Comment_Query( array(
    665             'meta_key' => 'dsq_post_id',
    666             'meta_value' => $post['id'],
    667             'number' => 1,
    668         ) );
    669 
    670         $comments = $comment_query->comments;
    671 
    672         if ( empty( $comments ) ) {
    673             $this->log_sync_message( 'Error updating synced comment "' . $post['id'] . '" from Disqus. Comment with this dsq_post_id was not in the local database' );
    674             return 0;
    675         }
    676 
     668    private function create_comment_from_post( $post ) {
     669        $comment_data = $this->comment_data_from_post( $post );
     670
     671        $new_comment_id = wp_insert_comment( $comment_data );
     672
     673        return $new_comment_id;
     674    }
     675
     676    /**
     677     * Updates a comment in the WordPress database given a Disqus post.
     678     *
     679     * @since    3.0
     680     * @param    array $post        The Disqus post object.
     681     * @param    array $comments    The comments found matching the dsq_post_id.
     682     * @return   int                The newly created comment ID.
     683     * @throws   Exception          An exception if comment can't be saved from post data.
     684     */
     685    private function update_comment_from_post( $post, $comments ) {
    677686        foreach ( $comments as $comment ) {
    678687            $updated_comment_id = $comment->comment_ID;
     
    717726     */
    718727    private function comment_data_from_post( $post ) {
    719         $thread = $post['threadData'];
     728        $thread = array_key_exists( 'threadData', $post ) ? $post['threadData'] : $post['thread'];
    720729        $author = $post['author'];
    721730
Note: See TracChangeset for help on using the changeset viewer.