Disqus Comment System - Version 2.69

Version Description

Download this release

Release Info

Developer Disqus
Plugin Icon Disqus Comment System
Version 2.69
Comparing to
See all releases

Code changes from version 2.67 to 2.69

comments.php CHANGED
@@ -5,32 +5,39 @@ if (DISQUS_DEBUG) {
5
  ?>
6
 
7
  <div id="disqus_thread">
8
- <?php if (!get_option('disqus_disable_ssr') && !empty($comments)): ?>
9
  <?php
10
  // if (is_file(TEMPLATEPATH . '/comments.php')) {
11
  // include(TEMPLATEPATH . '/comments.php');
12
  // }
13
  ?>
14
  <div id="dsq-content">
 
 
 
 
 
 
 
 
15
  <ul id="dsq-comments">
16
- <?php foreach ($comments as $comment) : ?>
17
- <li id="dsq-comment-<?php echo comment_ID(); ?>">
18
- <div id="dsq-comment-header-<?php echo comment_ID(); ?>" class="dsq-comment-header">
19
- <cite id="dsq-cite-<?php echo comment_ID(); ?>">
20
- <?php if(comment_author_url()) : ?>
21
- <a id="dsq-author-user-<?php echo comment_ID(); ?>" href="<?php echo comment_author_url(); ?>" target="_blank" rel="nofollow"><?php echo comment_author(); ?></a>
22
- <?php else : ?>
23
- <span id="dsq-author-user-<?php echo comment_ID(); ?>"><?php echo comment_author(); ?></span>
24
- <?php endif; ?>
25
- </cite>
26
- </div>
27
- <div id="dsq-comment-body-<?php echo comment_ID(); ?>" class="dsq-comment-body">
28
- <div id="dsq-comment-message-<?php echo comment_ID(); ?>" class="dsq-comment-message"><?php echo wp_filter_kses(comment_text()); ?></div>
29
- </div>
30
- </li>
31
- <?php endforeach; ?>
32
  </ul>
 
 
 
 
 
 
 
 
33
  </div>
 
34
  <?php endif; ?>
35
  </div>
36
 
@@ -48,7 +55,7 @@ if (DISQUS_DEBUG) {
48
  var disqus_config = function () {
49
  var config = this; // Access to the config object
50
 
51
- /*
52
  All currently supported events:
53
  * preData — fires just before we request for initial data
54
  * preInit - fires after we get initial data but before we load any dependencies
5
  ?>
6
 
7
  <div id="disqus_thread">
8
+ <?php if (!get_option('disqus_disable_ssr') && have_comments()): ?>
9
  <?php
10
  // if (is_file(TEMPLATEPATH . '/comments.php')) {
11
  // include(TEMPLATEPATH . '/comments.php');
12
  // }
13
  ?>
14
  <div id="dsq-content">
15
+
16
+ <?php if (get_comment_pages_count() > 1 && get_option('page_comments')): // Are there comments to navigate through? ?>
17
+ <div class="navigation">
18
+ <div class="nav-previous"><?php previous_comments_link(dsq_i( '<span class="meta-nav">&larr;</span> Older Comments')); ?></div>
19
+ <div class="nav-next"><?php next_comments_link(dsq_i('Newer Comments <span class="meta-nav">&rarr;</span>')); ?></div>
20
+ </div> <!-- .navigation -->
21
+ <?php endif; // check for comment navigation ?>
22
+
23
  <ul id="dsq-comments">
24
+ <?php
25
+ /* Loop through and list the comments. Tell wp_list_comments()
26
+ * to use dsq_comment() to format the comments.
27
+ */
28
+ wp_list_comments(array('callback' => 'dsq_comment'));
29
+ ?>
 
 
 
 
 
 
 
 
 
 
30
  </ul>
31
+
32
+ <?php if (get_comment_pages_count() > 1 && get_option('page_comments')): // Are there comments to navigate through? ?>
33
+ <div class="navigation">
34
+ <div class="nav-previous"><?php previous_comments_link(dsq_i( '<span class="meta-nav">&larr;</span> Older Comments')); ?></div>
35
+ <div class="nav-next"><?php next_comments_link(dsq_i( 'Newer Comments <span class="meta-nav">&rarr;</span>')); ?></div>
36
+ </div><!-- .navigation -->
37
+ <?php endif; // check for comment navigation ?>
38
+
39
  </div>
40
+
41
  <?php endif; ?>
42
  </div>
43
 
55
  var disqus_config = function () {
56
  var config = this; // Access to the config object
57
 
58
+ /*
59
  All currently supported events:
60
  * preData — fires just before we request for initial data
61
  * preInit - fires after we get initial data but before we load any dependencies
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.67
8
  Author URI: http://disqus.com/
9
  */
10
 
@@ -31,7 +31,8 @@ define('DISQUS_CAN_EXPORT', is_file(dirname(__FILE__) . '/export.php'));
31
  if (!defined('DISQUS_DEBUG')) {
32
  define('DISQUS_DEBUG', false);
33
  }
34
- define('DISQUS_VERSION', '2.67');
 
35
 
36
  /**
37
  * Returns an array of all option identifiers used by DISQUS.
@@ -218,6 +219,9 @@ function dsq_sync_comments($comments) {
218
  if ($post_ID = (int)substr($identifier, 0, strpos($identifier, ' '))) {
219
  $thread_map[$comment->thread->id] = $post_ID;
220
  update_post_meta($post_ID, 'dsq_thread_id', $comment->thread->id);
 
 
 
221
  }
222
  }
223
  unset($identifier);
@@ -389,14 +393,9 @@ function dsq_request_handler() {
389
  }
390
  // schedule the event for 5 minutes from now in case they
391
  // happen to make a quick post
392
- $post_ids = dsq_get_pending_post_ids();
393
- if (!in_array($post_id, $post_ids)) {
394
- $post_ids[] = $post_id;
395
- update_option('_disqus_sync_post_ids', $post_ids);
396
- }
397
 
398
  if (DISQUS_DEBUG) {
399
- dsq_sync_post($post_id);
400
  $response = dsq_sync_forum();
401
  if (!$response) {
402
  die('// error: '.$dsq_api->get_last_error());
@@ -474,15 +473,13 @@ function dsq_request_handler() {
474
  if (!isset($_GET['last_comment_id'])) $last_comment_id = false;
475
  else $last_comment_id = $_GET['last_comment_id'];
476
 
477
- $force = ($_GET['force'] == '1');
478
-
479
  if ($_GET['wipe'] == '1') {
480
  $wpdb->query("DELETE FROM `".$wpdb->prefix."commentmeta` WHERE meta_key IN ('dsq_post_id', 'dsq_parent_post_id')");
481
  $wpdb->query("DELETE FROM `".$wpdb->prefix."comments` WHERE comment_agent LIKE 'Disqus/%%'");
482
  }
483
 
484
  ob_start();
485
- $response = dsq_sync_forum($last_comment_id, $force);
486
  $debug = ob_get_clean();
487
  if (!$response) {
488
  $status = 'error';
@@ -513,14 +510,31 @@ function dsq_request_handler() {
513
 
514
  add_action('init', 'dsq_request_handler');
515
 
 
 
 
 
516
  function dsq_get_pending_post_ids() {
517
- $post_ids = get_option('_disqus_sync_post_ids');
518
- if (empty($post_ids)) {
519
- return array();
 
 
 
520
  }
521
- return (array)$post_ids;
 
 
 
 
 
 
 
 
 
522
  }
523
 
 
524
  function dsq_sync_post($post_id) {
525
  global $dsq_api, $wpdb;
526
 
@@ -533,23 +547,26 @@ function dsq_sync_post($post_id) {
533
  function dsq_sync_forum($last_comment_id=false, $force=false) {
534
  global $dsq_api, $wpdb;
535
 
 
 
536
  if ($force) {
537
  $sync_time = null;
538
  } else {
539
  $sync_time = (int)get_option('_disqus_sync_lock');
540
  }
541
-
542
- // lock expires after 1 day
543
- if ($sync_time && $sync_time > time() - 86400) {
544
  $dsq_api->api->last_error = 'Sync already in progress (lock found)';
545
  return false;
546
  } else {
547
  update_option('_disqus_sync_lock', time());
548
  }
549
-
550
  // sync all pending posts
551
  $post_ids = dsq_get_pending_post_ids();
552
- delete_option('_disqus_sync_post_ids');
 
553
  foreach ($post_ids as $post_id) {
554
  dsq_sync_post($post_id);
555
  }
@@ -594,6 +611,10 @@ add_action('dsq_sync_forum', 'dsq_sync_forum');
594
  function dsq_update_permalink($post) {
595
  global $dsq_api;
596
 
 
 
 
 
597
  $response = $dsq_api->api->update_thread(null, array(
598
  'thread_identifier' => dsq_identifier_for_post($post),
599
  'title' => dsq_title_for_post($post),
@@ -756,6 +777,39 @@ function dsq_comments_template($value) {
756
  return dirname(__FILE__) . '/comments.php';
757
  }
758
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
759
  // Mark entries in index to replace comments link.
760
  // As of WordPress 3.1 this is required to return a numerical value
761
  function dsq_comments_number($count) {
@@ -785,7 +839,7 @@ function dsq_bloginfo_url($url) {
785
  function dsq_plugin_action_links($links, $file) {
786
  $plugin_file = basename(__FILE__);
787
  if (basename($file) == $plugin_file) {
788
- $settings_link = '<a href="edit-comments.php?page=disqus#adv">'.__('Settings', 'disqus-comment-system').'</a>';
789
  array_unshift($links, $settings_link);
790
  }
791
  return $links;
@@ -971,14 +1025,13 @@ dsq_fire_import = function() {
971
  var $ = jQuery;
972
  $('#dsq_import a.button, #dsq_import_retry').unbind().click(function() {
973
  var wipe = $('#dsq_import_wipe').is(':checked');
974
- var force = $('#dsq_import_force').is(':checked');
975
  $('#dsq_import').html('<p class="status"></p>');
976
  $('#dsq_import .status').removeClass('dsq-import-fail').addClass('dsq-importing').html('Processing...');
977
- dsq_import_comments(wipe, force);
978
  return false;
979
  });
980
  }
981
- dsq_import_comments = function(wipe, force) {
982
  var $ = jQuery;
983
  var status = $('#dsq_import .status');
984
  var last_comment_id = status.attr('rel') || '0';
@@ -987,8 +1040,7 @@ dsq_import_comments = function(wipe, force) {
987
  {
988
  cf_action: 'import_comments',
989
  last_comment_id: last_comment_id,
990
- wipe: (wipe ? 1 : 0),
991
- force: (force ? 1 : 0)
992
  },
993
  function(response) {
994
  switch (response.result) {
@@ -996,7 +1048,7 @@ dsq_import_comments = function(wipe, force) {
996
  status.html(response.msg).attr('rel', response.last_comment_id);
997
  switch (response.status) {
998
  case 'partial':
999
- dsq_import_comments();
1000
  break;
1001
  case 'complete':
1002
  status.removeClass('dsq-importing').addClass('dsq-imported');
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.69
8
  Author URI: http://disqus.com/
9
  */
10
 
31
  if (!defined('DISQUS_DEBUG')) {
32
  define('DISQUS_DEBUG', false);
33
  }
34
+ define('DISQUS_VERSION', '2.69');
35
+ define('DISQUS_SYNC_TIMEOUT', 30);
36
 
37
  /**
38
  * Returns an array of all option identifiers used by DISQUS.
219
  if ($post_ID = (int)substr($identifier, 0, strpos($identifier, ' '))) {
220
  $thread_map[$comment->thread->id] = $post_ID;
221
  update_post_meta($post_ID, 'dsq_thread_id', $comment->thread->id);
222
+ if (DISQUS_DEBUG) {
223
+ echo "updated post {$post_ID}: dsq_thread_id set to {$comment->thread->id}\n";
224
+ }
225
  }
226
  }
227
  unset($identifier);
393
  }
394
  // schedule the event for 5 minutes from now in case they
395
  // happen to make a quick post
396
+ dsq_add_pending_post_id($post_id);
 
 
 
 
397
 
398
  if (DISQUS_DEBUG) {
 
399
  $response = dsq_sync_forum();
400
  if (!$response) {
401
  die('// error: '.$dsq_api->get_last_error());
473
  if (!isset($_GET['last_comment_id'])) $last_comment_id = false;
474
  else $last_comment_id = $_GET['last_comment_id'];
475
 
 
 
476
  if ($_GET['wipe'] == '1') {
477
  $wpdb->query("DELETE FROM `".$wpdb->prefix."commentmeta` WHERE meta_key IN ('dsq_post_id', 'dsq_parent_post_id')");
478
  $wpdb->query("DELETE FROM `".$wpdb->prefix."comments` WHERE comment_agent LIKE 'Disqus/%%'");
479
  }
480
 
481
  ob_start();
482
+ $response = dsq_sync_forum($last_comment_id, true);
483
  $debug = ob_get_clean();
484
  if (!$response) {
485
  $status = 'error';
510
 
511
  add_action('init', 'dsq_request_handler');
512
 
513
+ function dsq_add_pending_post_id($post_id) {
514
+ update_post_meta($post_id, 'dsq_needs_sync', '1', $unique=true);
515
+ }
516
+
517
  function dsq_get_pending_post_ids() {
518
+ global $wpdb;
519
+
520
+ $results = $wpdb->get_results( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = 'dsq_needs_sync'");
521
+ $post_ids = array();
522
+ foreach ($results as $result) {
523
+ $post_ids[] = $result->post_id;
524
  }
525
+ return $post_ids;
526
+ }
527
+
528
+ function dsq_clear_pending_post_ids($post_ids) {
529
+ global $wpdb;
530
+
531
+ $post_ids_query = "'" . implode("', '", $post_ids) . "'";
532
+ $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE meta_key = 'dsq_needs_sync' AND post_id IN ({$post_ids_query})");
533
+
534
+ update_meta_cache('dsq_needs_sync', $post_ids);
535
  }
536
 
537
+
538
  function dsq_sync_post($post_id) {
539
  global $dsq_api, $wpdb;
540
 
547
  function dsq_sync_forum($last_comment_id=false, $force=false) {
548
  global $dsq_api, $wpdb;
549
 
550
+ set_time_limit(DISQUS_SYNC_TIMEOUT);
551
+
552
  if ($force) {
553
  $sync_time = null;
554
  } else {
555
  $sync_time = (int)get_option('_disqus_sync_lock');
556
  }
557
+
558
+ // lock expires after 1 hour
559
+ if ($sync_time && $sync_time > time() - 60*60) {
560
  $dsq_api->api->last_error = 'Sync already in progress (lock found)';
561
  return false;
562
  } else {
563
  update_option('_disqus_sync_lock', time());
564
  }
565
+
566
  // sync all pending posts
567
  $post_ids = dsq_get_pending_post_ids();
568
+ dsq_clear_pending_post_ids($post_ids);
569
+
570
  foreach ($post_ids as $post_id) {
571
  dsq_sync_post($post_id);
572
  }
611
  function dsq_update_permalink($post) {
612
  global $dsq_api;
613
 
614
+ if (DISQUS_DEBUG) {
615
+ echo "updating post on disqus: {$post->ID}\n";
616
+ }
617
+
618
  $response = $dsq_api->api->update_thread(null, array(
619
  'thread_identifier' => dsq_identifier_for_post($post),
620
  'title' => dsq_title_for_post($post),
777
  return dirname(__FILE__) . '/comments.php';
778
  }
779
 
780
+ function dsq_comment( $comment, $args, $depth ) {
781
+ $GLOBALS['comment'] = $comment;
782
+ switch ($comment->comment_type):
783
+ case '' :
784
+ ?>
785
+ <li <?php comment_class(); ?> id="dsq-comment-<?php echo comment_ID(); ?>">
786
+ <div id="dsq-comment-header-<?php echo comment_ID(); ?>" class="dsq-comment-header">
787
+ <cite id="dsq-cite-<?php echo comment_ID(); ?>">
788
+ <?php if(comment_author_url()) : ?>
789
+ <a id="dsq-author-user-<?php echo comment_ID(); ?>" href="<?php echo comment_author_url(); ?>" target="_blank" rel="nofollow"><?php echo comment_author(); ?></a>
790
+ <?php else : ?>
791
+ <span id="dsq-author-user-<?php echo comment_ID(); ?>"><?php echo comment_author(); ?></span>
792
+ <?php endif; ?>
793
+ </cite>
794
+ </div>
795
+ <div id="dsq-comment-body-<?php echo comment_ID(); ?>" class="dsq-comment-body">
796
+ <div id="dsq-comment-message-<?php echo comment_ID(); ?>" class="dsq-comment-message"><?php echo wp_filter_kses(comment_text()); ?></div>
797
+ </div>
798
+ </li>
799
+
800
+ <?php
801
+ break;
802
+ case 'pingback' :
803
+ case 'trackback' :
804
+ ?>
805
+ <li class="post pingback">
806
+ <p><?php echo dsq_i('Pingback:'); ?> <?php comment_author_link(); ?><?php edit_comment_link(dsq_i('(Edit)'), ' '); ?></p>
807
+ </li>
808
+ <?php
809
+ break;
810
+ endswitch;
811
+ }
812
+
813
  // Mark entries in index to replace comments link.
814
  // As of WordPress 3.1 this is required to return a numerical value
815
  function dsq_comments_number($count) {
839
  function dsq_plugin_action_links($links, $file) {
840
  $plugin_file = basename(__FILE__);
841
  if (basename($file) == $plugin_file) {
842
+ $settings_link = '<a href="edit-comments.php?page=disqus#adv">'.dsq_i('Settings').'</a>';
843
  array_unshift($links, $settings_link);
844
  }
845
  return $links;
1025
  var $ = jQuery;
1026
  $('#dsq_import a.button, #dsq_import_retry').unbind().click(function() {
1027
  var wipe = $('#dsq_import_wipe').is(':checked');
 
1028
  $('#dsq_import').html('<p class="status"></p>');
1029
  $('#dsq_import .status').removeClass('dsq-import-fail').addClass('dsq-importing').html('Processing...');
1030
+ dsq_import_comments(wipe);
1031
  return false;
1032
  });
1033
  }
1034
+ dsq_import_comments = function(wipe) {
1035
  var $ = jQuery;
1036
  var status = $('#dsq_import .status');
1037
  var last_comment_id = status.attr('rel') || '0';
1040
  {
1041
  cf_action: 'import_comments',
1042
  last_comment_id: last_comment_id,
1043
+ wipe: (wipe ? 1 : 0)
 
1044
  },
1045
  function(response) {
1046
  switch (response.result) {
1048
  status.html(response.msg).attr('rel', response.last_comment_id);
1049
  switch (response.status) {
1050
  case 'partial':
1051
+ dsq_import_comments(false);
1052
  break;
1053
  case 'complete':
1054
  status.removeClass('dsq-importing').addClass('dsq-imported');
lib/wp-cli.php CHANGED
@@ -4,9 +4,6 @@
4
  */
5
  error_reporting(E_ALL | E_STRICT);
6
 
7
- var_dump($_SERVER);
8
-
9
-
10
  if (php_sapi_name() != 'cli' && !empty($_SERVER['REMOTE_ADDR'])) {
11
  // Don't execute for web requests
12
  die("This script must be run from CLI.");
@@ -25,7 +22,7 @@ function print_line() {
25
  define('DOING_AJAX', true);
26
  define('WP_USE_THEMES', false);
27
  if (isset($_ENV['WORDPRESS_PATH'])) {
28
- define('WORDPRESS_PATH', $_ENV['WORDPRESS_PATH']);
29
  } else {
30
  if (substr($_SERVER['SCRIPT_FILENAME'], 0, 1) != '/') {
31
  $script_path = $_SERVER['PWD'] . $_SERVER['SCRIPT_FILENAME'];
@@ -44,13 +41,13 @@ if (isset($_ENV['WORDPRESS_PATH'])) {
44
 
45
  foreach ($paths as $path) {
46
  if (is_file($path.'/wp-config.php')) {
47
- define('WORDPRESS_PATH', $path);
48
  break;
49
  }
50
  }
51
  }
52
 
53
- if (!defined('WORDPRESS_PATH')) {
54
  print_line("Unable to determine wordpress path. Please set it using WORDPRESS_PATH.");
55
  die();
56
  }
@@ -63,7 +60,7 @@ $_SERVER = array(
63
  "REQUEST_URI" => "/",
64
  "REQUEST_METHOD" => "GET"
65
  );
66
- require_once(WORDPRESS_PATH . '/wp-config.php');
67
 
68
  // swap out the object cache due to memory constraints
69
 
@@ -73,8 +70,19 @@ class DummyWP_Object_Cache extends WP_Object_Cache {
73
  function set($id, $data, $group = 'default', $expire = '') {
74
  return;
75
  }
 
 
 
 
 
 
76
  }
77
 
78
- $wp_object_cache = new DummyWP_Object_Cache();
 
 
 
 
 
79
 
80
  ?>
4
  */
5
  error_reporting(E_ALL | E_STRICT);
6
 
 
 
 
7
  if (php_sapi_name() != 'cli' && !empty($_SERVER['REMOTE_ADDR'])) {
8
  // Don't execute for web requests
9
  die("This script must be run from CLI.");
22
  define('DOING_AJAX', true);
23
  define('WP_USE_THEMES', false);
24
  if (isset($_ENV['WORDPRESS_PATH'])) {
25
+ define('ABSPATH', $_ENV['WORDPRESS_PATH']);
26
  } else {
27
  if (substr($_SERVER['SCRIPT_FILENAME'], 0, 1) != '/') {
28
  $script_path = $_SERVER['PWD'] . $_SERVER['SCRIPT_FILENAME'];
41
 
42
  foreach ($paths as $path) {
43
  if (is_file($path.'/wp-config.php')) {
44
+ define('ABSPATH', $path . '/');
45
  break;
46
  }
47
  }
48
  }
49
 
50
+ if (!defined('ABSPATH')) {
51
  print_line("Unable to determine wordpress path. Please set it using WORDPRESS_PATH.");
52
  die();
53
  }
60
  "REQUEST_URI" => "/",
61
  "REQUEST_METHOD" => "GET"
62
  );
63
+ require_once(ABSPATH . 'wp-config.php');
64
 
65
  // swap out the object cache due to memory constraints
66
 
70
  function set($id, $data, $group = 'default', $expire = '') {
71
  return;
72
  }
73
+ function delete($id, $group = 'default', $force = false) {
74
+ return;
75
+ }
76
+ function add($id, $data, $group = 'default', $expire = '') {
77
+ return;
78
+ }
79
  }
80
 
81
+ // HACK: kill all output buffers (some plugins, like Hyper Cache, use theses)
82
+ while (@ob_end_flush());
83
+
84
+ // We cant simply replace the object cache incase set/add do something that
85
+ // matters to the webserver
86
+ // $wp_object_cache = new DummyWP_Object_Cache();
87
 
88
  ?>
manage.php CHANGED
@@ -378,7 +378,6 @@ case 0:
378
  <div class="status">
379
  <p><?php echo dsq_i('This will download your Disqus comments and store them locally in WordPress'); ?></p>
380
  <label><input type="checkbox" id="dsq_import_wipe" name="dsq_import_wipe" value="1"/> <?php echo dsq_i('Remove all imported Disqus comments before syncing.'); ?></label><br/>
381
- <label><input type="checkbox" id="dsq_import_force" name="dsq_import_force" value="1"/> <?php echo dsq_i('Force the sync task even if it\'s already in progress.'); ?></label><br/>
382
  <p><a href="#" class="button"><?php echo dsq_i('Sync Comments'); ?></a></p>
383
  </div>
384
  </div>
@@ -403,17 +402,17 @@ case 0:
403
  <br/>
404
  <h3><?php echo dsq_i('Debug Information'); ?></h3>
405
  <p><?php echo dsq_i('Having problems with the plugin? <a href="%s">Drop us a line</a> and include the following details and we\'ll do what we can.', 'mailto:help+wp@disqus.com'); ?></p>
406
- <textarea style="width:90%; height:200px;">URL: <?php echo get_option('siteurl'); ?>
407
- PHP Version: <?php echo phpversion(); ?>
408
- Version: <?php echo $wp_version; ?>
409
- Active Theme: <?php $theme = get_theme(get_current_theme()); echo $theme['Name'].' '.$theme['Version']; ?>
410
- URLOpen Method: <?php echo dsq_url_method(); ?>
411
 
412
- Plugin Version: <?php echo DISQUS_VERSION; ?>
413
 
414
  Settings:
415
 
416
- dsq_is_installed: <?php echo dsq_is_installed(); ?>
417
 
418
  <?php foreach (dsq_options() as $opt) {
419
  echo $opt.': '.get_option($opt)."\n";
378
  <div class="status">
379
  <p><?php echo dsq_i('This will download your Disqus comments and store them locally in WordPress'); ?></p>
380
  <label><input type="checkbox" id="dsq_import_wipe" name="dsq_import_wipe" value="1"/> <?php echo dsq_i('Remove all imported Disqus comments before syncing.'); ?></label><br/>
 
381
  <p><a href="#" class="button"><?php echo dsq_i('Sync Comments'); ?></a></p>
382
  </div>
383
  </div>
402
  <br/>
403
  <h3><?php echo dsq_i('Debug Information'); ?></h3>
404
  <p><?php echo dsq_i('Having problems with the plugin? <a href="%s">Drop us a line</a> and include the following details and we\'ll do what we can.', 'mailto:help+wp@disqus.com'); ?></p>
405
+ <textarea style="width:90%; height:200px;">URL: <?php echo get_option('siteurl'); ?>
406
+ PHP Version: <?php echo phpversion(); ?>
407
+ Version: <?php echo $wp_version; ?>
408
+ Active Theme: <?php $theme = get_theme(get_current_theme()); echo $theme['Name'].' '.$theme['Version']; ?>
409
+ URLOpen Method: <?php echo dsq_url_method(); ?>
410
 
411
+ Plugin Version: <?php echo DISQUS_VERSION; ?>
412
 
413
  Settings:
414
 
415
+ dsq_is_installed: <?php echo dsq_is_installed(); ?>
416
 
417
  <?php foreach (dsq_options() as $opt) {
418
  echo $opt.': '.get_option($opt)."\n";
readme.txt CHANGED
@@ -2,8 +2,8 @@
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.1.2
6
- Stable tag: 2.67
7
 
8
  The Disqus comment system replaces your WordPress comment system with your comments hosted and powered by Disqus.
9
 
@@ -54,6 +54,18 @@ Go to [http://disqus.com/help/wordpress](http://disqus.com/help/wordpress)
54
 
55
  == Changes ==
56
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  2.67
58
 
59
  * Bumped synchronization timer delays to 5 minutes.
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.2.1
6
+ Stable tag: 2.69
7
 
8
  The Disqus comment system replaces your WordPress comment system with your comments hosted and powered by Disqus.
9
 
54
 
55
  == Changes ==
56
 
57
+ 2.69
58
+
59
+ * Bumped version number.
60
+
61
+ 2.68
62
+
63
+ * Removed debugging information from web requests in CLI scripts (thanks
64
+ Ryan Dewhurst for the report).
65
+ * Reduced sync lock time to 1 hour.
66
+ * Fixed an issue which was not allowing pending posts (for sync) to clear.
67
+ * Fixed an issue with CLI scripts when used with certain caching plugins.
68
+
69
  2.67
70
 
71
  * Bumped synchronization timer delays to 5 minutes.
scripts/export-comments.php CHANGED
@@ -34,7 +34,7 @@ $global_start = microtime();
34
 
35
  $max_post_id = $wpdb->get_var($wpdb->prepare("
36
  SELECT MAX(ID)
37
- FROM $wpdb->posts
38
  WHERE post_type != 'revision'
39
  AND post_status = 'publish'
40
  AND comment_count > 0
@@ -45,10 +45,10 @@ print_line('Max post id is %d', $max_post_id);
45
 
46
  while ($post_id < $max_post_id) {
47
  $start = microtime();
48
-
49
  $post = $wpdb->get_results($wpdb->prepare("
50
- SELECT *
51
- FROM $wpdb->posts
52
  WHERE post_type != 'revision'
53
  AND post_status = 'publish'
54
  AND comment_count > 0
@@ -64,7 +64,7 @@ while ($post_id < $max_post_id) {
64
  $response = null;
65
  $query = $wpdb->get_results( $wpdb->prepare("SELECT COUNT(*) as total FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_agent NOT LIKE 'Disqus/%%' LIMIT ".EXPORT_CHUNK_SIZE, $post_id) );
66
  $total_comments = $query[0]->total;
67
-
68
  $comments = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_agent NOT LIKE 'Disqus/%%' LIMIT ".EXPORT_CHUNK_SIZE, $post_id) );
69
  $group_id = null;
70
  $at = 0;
@@ -87,8 +87,11 @@ while ($post_id < $max_post_id) {
87
  $total_exported += count($comments);
88
  $at += EXPORT_CHUNK_SIZE;
89
  $comments = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_agent NOT LIKE 'Disqus/%%' LIMIT ".EXPORT_CHUNK_SIZE." OFFSET {$at}", $post->ID) );
 
 
 
90
  }
91
-
92
  $time = abs(microtime() - $start);
93
  print_line(' Done! (took %.2fs)', $time);
94
  }
34
 
35
  $max_post_id = $wpdb->get_var($wpdb->prepare("
36
  SELECT MAX(ID)
37
+ FROM $wpdb->posts
38
  WHERE post_type != 'revision'
39
  AND post_status = 'publish'
40
  AND comment_count > 0
45
 
46
  while ($post_id < $max_post_id) {
47
  $start = microtime();
48
+
49
  $post = $wpdb->get_results($wpdb->prepare("
50
+ SELECT *
51
+ FROM $wpdb->posts
52
  WHERE post_type != 'revision'
53
  AND post_status = 'publish'
54
  AND comment_count > 0
64
  $response = null;
65
  $query = $wpdb->get_results( $wpdb->prepare("SELECT COUNT(*) as total FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_agent NOT LIKE 'Disqus/%%' LIMIT ".EXPORT_CHUNK_SIZE, $post_id) );
66
  $total_comments = $query[0]->total;
67
+
68
  $comments = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_agent NOT LIKE 'Disqus/%%' LIMIT ".EXPORT_CHUNK_SIZE, $post_id) );
69
  $group_id = null;
70
  $at = 0;
87
  $total_exported += count($comments);
88
  $at += EXPORT_CHUNK_SIZE;
89
  $comments = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_agent NOT LIKE 'Disqus/%%' LIMIT ".EXPORT_CHUNK_SIZE." OFFSET {$at}", $post->ID) );
90
+ // assuming the cache is the internal, reset it's value to empty to avoid
91
+ // large memory consumption
92
+ $wp_object_cache->cache = array();
93
  }
94
+
95
  $time = abs(microtime() - $start);
96
  print_line(' Done! (took %.2fs)', $time);
97
  }
scripts/import-comments.php CHANGED
@@ -30,6 +30,7 @@ $force = (in_array('--force', $argv));
30
  $total = 0;
31
  $global_start = microtime();
32
 
 
33
  while ($imported) {
34
  print_line(' Importing chunk starting at comment id %d', $last_comment_id);
35
  $start = microtime();
@@ -46,7 +47,14 @@ while ($imported) {
46
  }
47
  $total += $imported;
48
  $time = abs(microtime() - $start);
49
- print_line(' %d comments imported (took %.2fs)', $imported, $time);
 
 
 
 
 
 
 
50
  }
51
  $total_time = abs(microtime() - $global_start);
52
  print_line('---------------------------------------------------------');
30
  $total = 0;
31
  $global_start = microtime();
32
 
33
+ $memory_usage = memory_get_peak_usage();
34
  while ($imported) {
35
  print_line(' Importing chunk starting at comment id %d', $last_comment_id);
36
  $start = microtime();
47
  }
48
  $total += $imported;
49
  $time = abs(microtime() - $start);
50
+
51
+ // assuming the cache is the internal, reset it's value to empty to avoid
52
+ // large memory consump
53
+ $wp_object_cache->cache = array();
54
+
55
+ $new_memory_usage = memory_get_peak_usage();
56
+ print_line(' %d comments imported (took %.2fs, memory increased by %db)', $imported, $time, ($new_memory_usage - $memory_usage));
57
+ $memory_usage = $new_memory_usage;
58
  }
59
  $total_time = abs(microtime() - $global_start);
60
  print_line('---------------------------------------------------------');