Last active
August 29, 2015 13:56
-
-
Save Da-Fecto/9143218 to your computer and use it in GitHub Desktop.
Emailaddress to mailto link
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 characters
<?php | |
/** | |
* ProcessWire Emailaddress mailto link | |
* | |
* ProcessWire 2.x | |
* Copyright (C) 2010 by Ryan Cramer | |
* Licensed under GNU/GPL v2, see LICENSE.TXT | |
* | |
* http://www.processwire.com | |
* http://www.ryancramer.com | |
* | |
*/ | |
class TextformatterEmail extends Textformatter { | |
public static function getModuleInfo() { | |
return array( | |
'title' => 'Emailaddress to mailto links', | |
'version' => 1, | |
'summary' => "Converts emailaddresses to mailto links.", | |
); | |
} | |
public function format(&$str) { | |
$str = preg_replace('/([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6})/', '<a href="mailto:$1">$1</a>', $str); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment