Changeset 2660486
- Timestamp:
- 01/20/2022 03:56:24 AM (4 years ago)
- Location:
- fastcomments
- Files:
-
- 56 added
- 6 edited
-
tags/3.10.4 (added)
-
tags/3.10.4/.gitignore (added)
-
tags/3.10.4/LICENSE (added)
-
tags/3.10.4/README.md (added)
-
tags/3.10.4/README.txt (added)
-
tags/3.10.4/admin (added)
-
tags/3.10.4/admin/fastcomments-admin-advanced-settings-view.js (added)
-
tags/3.10.4/admin/fastcomments-admin-advanced-settings-view.php (added)
-
tags/3.10.4/admin/fastcomments-admin-manual-sync-view.js (added)
-
tags/3.10.4/admin/fastcomments-admin-manual-sync-view.php (added)
-
tags/3.10.4/admin/fastcomments-admin-setup-view.js (added)
-
tags/3.10.4/admin/fastcomments-admin-setup-view.php (added)
-
tags/3.10.4/admin/fastcomments-admin-sso-view.css (added)
-
tags/3.10.4/admin/fastcomments-admin-sso-view.js (added)
-
tags/3.10.4/admin/fastcomments-admin-sso-view.php (added)
-
tags/3.10.4/admin/fastcomments-admin-support-view.php (added)
-
tags/3.10.4/admin/fastcomments-admin-view.php (added)
-
tags/3.10.4/admin/fastcomments-admin.css (added)
-
tags/3.10.4/admin/fastcomments-admin.php (added)
-
tags/3.10.4/admin/images (added)
-
tags/3.10.4/admin/images/api.png (added)
-
tags/3.10.4/admin/images/crown.png (added)
-
tags/3.10.4/admin/images/css.png (added)
-
tags/3.10.4/admin/images/debugging.png (added)
-
tags/3.10.4/admin/images/download.png (added)
-
tags/3.10.4/admin/images/home.png (added)
-
tags/3.10.4/admin/images/logo-50.png (added)
-
tags/3.10.4/admin/images/logo.png (added)
-
tags/3.10.4/admin/images/settings.png (added)
-
tags/3.10.4/admin/images/support.png (added)
-
tags/3.10.4/admin/images/sync-status.png (added)
-
tags/3.10.4/admin/images/sync.png (added)
-
tags/3.10.4/assets (added)
-
tags/3.10.4/assets/crown.png (added)
-
tags/3.10.4/assets/css.png (added)
-
tags/3.10.4/assets/debugging.png (added)
-
tags/3.10.4/assets/download.png (added)
-
tags/3.10.4/assets/fastcomments-admin.css (added)
-
tags/3.10.4/assets/home.png (added)
-
tags/3.10.4/assets/icon-128x128.png (added)
-
tags/3.10.4/assets/icon-256x256.png (added)
-
tags/3.10.4/assets/screenshot-1.png (added)
-
tags/3.10.4/assets/screenshot-2.png (added)
-
tags/3.10.4/assets/support.png (added)
-
tags/3.10.4/assets/sync.png (added)
-
tags/3.10.4/core (added)
-
tags/3.10.4/core/FastCommentsIntegrationCore.php (added)
-
tags/3.10.4/core/FastCommentsWordPressIntegration.php (added)
-
tags/3.10.4/fastcomments-wordpress-plugin.php (added)
-
tags/3.10.4/public (added)
-
tags/3.10.4/public/fastcomments-public.php (added)
-
tags/3.10.4/public/fastcomments-widget-view.php (added)
-
tags/3.10.4/uninstall.php (added)
-
trunk/README.txt (modified) (2 diffs)
-
trunk/admin/fastcomments-admin-manual-sync-view.js (added)
-
trunk/admin/fastcomments-admin-manual-sync-view.php (added)
-
trunk/admin/fastcomments-admin-view.php (modified) (1 diff)
-
trunk/admin/fastcomments-admin.php (modified) (3 diffs)
-
trunk/admin/images/sync-status.png (added)
-
trunk/core/FastCommentsWordPressIntegration.php (modified) (6 diffs)
-
trunk/fastcomments-wordpress-plugin.php (modified) (2 diffs)
-
trunk/public/fastcomments-public.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
fastcomments/trunk/README.txt
r2658501 r2660486 4 4 Requires at least: 4.6 5 5 Tested up to: 5.8 6 Stable tag: 3.10. 36 Stable tag: 3.10.4 7 7 Requires PHP: 5.2.4 8 8 License: GPLv2 or later … … 85 85 86 86 == Changelog == 87 88 = 3.10.4 = 89 * Support for syncing all of your Comment data from FastComments back to WordPress has been added. 87 90 88 91 = 3.10.3 = -
fastcomments/trunk/admin/fastcomments-admin-view.php
r2613148 r2660486 22 22 </a> 23 23 <a href="https://fastcomments.com/auth/my-account/integrations/v1/setup?token=<?php echo get_option("fastcomments_token") ?>&hasAccount=true" target="_blank"> 24 <img src="<?php echo plugin_dir_url( dirname( __FILE__ ) ); ?>/admin/images/sync-status.png" alt="Check Integration Status" title="Check Integration Status"/> 25 <div>Check Integration Status</div> 26 </a> 27 <a href="<?php echo admin_url('admin.php?page=fastcomments&sub_page=manual-sync'); ?>"> 24 28 <img src="<?php echo plugin_dir_url( dirname( __FILE__ ) ); ?>/admin/images/sync.png" alt="Manually Run Sync" title="Manually Run Sync"/> 25 <div>Manually RunSync</div>29 <div>Manually Sync</div> 26 30 </a> 27 31 <a href="<?php echo admin_url('admin.php?page=fastcomments&sub_page=support'); ?>"> -
fastcomments/trunk/admin/fastcomments-admin.php
r2613148 r2660486 73 73 ); 74 74 75 $fastcomments_my_account_node_args = array( 75 $fastcomments_manual_sync_node_args = array( 76 'parent' => 'fastcomments', 77 'id' => 'manual-sync', 78 'title' => 'Manual Sync', 79 'href' => admin_url('admin.php?page=fastcomments&sub_page=manual-sync'), 80 ); 81 82 $fastcomments_support_node_args = array( 76 83 'parent' => 'fastcomments', 77 84 'id' => 'fastcomments_support', … … 88 95 89 96 $wp_admin_bar->add_node($fastcomments_node_args); 97 $wp_admin_bar->add_node($fastcomments_my_account_node_args); 90 98 $wp_admin_bar->add_node($fastcomments_moderate_node_args); 91 99 $wp_admin_bar->add_node($fastcomments_analytics_node_args); 92 100 $wp_admin_bar->add_node($fastcomments_customize_node_args); 93 $wp_admin_bar->add_node($fastcomments_my_account_node_args); 101 $wp_admin_bar->add_node($fastcomments_manual_sync_node_args); 102 $wp_admin_bar->add_node($fastcomments_support_node_args); 94 103 $wp_admin_bar->add_node($fastcomments_configure_node_args); 95 104 } … … 115 124 $subPage = isset($_GET['sub_page']) ? $_GET['sub_page'] : 'n/a'; 116 125 switch ($subPage) { 126 case 'manual-sync': 127 require_once plugin_dir_path(__FILE__) . 'fastcomments-admin-manual-sync-view.php'; 128 break; 117 129 case 'support': 118 130 global $diagnostic_info; -
fastcomments/trunk/core/FastCommentsWordPressIntegration.php
r2613148 r2660486 272 272 } 273 273 274 public function fc_to_wp_comment($fc_comment ) {274 public function fc_to_wp_comment($fc_comment, $skipWPCheck) { 275 275 /* 276 276 We intentionally don't send these fields, as they don't apply to us so they won't ever change on our side. … … 288 288 if (isset($fc_comment->meta->wpPostId)) { 289 289 $post_id = $fc_comment->meta->wpPostId; 290 } else if ($skipWPCheck && isset($fc_comment->urlId)) { 291 $post_id = (int)$fc_comment->urlId; 290 292 } 291 293 if (isset($fc_comment->meta->wpUserId)) { 292 294 $user_id = $fc_comment->meta->wpUserId; 293 295 } 294 } 295 296 if (!$post_id) { 296 } else if ($skipWPCheck && isset($fc_comment->urlId)) { 297 $post_id = (int)$fc_comment->urlId; 298 } 299 300 if (!$skipWPCheck && !$post_id) { 297 301 return null; // don't try to set post id to a url... this is probably not a comment from the WP integration. 298 302 } … … 321 325 $wp_comment['comment_date'] = $date_formatted; 322 326 $wp_comment['comment_date_gmt'] = $date_formatted_gmt; 323 $wp_comment['comment_content'] = $fc_comment->comment ;327 $wp_comment['comment_content'] = $fc_comment->commentHTML; 324 328 $wp_comment['comment_karma'] = $fc_comment->votes; 325 329 $wp_comment['comment_approved'] = $fc_comment->approved ? 1 : 0; … … 401 405 } 402 406 403 $new_wp_comment = $this->fc_to_wp_comment($eventData->comment );407 $new_wp_comment = $this->fc_to_wp_comment($eventData->comment, false); 404 408 if ($new_wp_comment) { 405 409 $comment_id_or_false = wp_insert_comment($new_wp_comment); … … 419 423 $fcId = $eventData->comment->_id; 420 424 $this->log('debug', "Updating comment $fcId"); 421 $wp_comment = $this->fc_to_wp_comment($eventData->comment );425 $wp_comment = $this->fc_to_wp_comment($eventData->comment, false); 422 426 if ($wp_comment) { 423 427 wp_update_comment($wp_comment); … … 512 516 } 513 517 } 514 -
fastcomments/trunk/fastcomments-wordpress-plugin.php
r2658501 r2660486 4 4 Plugin URI: https://fastcomments.com 5 5 Description: Live Comments, Fast. A comment system that will delight your users and developers. 6 Version: 3.10. 36 Version: 3.10.4 7 7 Author: winrid @ FastComments 8 8 License: GPL-2.0+ … … 14 14 } 15 15 16 $FASTCOMMENTS_VERSION = 3.10 1;16 $FASTCOMMENTS_VERSION = 3.104; 17 17 18 18 require_once plugin_dir_path(__FILE__) . 'admin/fastcomments-admin.php'; -
fastcomments/trunk/public/fastcomments-public.php
r2613148 r2660486 22 22 'methods' => 'PUT', 23 23 'callback' => array($this, 'handle_set_sso_enabled_request'), 24 'permission_callback' => function () { 25 return current_user_can('activate_plugins'); 26 } 27 )); 28 register_rest_route('fastcomments/v1', '/api/sync-to-wp', array( 29 'methods' => 'PUT', 30 'callback' => array($this, 'handle_sync_to_wp_request'), 24 31 'permission_callback' => function () { 25 32 return current_user_can('activate_plugins'); … … 61 68 62 69 return new WP_REST_Response(array('status' => 'success'), 200); 70 } 71 72 public function handle_sync_to_wp_request(WP_REST_Request $request) { 73 $includeCount = $request->get_param('includeCount'); 74 $skip = $request->get_param('skip'); 75 require_once plugin_dir_path(__FILE__) . '../core/FastCommentsWordPressIntegration.php'; 76 $fastcomments = new FastCommentsWordPressIntegration(); 77 $token = $fastcomments->getSettingValue('fastcomments_token'); 78 $request_url = "https://fastcomments.com/integrations/v1/comments?token=$token"; 79 if ($includeCount) { 80 $request_url .= '&includeCount=true'; 81 } 82 if ($skip) { 83 $request_url .= "&skip=$skip"; 84 } 85 $get_comments_response_raw = $fastcomments->makeHTTPRequest('GET', $request_url, null); 86 $get_comments_response = json_decode($get_comments_response_raw->responseBody); 87 if ($get_comments_response->status === 'success') { 88 $count = count($get_comments_response->comments); 89 if ($count > 0) { 90 foreach ($get_comments_response->comments as $comment) { 91 $wp_comment = $fastcomments->fc_to_wp_comment($comment, true); 92 if(!wp_update_comment($wp_comment)) { 93 wp_insert_comment($wp_comment); 94 } 95 } 96 return new WP_REST_Response(array('status' => 'success', 'hasMore' => $get_comments_response->hasMore, 'totalCount' => $includeCount ? $get_comments_response->totalCount : null, 'count' => $count), 200); 97 } else { 98 return new WP_REST_Response(array('status' => 'success'), 200); 99 } 100 } else { 101 return new WP_REST_Response(array('status' => 'failed'), 500); 102 } 63 103 } 64 104
Note: See TracChangeset
for help on using the changeset viewer.