here. You may enable graceful Javascript degradation in the settings page. This will also escape emails used in comments if they use this shortcode. It will ONLY enable this shortcode for comments for security purposes. Author: Adam Hunter Version: 1.20 Author URI: http://blueberryware.net */ class emailEscape { /** * determines whether or not to degrade gracefull if javascript is not enabled * * @var bool */ var $degrade; var $wraps = array( array('[', ']'), array('{', '}'), array(':', ':'), array('<', '>'), array('«', '»'), array('‹', '›') ); /** * sets up options for escaping email, is run at init action hook */ function init() { add_option('email_js_degrade', false); $this->degrade = get_option('email_js_degrade'); if ( $this->degrade ) { wp_enqueue_script('jquery'); } add_shortcode('escapeemail', array($this, 'run')); add_filter('comment_text', array($this, 'comments')); add_action('admin_menu', array($this, 'link')); } /** * Removes all registered shortcodes, adds the emailescape shortcode, runs, * then restores all other shortcodes. This is meant for applying a shortcode to * comment_text, but not allowing any other shortcodes that may be registered to run * * @param string $content * @return string */ function comments($content) { global $shortcode_tags; $saved_shortcodes = $shortcode_tags; $shortcode_tags = array('escapeemail' => array($this, 'run')); $pattern = get_shortcode_regex(); $return = preg_replace_callback('/'.$pattern.'/s', 'do_shortcode_tag', $content); $shortcode_tags = $saved_shortcodes; return $return; } /** * Creates url encoded javascript powered link to email address * * @param array $atts * @return string */ function run($atts) { extract($atts); if ( empty($email) ) { return; } $text = str_replace('@', ' at ', $email); $text = str_replace('.', ' dot ', $text); $string = 'document.write(\'' . $text . '\')'; /* break string into array of characters, we can't use string_split because its php5 only :( */ $split = preg_split('||', $string); $out = ''; /* if degrading is enabled, create span with text and js to remove text */ if ( $this->degrade ) { $wrap = $this->wraps[array_rand($this->wraps)]; $at = ' ' . $wrap[0] . 'at' . $wrap[1] . ' '; $dot = ' ' . $wrap[0] . 'dot' . $wrap[1] . ' '; $text = str_replace('@', $at, $email); $text = str_replace('.', $dot, $text); $html = '' . $text . '' . ''; $out .= $html; } return $out; } function link() { add_options_page(__('Email Spam Protection Options'), __('Email Spam Proction'), 'manage_options', 'email-escape', array($this, 'options') ); } function options() { ?> save() ) { ?>

You have saved your Email Spam Protection Options :)

save() ) */ ?>

Email Spam Protection Options

degrade = true; } else { update_option('email_js_degrade', false); $this->degrade = false; } return true; } } $emailescape = new emailEscape(); add_action('init', array($emailescape, 'init'));