英文:
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 '<a href="http://test.com/wp-login.php?action=lostpassword" target="_blank">忘记密码</a>';
}
英文:
How make this code add target=_blank
on return, so when user clicks they will be redirected?
add_filter( 'wpmem_forgot_link', 'my_forgot_link', 10, 2 );
function my_forgot_link( $link, $tag ) {
// Using home_url() instead makes your filter portable.
return 'http://test.com/wp-login.php?action=lostpassword';
}
答案1
得分: 0
你应该使用wpmem_forgot_link_str
挂钩,这将允许你向生成的HTML中添加target="blank"
。
需要的示例代码如下:
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="blank"
to the HTML being generated.
An example of what you'd need:
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\">Forgot your password?</a>";
}
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论