I was hoping to use the eventorganiser_ical_description
filter to add a bunch of content to event descriptions in the calendar feed. Is there a way to add line breaks when using this filter without having to modify ical.php?
I noticed that eventorganiser_escape_ical_text()
is removing my \n
‘s. But there is a note in the code that says:
An intentional formatted text line break MUST only be included in a “TEXT” property value by representing the line break with the character sequence of BACKSLASH (US-ASCII decimal 92), followed by a LATIN SMALL LETTER N (US-ASCII decimal 110) or a LATIN CAPITAL LETTER N (US-ASCII decimal 78), that is “\n” or “\N”.
Unfortunately, that ^ doesn’t make sense to me… Does it mean that somehow I should be able to use \n
‘s? How exactly is that done?
Thanks!
Dan Brubaker
eventorganiser_escape_ical_text()
doesn’t remove the \n
is just escapes the backslash (otherwise it’ll appear as a new line in the feed itself – which you don’t want).
To add new lines:
add_filter('eventorganiser_ical_description', function(){
return 'Line one\n Line two';
});.
Incidentally if you find you need to modify ical.php
, copy it to your theme first, so that it’ll survive plug-in updates. The ical.php
template is like all the other templates in the plug-in – overridable by the theme.
Stephen Harris
Well, that is the behavior that I expected, but something still is not working right…is there a bug? I don’t know what I’m missing here.
This…
add_filter('eventorganiser_ical_description', function(){
return 'Line one\n Line two';
});
Outputs this in Apple Calendar’s event descriptions…
Line one\n Line two
Not this…
Line one
Line two
It only works when I comment out $description = eventorganiser_escape_ical_text( $description );
on line 129 in ical.php.
Dan Brubaker
Sorry, try
add_filter('eventorganiser_ical_description', function(){
return "Line one" . PHP_EOL . "Line two";
});
or using double quotes
add_filter('eventorganiser_ical_description', function(){
return "Line one \n Line two";
});
Stephen Harris