edit subscription form + save

This commit is contained in:
Jonathan Labreuille
2016-03-03 15:57:42 +01:00
parent 85995bc8a6
commit 4b528549f5
13 changed files with 302 additions and 146 deletions

55
lib/Util/Url.php Normal file
View File

@ -0,0 +1,55 @@
<?php
namespace MailPoet\Util;
class Url {
function __construct() {
}
static function getCurrentUrl() {
global $wp;
return home_url(
add_query_arg(
$wp->query_string,
$wp->request
)
);
}
static function redirectTo($url = null) {
wp_safe_redirect($url);
exit();
}
static function redirectBack() {
$referer = (isset($_REQUEST['mailpoet_redirect'])
? $_REQUEST['mailpoet_redirect']
: null
);
if($referer === null) {
// try to get the server's referer
if(!empty($_SERVER['HTTP_REFERER'])) {
$referer = $_SERVER['HTTP_REFERER'];
}
}
if($referer !== null) {
self::redirectTo($referer);
}
exit();
}
static function redirectWithReferer($url = null) {
$current_url = self::getCurrentUrl();
$url = add_query_arg(
array(
'mailpoet_redirect' => urlencode($current_url)
),
$url
);
if($url !== $current_url) {
self::redirectTo($url);
}
exit();
}
}