在WordPress函数中添加target=blank用于WP-Members。

huangapple go评论55阅读模式
英文:

Add target=blank in WordPress function for WP-Members

问题

如何使这段代码在返回时添加 target=_blank,以便用户单击后会被重定向?

add_filter( 'wpmem_forgot_link', 'my_forgot_link', 10, 2 );
function my_forgot_link( $link, $tag ) {
    // 使用 home_url() 代替可以使您的过滤器更具可移植性。
    return &#39;<a href="http://test.com/wp-login.php?action=lostpassword" target="_blank">忘记密码</a>&#39;;
}
英文:

How make this code add target=_blank on return, so when user clicks they will be redirected?

add_filter( &#39;wpmem_forgot_link&#39;, &#39;my_forgot_link&#39;, 10, 2 );
function my_forgot_link( $link, $tag ) {
    // Using home_url() instead makes your filter portable.
    return &#39;http://test.com/wp-login.php?action=lostpassword&#39;;
}

答案1

得分: 0

你应该使用wpmem_forgot_link_str挂钩,这将允许你向生成的HTML中添加target=&quot;blank&quot;

需要的示例代码如下:

add_filter( 'wpmem_forgot_link_str', 'my_forgot_link_str', 10, 2 );
function my_forgot_link_str( $str, $link ) {
	return "<a href=\"$link\" target=\"blank\">忘记密码?</a>";
}
英文:

You should be using the wpmem_forgot_link_str hook instead, which would allow you to add target=&quot;blank&quot; to the HTML being generated.

An example of what you'd need:

add_filter( &#39;wpmem_forgot_link_str&#39;, &#39;my_forgot_link_str&#39;, 10, 2 );
function my_forgot_link_str( $str, $link ) {
	return &quot;&lt;a href=\&quot;$link\&quot; target=\&quot;blank\&quot;&gt;Forgot your password?&lt;/a&gt;&quot;;
}

</details>



huangapple
  • 本文由 发表于 2023年3月1日 11:16:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/75599263.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定