Tuesday, January 29, 2013

WordPress | Enable error handling

Production handling

- create theme's 404.php
- create theme's 500.php

htcaccess file or IIS CGI configuration error page location:
ErrorDocument 404 /index.php?error=404
ErrorDocument 500 /wp-content/themes/theme_name/500.php

- for IIS, we should make an additional configuration to avoid *.php pages not to show "No input file specified."

Development handling

Edit wp-config.php, and add:

#enable debug to view warnings and errors in pages
define("WP_DEBUG", true);

#deactivate cron warnings
define('ALTERNATE_WP_CRON', true);

#PHP Warning:  fopen failed to open stream: HTTP request failed! class-http.php on line 921
#$handle = fopen($url, 'r', false, $context);

Check if server variable exists without crashing the page

        $userIP = $_SERVER['REMOTE_ADDR'];

No comments:

Post a Comment