get_the_privacy_policy_link

函数
get_the_privacy_policy_link ( $before = '', $after = '' )
参数
  • (string) $before Optional. Display before privacy policy link. Default empty.
    Required:
    Default: (empty)
  • (string) $after Optional. Display after privacy policy link. Default empty.
    Required:
    Default: (empty)
返回值
  • (string) Markup for the link and surrounding elements. Empty string if it doesn't exist.
定义位置
相关方法
the_privacy_policy_linkget_privacy_policy_urlget_privacy_policy_templateget_the_permalinkis_privacy_policy
引入
4.9.6
弃用
-

get_the_privacy_policy_link: 这个函数返回当前网站的隐私政策链接。

在适用情况下,返回带有格式化的隐私政策链接。

function get_the_privacy_policy_link( $before = '', $after = '' ) {
	$link               = '';
	$privacy_policy_url = get_privacy_policy_url();
	$policy_page_id     = (int) get_option( 'wp_page_for_privacy_policy' );
	$page_title         = ( $policy_page_id ) ? get_the_title( $policy_page_id ) : '';

	if ( $privacy_policy_url && $page_title ) {
		$link = sprintf(
			'<a class="privacy-policy-link" href="%s">%s</a>',
			esc_url( $privacy_policy_url ),
			esc_html( $page_title )
		);
	}

	/**
	 * Filters the privacy policy link.
	 *
	 * @since 4.9.6
	 *
	 * @param string $link               The privacy policy link. Empty string if it
	 *                                   doesn't exist.
	 * @param string $privacy_policy_url The URL of the privacy policy. Empty string
	 *                                   if it doesn't exist.
	 */
	$link = apply_filters( 'the_privacy_policy_link', $link, $privacy_policy_url );

	if ( $link ) {
		return $before . $link . $after;
	}

	return '';
}

常见问题

FAQs
查看更多 >