WordPress 3.1 | Techerator https://techerator.com Techerator is an excellent source of tips, guides, and reviews about software, web apps, technology, mobile phones, and computers. Fri, 04 Nov 2011 15:43:44 +0000 en-US hourly 1 https://wordpress.org/?v=7.0.2 7158109 Fix: WordPress 3.1 and Disqus Plugin Error When Returning Comments Count https://techerator.com/2011/02/fix-wordpress-3-1-and-disqus-plugin-error-when-returning-comments-count/?utm_source=rss&utm_medium=rss&utm_campaign=fix-wordpress-3-1-and-disqus-plugin-error-when-returning-comments-count https://techerator.com/2011/02/fix-wordpress-3-1-and-disqus-plugin-error-when-returning-comments-count/#comments Thu, 24 Feb 2011 18:54:32 +0000 http://44.229.110.106/?p=11908 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 […]

The post Fix: WordPress 3.1 and Disqus Plugin Error When Returning Comments Count first appeared on Techerator.

]]>
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:

[code lang=”xml”]

<span class="dsq-postid" rel="{unique post identifier}">{number of comments}</span>

[/code]

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:

[code lang=”php” firstline=”692″]

function dsq_comments_number($count) {
global $post;

if ( dsq_can_replace() ) {
return ‘<span class="dsq-postid" rel="’.htmlspecialchars(dsq_identifier_for_post($post)).’">’.$count.'</span>’;
} else {
return $count;
}
}

[/code]

Replace it with:

[code lang=”php” firstline=”692″]

function dsq_comments_number($count) {
global $post;

return $count;
}

[/code]

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:

[code lang=”php” firstline=”697″]

function dsq_comments_text($comment_text) {
global $post;

if ( dsq_can_replace() ) {
return ‘<span class="dsq-postid" rel="’.htmlspecialchars(dsq_identifier_for_post($post)).’">View Comments</span>’;
} else {
return $comment_text;
}
}

[/code]

Replace it with:

[code lang=”php” firstline=”697″]

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

[/code]

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

[code lang=”php”]

<?php comments_number(”,’ / 1 Comment’,’ / % Comments’); ?>

[/code]

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.

The post Fix: WordPress 3.1 and Disqus Plugin Error When Returning Comments Count first appeared on Techerator.

]]>
https://techerator.com/2011/02/fix-wordpress-3-1-and-disqus-plugin-error-when-returning-comments-count/feed/ 68 11908
Fix: WPtouch Pro Plugin Breaks WordPress 3.1’s Admin Bar https://techerator.com/2011/02/fix-wptouch-pro-plugin-breaks-wordpress-3-1s-admin-bar/?utm_source=rss&utm_medium=rss&utm_campaign=fix-wptouch-pro-plugin-breaks-wordpress-3-1s-admin-bar https://techerator.com/2011/02/fix-wptouch-pro-plugin-breaks-wordpress-3-1s-admin-bar/#comments Wed, 23 Feb 2011 22:47:36 +0000 http://44.229.110.106/?p=11870 WordPress 3.1 rolled out today and brought with it several new features, one being the WordPress admin bar. This feature has been previously available to WordPress.com users and is now available to self-hosted sites (like Techerator), and gives logged-in users access to page controls without having to leave the site. Sites that use the popular […]

The post Fix: WPtouch Pro Plugin Breaks WordPress 3.1’s Admin Bar first appeared on Techerator.

]]>
WordPress 3.1 rolled out today and brought with it several new features, one being the WordPress admin bar. This feature has been previously available to WordPress.com users and is now available to self-hosted sites (like Techerator), and gives logged-in users access to page controls without having to leave the site.

Sites that use the popular WordPress plugin WPtouch or WPtouch Pro will notice that this plugin breaks the new admin bar. While WPtouch is active, the admin bar will not appear on the main site or in the WordPress Dashboard (it took quite a bit of troubleshooting to narrow down which plugin was the culprit!).

The fix is very simple, and the team behind WPtouch has confirmed they are aware of the problem and intend to fix it.

The Fix

This guide requires that you edit plugin files in your WordPress installation. If you do not feel comfortable following this guide, please seek assitance before proceeding. And above all – make a backup!

Step 1: Navigate to the WPtouch plugin themes folder on your web server. Mine was located in /wp-content/plugins/wptouch-pro/themes/classic (If you’re using a different mobile theme, select that instead of classic.)

Step 2: Edit root-functions.php

Step 3: Locate the following code:

[code lang=”php” firstline=”18″]

if ( function_exists( ‘show_admin_bar’ ) ) {
add_filter( ‘show_admin_bar’, ‘__return_false’ );
}

[/code]

And comment it all out:

[code lang=”php” firstline=”18″]

//if ( function_exists( ‘show_admin_bar’ ) ) {
// add_filter( ‘show_admin_bar’, ‘__return_false’ );
//}

[/code]

That’s it! Your WordPress 3.1 admin bar should now be visible on your site. To enable or disable the admin bar, visit your User settings under Users –> Your Profile in WordPress.

The post Fix: WPtouch Pro Plugin Breaks WordPress 3.1’s Admin Bar first appeared on Techerator.

]]>
https://techerator.com/2011/02/fix-wptouch-pro-plugin-breaks-wordpress-3-1s-admin-bar/feed/ 5 11870