Version Description
Download this release
Release Info
Developer | Disqus |
Plugin | Disqus Comment System |
Version | 2.48 |
Comparing to | |
See all releases |
Code changes from version 2.46 to 2.48
- comments.php +12 -10
- disqus.php +99 -96
- lib/wpapi.php +4 -15
- manage.php +21 -5
- readme.txt +14 -2
comments.php
CHANGED
@@ -1,13 +1,17 @@
|
|
1 |
<?php
|
2 |
-
|
|
|
|
|
|
|
|
|
3 |
?>
|
4 |
|
5 |
<div id="disqus_thread">
|
6 |
-
<?php
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
?>
|
12 |
<div id="dsq-content">
|
13 |
<ul id="dsq-comments">
|
@@ -23,15 +27,13 @@
|
|
23 |
</cite>
|
24 |
</div>
|
25 |
<div id="dsq-comment-body-<?php echo comment_ID(); ?>" class="dsq-comment-body">
|
26 |
-
<div id="dsq-comment-message-<?php echo comment_ID(); ?>" class="dsq-comment-message"><?php comment_text(); ?></div>
|
27 |
</div>
|
28 |
</li>
|
29 |
<?php endforeach; ?>
|
30 |
</ul>
|
31 |
</div>
|
32 |
-
|
33 |
-
}
|
34 |
-
?>
|
35 |
</div>
|
36 |
|
37 |
<a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a>
|
1 |
<?php
|
2 |
+
global $dsq_version;
|
3 |
+
|
4 |
+
if (DISQUS_DEBUG) {
|
5 |
+
echo "<p><strong>Disqus Debug</strong> thread_id: ".get_post_meta($post->ID, 'dsq_thread_id', true)."</p>";
|
6 |
+
}
|
7 |
?>
|
8 |
|
9 |
<div id="disqus_thread">
|
10 |
+
<?php if (!get_option('disqus_disable_ssr')): ?>
|
11 |
+
<?php
|
12 |
+
// if (is_file(TEMPLATEPATH . '/comments.php')) {
|
13 |
+
// include(TEMPLATEPATH . '/comments.php');
|
14 |
+
// }
|
15 |
?>
|
16 |
<div id="dsq-content">
|
17 |
<ul id="dsq-comments">
|
27 |
</cite>
|
28 |
</div>
|
29 |
<div id="dsq-comment-body-<?php echo comment_ID(); ?>" class="dsq-comment-body">
|
30 |
+
<div id="dsq-comment-message-<?php echo comment_ID(); ?>" class="dsq-comment-message"><?php echo wp_filter_kses(comment_text()); ?></div>
|
31 |
</div>
|
32 |
</li>
|
33 |
<?php endforeach; ?>
|
34 |
</ul>
|
35 |
</div>
|
36 |
+
<?php endif; ?>
|
|
|
|
|
37 |
</div>
|
38 |
|
39 |
<a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a>
|
disqus.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Disqus Comment System
|
|
4 |
Plugin URI: http://disqus.com/
|
5 |
Description: The Disqus comment system replaces your WordPress comment system with your comments hosted and powered by Disqus. Head over to the Comments admin page to set up your DISQUS Comment System.
|
6 |
Author: Disqus <team@disqus.com>
|
7 |
-
Version: 2.
|
8 |
Author URI: http://disqus.com/
|
9 |
*/
|
10 |
|
@@ -17,6 +17,9 @@ define('DISQUS_IMPORTER_URL', 'http://import.disqus.net/');
|
|
17 |
define('DISQUS_MEDIA_URL', 'http://disqus.com/media/');
|
18 |
define('DISQUS_RSS_PATH', '/latest.rss');
|
19 |
define('DISQUS_CAN_EXPORT', is_file(dirname(__FILE__) . '/export.php'));
|
|
|
|
|
|
|
20 |
|
21 |
/**
|
22 |
* Returns an array of all option identifiers used by DISQUS.
|
@@ -29,6 +32,12 @@ function dsq_options() {
|
|
29 |
'disqus_partner_key',
|
30 |
'disqus_replace',
|
31 |
'disqus_cc_fix',
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
);
|
33 |
}
|
34 |
|
@@ -63,7 +72,7 @@ define('DSQ_PLUGIN_URL', WP_CONTENT_URL . '/plugins/' . dsq_plugin_basename(__FI
|
|
63 |
* @global string $dsq_version
|
64 |
* @since 1.0
|
65 |
*/
|
66 |
-
$dsq_version = '2.
|
67 |
$mt_dsq_version = '2.01';
|
68 |
/**
|
69 |
* Response from Disqus get_thread API call for comments template.
|
@@ -177,39 +186,53 @@ function dsq_manage_dialog($message, $error = false) {
|
|
177 |
. '</strong></p></div>';
|
178 |
}
|
179 |
|
180 |
-
function dsq_sync_comments($
|
181 |
-
global $wpdb;
|
182 |
-
|
183 |
-
$_has_updated_thread = false;
|
184 |
|
185 |
-
//
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
|
|
191 |
}
|
192 |
-
|
193 |
-
|
194 |
-
|
|
|
|
|
195 |
}
|
196 |
|
197 |
foreach ( $comments as $comment ) {
|
198 |
$ts = strtotime($comment->created_at);
|
199 |
-
if (
|
200 |
-
|
201 |
-
|
202 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
continue;
|
204 |
-
}
|
205 |
-
|
|
|
|
|
206 |
$commentdata = array(
|
207 |
-
'comment_post_ID' => $
|
208 |
'comment_date' => $comment->created_at,
|
209 |
'comment_date_gmt' => $comment->created_at,
|
210 |
-
'comment_content' => $comment->message,
|
211 |
'comment_approved' => 1,
|
212 |
-
'comment_agent' => 'Disqus/1.
|
213 |
'comment_type' => '',
|
214 |
);
|
215 |
if ($comment->is_anonymous) {
|
@@ -224,20 +247,17 @@ function dsq_sync_comments($post, $comments) {
|
|
224 |
$commentdata['comment_author_url'] = $comment->author->url;
|
225 |
$commentdata['comment_author_IP'] = $comment->author->ip_address;
|
226 |
}
|
227 |
-
|
228 |
-
update_post_meta($post->ID, 'dsq_thread_id', $comment->thread->id);
|
229 |
-
$_has_updated_thread = true;
|
230 |
-
}
|
231 |
-
$comment_id = wp_insert_comment($commentdata);
|
232 |
if ($comment->parent_post) {
|
233 |
$parent_id = $wpdb->get_var($wpdb->prepare( "SELECT comment_id FROM $wpdb->commentmeta WHERE meta_key = 'dsq_post_id' AND meta_value = '%s' LIMIT 1", $comment->parent_post));
|
234 |
if ($parent_id) {
|
235 |
$commentdata['comment_parent'] = $parent_id;
|
236 |
}
|
237 |
}
|
238 |
-
|
239 |
-
update_comment_meta($comment_id, 'dsq_post_id', $comment->id);
|
240 |
}
|
|
|
|
|
241 |
}
|
242 |
|
243 |
if( isset($_POST['dsq_api_key']) && $_POST['dsq_api_key'] == get_option('disqus_api_key') ) {
|
@@ -284,10 +304,15 @@ function dsq_request_handler() {
|
|
284 |
}
|
285 |
// schedule the event for 30 seconds from now in case they
|
286 |
// happen to make a quick post
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
|
|
|
|
|
|
|
|
|
|
291 |
break;
|
292 |
case 'export_comments':
|
293 |
if (current_user_can('manage_options') && DISQUS_CAN_EXPORT) {
|
@@ -357,59 +382,17 @@ function dsq_request_handler() {
|
|
357 |
break;
|
358 |
case 'import_comments':
|
359 |
if (current_user_can('manage_options')) {
|
360 |
-
$
|
361 |
-
|
362 |
-
global $wpdb, $dsq_api;
|
363 |
-
$posts = $wpdb->get_results($wpdb->prepare("
|
364 |
-
SELECT ID
|
365 |
-
FROM $wpdb->posts
|
366 |
-
WHERE post_type != 'revision'
|
367 |
-
AND post_status = 'publish'
|
368 |
-
AND comment_count > 0
|
369 |
-
AND ID > %d
|
370 |
-
ORDER BY ID ASC
|
371 |
-
LIMIT $limit
|
372 |
-
", $post_id));
|
373 |
-
$first_post_id = $posts[0]->ID;
|
374 |
-
$last_post_id = $posts[(count($posts) - 1)]->ID;
|
375 |
-
$max_post_id = $wpdb->get_var($wpdb->prepare("
|
376 |
-
SELECT MAX(ID)
|
377 |
-
FROM $wpdb->posts
|
378 |
-
WHERE post_type != 'revision'
|
379 |
-
AND post_status = 'publish'
|
380 |
-
AND comment_count > 0
|
381 |
-
AND ID > %d
|
382 |
-
", $post_id));
|
383 |
-
$eof = (int)($last_post_id == $max_post_id);
|
384 |
-
if ($eof) {
|
385 |
$status = 'complete';
|
386 |
$msg = dsq_i('Your comments have been downloaded from Disqus and saved in your local database.');
|
387 |
}
|
388 |
else {
|
389 |
$status = 'partial';
|
390 |
-
|
391 |
-
$msg = dsq_i('Imported comments on post #%s…', $first_post_id);
|
392 |
-
}
|
393 |
-
else {
|
394 |
-
$msg = dsq_i('Imported comments on posts #%s-%s…', $first_post_id, $last_post_id);
|
395 |
-
}
|
396 |
}
|
397 |
-
$result = '
|
398 |
-
$response =
|
399 |
-
if (count($posts)) {
|
400 |
-
foreach ($posts as $post) {
|
401 |
-
$result = dsq_sync_post($post->ID);
|
402 |
-
# Threads with no comments may not exist
|
403 |
-
if (!($result > 0) && $result != 'Invalid thread identifier specified.') {
|
404 |
-
$msg = '<p class="status dsq-export-fail">' . $result . ' Please <a href="#" id="dsq_import_retry">try again</a>.</p>';
|
405 |
-
$result = 'fail';
|
406 |
-
break;
|
407 |
-
}
|
408 |
-
$result = 'success';
|
409 |
-
}
|
410 |
-
}
|
411 |
-
// send AJAX response
|
412 |
-
$response = compact('result', 'status', 'last_post_id', 'msg');
|
413 |
header('Content-type: text/javascript');
|
414 |
echo cf_json_encode($response);
|
415 |
die();
|
@@ -428,26 +411,40 @@ function dsq_sync_post($post_id) {
|
|
428 |
|
429 |
// Call update_thread to ensure our permalink is up to date
|
430 |
dsq_update_permalink($post);
|
|
|
431 |
|
432 |
-
|
433 |
-
|
|
|
|
|
|
|
|
|
434 |
if (!$last_comment_id) {
|
435 |
$last_comment_id = 0;
|
436 |
} else {
|
437 |
$last_comment_id++;
|
438 |
}
|
439 |
|
|
|
|
|
440 |
// Pull comments from API
|
441 |
-
$dsq_response = $dsq_api->
|
442 |
if( $dsq_response < 0 || $dsq_response === false ) {
|
443 |
return $dsq_api->get_last_error();
|
444 |
}
|
|
|
445 |
// Sync comments with database.
|
446 |
-
dsq_sync_comments($
|
447 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
448 |
}
|
449 |
|
450 |
-
add_action('
|
451 |
|
452 |
function dsq_update_permalink($post) {
|
453 |
global $dsq_api;
|
@@ -458,6 +455,8 @@ function dsq_update_permalink($post) {
|
|
458 |
'url' => dsq_link_for_post($post)
|
459 |
));
|
460 |
|
|
|
|
|
461 |
return $response;
|
462 |
}
|
463 |
|
@@ -591,6 +590,16 @@ function esc_attr( $text ) {
|
|
591 |
*/
|
592 |
|
593 |
function dsq_get_style() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
594 |
echo "<link rel=\"stylesheet\" href=\"" . DISQUS_URL ."stylesheets/" . strtolower(get_option('disqus_forum_url')) . "/disqus.css?v=2.0\" type=\"text/css\" media=\"screen\" />";
|
595 |
}
|
596 |
|
@@ -607,11 +616,7 @@ function dsq_comments_template($value) {
|
|
607 |
return;
|
608 |
}
|
609 |
|
610 |
-
if ( !dsq_can_replace() ) {
|
611 |
-
return $value;
|
612 |
-
}
|
613 |
-
|
614 |
-
if ( !dsq_is_installed() ) {
|
615 |
return $value;
|
616 |
}
|
617 |
|
@@ -830,12 +835,10 @@ dsq_fire_import = function() {
|
|
830 |
dsq_import_comments = function() {
|
831 |
var $ = jQuery;
|
832 |
var status = $('#dsq_import .status');
|
833 |
-
var info = status.attr('rel');
|
834 |
$.get(
|
835 |
'<?php echo admin_url('index.php'); ?>',
|
836 |
{
|
837 |
-
cf_action: 'import_comments'
|
838 |
-
post_id: info,
|
839 |
},
|
840 |
function(response) {
|
841 |
switch (response.result) {
|
4 |
Plugin URI: http://disqus.com/
|
5 |
Description: The Disqus comment system replaces your WordPress comment system with your comments hosted and powered by Disqus. Head over to the Comments admin page to set up your DISQUS Comment System.
|
6 |
Author: Disqus <team@disqus.com>
|
7 |
+
Version: 2.48
|
8 |
Author URI: http://disqus.com/
|
9 |
*/
|
10 |
|
17 |
define('DISQUS_MEDIA_URL', 'http://disqus.com/media/');
|
18 |
define('DISQUS_RSS_PATH', '/latest.rss');
|
19 |
define('DISQUS_CAN_EXPORT', is_file(dirname(__FILE__) . '/export.php'));
|
20 |
+
if (!defined('DISQUS_DEBUG')) {
|
21 |
+
define('DISQUS_DEBUG', false);
|
22 |
+
}
|
23 |
|
24 |
/**
|
25 |
* Returns an array of all option identifiers used by DISQUS.
|
32 |
'disqus_partner_key',
|
33 |
'disqus_replace',
|
34 |
'disqus_cc_fix',
|
35 |
+
# disables automatic sync via cron
|
36 |
+
'disqus_manual_sync',
|
37 |
+
# disables server side rendering
|
38 |
+
'disqus_disable_ssr',
|
39 |
+
# the last sync comment id (from get_forum_posts)
|
40 |
+
'disqus_last_comment_id',
|
41 |
);
|
42 |
}
|
43 |
|
72 |
* @global string $dsq_version
|
73 |
* @since 1.0
|
74 |
*/
|
75 |
+
$dsq_version = '2.48';
|
76 |
$mt_dsq_version = '2.01';
|
77 |
/**
|
78 |
* Response from Disqus get_thread API call for comments template.
|
186 |
. '</strong></p></div>';
|
187 |
}
|
188 |
|
189 |
+
function dsq_sync_comments($comments) {
|
190 |
+
global $wpdb, $dsq_version;
|
|
|
|
|
191 |
|
192 |
+
// user MUST be logged out during this process
|
193 |
+
wp_set_current_user(0);
|
194 |
+
|
195 |
+
// we need the thread_ids so we can map them to posts
|
196 |
+
$thread_map = array();
|
197 |
+
foreach ( $comments as $comment ) {
|
198 |
+
$thread_map[$comment->thread->id] = null;
|
199 |
}
|
200 |
+
$thread_ids = "'" . implode("', '", array_keys($thread_map)) . "'";
|
201 |
+
|
202 |
+
$results = $wpdb->get_results( "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = 'dsq_thread_id' AND meta_value IN ({$thread_ids}) LIMIT 1");
|
203 |
+
foreach ( $results as $result ) {
|
204 |
+
$thread_map[$result->meta_value] = $result->post_id;
|
205 |
}
|
206 |
|
207 |
foreach ( $comments as $comment ) {
|
208 |
$ts = strtotime($comment->created_at);
|
209 |
+
if (!$thread_map[$comment->thread->id]) {
|
210 |
+
// legacy threads dont already have their meta stored
|
211 |
+
foreach ( $comment->thread->identifier as $identifier ) {
|
212 |
+
// we know identifier starts with post_ID
|
213 |
+
if ($post_ID = (int)substr($identifier, 0, strpos($identifier, ' '))) {
|
214 |
+
$thread_map[$comment->thread->id] = $post_ID;
|
215 |
+
update_post_meta($post_ID, 'dsq_thread_id', $comment->thread->id);
|
216 |
+
}
|
217 |
+
}
|
218 |
+
if (!$thread_map[$comment->thread->id]) {
|
219 |
+
// shouldn't ever happen, but we can't be certain
|
220 |
+
continue;
|
221 |
+
}
|
222 |
+
} else if ($wpdb->get_results($wpdb->prepare( "SELECT comment_id FROM $wpdb->commentmeta WHERE meta_key = 'dsq_post_id' AND meta_value = '%s' LIMIT 1", $comment->id))) {
|
223 |
+
// already exists
|
224 |
continue;
|
225 |
+
}
|
226 |
+
$comment_id = $wpdb->get_var($wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_agent LIKE 'Disqus/%%:{$comment->id}' LIMIT 1"));
|
227 |
+
if (!$comment_id) {
|
228 |
+
// Comment doesnt exist yet, lets insert it
|
229 |
$commentdata = array(
|
230 |
+
'comment_post_ID' => $thread_map[$comment->thread->id],
|
231 |
'comment_date' => $comment->created_at,
|
232 |
'comment_date_gmt' => $comment->created_at,
|
233 |
+
'comment_content' => apply_filters('pre_comment_content', $comment->message),
|
234 |
'comment_approved' => 1,
|
235 |
+
'comment_agent' => 'Disqus/1.1('.$dsq_version.'):' . intval($comment->id),
|
236 |
'comment_type' => '',
|
237 |
);
|
238 |
if ($comment->is_anonymous) {
|
247 |
$commentdata['comment_author_url'] = $comment->author->url;
|
248 |
$commentdata['comment_author_IP'] = $comment->author->ip_address;
|
249 |
}
|
250 |
+
$commentdata = wp_filter_comment($commentdata);
|
|
|
|
|
|
|
|
|
251 |
if ($comment->parent_post) {
|
252 |
$parent_id = $wpdb->get_var($wpdb->prepare( "SELECT comment_id FROM $wpdb->commentmeta WHERE meta_key = 'dsq_post_id' AND meta_value = '%s' LIMIT 1", $comment->parent_post));
|
253 |
if ($parent_id) {
|
254 |
$commentdata['comment_parent'] = $parent_id;
|
255 |
}
|
256 |
}
|
257 |
+
$comment_id = wp_insert_comment($commentdata);
|
|
|
258 |
}
|
259 |
+
update_comment_meta($comment_id, 'dsq_parent_post_id', $comment->parent_post);
|
260 |
+
update_comment_meta($comment_id, 'dsq_post_id', $comment->id);
|
261 |
}
|
262 |
|
263 |
if( isset($_POST['dsq_api_key']) && $_POST['dsq_api_key'] == get_option('disqus_api_key') ) {
|
304 |
}
|
305 |
// schedule the event for 30 seconds from now in case they
|
306 |
// happen to make a quick post
|
307 |
+
if (DISQUS_DEBUG) {
|
308 |
+
dsq_sync_post($post_id);
|
309 |
+
$comments = dsq_sync_forum();
|
310 |
+
die('// synced '.$comments.' comments');
|
311 |
+
} else {
|
312 |
+
wp_schedule_single_event(time(), 'dsq_sync_post', array($post_id));
|
313 |
+
wp_schedule_single_event(time(), 'dsq_sync_forum');
|
314 |
+
die('// sync scheduled');
|
315 |
+
}
|
316 |
break;
|
317 |
case 'export_comments':
|
318 |
if (current_user_can('manage_options') && DISQUS_CAN_EXPORT) {
|
382 |
break;
|
383 |
case 'import_comments':
|
384 |
if (current_user_can('manage_options')) {
|
385 |
+
$comments = dsq_sync_forum();
|
386 |
+
if (!$comments) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
387 |
$status = 'complete';
|
388 |
$msg = dsq_i('Your comments have been downloaded from Disqus and saved in your local database.');
|
389 |
}
|
390 |
else {
|
391 |
$status = 'partial';
|
392 |
+
$msg = dsq_i('Import in progress …', $first_post_id, $last_post_id);
|
|
|
|
|
|
|
|
|
|
|
393 |
}
|
394 |
+
$result = 'success';
|
395 |
+
$response = compact('result', 'status', 'comments', 'msg');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
396 |
header('Content-type: text/javascript');
|
397 |
echo cf_json_encode($response);
|
398 |
die();
|
411 |
|
412 |
// Call update_thread to ensure our permalink is up to date
|
413 |
dsq_update_permalink($post);
|
414 |
+
}
|
415 |
|
416 |
+
add_action('dsq_sync_post', 'dsq_sync_post');
|
417 |
+
|
418 |
+
function dsq_sync_forum() {
|
419 |
+
global $dsq_api, $wpdb;
|
420 |
+
|
421 |
+
$last_comment_id = get_option('disqus_last_comment_id');
|
422 |
if (!$last_comment_id) {
|
423 |
$last_comment_id = 0;
|
424 |
} else {
|
425 |
$last_comment_id++;
|
426 |
}
|
427 |
|
428 |
+
//$last_comment_id = 0;
|
429 |
+
|
430 |
// Pull comments from API
|
431 |
+
$dsq_response = $dsq_api->get_forum_posts($last_comment_id);
|
432 |
if( $dsq_response < 0 || $dsq_response === false ) {
|
433 |
return $dsq_api->get_last_error();
|
434 |
}
|
435 |
+
|
436 |
// Sync comments with database.
|
437 |
+
dsq_sync_comments($dsq_response);
|
438 |
+
if ($dsq_response) {
|
439 |
+
foreach ($dsq_response as $comment) {
|
440 |
+
if ($comment->id > $last_comment_id) $last_comment_id = $comment->id;
|
441 |
+
}
|
442 |
+
update_option('disqus_last_comment_id', $last_comment_id);
|
443 |
+
}
|
444 |
+
return count($dsq_response);
|
445 |
}
|
446 |
|
447 |
+
add_action('dsq_sync_forum', 'dsq_sync_forum');
|
448 |
|
449 |
function dsq_update_permalink($post) {
|
450 |
global $dsq_api;
|
455 |
'url' => dsq_link_for_post($post)
|
456 |
));
|
457 |
|
458 |
+
update_post_meta($post->ID, 'dsq_thread_id', $response->id);
|
459 |
+
|
460 |
return $response;
|
461 |
}
|
462 |
|
590 |
*/
|
591 |
|
592 |
function dsq_get_style() {
|
593 |
+
global $post;
|
594 |
+
|
595 |
+
if ( !( is_singular() && ( have_comments() || 'open' == $post->comment_status ) ) ) {
|
596 |
+
return;
|
597 |
+
}
|
598 |
+
|
599 |
+
if ( !dsq_is_installed() || !dsq_can_replace() ) {
|
600 |
+
return;
|
601 |
+
}
|
602 |
+
|
603 |
echo "<link rel=\"stylesheet\" href=\"" . DISQUS_URL ."stylesheets/" . strtolower(get_option('disqus_forum_url')) . "/disqus.css?v=2.0\" type=\"text/css\" media=\"screen\" />";
|
604 |
}
|
605 |
|
616 |
return;
|
617 |
}
|
618 |
|
619 |
+
if ( !dsq_is_installed() || !dsq_can_replace() ) {
|
|
|
|
|
|
|
|
|
620 |
return $value;
|
621 |
}
|
622 |
|
835 |
dsq_import_comments = function() {
|
836 |
var $ = jQuery;
|
837 |
var status = $('#dsq_import .status');
|
|
|
838 |
$.get(
|
839 |
'<?php echo admin_url('index.php'); ?>',
|
840 |
{
|
841 |
+
cf_action: 'import_comments'
|
|
|
842 |
},
|
843 |
function(response) {
|
844 |
switch (response.result) {
|
lib/wpapi.php
CHANGED
@@ -62,25 +62,14 @@ class DisqusWordPressAPI {
|
|
62 |
return $this->api->get_forum_api_key($id);
|
63 |
}
|
64 |
|
65 |
-
function
|
66 |
-
$identifier = dsq_identifier_for_post($post);
|
67 |
-
|
68 |
-
$title = dsq_title_for_post($post);
|
69 |
-
|
70 |
-
$response = $this->api->thread_by_identifier(array(
|
71 |
-
'identifier' => $identifier,
|
72 |
-
'title' => $title,
|
73 |
-
));
|
74 |
-
return $response->thread;
|
75 |
-
}
|
76 |
-
|
77 |
-
function get_thread($post, $start_id=0) {
|
78 |
$identifier = dsq_identifier_for_post($post);
|
79 |
|
80 |
-
$response = $this->api->
|
81 |
-
'thread_identifier' => $identifier,
|
82 |
'filter' => 'approved',
|
83 |
'start_id' => $start_id,
|
|
|
|
|
84 |
));
|
85 |
return $response;
|
86 |
}
|
62 |
return $this->api->get_forum_api_key($id);
|
63 |
}
|
64 |
|
65 |
+
function get_forum_posts($start_id=0) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
$identifier = dsq_identifier_for_post($post);
|
67 |
|
68 |
+
$response = $this->api->get_forum_posts(null, array(
|
|
|
69 |
'filter' => 'approved',
|
70 |
'start_id' => $start_id,
|
71 |
+
'limit' => 100,
|
72 |
+
'order' => 'asc'
|
73 |
));
|
74 |
return $response;
|
75 |
}
|
manage.php
CHANGED
@@ -31,6 +31,7 @@ if ( isset($_POST['uninstall']) ) {
|
|
31 |
foreach (dsq_options() as $opt) {
|
32 |
delete_option($opt);
|
33 |
}
|
|
|
34 |
}
|
35 |
|
36 |
// Clean-up POST parameters.
|
@@ -73,6 +74,7 @@ if ( isset($_POST['disqus_forum_url']) && isset($_POST['disqus_replace']) ) {
|
|
73 |
update_option('disqus_replace', $_POST['disqus_replace']);
|
74 |
update_option('disqus_cc_fix', isset($_POST['disqus_cc_fix']));
|
75 |
update_option('disqus_manual_sync', isset($_POST['disqus_manual_sync']));
|
|
|
76 |
dsq_manage_dialog('Your settings have been changed.');
|
77 |
}
|
78 |
|
@@ -86,15 +88,20 @@ $step = (dsq_is_installed()) ? 0 : ($step ? $step : 1);
|
|
86 |
|
87 |
if ( 2 == $step && isset($_POST['dsq_username']) && isset($_POST['dsq_password']) ) {
|
88 |
$dsq_user_api_key = $dsq_api->get_user_api_key($_POST['dsq_username'], $_POST['dsq_password']);
|
89 |
-
if ( !$dsq_user_api_key ) {
|
90 |
$step = 1;
|
91 |
dsq_manage_dialog($dsq_api->get_last_error(), true);
|
92 |
}
|
93 |
|
94 |
-
$
|
95 |
-
|
96 |
-
$
|
97 |
-
|
|
|
|
|
|
|
|
|
|
|
98 |
}
|
99 |
}
|
100 |
|
@@ -193,6 +200,7 @@ case 0:
|
|
193 |
$dsq_partner_key = get_option('disqus_partner_key');
|
194 |
$dsq_cc_fix = get_option('disqus_cc_fix');
|
195 |
$dsq_manual_sync = get_option('disqus_manual_sync');
|
|
|
196 |
?>
|
197 |
<!-- Advanced options -->
|
198 |
<div id="dsq-advanced" class="dsq-content dsq-advanced" style="display:none;">
|
@@ -267,6 +275,14 @@ case 0:
|
|
267 |
</td>
|
268 |
</tr>
|
269 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
270 |
</table>
|
271 |
|
272 |
<p class="submit" style="text-align: left">
|
31 |
foreach (dsq_options() as $opt) {
|
32 |
delete_option($opt);
|
33 |
}
|
34 |
+
unset($_POST);
|
35 |
}
|
36 |
|
37 |
// Clean-up POST parameters.
|
74 |
update_option('disqus_replace', $_POST['disqus_replace']);
|
75 |
update_option('disqus_cc_fix', isset($_POST['disqus_cc_fix']));
|
76 |
update_option('disqus_manual_sync', isset($_POST['disqus_manual_sync']));
|
77 |
+
update_option('disqus_disable_ssr', isset($_POST['disqus_disable_ssr']));
|
78 |
dsq_manage_dialog('Your settings have been changed.');
|
79 |
}
|
80 |
|
88 |
|
89 |
if ( 2 == $step && isset($_POST['dsq_username']) && isset($_POST['dsq_password']) ) {
|
90 |
$dsq_user_api_key = $dsq_api->get_user_api_key($_POST['dsq_username'], $_POST['dsq_password']);
|
91 |
+
if ( $dsq_user_api_key < 0 || !$dsq_user_api_key ) {
|
92 |
$step = 1;
|
93 |
dsq_manage_dialog($dsq_api->get_last_error(), true);
|
94 |
}
|
95 |
|
96 |
+
if ( $step == 2 ) {
|
97 |
+
$dsq_sites = $dsq_api->get_forum_list($dsq_user_api_key);
|
98 |
+
if ( $dsq_sites < 0 ) {
|
99 |
+
$step = 1;
|
100 |
+
dsq_manage_dialog($dsq_api->get_last_error(), true);
|
101 |
+
} else if ( !$dsq_sites ) {
|
102 |
+
$step = 1;
|
103 |
+
dsq_manage_dialog(dsq_i('There aren\'t any sites associated with this account. Maybe you want to <a href="%s">create a site</a>?', 'http://disqus.com/comments/register/'), true);
|
104 |
+
}
|
105 |
}
|
106 |
}
|
107 |
|
200 |
$dsq_partner_key = get_option('disqus_partner_key');
|
201 |
$dsq_cc_fix = get_option('disqus_cc_fix');
|
202 |
$dsq_manual_sync = get_option('disqus_manual_sync');
|
203 |
+
$dsq_disable_ssr = get_option('disqus_disable_ssr');
|
204 |
?>
|
205 |
<!-- Advanced options -->
|
206 |
<div id="dsq-advanced" class="dsq-content dsq-advanced" style="display:none;">
|
275 |
</td>
|
276 |
</tr>
|
277 |
|
278 |
+
<tr>
|
279 |
+
<th scope="row" valign="top"><?php echo dsq_i('Server Side Rendering'); ?></th>
|
280 |
+
<td>
|
281 |
+
<input type="checkbox" id="disqus_disable_ssr" name="disqus_disable_ssr" <?php if($dsq_disable_ssr){echo 'checked="checked"';}?> >
|
282 |
+
<label for="disqus_disable_ssr"><?php echo dsq_i('Disable server side rendering of comments'); ?></label>
|
283 |
+
<br /><?php echo dsq_i('NOTE: This will hide comments from nearly all search engines'); ?>
|
284 |
+
</td>
|
285 |
+
</tr>
|
286 |
</table>
|
287 |
|
288 |
<p class="submit" style="text-align: left">
|
readme.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
=== Disqus Comment System ===
|
2 |
Contributors: disqus, alexkingorg, crowdfavorite
|
3 |
-
Tags: comments, threaded, email, notification, spam, avatars, community, profile, widget
|
4 |
Requires at least: 2.8
|
5 |
Tested up to: 3.0
|
6 |
-
Stable tag: 2.
|
7 |
|
8 |
The Disqus comment system replaces your WordPress comment system with your comments hosted and powered by Disqus.
|
9 |
|
@@ -62,6 +62,18 @@ you should remove it, and the new plugin should be stored in 'disqus'.
|
|
62 |
|
63 |
== Changes ==
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
2.46
|
66 |
|
67 |
* Better debugging information for export errors.
|
1 |
=== Disqus Comment System ===
|
2 |
Contributors: disqus, alexkingorg, crowdfavorite
|
3 |
+
Tags: comments, threaded, email, notification, spam, avatars, community, profile, widget, disqus
|
4 |
Requires at least: 2.8
|
5 |
Tested up to: 3.0
|
6 |
+
Stable tag: 2.48
|
7 |
|
8 |
The Disqus comment system replaces your WordPress comment system with your comments hosted and powered by Disqus.
|
9 |
|
62 |
|
63 |
== Changes ==
|
64 |
|
65 |
+
2.48
|
66 |
+
|
67 |
+
* Comment synchronization has been optimized to be a single call per-site.
|
68 |
+
* disqus.css will now only load when displaying comments
|
69 |
+
|
70 |
+
2.47
|
71 |
+
|
72 |
+
* Fixed a security hole with comment importing.
|
73 |
+
* Reverted ability to use default template comments design.
|
74 |
+
* Comments will now store which version they were imported under.
|
75 |
+
* Added an option to disable server side rendering.
|
76 |
+
|
77 |
2.46
|
78 |
|
79 |
* Better debugging information for export errors.
|