login_footer()
云策文档标注
概述
login_footer() 函数用于输出 WordPress 登录页面的页脚内容,包括一个可选的“返回站点”链接。该函数接受一个参数来控制自动聚焦的输入框,并包含一个过滤器以允许自定义链接。
关键要点
- login_footer() 输出登录页面的页脚,默认显示一个指向网站首页的链接。
- 参数 $input_id 用于指定自动聚焦的输入框 ID,默认为空字符串。
- 函数内部使用全局变量 $interim_login 来判断是否为临时登录,临时登录时不显示导航链接。
- 通过 login_site_html_link 过滤器可以自定义“返回站点”链接的 HTML 输出。
代码示例
function login_footer( $input_id = '' ) {
global $interim_login;
// Don't allow interim logins to navigate away from the page.
if ( ! $interim_login ) {
?>
<p id="backtoblog">
<?php
$html_link = sprintf(
'<a href="%s">%s</a>',
esc_url( home_url( '/' ) ),
sprintf(
/* translators: %s: Site title. */
_x( '← Go to %s', 'site' ),
get_bloginfo( 'title', 'display' )
)
);
/**
* Filters the "Go to site" link displayed in the login page footer.
*
* @since 5.7.0
*
* @param string $link HTML link to the home URL of the current site.
*/
echo apply_filters( 'login_site_html_link', $html_link );
?>
</p>
<?php
}
}注意事项
- 该函数主要用于 wp-login.php 页面,开发者不应直接调用,除非在自定义登录页面中需要类似功能。
- 使用过滤器时,确保返回的链接是安全的,避免 XSS 攻击。
原文内容
Outputs the footer for the login page.
Parameters
$input_idstringrequired-
Which input to auto-focus.
Source
function login_footer( $input_id = '' ) {
global $interim_login;
// Don't allow interim logins to navigate away from the page.
if ( ! $interim_login ) {
?>
%s',
esc_url( home_url( '/' ) ),
sprintf(
/* translators: %s: Site title. */
_x( '← Go to %s', 'site' ),
get_bloginfo( 'title', 'display' )
)
);
/**
* Filters the "Go to site" link displayed in the login page footer.
*
* @since 5.7.0
*
* @param string $link HTML link to the home URL of the current site.
*/
echo apply_filters( 'login_site_html_link', $html_link );
?>
', '