Fix: WordPress 3.1 and Disqus Plugin Error When Returning Comments Count

If you use the popular 3rd-party commenting system Disqus in your WordPress-powered website, you may have noticed that some errors appeared in your Posts lists after upgrading to WordPress 3.1.  The specific error you see would be something like:

Warning: number_format() expects parameter 1 to be double, string given in /wp-includes/functions.php on line 155

I’ve had problems with Disqus messing with WordPress comment counts in the past, and since those minor problems were never properly resolved, they caused more severe problems when WordPress updated their Posts view in version 3.1.

Essentially, Disqus takes the WordPress comment count and reformats it internally to wrap it in an identifying span that follows the format:


{number of comments}

Disqus effectively usurps WordPress’s comment count (which isn’t a big deal by itself), but the added HTML around the comment count is what breaks WordPress 3.1.

Why It Breaks

In the WordPress core file /wp-admin/includes/class-wp-list-table.php, WordPress makes a call to the get_comments_number() function and passes it to its internal function number_format_i18n().  Since Disqus has replaced the normal value returned from get_comments_number() with its own value wrapped in HTML, this breaks WordPress’s number_format_i18n function which expects the value to be a double instead of a string.

After quite a bit of troubleshooting, I figured out a way to fix this by making a small change to the Disqus plugin.

How to Fix It

Note: This method involves editing PHP files for WordPress plugins on your web server. If you do not feel comfortable following this guide, please seek assistance. And above all – make a backup!

Step 1: Edit the file /wp-content/plugins/disqus-comment-system/disqus.php

Step 2: Locate the following code at line 692:


function dsq_comments_number($count) {
 global $post;

 if ( dsq_can_replace() ) {
 return ''.$count.'';
 } else {
 return $count;
 }
}

Replace it with:


function dsq_comments_number($count) {
global $post;

return $count;
}

Step 4 (optional – this will fix comment counts in the front-end of your blog if using the comments_number() function in your theme): Locate the following code at line 697:


function dsq_comments_text($comment_text) {
global $post;

if ( dsq_can_replace() ) {
return 'View Comments';
} else {
return $comment_text;
}
}

Replace it with:


function dsq_comments_text($comment_text) {
global $post;
$number_of_comments = get_comments_number();
return $number_of_comments;
}

Finally, to display the comment count in your WordPress theme, use the following code wherever you want to display “X Comments”:




This should fix the comments count in your WordPress Posts view, and make comments appear correctly on your blog if you use the comments_number() function in your theme.

How to Install Adobe Reader Without Installing Adobe DLM (Download Manager) Browser Plugin

As a quick follow-up to my previous article about installing Flash player without installing Adobe’s DLM browser plugin, I’ll cover how to avoid installing this unnecessary intermediary software when installing Adobe Reader.

If you didn’t read my previous article, here’s what you need to know:

  • Adobe DLM is a “download manager” plugin that is installed in your browser by default when trying to install some Adobe products such as Flash player and Reader.  This software simply performs the download (just like your browser normally would), and has no real added benefit.
  • These products will run just the same whether you use Adobe DLM to download them or use the standard installer directly.
  • The standard installer is not the default method to install these products, so you’ll want to follow this procedure whenever installing Adobe products to avoid extra software.

Update 10/6/2010

As noted in the comments, Adobe has now changed their website so the Reader installer is even harder to find.  By default, you are now required to download Adobe DLM, then cancel the download, click a secondary link, then remove Adobe DLM.

Not fun, right?  Don’t worry, here’s the solution:

Step 1: Open Adobe’s FTP server in your browser and select your operating system (“win”, “mac”, or “unix”).

Step 2: Select the most recent core version of the software.  In my case, this was “9.x”.

Step 3: Select the newest version listed again.  In my case, this was “9.4.0”.

Step 4: Select your language from the list.  United States English is “en_US”.

Step 5: Download the .exe installer and install Adobe Reader as usual.  That’s it, you’re done!

Removing Adobe DLM

If you’re using Firefox and have installed Adobe products in the past, you can check to see if Adobe DLM was installed by going to Tools –> Add-ons and locating it in the list.  From this menu it can be disabled and/or removed.

How to Install Adobe Flash Player Without Installing Adobe’s DLM (Download Manager) Browser Plugin

Most of us use Adobe Flash, that’s simply a fact of the internet.  YouTube, Hulu, Pandora, and dozens of other sites currently use Flash to provide you with interactive media and applications, and until HTML5 (hopefully) gives us a viable alternative, we’re stuck with it in many ways.

Don’t get me wrong – I don’t mind Flash.  What I dislike is when Adobe starts forcing me to install an intermediary application, Adobe DLM, to install Flash instead of directly installing the software.  For those of you that have been on the internet for a while and remember “download manager” applications, when was the last time you needed one in the age of high speed internet?

I’m sure Adobe has plenty of reasons for wanting you to download and install two applications instead of just one, but I’m not having it.  And unfortunately for all of us, the default (and only obvious) way to install Flash is to install the Adobe DLM plugin to your browser.  You’ll probably notice this little yellow bar at the top of your browser when you try to install Flash:

Even I am tempted to quickly grant access to Adobe DLM so I can get my Flash fix on.  But you can install Flash without Adobe DLM with just a few steps:

Installing Adobe Flash Player without Adobe DLM

Step 1: Instead of installing Flash from the normal installation page, head to the Flash troubleshooting page.  You can alternatively get to this location from the normal installation page by clicking the link “click here for troubleshooting information” as shown below.

Step 2: On the troubleshooting page, click the link that says “Troubleshoot Flash Player installation”.  I haven’t tested this in other operating systems, but I was presented with a specific Windows link.  Please post in the comments if you’re using another OS and see something different.

Step 3: Skip all the steps presented on this page and instead click the link that says “Download Flash Player with the manual installer”.

Step 4: Select the correct file for the browser you are using.  One file is for Internet Explorer, the other is for all other browsers.

Now just install Flash as usual.  It was a little more work, but now you are only installing the software you wanted to use in the first place.  Hooray!

If you’re using Firefox and have installed Flash in the past, you can check to see if Adobe DLM was installed by going to Tools –> Add-ons and locating it in the list.  From this menu it can be disabled and/or removed.

How To: Create and Store Passwords Securely Using LastPass

Answer the following:

  • Do you use the same password for multiple (or all) websites?
  • Have you had the same password for more than 6 months?
  • Is your password strong?
  • Does your password contain plain dictionary words, or include personal information such as your name, address, or phone number?
  • Do you use your browser’s built-in password storing feature?

If any of these things are true, it’s understandable – nobody wants to memorize multiple passwords and make them overly complicated.  Unfortunately, it also means that your online security is compromised and could lead to you becoming a victim of identity theft.

Think of it this way:  if someone was able to access your Twitter account, they could potentially access your email if you had the same password for both.  Once your email has been compromised, an intruder could reset the passwords for the rest of your secure accounts (or even access something as important as your online bank accounts).

The solution to creating and managing strong, unique passwords across multiple websites is to use a password manager such as LastPass.  LastPass is an online password service that can be used with feature-rich plugins in Firefox and Internet Explorer, and can be used on any browser via unique bookmarklets or web access.

LastPass stores your passwords in a secure online vault which can only be opened with a master password that they do not store or even have access to.  Instead of remembering dozens of complicated passwords, all you have to do is remember your master password and it will unlock the rest of your passwords.

While it may seem dangerous to have one master password that can unlock all other passwords, the idea is that since you only have one password to remember, you’ll treat it with the utmost safety and change the password often.  To protect you from keyloggers (programs designed to record keystrokes), LastPass provides a visual keyboard which allows you to enter your password via mouse clicks.

Getting Started

To get started, you’ll want visit the LastPass download site to get the appropriate client.  The main download (recommended) contains plugins for both Internet Explorer and Firefox, but you can download a Firefox-specific plugin here.  If you don’t use Firefox or Internet Explorer, don’t worry – I’ll cover how to access your passwords without the plugins later in this article.

