[英]How to get rid of ampersand using WP Nonce URL and WP Redirect or PHP header
My code was working fine:我的代码工作正常:
$registrado = "no";
$redirect_url = site_url( "/pedido-nao-recebido/?mpms2pagarme=retorno&codigo=nao200&mensagem=oui®istrado=$registrado");
wp_redirect($redirect_url);
exit;
With this, I was being redirected to有了这个,我被重定向到
http://s16138.p360.sites.pressdns.com/pedido-nao-recebido/?mpms2pagarme=retorno&codigo=nao200&mensagem=oui®istrado=no.
Exactly what I need.正是我需要的。
Then I decided to take a security measure, with wp_nonce_url
.然后我决定采取安全措施,使用
wp_nonce_url
。
$registrado = "no";
$redirect_url = site_url( "/pedido-nao-recebido/?mpms2pagarme=retorno&codigo=nao200&mensagem=oui®istrado=$registrado");
//WP Nonce (security measure)
$nonce_redirect_url = wp_nonce_url( $redirect_url, 'pedido-nao-recebido', 'mpms2nonce' );
wp_redirect($nonce_redirect_url);
exit;
Now I get this URL:现在我得到这个网址:
http://s16138.p360.sites.pressdns.com/pedido-nao-recebido/?mpms2pagarme=retorno&codigo=nao200&mensagem=oui&registrado=no&mpms2nonce=aeb5ba40d2.
Because of these amp;
因为这些
amp;
, my code is broke and browser gives me a The s16138.p360.sites.pressdns.com page isn't working
. ,我的代码
The s16138.p360.sites.pressdns.com page isn't working
了,浏览器给了我一个The s16138.p360.sites.pressdns.com page isn't working
。 There is a script on the redirected page that is not running.重定向页面上有一个未运行的脚本。 It goes like this:
它是这样的:
//If it is not a subscription request, abort...
if ( !isset( $_GET['mpms2pagarme'] ) || 'retorno' != $_GET['mpms2pagarme'] || !isset( $_GET['codigo'] ) || !isset( $_GET['mensagem'] ) ) {
return;
}
//Checking WP Nonce
check_admin_referer( 'pedido-nao-recebido', 'mpms2nonce' );
(...)
I tried using php header
function instead of wp_redirect
, but the same happened (ampersand).我尝试使用 php
header
函数而不是wp_redirect
,但发生了同样的事情(&符号)。 I tried also esc_url
, esc_url_raw
, urlencode
...with no success.我也试过
esc_url
、 esc_url_raw
、 urlencode
...但没有成功。
Strange thing... wp_redirect
(or header
) only works for me without wp_nonce_url
.奇怪的事情......
wp_redirect
(或header
)只适用于没有wp_nonce_url
我。 Should I get rid of the latter?我应该摆脱后者吗? Any other solution?
还有其他解决办法吗?
Thanks in advance.提前致谢。
You can use html_entity_decode()
to convert &
您可以使用
html_entity_decode()
来转换&
back to &
回到
&
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.