Disqus Comment System - Version 2.73

Version Description

Download this release

Release Info

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

Code changes from version 2.72 to 2.73

Files changed (8) hide show
  1. comments.php +10 -2
  2. disqus.php +63 -7
  3. export.php +1 -1
  4. manage.php +43 -4
  5. readme.txt +21 -3
  6. screenshot-1.png +0 -0
  7. screenshot-2.png +0 -0
  8. screenshot-3.png +0 -0
comments.php CHANGED
@@ -71,7 +71,12 @@ if (DISQUS_DEBUG) {
71
  <?php if (!get_option('disqus_manual_sync')): ?>
72
  config.callbacks.onReady.push(function() {
73
  // sync comments in the background so we don't block the page
74
- DISQUS.request.get('?cf_action=sync_comments&post_id=<?php echo $post->ID; ?>');
 
 
 
 
 
75
  });
76
  <?php endif; ?>
77
  <?php
@@ -81,6 +86,9 @@ if (DISQUS_DEBUG) {
81
  echo "this.page.{$k} = '{$v}';\n";
82
  }
83
  }
 
 
 
84
  ?>
85
  };
86
  var facebookXdReceiverPath = '<?php echo DSQ_PLUGIN_URL . '/xd_receiver.htm' ?>';
@@ -128,7 +136,7 @@ if (DISQUS_DEBUG) {
128
  $connection_type = "http";
129
  }
130
  ?>
131
- dsq.src = '<?php echo $connection_type; ?>' + '://' + disqus_shortname + '.' + disqus_domain + '/embed.js?pname=wordpress&pver=<?php echo DISQUS_VERSION; ?>';
132
  (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
133
  })();
134
  /* ]]> */
71
  <?php if (!get_option('disqus_manual_sync')): ?>
72
  config.callbacks.onReady.push(function() {
73
  // sync comments in the background so we don't block the page
74
+ var script = document.createElement('script');
75
+ script.async = true;
76
+ script.src = '?cf_action=sync_comments&post_id=<?php echo $post->ID; ?>';
77
+
78
+ var firstScript = document.getElementsByTagName( "script" )[0];
79
+ firstScript.parentNode.insertBefore(script, firstScript);
80
  });
81
  <?php endif; ?>
82
  <?php
86
  echo "this.page.{$k} = '{$v}';\n";
87
  }
88
  }
89
+ if (get_option('disqus_sso_button')) {
90
+ echo dsq_sso_login();
91
+ }
92
  ?>
93
  };
94
  var facebookXdReceiverPath = '<?php echo DSQ_PLUGIN_URL . '/xd_receiver.htm' ?>';
136
  $connection_type = "http";
137
  }
138
  ?>
139
+ dsq.src = '<?php echo $connection_type; ?>' + '://' + disqus_shortname + '.' + '<?php echo DISQUS_DOMAIN; ?>' + '/embed.js?pname=wordpress&pver=<?php echo DISQUS_VERSION; ?>';
140
  (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
141
  })();
142
  /* ]]> */
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.72
8
  Author URI: http://disqus.com/
9
  */
10
 
@@ -31,7 +31,7 @@ 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.72');
35
  define('DISQUS_SYNC_TIMEOUT', 30);
36
 
