Last active
August 29, 2015 13:57
-
-
Save benheu/0f32277338dafb4d2ee5 to your computer and use it in GitHub Desktop.
Generate a undo unsubscribe link to display in my theme
This file contains hidden or 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 | |
/** | |
* 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