Hi,
I have created a Kirbytext filter for an email address. It works fine if I add the email address in the config file, but I would like to use the value from the site settings instead.
This works:
c::set('kirbytext.snippets', array(
'email' => 'person@email.com',
));
This doesn’t:
c::set('kirbytext.snippets', array(
'email' => $site->email(),
));
It gives me a blank screen, indicating a PHP error.
I have tried replacing the email value in the plugin file like this:
kirbytext::$pre[] = function($kirbytext, $value) {
$snippets = c::get('kirbytext.snippets', array());
$values = array_values($snippets);
$keys = array_map(function($key) {
$key = $site()->phone()->email();
return '{{' . $key . '}}';
}, array_keys($snippets));
return str_replace($keys, $values, $value);
};
But that gives an error too.
Any ideas what I am doing wrong?
Thanks in advance.