Skip to content

Instantly share code, notes, and snippets.

@Da-Fecto
Last active August 29, 2015 13:56
Show Gist options
  • Save Da-Fecto/9143218 to your computer and use it in GitHub Desktop.
Save Da-Fecto/9143218 to your computer and use it in GitHub Desktop.
Emailaddress to mailto link
<?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