Hi Team,
Experiencing strange behavour when using Dynamic Content with the Telephone link type.
I’m using an ACF fields but the same behaviour occurs with a hard coded string.
I store the number with whitespaces which is displayed on the frontend and remove whitespace for Phone link.
For example, create the following function
add_filter('cs_dynamic_content_phone_spaces', function ($result, $field, $args = array()) {
$strip = isset($args['strip']) ? true : false;
$phone = '+1 2 3 4 5';
$result = $strip ? preg_replace('/\s+/', '', $phone) : $phone;
return $result;
}, 10, 3);
Add a Headline Element and set the Content > Edit Text to {{dc:phone_spaces}} {{dc:phone_spaces strip="true"}}
This should render correctly, with whitespace removed when strip=“true”.
Then enable Link on the Headline Element, choose link type Phone and set to {{dc:phone_spaces strip="true"}}
. This will result in href="tel:%2B1%202%203%204%205"
being rendered on the <a>
tag.
The URL and Email types seem to work ok and strip the spaces, with URL removing the starting +
and Email preserving it.
I’ve found the same problem with the Div and Column element when using an <a>
tag. This is potentially a problem with all Elements that use the Link Types.