Forked from benheu/undo_unsubscribe_shortcode.php
Last active
August 29, 2015 14:03
-
-
Save RafaelFunchal/33e45a59568ae0e15051 to your computer and use it in GitHub Desktop.
Shortcode to insert a link to undo the action when someone unsubscribed
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 | |
/** | |
* 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