fbpx
/** throw this in your child theme's "functions.php" file
* Encode an email address to display on your website
* converts the address to ASCII character codes
* that the browser displays fine but most spambots can't decipher.
*
* usage: [encode_email email="you@yourdomain.com"]
*
*/
add_shortcode('encode_email','encode_email_address');
function encode_email_address( $atts ) {
	$atts = shortcode_atts(
		array(
			'email' => false,
		), $atts, 'encode_email');
	extract($atts);
	if(!$email) return;
	$output = '';
	for ($i = 0; $i < strlen($email); $i++) {
		$output .= '&#'.ord($email[$i]).';'; 
	}
	return $output;
}