37
  /**
@@ -44,14 +44,17 @@ function dsq_options() {
44
  '_disqus_sync_post_ids',
45
  # render disqus in the embed
46
  'disqus_active',
47
- 'disqus_public_key',
48
- 'disqus_secret_key',
49
  'disqus_forum_url',
50
  'disqus_api_key',
51
  'disqus_user_api_key',
52
- 'disqus_partner_key',
53
  'disqus_replace',
54
  'disqus_cc_fix',
 
 
 
 
 
 
55
  # disables automatic sync via cron
56
  'disqus_manual_sync',
57
  # disables server side rendering
@@ -514,6 +517,31 @@ function dsq_request_handler() {
514
 
515
  add_action('init', 'dsq_request_handler');
516
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
517
  function dsq_add_pending_post_id($post_id) {
518
  update_post_meta($post_id, 'dsq_needs_sync', '1', $unique=true);
519
  }
@@ -1213,7 +1241,14 @@ function dsq_output_footer_comment_js() {
1213
  }
1214
  var s = document.createElement('script'); s.async = true;
1215
  s.type = 'text/javascript';
1216
- s.src = 'http://<?php echo DISQUS_DOMAIN; ?>/forums/' + disqus_shortname + '/count.js';
 
 
 
 
 
 
 
1217
  (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
1218
  }());
1219
  //]]>
@@ -1371,6 +1406,7 @@ function dsq_sso() {
1371
  'id' => $current_user->ID,
1372
  'avatar' => $avatar,
1373
  'email' => $current_user->user_email,
 
1374
  );
1375
  }
1376
  else {
@@ -1389,8 +1425,26 @@ function dsq_sso() {
1389
  }
1390
  }
1391
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1392
  // from: http://www.php.net/manual/en/function.sha1.php#39492
1393
- //Calculate HMAC-SHA1 according to RFC2104
1394
  // http://www.ietf.org/rfc/rfc2104.txt
1395
  function dsq_hmacsha1($data, $key) {
1396
  $blocksize=64;
@@ -1475,6 +1529,8 @@ function dsq_install_database($version=0) {
1475
  }
1476
  }
1477
  function dsq_uninstall_database($version=0) {
 
 
1478
  if (version_compare($version, '2.49', '>=')) {
1479
  $wpdb->query("DROP INDEX disqus_dupecheck ON `".$wpdb->prefix."commentmeta`;");
1480
  }
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.73
8
  Author URI: http://disqus.com/
9
  */
10
 
31
  if (!defined('DISQUS_DEBUG')) {
32
  define('DISQUS_DEBUG', false);
33
  }
34
+ define('DISQUS_VERSION', '2.73');
35
  define('DISQUS_SYNC_TIMEOUT', 30);
36
 
37
  /**
44
  '_disqus_sync_post_ids',
45
  # render disqus in the embed
46
  'disqus_active',
 
 
47
  'disqus_forum_url',
48
  'disqus_api_key',
49
  'disqus_user_api_key',
 
50
  'disqus_replace',
51
  'disqus_cc_fix',
52
+ # SSO features
53
+ 'disqus_partner_key',
54
+ 'disqus_public_key',
55
+ 'disqus_secret_key',
56
+ 'disqus_sso_button',
57
+ 'disqus_sso_icon',
58
  # disables automatic sync via cron
59
  'disqus_manual_sync',
60
  # disables server side rendering
517
 
518
  add_action('init', 'dsq_request_handler');
519
 
520
+ /**
521
+ * @param string $option_name
522
+ */
523
+ function dsq_image_upload_handler($option_name) {
524
+ // If the upload field has a file in it
525
+ if(isset($_FILES[$option_name]) && ($_FILES[$option_name]['size'] > 0)) {
526
+ // Get the type of the uploaded file. This is returned as "type/extension"
527
+ $arr_file_type = wp_check_filetype(basename($_FILES[$option_name]['name']));
528
+ $uploaded_file_type = $arr_file_type['type'];
529
+ // Set an array containing a list of acceptable formats
530
+ $allowed_file_types = array('image/jpg','image/jpeg','image/gif','image/png','image/x-icon');
531
+ // If the uploaded file is the right format
532
+ if(in_array($uploaded_file_type, $allowed_file_types)) {
533
+ // Options array for the wp_handle_upload function. 'test_upload' => false
534
+ $upload_overrides = array( 'test_form' => false );
535
+ // Handle the upload using WP's wp_handle_upload function. Takes the posted file and an options array
536
+ $uploaded_file = wp_handle_upload($_FILES[$option_name], $upload_overrides);
537
+ // If the wp_handle_upload call returned a local path for the image
538
+ if(isset($uploaded_file['url'])) {
539
+ update_option($option_name, $uploaded_file['url']);
540
+ }
541
+ }
542
+ }
543
+ }
544
+
545
  function dsq_add_pending_post_id($post_id) {
546
  update_post_meta($post_id, 'dsq_needs_sync', '1', $unique=true);
547
  }
