Skip to content

Commit 63663f2

Browse files
Allow shortcodes in Person Mail/Phone fields
1 parent e12c176 commit 63663f2

5 files changed

Lines changed: 35 additions & 4 deletions

File tree

wordpress/wp-content/themes/les-verts/acf-json/group_5b6c0884eb9b8.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"key": "field_5b6c097794180",
7070
"label": "Email",
7171
"name": "email",
72-
"type": "email",
72+
"type": "text",
7373
"instructions": "",
7474
"required": 0,
7575
"conditional_logic": 0,

wordpress/wp-content/themes/les-verts/acf-translate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6173,7 +6173,7 @@
61736173
'label' => __( 'Email', 'lesverts' ),
61746174
'name' => 'email',
61756175
'aria-label' => '',
6176-
'type' => 'email',
6176+
'type' => 'text',
61776177
'instructions' => '',
61786178
'required' => 0,
61796179
'conditional_logic' => 0,

wordpress/wp-content/themes/les-verts/lib/_loader.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@
222222
require_once __DIR__ . '/twig/functions/image-handling.php';
223223

224224
// filters
225+
require_once __DIR__ . '/twig/filters/shortcode.php';
225226
require_once __DIR__ . '/twig/filters/email.php';
226227
require_once __DIR__ . '/twig/filters/phone.php';
227228
require_once __DIR__ . '/twig/filters/social_link.php';
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace SUPT;
4+
5+
use Twig\TwigFilter;
6+
7+
add_filter( 'get_twig', function ( $twig ) {
8+
$twig->addFilter(
9+
new TwigFilter( 'shortcode', function ( $string ) {
10+
if ( ! empty( $string ) && is_string( $string ) ) {
11+
return do_shortcode( $string );
12+
}
13+
return $string;
14+
} )
15+
);
16+
17+
return $twig;
18+
} );

wordpress/wp-content/themes/les-verts/templates/atoms/a-contact.twig

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
{% if 'email' == acf_fc_layout %}
2-
<a href="{{email|email|hexencode}}" class="a-contact a-contact--email">{{email|hexencode}}</a>
2+
{% if '[' in email %}
3+
{# Shortcode detected - let plugin handle everything #}
4+
<div class="a-contact a-contact--email">{{email|shortcode|raw}}</div>
5+
{% else %}
6+
{# Plain email - create normal link #}
7+
<a href="{{email|email|hexencode}}" class="a-contact a-contact--email">{{email|hexencode}}</a>
8+
{% endif %}
39
{% endif %}
410

511
{% if 'phone' == acf_fc_layout %}
6-
<a href="{{phone|phone}}" class="a-contact a-contact--phone">{{phone}}</a>
12+
{% if '[' in phone %}
13+
{# Shortcode detected - let plugin handle everything #}
14+
<div class="a-contact a-contact--phone">{{phone|shortcode|raw}}</div>
15+
{% else %}
16+
{# Plain phone - create normal link #}
17+
<a href="{{phone|phone}}" class="a-contact a-contact--phone">{{phone}}</a>
18+
{% endif %}
719
{% endif %}
820

921
{% if 'website' == acf_fc_layout %}

0 commit comments

Comments
 (0)