Skip to content

Instantly share code, notes, and snippets.

@benheu
Last active August 29, 2015 13:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save benheu/0f32277338dafb4d2ee5 to your computer and use it in GitHub Desktop.
Save benheu/0f32277338dafb4d2ee5 to your computer and use it in GitHub Desktop.
Generate a undo unsubscribe link to display in my theme
<?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('unsubscribe_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