1241
  }
1242
  var s = document.createElement('script'); s.async = true;
1243
  s.type = 'text/javascript';
1244
+ <?php
1245
+ if (is_ssl()) {
1246
+ $connection_type = "https";
1247
+ } else {
1248
+ $connection_type = "http";
1249
+ }
1250
+ ?>
1251
+ s.src = '<?php echo $connection_type; ?>' + '://' + '<?php echo DISQUS_DOMAIN; ?>/forums/' + disqus_shortname + '/count.js';
1252
  (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
1253
  }());
1254
  //]]>
1406
  'id' => $current_user->ID,
1407
  'avatar' => $avatar,
1408
  'email' => $current_user->user_email,
1409
+ 'url' => $current_user->user_url,
1410
  );
1411
  }
1412
  else {
1425
  }
1426
  }
1427
 
1428
+ function dsq_sso_login() {
1429
+ global $current_site;
1430
+ $sitename = get_bloginfo('name');
1431
+ $siteurl = site_url();
1432
+ $button = get_option('disqus_sso_button');
1433
+ $icon = get_option('disqus_sso_icon');
1434
+ $sso_login_str = 'this.sso = {
1435
+ name: "'.$sitename.'",
1436
+ button: "'.$button.'",
1437
+ icon: "'.$icon.'",
1438
+ url: "'.$siteurl.'/wp-login.php",
1439
+ logout: "'.$siteurl.'/wp-login.php?action=logout",
1440
+ width: "800",
1441
+ height: "700"
1442
+ }';
1443
+ return $sso_login_str;
1444
+ }
1445
+
1446
  // from: http://www.php.net/manual/en/function.sha1.php#39492
1447
+ // Calculate HMAC-SHA1 according to RFC2104
1448
  // http://www.ietf.org/rfc/rfc2104.txt
1449
  function dsq_hmacsha1($data, $key) {
1450
  $blocksize=64;
1529
  }
1530
  }
1531
  function dsq_uninstall_database($version=0) {
1532
+ global $wpdb;
1533
+
1534
  if (version_compare($version, '2.49', '>=')) {
1535
  $wpdb->query("DROP INDEX disqus_dupecheck ON `".$wpdb->prefix."commentmeta`;");
1536
  }
export.php CHANGED
@@ -41,7 +41,7 @@ function dsq_export_wxr_cdata($str) {
41
 
42
  // $str = ent2ncr(esc_html($str));
43
 
44
- $str = "<![CDATA[$str" . ( ( substr($str, -1) == ']' ) ? ' ' : '') . "]]>";
45
 
46
  return $str;
47
  }
41
 
42
  // $str = ent2ncr(esc_html($str));
43
 
44
+ $str = '<![CDATA[' . str_replace( ']]>', ']]]]><![CDATA[>', $str ) . ']]>';
45
 
46
  return $str;
47
  }
manage.php CHANGED
@@ -71,6 +71,13 @@ if ( isset($_POST['disqus_forum_url']) && isset($_POST['disqus_replace']) ) {
71
  update_option('disqus_disable_ssr', isset($_POST['disqus_disable_ssr']));
72
  update_option('disqus_public_key', $_POST['disqus_public_key']);
73
  update_option('disqus_secret_key', $_POST['disqus_secret_key']);
 
 
 
 
 
 
 
74
  dsq_manage_dialog('Your settings have been changed.');
75
  }
76
 
@@ -240,9 +247,10 @@ case 0:
240
  $dsq_cc_fix = get_option('disqus_cc_fix');
241
  $dsq_manual_sync = get_option('disqus_manual_sync');
242
  $dsq_disable_ssr = get_option('disqus_disable_ssr');
243
-
244
  $dsq_public_key = get_option('disqus_public_key');
245
  $dsq_secret_key = get_option('disqus_secret_key');
 
 
246
  ?>
247
  <!-- Advanced options -->
248
  <div id="dsq-advanced" class="dsq-content dsq-advanced"<?php if (!$show_advanced) echo ' style="display:none;"'; ?>>
@@ -256,7 +264,7 @@ case 0:
256
  echo '<p class="status">Disqus comments are currently enabled. (<a href="?page=disqus&amp;active=0">Disable</a>)</p>';
257
  }
258
  ?>
259
- <form method="POST">
260
  <?php wp_nonce_field('dsq-advanced'); ?>
261
  <h3>Configuration</h3>
262
  <table class="form-table">
@@ -313,6 +321,33 @@ case 0:
313
  </td>
314
  </tr>
315
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
316
  <tr>
317
  <th scope="row" valign="top"><?php echo dsq_i('Use Disqus Comments on'); ?></th>
318
  <td>
@@ -421,8 +456,12 @@ dsq_is_installed: <?php echo dsq_is_installed(); ?>
421
  Plugins:
422
 
423
  <?php
424
- foreach (get_plugins() as $plugin) {
425
- echo $plugin['Name'].' '.$plugin['Version']."\n";
 
 
 
 
426
  }
427
  ?></textarea><br/>
428
  </div>
71
  update_option('disqus_disable_ssr', isset($_POST['disqus_disable_ssr']));
72
  update_option('disqus_public_key', $_POST['disqus_public_key']);
73
  update_option('disqus_secret_key', $_POST['disqus_secret_key']);
74
+ // Handle any SSO button and icon uploads
75
+ if(isset($_FILES['disqus_sso_button'])) {
76
+ dsq_image_upload_handler('disqus_sso_button');
77
+ }
78
+ if(isset($_FILES['disqus_sso_icon'])) {
79
+ dsq_image_upload_handler('disqus_sso_icon');
80
+ }
81
  dsq_manage_dialog('Your settings have been changed.');
82
  }
83
 
247
  $dsq_cc_fix = get_option('disqus_cc_fix');
248
  $dsq_manual_sync = get_option('disqus_manual_sync');
249
  $dsq_disable_ssr = get_option('disqus_disable_ssr');
 
250
  $dsq_public_key = get_option('disqus_public_key');
251
  $dsq_secret_key = get_option('disqus_secret_key');
252
+ $dsq_sso_button = get_option('disqus_sso_button');
253
+ $dsq_sso_icon = get_option('disqus_sso_icon');
254
  ?>
255
  <!-- Advanced options -->
256
  <div id="dsq-advanced" class="dsq-content dsq-advanced"<?php if (!$show_advanced) echo ' style="display:none;"'; ?>>
264
  echo '<p class="status">Disqus comments are currently enabled. (<a href="?page=disqus&amp;active=0">Disable</a>)</p>';
265
  }
266
  ?>
267
+ <form method="POST" enctype="multipart/form-data">
268
  <?php wp_nonce_field('dsq-advanced'); ?>
269
  <h3>Configuration</h3>
270
  <table class="form-table">
321
  </td>
322
  </tr>
323
 
324
+ <tr>
325
+ <th scope="row" valign="top"><?php echo dsq_i('Custom Log-in Button'); ?></th>
326
+ <td>
327
+ <?php if (!empty($dsq_sso_button)) { ?>
328
+ <img src="<?php echo esc_attr($dsq_sso_button); ?>" alt="<?php echo esc_attr($dsq_sso_button); ?>" />
329
+ <br />
330
+ <?php } ?>
331
+ <input type="file" name="disqus_sso_button" value="<?php echo esc_attr($dsq_sso_button); ?>" tabindex="2">
332
+ <br />
333
+ <?php echo dsq_i('Allows users to log in to Disqus via WordPress. (<a href="%s">Example screenshot</a>.)','http://content.disqus.com/docs/sso-button.png'); ?>
334
+ <?php echo dsq_i('<br />Dimensions: 89x21 for non-Disqus 2012 sites. Disqus 2012 sites, see <a href="%s">our SSO button template</a>.','http://help.disqus.com/customer/portal/articles/236206#button-style-template'); ?>
335
+ </td>
336
+ </tr>
337
+ <tr>
338
+ <th scope="row" valign="top"><?php echo dsq_i('Custom Log-in Icon<br>'); ?></th>
339
+ <td>
340
+ <?php if (!empty($dsq_sso_icon)) { ?>
341
+ <img src="<?php echo esc_attr($dsq_sso_icon); ?>" alt="<?php echo esc_attr($dsq_sso_icon); ?>" />
342
+ <br />
343
+ <?php } ?>
344
+ <input type="file" name="disqus_sso_icon" value="<?php echo esc_attr($dsq_sso_icon); ?>" tabindex="2">
345
+ <br />
346
+ <?php echo dsq_i('Adds an icon to the log-in modal. Not necessary for sites using Disqus 2012. (<a href="%s">Example screenshot</a>.)','http://content.disqus.com/docs/sso-icon.png'); ?>
347
+ <?php echo dsq_i('<br />Dimensions: 16x16.'); ?>
348
+ </td>
349
+ </tr>
350
+
351
  <tr>
352
  <th scope="row" valign="top"><?php echo dsq_i('Use Disqus Comments on'); ?></th>
353
  <td>
456
  Plugins:
457
 
458
  <?php
459
+ foreach (get_plugins() as $key => $plugin) {
460
+ $isactive = "";
461
+ if (is_plugin_active($key)) {
462
+ $isactive = "(active)";
463
+ }
464
+ echo $plugin['Name'].' '.$plugin['Version'].' '.$isactive."\n";
465
  }
466
  ?></textarea><br/>
467
  </div>
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, disqus
4
  Requires at least: 2.8
5
- Tested up to: 3.3.1
6
- Stable tag: 2.72
7
 
8
  The Disqus comment system replaces your WordPress comment system with your comments hosted and powered by Disqus.
9
 
@@ -52,8 +52,26 @@ The Disqus for WordPress plugin seamlessly integrates using the Disqus API and b
52
 
53
  Go to [http://disqus.com/help/wordpress](http://disqus.com/help/wordpress)
54
 
 
 
 
 
 
 
55
  == Changes ==
56
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  2.72
58
 
59
  * Load count.js via SSL when page is accessed via HTTPS
1
  === Disqus Comment System ===
2
+ Contributors: disqus, alexkingorg, crowdfavorite, zeeg, tail, thetylerhayes
3
  Tags: comments, threaded, email, notification, spam, avatars, community, profile, widget, disqus
4
  Requires at least: 2.8
5
+ Tested up to: 3.4.1
6
+ Stable tag: 2.73
7
 
8
  The Disqus comment system replaces your WordPress comment system with your comments hosted and powered by Disqus.
9
 
52
 
53
  Go to [http://disqus.com/help/wordpress](http://disqus.com/help/wordpress)
54
 
55
+ == Screenshots ==
56
+
57
+ 1. Disqus Comments
58
+ 2. Discovery Box (part of Disqus Comments)
59
+ 3. Inline Moderation Interface
60
+
61
  == Changes ==
62
 
63
+ 2.73
64
+
65
+ * Apply CDATA patch from Wordpress 3.4 to dsq_export_wxr_cdata() (thanks Artem
66
+ Russakovskii for the patch).
67
+ * Added Single Sign-On log-in button and icon to options (only for sites using SSO)
68
+ * Output user website if set in SSO payload
69
+ * Added plugin activation statuses to debug info
70
+ * Bump supported WordPress version to 3.4.1
71
+ * Fixed issue where disqus_dupecheck won't properly uninstall
72
+ * Load second count.js (output-in-footer version) reference via SSL too
73
+ * Added screenshots
74
+
75
  2.72
76
 
77
  * Load count.js via SSL when page is accessed via HTTPS
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file
screenshot-3.png ADDED
Binary file