While we believe security should be an entitlement for Web hosting customers, and that every hosting provider should go above and beyond PCI compliance, I do believe individual site owners should take a level of responsibility, and add another set of eyes as it relates to their own Web site.

Today, I would like to walk you through an easy to use WordPress plugin that will display any PHP errors for your WordPress site in your WordPress dashboard. Why is this necessary?

When I read the well written article, What Lurks in the WordPress Plugin Repository? the part about “85% of the plugins I tested had PHP warnings, errors and notices” stood out as something which a site owner can easily tackle compared to others.

Maybe not in terms of being able to fix any errors, but on the Internet, what you don’t know can hurt you. So why not be “in the know,” and at least be able to know there are errors, potentially contact the plugin author, or at least be able to make a decision, based on the errors, to remove a plugin or several and move on to something that works better?

PHP Errors Widget is a relatively easy to set up and use plugin that helps WordPress site owners and administrators to easily see if there are PHP errors on their site from the comfort of the WordPress dashboard.

Install the plugin, activate it.

Now, before going to settings, PHP Errors Widget, first let’s do some server side work which you can do via your favorite FTP client.

Download your .htaccess file from your HTML document root to your personal computer; and edit the file with a text editor of choice; if you use Windows XP or 7, I recommend WordPad.

Add the following lines (replacing only the line dealing with the location of your PHP error log):

### php error handling
### http://perishablepress.com/press/2008/01/30/advanced-php-error-handling-via-php/php_error.log

# disable display of startup errors
php_flag display_startup_errors false
# disable display of all other errors
php_flag display_errors false
# disable html markup of errors
php_flag html_errors false
# enable logging of errors
php_flag log_errors true
# disable ignoring of repeat errors
php_flag ignore_repeated_errors false
# disable ignoring of unique source errors
php_flag ignore_repeated_source false
# enable logging of php memory leaks
php_flag report_memleaks true
# preserve most recent error via php_errormsg
php_flag track_errors true
# disable formatting of error reference links
php_flag docref_root 0
# disable formatting of error reference links
php_flag docref_ext 0
# specify path to php error log
php_flag error_log [FULL PATH to where your site stores error logs]/php_error.log
# specify recording of all php errors
php_flag error_reporting 999999999
# disable max error string length
php_flag log_errors_max_len 0

# prevent access to PHP error log
<Files php_error.log>
Order allow,deny
Deny from all
Satisfy All

You will need to create the php_error.log file in a location where your web site stores log files. If you are one of our managed hosting customers, then this would be at /hsphere/local/home/[your control panel user id]/logs/[your domain name]/php_error.log where you would create php_error.log (empty file) in the /hsphere/local/home/[your control panel user id]/logs/[your domain name] directory or ask us to create it for you.

Once that’s done, in WordPress as the administrator, go to settings, PHP Error Widget and enter the full path to the location of the php_error.log and click on the save options button.

Then go to your WordPress dashboard. If there is a problem with the php_error.log path, it will show up in the dashboard. The path (directory structure) and file must exist; if you have problems in this area, contact your hosting provider support team to help you with the path or file; otherwise, double check your work.

If you see errors, then it will be a combination of working with your hosting provider technical support team and the author(s) of the plugins causing the error. While chances are high, only the plugin author can fix the problem, if you are not sure of the plugin or cause, your hosting provider technical support team should be able to help you track it down.

On a well run WordPress site, you should have zero (0) php errors.