函数文档

the_privacy_policy_link()

💡 云策文档标注

概述

the_privacy_policy_link() 函数用于在 WordPress 主题中输出格式化的隐私政策链接,适用于需要显示隐私政策页面的场景。它通过调用 get_the_privacy_policy_link() 实现,并允许自定义链接前后的文本。

关键要点

  • 函数用于显示隐私政策链接,带格式化输出,仅在适用时显示
  • 接受两个可选参数:$before(链接前文本)和 $after(链接后文本),默认均为空字符串
  • 内部调用 get_the_privacy_policy_link() 函数来获取链接
  • 首次引入于 WordPress 4.9.6 版本
  • 相关函数包括 get_the_privacy_policy_link() 和 login_footer()

代码示例

if ( function_exists( 'the_privacy_policy_link' ) ) {
    the_privacy_policy_link( '<p>', '</p>' );
}

注意事项

  • 建议使用 function_exists() 检查函数是否存在,以避免在旧版本 WordPress 中引发致命错误
  • 输出示例为 HTML 链接,如 <a href="https://example.com/privacy-policy/" rel="nofollow ugc">Privacy Policy</a>

📄 原文内容

Displays the privacy policy link with formatting, when applicable.

Parameters

$beforestringoptional
Display before privacy policy link. Default empty.
$afterstringoptional
Display after privacy policy link. Default empty.

Source

function the_privacy_policy_link( $before = '', $after = '' ) {
	echo get_the_privacy_policy_link( $before, $after );
}

Changelog

Version Description
4.9.6 Introduced.

User Contributed Notes

  1. Skip to note 2 content

    Sample code for theme integration, with function_exists() test to avoid fatal error on previous WordPress versions.

    ', '</div>' );
    }
    ?>

    HTML output example (the permalink and the anchor will be dynamically generated):

    <div class="privacy-policy-link-wrapper">
    	<a class="privacy-policy-link" href="<a href="https://example.com/privacy-policy/">Privacy" rel="nofollow ugc">https://example.com/privacy-policy/">Privacy</a> Policy</a>
    </div>