Bulk Delete WordPress Comment Spam

I notice a lot of my newly built client’s wordpress sites seem to be attracting a lot of comment spam quickly, even though they might not be blogging regularly. It’s not uncommon to see hundreds or even thousands of unapproved comments listed within months of going live. One site has only been up a few weeks and already attracted nearly 8,000 spam comments.

Trying to delete or process these comments in bulk is not supported very well in current wordpress versions as you can only show a max of 999 comments on a page so it leaves you going through pages and pages of unapproved comments. Until wordpress provides a simple “Delete all unapproved comments” or similar button, here’s a quick way of processing more than 999 comments at once.

It requires hosting and database/phpMyAdmin access so it’s not for the faint hearted but it only takes a couple of minutes. Backup your database first, then run one of these SQL commands:

DELETE FROM wp_comments WHERE comment_approved = "spam";

Or

DELETE FROM wp_comments WHERE comment_approved = "0";

Or

DELETE FROM wp_comments WHERE comment_type = "spam";

And you’re done.

It might be wise to install a spam filter to avoid these comment build ups in the first place. Akismet or SI Captcha for WordPress are good.

Leon

Add Multiple Google +1 Buttons to WordPress

It’s recently been announced that the number of +1’s your site receives might affect your Google page rank so it’s worth having a Google +1 button on your site.

The obvious way to add a single Google +1 button is to just use a WordPress Google +1 plugin but what if you want to keep plugin numbers down for performance reasons or want to add multiple instances of Google +1 to your site, all promoting different url’s, ie – one at the top of your home page for your main site url and one on individual blog posts? Well this is what I needed to do and found it wasn’t that easy! Here’s how I managed it:

Go to www.google.com/webmasters/+1/button and grab your button code, making sure to enter a target url for your main site, then paste it into your site template, taking care to paste the right bits in the right places. The following goes in your header.php file in the <head> section:

<!-- Place this render call where appropriate -->
<script type="text/javascript">
  window.___gcfg = {lang: 'en-GB'};

  (function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
  })();
</script>

And the following goes wherever you want the button to show, typically inside the header.php file somewhere after the opening <body> tag:

<!-- Place this tag where you want the +1 button to render -->
<g:plusone annotation="inline" href="http://www.reverbstudios.ie"></g:plusone>

Now, if you wanted to also have a button on each blog post, to specifically target that blog post url, you need to paste the above code into your single.php template file, somewhere inside the loop but this time change the url to “<?php the_permalink(); ?>”, ie:

<!-- Place this tag where you want the +1 button to render -->
<g:plusone annotation="inline" href="<?php the_permalink(); ?>"></g:plusone>

What this does is automatically grab the post url of the post your’re currently reading and allows it to be +1’d!

See the top left of this site and the share section just below this blog post’s title to see both buttons in action.

Leon

Template Monster Sucks

I’ve had a nice little setup with Template Monster for a few years now. I sell their WordPress themes from my own site and use them for client projects and get a nice affiliate discount. The themes have always been fine and have been very handy for clients not sure what they need design wise. I just get them to browse the templates, pick one they like and I buy it and customise it for them. I collect my 20% discount when my account reaches $100.

The problems started for me when they decided to require database dumps to get the template looking the same as the one demoed, ie – you need to import a database to a fresh wordpress install via phpMyadmin or something similar. Not for the faint hearted. Otherwise, you face a massive job trying to re-create the functionality that was sold to you via the demo.

Lately, the quality of more than a few templates has been awful – to the point where the whole reason for using templates in the first place, ie efficiency, is compromised as you try to fix layout and css issues that result from even the most minor of hacks/customisations.

The latest issue I’ve had and the one that will probably mean me not using Template Monster again concerns a template that only works with a rather old and insecure WordPress 3.0 and not the latest version 3.2.1. After some testing in Internet Explorer 9.0, my client and I found issues with wordpress that meant we couldn’t use version 3.0 but when we tried 3.2.1, certain, very important parts of the template wouldn’t work.

I was pretty snookered and after weeks of bouncing back and forth in Template Monster’s support system, during which they done nothing but supplied useless information, never read what I’d already said and wouldn’t refund me, I’ve had to abandon the template and them along with it!

Leon

Gravity Forms and WordPresss Custom Post Types

I’ve brushed by the problem of getting the Gravity Forms wordpress plugin to populate wordpress content a few times now and while it can handle basic post creation by default, with Title, Content, Images, Category, Tags, etc.. what if you need a front end form to create or populate a Custom Post Type and fill in the various bits of meta/taxonomy information that might be contained in that custom post type?

For one of my latest projects I’m building a property site and using an off the shelf template that comes with a custom post type called Listings which has contained within it custom fields and taxonomies such as:

  • Property Type,
  • No of Beds,
  • Location,
  • Price,
  • etc..

I figured initially that this should be easy enough but on researching found it wasn’t! Luckily the Gravity Forms + Custom Post Types plugin does pretty much all you need. Here’s how it works:

Install and activate the above plugin and go create a new Gravity Form as usual and add a new Title field from the ‘Post Fields’ section. This will be the title of the post and in my case, property name. Go into the advanced settings for that field and tick Save as Custom Post Type. The drop down box choice will list any custom post type created already. See below:

Custom Post

Next create either a drop down, multiple choice or checkbox field and go into the Advanced tab of the field settings and tick ‘Populate with a Taxonomy’, choosing your taxonomy from the resulting list. If you add a list of taxonomies to the custom post type in wordpress admin then these will be the values that populate that drop down/checkbox list on the front end when someone uses the form! See here:

Taxonomy

For this particular site I’m working on I can now have a client register an account, list a property (with ‘Pending’ status) and pay for the listing all through 1 form. Cool!

Leon

Disqus Advanced Blog Commenting

I’ve recently switched over to the Disqus Commenting system from the native WordPress one for the management of comments on this blog. I seen it on a few friends blogs and thought it rocked. Here’s why:

  • Easy installation and import of existing/old comments,
  • Full comment moderation/filtering,
  • Fits in with your existing theme/CSS,
  • Nested/Indented comment replies,
  • Comment reply notification & RSS subscription,
  • Social Media sharing,
  • Facebook, Twitter, Google, OpenID login,
  • Disqus dashboard at Disqus.com with a wealth of  settings,
  • Comments are SEO friendly.

The standout feature for me and the main reason I switched is the ability Disqus gives you to SHARE your comments and replies on Twitter and Facebook. Doing this automatically creates a status update in your name on both sites with a link back to the exact comment or reply. This is a great way to gain more exposure for your article and promote discussion on it!

There’s a WordPress Disqus plugin (of course there is!) available at WordPress.org/extend/plugins/disqus-comment-system/ which when installed will magically import all your existing blog’s comments and auto-sync new blog comments with your online Disqus account. On plugin activation, you’ll have a brand new, seamlessly integrated, advanced but easy to use commenting system!

Sign up now at Disqus.com

Leon.

Website and WordPress Security

Unfortunately this post has been prompted by my own security scare! The problem, which surfaced yesterday seemed to center around the .htaccess file in the root directory of client WordPress powered sites. A hacker managed to exploit a file permissions vulnerability in this file in a pile of sites which basically allowed him/her/it to inject some code in there, redirecting any site visitor to http://r1estudio.com/cabanas with the following slightly pointless message:

Hack

I had a habit of setting the permissions on the .htaccess file to 666 which is the lowest permission I could give it and still enable WordPress to write things like Permalink, Cache & Mobile configuration to the file. Trouble is I never changed back once I had WordPress configured. The ideal permission for that file seems to be 644 which should stop anything editing it.

The .htaccess and wp-config files happen to be quite important in WordPress so make sure yours can’t be written to. As usual, you learn the hard way.

The same goes for all sites, whether WordPress powered or not. Watch your file permissions and passwords!

Leon.

WordPress Optimization and Speed

I’ve been having problems with my sites for a while now on various different VPS web hosting servers. Essentially, I’m getting intermittent faults, the worst kind and hardest to diagnose nevermind fix! Basically all my sites can be running fine then for no reason and without me making any changes to any site, they become incredibly slow. The server and/or apache dies more often than I’d like it too aswell, requiring a manual server restart.

I decided to do a bit of proper research and fault finding this week and while I can’t say for sure everything is fixed now, as of this moment, everything seems fine. Here’s a few of the things I done to try optimize a couple of my biggest, most trafficked sites – both WordPress blogs.

Basic Optimization

  • Update WordPress itself to the most recent version,
  • Update all plugins,
  • Remove plugins that you don’t really need or which you can easily replicate the functions of by hardcoding, ie – Facebook Like Buttons,
  • Limit plugins that communicate with external sources, ie – Facebook boxes, Twitter feeds, etc..,
  • Only use plugins included in the WordPress.org database,
  • Only use plugins that are listed as 100% compatible with your WordPress version,
  • Keep images small and image numbers low,
  • Use HTTP Compression,
  • Use a Caching plugin like W3 or WP Super Cache,

