Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save RafaelFunchal/33e45a59568ae0e15051 to your computer and use it in GitHub Desktop.
Save RafaelFunchal/33e45a59568ae0e15051 to your computer and use it in GitHub Desktop.
Shortcode to insert a link to undo the action when someone unsubscribed
<?php
/**
* function to return an undo unsbscribe string for MailPoet newsletters
* you could place it in the functions.php of your theme
* @return string
*/
function mpoet_get_undo_unsubscribe(){
if(class_exists('WYSIJA') && !empty($_REQUEST['wysija-key'])){
$undo_paramsurl = array(
'wysija-page'=>1,
'controller'=>'confirm',
'action'=>'undounsubscribe',
'wysija-key'=>$_REQUEST['wysija-key']
);
$model_config = WYSIJA::get('config','model');
$link_undo_unsubscribe = WYSIJA::get_permalink($model_config->getValue('confirmation_page'),$undo_paramsurl);
$undo_unsubscribe = str_replace(
array('[link]','[/link]'),
array('<a href="'.$link_undo_unsubscribe.'">','</a>'),
'<p><b>'.__('You made a mistake? [link]Undo unsubscribe[/link].',WYSIJA)).'</b></p>';
return $undo_unsubscribe;
}
return '';
}
// will replace the shortcode [mailpoet_undo_unsubscribe]
add_shortcode('mailpoet_undo_unsubscribe', 'mpoet_get_undo_unsubscribe');
// echo the link directly in your theme if you like
echo mpoet_get_undo_unsubscribe();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment