Disqus Comment System - Version 2.49

Version Description

Download this release

Release Info

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

Code changes from version 2.48 to 2.49

Files changed (4) hide show
  1. comments.php +1 -3
  2. disqus.php +57 -13
  3. manage.php +3 -3
  4. readme.txt +5 -1
comments.php CHANGED
@@ -1,6 +1,4 @@
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
  }
@@ -105,7 +103,7 @@ if (DISQUS_DEBUG) {
105
  (function() {
106
  var dsq = document.createElement('script'); dsq.type = 'text/javascript';
107
  dsq.async = true;
108
- dsq.src = 'http://' + disqus_shortname + '.' + disqus_domain + '/embed.js?pname=wordpress&pver=<?php echo $dsq_version; ?>';
109
  (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
110
  })();
111
  </script>
1
  <?php
 
 
2
  if (DISQUS_DEBUG) {
3
  echo "<p><strong>Disqus Debug</strong> thread_id: ".get_post_meta($post->ID, 'dsq_thread_id', true)."</p>";
4
  }
103
  (function() {
104
  var dsq = document.createElement('script'); dsq.type = 'text/javascript';
105
  dsq.async = true;
106
+ dsq.src = 'http://' + disqus_shortname + '.' + disqus_domain + '/embed.js?pname=wordpress&pver=<?php echo DISQUS_VERSION; ?>';
107
  (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
108
  })();
109
  </script>
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.48
8
  Author URI: http://disqus.com/
9
  */
10
 
@@ -20,6 +20,7 @@ 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.
@@ -38,6 +39,7 @@ function dsq_options() {
38
  'disqus_disable_ssr',
39
  # the last sync comment id (from get_forum_posts)
40
  'disqus_last_comment_id',
 
41
  );
42
  }
43
 
@@ -66,14 +68,7 @@ if ( !defined('PLUGINDIR') ) {
66
 
67
  define('DSQ_PLUGIN_URL', WP_CONTENT_URL . '/plugins/' . dsq_plugin_basename(__FILE__));
68
 
69
- /**
70
- * Disqus WordPress plugin version.
71
- *
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.
79
  *
@@ -187,7 +182,7 @@ function dsq_manage_dialog($message, $error = false) {
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);
@@ -219,7 +214,8 @@ function dsq_sync_comments($comments) {
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
  }
@@ -232,7 +228,7 @@ function dsq_sync_comments($comments) {
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) {
@@ -742,7 +738,14 @@ function dsq_wp_dashboard_setup() {
742
  add_action('wp_dashboard_setup', 'dsq_wp_dashboard_setup');
743
 
744
  function dsq_manage() {
745
- include_once(dirname(__FILE__) . '/manage.php');
 
 
 
 
 
 
 
746
  }
747
 
748
  function dsq_admin_head() {
@@ -1202,4 +1205,45 @@ function dsq_link_for_post($post) {
1202
  return get_permalink($post);
1203
  }
1204
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1205
  ?>
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.49
8
  Author URI: http://disqus.com/
9
  */
10
 
20
  if (!defined('DISQUS_DEBUG')) {
21
  define('DISQUS_DEBUG', false);
22
  }
23
+ define('DISQUS_VERSION', '2.49');
24
 
25
  /**
26
  * Returns an array of all option identifiers used by DISQUS.
39
  'disqus_disable_ssr',
40
  # the last sync comment id (from get_forum_posts)
41
  'disqus_last_comment_id',
42
+ 'disqus_version',
43
  );
44
  }
45
 
68
 
69
  define('DSQ_PLUGIN_URL', WP_CONTENT_URL . '/plugins/' . dsq_plugin_basename(__FILE__));
70
 
71
+ $mt_disqus_version = '2.01';
 
 
 
 
 
 
 
72
  /**
73
  * Response from Disqus get_thread API call for comments template.
74
  *
182
  }
183
 
184
  function dsq_sync_comments($comments) {
185
+ global $wpdb;
186
 
187
  // user MUST be logged out during this process
188
  wp_set_current_user(0);
214
  // shouldn't ever happen, but we can't be certain
215
  continue;
216
  }
217
+ }
218
+ 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))) {
219
  // already exists
220
  continue;
221
  }
228
  'comment_date_gmt' => $comment->created_at,
229
  'comment_content' => apply_filters('pre_comment_content', $comment->message),
230
  'comment_approved' => 1,
231
+ 'comment_agent' => 'Disqus/1.1('.DISQUS_VERSION.'):' . intval($comment->id),
232
  'comment_type' => '',
233
  );
234
  if ($comment->is_anonymous) {
738
  add_action('wp_dashboard_setup', 'dsq_wp_dashboard_setup');
739
 
740
  function dsq_manage() {
741
+ if (dsq_does_need_update() && isset($_POST['upgrade'])) {
742
+ dsq_install();
743
+ }
744
+ if (dsq_does_need_update()) {
745
+ include_once(dirname(__FILE__) . '/upgrade.php');
746
+ } else {
747
+ include_once(dirname(__FILE__) . '/manage.php');
748
+ }
749
  }
750
 
751
  function dsq_admin_head() {
1205
  return get_permalink($post);
1206
  }
1207
 
1208
+ function dsq_does_need_update() {
1209
+ $version = (string)get_option('disqus_version');
1210
+ if (!$version) {
1211
+ $version = '0';
1212
+ }
1213
+
1214
+ if (version_compare($version, '2.49', '<')) {
1215
+ return true;
1216
+ }
1217
+
1218
+ return false;
1219
+ }
1220
+
1221
+ function dsq_install($allow_database_install=true) {
1222
+ global $wpdb, $userdata;
1223
+
1224
+ $version = (string)get_option('disqus_version');
1225
+ if (!$version) {
1226
+ $version = '0';
1227
+ }
1228
+
1229
+ if ($allow_database_install)
1230
+ {
1231
+ dsq_install_database($version);
1232
+ }
1233
+
1234
+ if (version_compare($version, DISQUS_VERSION, '=')) return;
1235
+
1236
+ update_option('disqus_version', DISQUS_VERSION);
1237
+ }
1238
+
1239
+ /**
1240
+ * Initializes the database if it's not already present.
1241
+ */
1242
+ function dsq_install_database($version=0) {
1243
+ global $wpdb;
1244
+
1245
+ if (version_compare($version, '2.49', '<')) {
1246
+ $wpdb->query("CREATE INDEX disqus_dupecheck ON `".$wpdb->prefix."commentmeta` (meta_key, meta_value(11));");
1247
+ }
1248
+ }
1249
  ?>
manage.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- global $dsq_version, $dsq_api;
3
 
4
  require(ABSPATH . 'wp-includes/version.php');
5
 
@@ -205,7 +205,7 @@ case 0:
205
  <!-- Advanced options -->
206
  <div id="dsq-advanced" class="dsq-content dsq-advanced" style="display:none;">
207
  <h2><?php echo dsq_i('Advanced Options'); ?></h2>
208
- <?php echo dsq_i('Version: %s', esc_html($dsq_version)); ?>
209
  <form method="POST">
210
  <?php wp_nonce_field('dsq-advanced'); ?>
211
  <table class="form-table">
@@ -327,7 +327,7 @@ case 0:
327
  Version: <?php echo $wp_version; ?>
328
  Active Theme: <?php $theme = get_theme(get_current_theme()); echo $theme['Name'].' '.$theme['Version']; ?>
329
 
330
- Plugin Version: <?php echo $dsq_version; ?>
331
 
332
  Settings:
333
 
1
  <?php
2
+ global $dsq_api;
3
 
4
  require(ABSPATH . 'wp-includes/version.php');
5
 
205
  <!-- Advanced options -->
206
  <div id="dsq-advanced" class="dsq-content dsq-advanced" style="display:none;">
207
  <h2><?php echo dsq_i('Advanced Options'); ?></h2>
208
+ <?php echo dsq_i('Version: %s', esc_html(DISQUS_VERSION)); ?>
209
  <form method="POST">
210
  <?php wp_nonce_field('dsq-advanced'); ?>
211
  <table class="form-table">
327
  Version: <?php echo $wp_version; ?>
328
  Active Theme: <?php $theme = get_theme(get_current_theme()); echo $theme['Name'].' '.$theme['Version']; ?>
329
 
330
+ Plugin Version: <?php echo DISQUS_VERSION; ?>
331
 
332
  Settings:
333
 
readme.txt CHANGED
@@ -3,7 +3,7 @@ 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,6 +62,10 @@ you should remove it, and the new plugin should be stored in 'disqus'.
62
 
63
  == Changes ==
64
 
 
 
 
 
65
  2.48
66
 
67
  * Comment synchronization has been optimized to be a single call per-site.
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.49
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.49
66
+
67
+ * Database usage has been optimized for storing comment meta data.
68
+
69
  2.48
70
 
71
  * Comment synchronization has been optimized to be a single call per-site.