Advanced Optimization

  • Database Queries tend to slow down a WordPress site so check your number by adding "<!-- <?php echo get_num_queries(); ?> queries. <?php timer_stop(1); ?> seconds. -->" to your code and checking the page source on load,
  • Debug your Queries by adding the Debug Queries plugin to see what the actual queries are and how long each one takes,
  • Optimize your WordPress tables via phpMyadmin if you have access to it. The WP DB Manager plugin does this too if not,
  • Delete database tables that have been left over by deactivated or deleted plugins. Be careful here!
  • Turn off post revisions by adding “define('WP_POST_REVISIONS', FALSE);" to your wp-config file,
  • Delete all comments marked as spam via sql query – DELETE FROM  wp_comments WHERE  comment_approved = 'spam';,
  • Clean orphaned or unused entries in the WP-options table using the Clean Options plugin. Be careful!
  • Raise the default WordPress memory limit of 32MB by adding define('WP_MEMORY_LIMIT', '64M'); to the wp-config file,

Finally, you can create a basic error log for your WordPress site by adding the following lines to the wp-config file:

@ini_set('log_errors','On');
@ini_set('display_errors','Off');
@ini_set('error_log','/path/to/wordpress/blog/php_error.log');

Here’s a great article on WordPress Database Optimization.

Good Luck.

Leon.

WordPress Help Menu Plugin

Just a quick, simple little plugin I developed based on some code I found on the net that adds a new menu in your WordPress admin called “Reverb Help”. Clicking on it’s subpages shows various, official WordPress resources & Video Tutorials. I hope that it can be of use to people struggling with WordPress (there can’t be that many, it’s fairly easy to use!) and give them a handy reference from within their own site/blog on how to do the most commonly done things with the excellent WordPress system.

Download the plugin:

WordPress Help Menu Plugin

Installation Instructions:

Download the plugin zip file above then go to ‘Plugins – Add New’ in your wordpress admin. Click ‘Upload’ under ‘Install Plugins’ at the top of the screen and locate the downloaded zip file. WordPress will upload the zip file and present you with ‘Activation’ links. Click ‘Activate’ and you’re done! You’ll see the new “Reverb Help” menu on the top left.

Leon.

WordPress Custom Fields Plugin Review

I’m sad to say that despite using WordPress for ages now, I’ve only recently got into using custom fields. I can see myself using them a lot more now! Very handy things altogether.. For a recent web project, the client needed visitors to be able to register for the site and submit specific information about themselves while doing so. I needed an easy way to add questions and form fields to the existing WordPress registration form and also to make these fields available and editible to users who were logged in and wanted to change their profile info.

wordpress-custom-fields-plugin

I done a general Google search for such a plugin and there are many but I remembered seeing one on the Tribulant site whose excellent plugins I’ve used before and been happy with so ‘better the devil you know’! Tribulant’s Custom Field plugin is a commercial one but costs only $14.99 for a single site licence ($74.95 for developer/multi site) so I bought without testing, confident that it would live up to expectations and it did.

Here’s a run down on what the plugin can do:

  • Add Multiple fields to the Wordpres Registration Form,
  • Add fields to the ‘Edit Profile’ admin screen,
  • Field Validation,
  • Drah and Drop Field Ordering,
  • Add Multiple Field Types including:
  • Text,
  • List,
  • Drop Down,
  • File Upload,
  • Country List,
  • Text Area,
  • Radio Button
  • Date picker,

The standout feature for me was probably support for different field types. Predefined Country and date picker fields are also very handy as was the ability to order fields. Of course, data entered in any additional custom fields can also be used and displayed on the site front end giving endless possibilities for data display, ie – creating a business directory using WordPress in which companies submit their business info on registration and have it displayed on the site.

Here’s an example of a site I built using this plugin in conjunction with some others – www.RecruitAuto.ie

Demos, Documentation and Support HERE.

Get the plugin HERE.

Leon.

Secure WordPress Using Authentication Keys

Here’s how to better secure your WordPress installation by adding some unique authentication keys to the wp-config.php file. You’ll find this file in the root WordPress directory and it’s a file that governs some of the main and most important settings in any WordPress installation. Without it WordPress can’t function. Spammers and hackers know this and it’s one of the more attacked files so here’s how to secure it a bit.

Open up wp-config.php in a HTML editor and look for the following set of definitions:

define(‘AUTH_KEY’,         ‘put your unique phrase here’);
define(‘SECURE_AUTH_KEY’,  ‘put your unique phrase here’);
define(‘LOGGED_IN_KEY’,    ‘put your unique phrase here’);
define(‘NONCE_KEY’,        ‘put your unique phrase here’);
define(‘AUTH_SALT’,        ‘put your unique phrase here’);
define(‘SECURE_AUTH_SALT’, ‘put your unique phrase here’);
define(‘LOGGED_IN_SALT’,   ‘put your unique phrase here’);
define(‘NONCE_SALT’,       ‘put your unique phrase here’);

Go to the official WordPress Secret Key Generator https://api.wordpress.org/secret-key/1.1/salt/ and refresh to generate some random secret keys. Carefully copy and paste the given key values into the corresponding definitions above, replacing put your unique phrase here.

You can change these values as often as you like without consequence.

Leon.