The next step is to create a LastPass account.  This will be the information that safeguards your password vault, so make sure you use a strong password (and don’t forget it – if you are locked out of this account, there is no way to recover it!).

Once your account has been created, you will be prompted to import your current passwords.  While this step is optional, it is important to do because most of your passwords are stored insecurely on your local computer.  After importing, LastPass will give you the option to remove your insecure passwords (remember, if LastPass can find your passwords, what could a malicious program do?).  If you are concerned about the safety of your passwords, LastPass provides some additional security information about their service.

In the next screen, LastPass gives you the option of securely storing personal information for use in forms.  While this particular feature could be useful, I will exclusively be focusing on passwords for this guide.

Finally, you can choose whether LastPass should automatically log you out (for public or shared computers, more secure) or keep you logged in for two weeks (for private computers only, less secure).  I would also recommend setting the Homepage Preference to “Do not set LastPass Vault as my homepage”.  When you click Done, you will have the option to watch a short video on the LastPass service.

Now that LastPass is fully installed, you will have toolbar buttons in both Internet Explorer and Firefox.  Clicking these buttons gives you a host of options as well as the ability to manually log out of the service.

When visiting sites with a secure login, LastPass will function just like your browser’s password storing feature did by prompting you to save your passwords.  After clicking ‘Yes’, your password will now be securely stored in your vault which can be accessed via the LastPass toolbar button.  While saving your password, you’ll be able to give it a name, store it in a group, or make it a favorite.

lastpass_savepassword

The next time you visit a site with a stored password, it will automatically be inserted if you are logged into LastPass.

To access your password vault, simply click the LastPass toolbar button and select My LastPass Vault.  This will display a webpage containing details for your login information, and you can automatically login to a secure site by clicking its name.  To view any of your passwords, click the [Edit] button and then click [Show].

Changing Your Passwords to Strong Passwords

Now that your passwords have been securely stored using LastPass’s vault, you can change your existing passwords to something more secure.  The biggest advantage of LastPass is that it can keep track of an unlimited number of complicated passwords, so I recommend generating unique passwords for every website you use.

To store a new password, login to a website and locate the password change section.  LastPass will display an information bar at the top of the page and offer to enter your current password. You can then click the ‘Generate’ button to create a secure new password.  If you are not given the information bar, you can right click the password field and select LastPass –> Generate Secure Password.

lastpass_newpass

After clicking the Generate button, you can click the Generate button inside the resulting dialog box to create new random passwords.  When you’ve found a password you like, click Accept and it will be inserted into both the password and password confirmation boxes.

Password criteria and settings can be adjusted by clicking the ‘Show Advanced Options’ checkbox.  In here, you will be able to adjust the length of the password as well as what characters are used to generate it.  I highly recommend checking the ‘Special’ box because it adds characters like !@$%^&* which make your password much more secure.

Once you have submitted your password change, LastPass will notify you that it has detected a password change and gives you the option to save the new password.

lastpass_confirm

Accessing Your Passwords From a Different Computer or Browser

While the LastPass plugin is the best way to access your passwords, there are times when you need to access your passwords on a shared computer or a browser that doesn’t support plugins.  For these circumstances, LastPass provides convenient bookmarklets that can be launched from any browser or computer.

To use the bookmarklets, log into your LastPass account and click the Bookmarklets tab.  In the dialog box, you will be provided with several bookmarklet links and instructions on how to use them in different browsers.  Once you get the bookmarklets added to your browser, you can click the ‘LastPass Login!’ bookmarklet and you will be automatically signed in to any secure website you’ve saved a password for (as long as you are logged into LastPass).

You can also access your secure sites by logging into LastPass and clicking the title of any saved website.  You will be automatically taken to that website’s login page and logged in.

If you ever want to view any of your passwords, you can click the ‘Edit’ button on a saved site and then click the [Show] button near the password field, which will allow you to copy and paste it wherever you like.

More Information

Check out the LastPass website for additional information including a feature list and several videos/screencasts.  As with any online service, make sure you trust the provider before using their service.