The following function takes some nightmarish Word HTML and return a clean HTML output that you can use safely on the web. function cleanHTML($html) { $html = ereg_replace("<(/)?(font|span|del|ins)[^>]*>","",$html); $html = ereg_replace("<([^>]*)(class|lang|style|size|face)=("[^"]*"|'[^’]*’|[^>]+)([^>]*)>","<\1>",$html); $html = ereg_replace("<([^>]*)(class|lang|style|size|face)=("[^"]*"|’[^’]*’|[^>]+)([^>]*)>","<\1>",$html); return $html }
Category: Fixes
Obfuscate email addresses
As most of you know, spam bots are constantly scanning the internet in order to find emails to spam. Of course, you don’t want to receive spam, but what if you need to display your email (or someone else) on your blog? This code will create a shortcode which will obfuscate email adresses. As usual,… Continue reading Obfuscate email addresses
Block spam via .htaccess
RewriteEngine On RewriteCond %{REQUEST_METHOD} POST RewriteCond %{REQUEST_URI} .wp-comments-post\.php* RewriteCond %{HTTP_REFERER} !.*yourdomainname.com.* [OR] RewriteCond %{HTTP_USER_AGENT} ^$ RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L]
Fix a Fatal Memory Error
If you see this error either suddenly (no specific task was done to cause the error) or frequently, try deactivating all plugins to rule-out a plugin-specific issue and try switching themes to rule-out a theme-specific issue. Specific fixes: 1. If you’re using WordPress 2.9.2 or lower, try adding define(‘WP_MEMORY_LIMIT’, ‘256M’); to your wp-config.php file. If… Continue reading Fix a Fatal Memory Error