Last active
August 29, 2015 14:18
-
-
Save milesleif/7cecf92c749a3d754918 to your computer and use it in GitHub Desktop.
Revisions
-
milesleif revised this gist
Apr 2, 2015 . 1 changed file with 21 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ // used by encode_emails // available in wp-core function antispambot( $email_address, $hex_encoding = 0 ) { $email_no_spam_address = ''; for ( $i = 0; $i < strlen( $email_address ); $i++ ) { $j = rand( 0, 1 + $hex_encoding ); if ( $j == 0 ) { $email_no_spam_address .= '&#' . ord( $email_address[$i] ) . ';'; } elseif ( $j == 1 ) { $email_no_spam_address .= $email_address[$i]; } elseif ( $j == 2 ) { $email_no_spam_address .= '%' . zeroise( dechex( ord( $email_address[$i] ) ), 2 ); } } $email_no_spam_address = str_replace( '@', '@', $email_no_spam_address ); return $email_no_spam_address; } -
milesleif renamed this gist
Apr 2, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
milesleif created this gist
Apr 2, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ function encode_emails($string){ $pattern = "/[a-z0-9_\-\+]+@[a-z0-9\-]+\.([a-z]{2,3})(?:\.[a-z]{2})?/i"; preg_match_all($pattern, $string, $split); foreach ($split[0] as $value) { $clean_value = antispambot($value); $string = str_replace($value, $clean_value ,$string); } return $string; }