I am trying to create add-to-calendar links using shortcode. However when using return
following shortcode function outputs a broken link. (echo
does not!). Wordpress documentation recommends using return
and I am worried if echo
, even when it works, is the safe way of doing this.
<?php
add_shortcode('calendar-links', 'shortcode_function');
shortcode_function (){
$link = '<a href="data:text/calendar;charset=utf8;base64,QkVHSU46VkNBTEVOREFSDQpWRVJTSU...">Download</a>';
return $link;
}
The output of return
is as below:
<a href="https://localhost/text/calendar;charset=utf8;base64,QkVHSU46VkNBTEVOREFSDQpWRVJTSU...">Download</a>
I am assuming the shortcode output is going through some kind of sanitisation, but unable to find a fix for it. Also, if it helps, the shortcode is being outputted using an Elementor shortcode widget.
data
is not in the list of allowed protocols. Try addingdata
to that list per filter. Does that work?