-
-
Save koop-bremen/d30bea0325efdc2c0bf0 to your computer and use it in GitHub Desktop.
kirbytext: email with subject and body with linebreaks (\n)
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 | |
kirbytext::$tags['email'] = array( | |
'attr' => array( | |
'text', | |
'subject', | |
'body' | |
), | |
'html' => function($tag) { | |
$email = $tag->attr('email'); | |
$text = $tag->attr('text', $email); | |
$subject = rawurlencode($tag->attr('subject',null)); | |
$body = $tag->attr('body',null); | |
$body = rawurlencode(str_replace('\n', "\n", $body)); | |
$query = ($subject || $body) ? '?' : ''; | |
$query .= ($subject) ? 'subject='.$subject : ''; | |
$query .= ($subject && $body) ? '&' : ''; | |
$query .= ($body) ? 'body='.$body : ''; | |
return '<a href="mailto:'.$email.$query.'">'.$text.'</a>'; | |
} | |
); |
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
(email: [email protected] subject: reserve tickets body: Hi!\n I need the following tickets:\n\n\nBest,\n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment