Instantly share code, notes, and snippets.
Last active
March 13, 2025 14:16
-
Star
0
(0)
You must be signed in to star a gist -
Fork
0
(0)
You must be signed in to fork a gist
-
Save goranefbl/75b72658afc383b5e1a7246dc0a3a34c to your computer and use it in GitHub Desktop.
hardoded sharing email
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Email Body for Email Share | |
* | |
* @see https://wpgens.com/docs/how-to-edit-template-files-and-keep-them-after-plugin-update/ | |
* @version 2.0.0 | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; // Exit if accessed directly | |
} | |
function get_email_text($key, $language) { | |
$email_text = array( | |
'en_GB' => array( | |
'heading' => '{{name}} offers you a discount of 10€ on h2o Taps', | |
'message' => 'Hey {{friend_name}},<br><br>I wanted to share this water filter with you—I\'ve tried their products and really like them!<br>Click the link below to get a<b> 10€ discount</b> on your first purchase.<br> Hope you find it useful!<br><br>Have a nice day <br>{{name}}', | |
'shop_now' => 'Shop Now' | |
), | |
'nl_NL' => array( | |
'heading' => '{{name}} biedt je een korting van 10€ op h2o Taps', | |
'message' => 'Hoi {{friend_name}},<br><br>Ik wilde deze waterfilter met je delen—ik heb hun producten geprobeerd en vind ze echt goed!<br>Klik op de link hieronder om een<b> 10€ korting</b> te krijgen op je eerste aankoop.<br> Hoop dat je het nuttig vindt!<br><br>Fijne dag<br>{{name}}', | |
'shop_now' => 'Shop Nu' | |
), | |
'fr_FR' => array( | |
'heading' => '{{name}} vous offre une réduction de 10€ sur h2o Taps', | |
'message' => 'Bonjour {{friend_name}},<br><br>Je voulais partager ce filtre à eau avec toi—j\'ai essayé leurs produits et je les aime vraiment !<br>Clique sur le lien ci-dessous pour obtenir une<b> réduction de 10€</b> sur ton premier achat.<br> J\'espère que tu le trouveras utile !<br><br>Bonne journée<br>{{name}}', | |
'shop_now' => 'Acheter Maintenant' | |
), | |
'de_DE' => array( | |
'heading' => '{{name}} bietet dir einen Rabatt von 10€ auf h2o Taps', | |
'message' => 'Hallo {{friend_name}},<br><br>Ich wollte diesen Wasserfilter mit dir teilen—ich habe ihre Produkte ausprobiert und mag sie wirklich!<br>Klicke auf den Link unten, um einen<b> 10€ Rabatt</b> auf deinen ersten Einkauf zu erhalten.<br> Hoffe, du findest es nützlich!<br><br>Einen schönen Tag noch<br>{{name}}', | |
'shop_now' => 'Jetzt Einkaufen' | |
), | |
'it_IT' => array( | |
'heading' => '{{name}} ti offre uno sconto di 10€ su h2o Taps', | |
'message' => 'Ciao {{friend_name}},<br><br>Volevo condividere questo filtro per l\'acqua con te—ho provato i loro prodotti e mi piacciono davvero!<br>Clicca sul link qui sotto per ottenere uno<b> sconto di 10€</b> sul tuo primo acquisto.<br> Spero che tu lo trovi utile!<br><br>Buona giornata<br>{{name}}', | |
'shop_now' => 'Acquista Ora' | |
), | |
'es_ES' => array( | |
'heading' => '{{name}} te ofrece un descuento de 10€ en h2o Taps', | |
'message' => 'Hola {{friend_name}},<br><br>Quería compartir este filtro de agua contigo—¡He probado sus productos y realmente me gustan!<br>Haz clic en el enlace de abajo para obtener un<b> descuento de 10€</b> en tu primera compra.<br> ¡Espero que te resulte útil!<br><br>Que tengas un buen día<br>{{name}}', | |
'shop_now' => 'Comprar Ahora' | |
) | |
); | |
if (isset($email_text[$language]) && isset($email_text[$language][$key])) { | |
return $email_text[$language][$key]; | |
} | |
// Fallback to English if translation not found | |
return isset($email_text['en_GB'][$key]) ? $email_text['en_GB'][$key] : "Text not found for key: $key"; | |
} | |
// Get current language using WordPress locale | |
$current_language = get_locale(); | |
// For order-specific emails, you might want to use this function instead | |
function get_order_language($order_id) { | |
$trp_order_language = get_post_meta($order_id, 'trp_language', true); | |
return $trp_order_language ? $trp_order_language : get_locale(); | |
} | |
// Uncomment and use this if it's an order-specific email | |
// if (isset($order_id)) { | |
// $current_language = get_order_language($order_id); | |
// } | |
?> | |
<tbody> | |
<?php if(!$use_woo_template) { ?> | |
<tr> | |
<td style="background-color:<?php echo $color;?>;font-size:1px;line-height:3px" class="topBorder" height="3"> </td> | |
</tr> | |
<tr> | |
<td style="font-size:1px;line-height:1px" height="50"> </td> | |
</tr> | |
<?php } ?> | |
<tr> | |
<td align="center" valign="top" style="padding-bottom:40px" class="imgHero"> | |
<a href="#" style="text-decoration:none" target="_blank"> | |
<img alt="<?php echo esc_attr(get_email_text('heading', $current_language)); ?>" border="0" src="<?php echo WPGENS_RAF_URL. 'assets/img/hand.png'; ?>" style="width:100%;max-width:300px;height:auto;display:block" width="300"> | |
</a> | |
</td> | |
</tr> | |
<tr> | |
<td align="center" valign="top" style="padding-bottom:5px;padding-left:20px;padding-right:20px" class="title"> | |
<h2 class="bigTitle" style="color:#313131;font-family:'Open Sans',Helvetica,Arial,sans-serif;font-size:26px;font-weight:600;font-style:normal;letter-spacing:normal;line-height:34px;text-align:center;padding:0;margin:0"> | |
<?php echo get_email_text('heading', $current_language); ?> | |
</h2> | |
</td> | |
</tr> | |
<tr> | |
<td style="font-size:1px;line-height:1px" height="25"> </td> | |
</tr> | |
<tr> | |
<td align="center" valign="top" style="padding-left:20px;padding-right:20px" class="subTitle"> | |
<p style="font-family:'Open Sans',Helvetica,Arial,sans-serif;font-size:16px;font-weight:400;font-style:normal;letter-spacing:normal;line-height:24px;text-align:left;padding:0;margin:0;"> | |
<?php echo get_email_text('message', $current_language); ?> | |
</p> | |
</td> | |
</tr> | |
<tr> | |
<td style="font-size:1px;line-height:1px" height="30"> </td> | |
</tr> | |
<tr> | |
<td align="center" valign="top" style="padding-bottom:5px;padding-left:20px;padding-right:20px" class="btnCard"> | |
<table border="0" cellpadding="0" cellspacing="0" align="center"> | |
<tbody> | |
<tr> | |
<td align="center" width="200" height="40" bgcolor="<?php echo $color;?>" style="-webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; color: #ffffff; display: block;"> | |
<a href="<?php echo esc_url($refLink); ?>" style="font-size:16px; font-weight: bold; font-family: Helvetica, Arial, sans-serif; text-decoration: none; text-transform:uppercase;line-height:40px; width:100%; display:inline-block"> | |
<span style="color: #FFFFFF"> | |
<?php echo get_email_text('shop_now', $current_language); ?> | |
</span> | |
</a> | |
</td> | |
</tr> | |
</tbody> | |
</table> | |
</td> | |
</tr> | |
<tr> | |
<td style="font-size:1px;line-height:1px" height="50"> </td> | |
</tr> | |
</tbody> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment