WordPress at a glance

get_the_privacy_policy_link() WP 1.0

Returns the privacy policy link with formatting, when applicable.

Is the basis for: the_privacy_policy_link()
Works based on: get_privacy_policy_url()
Hooks from the function
Return

String. Markup for the link and surrounding elements. Empty string if it doesn't exist.

Usage

get_the_privacy_policy_link( $before, $after );
$before(string)
Display before privacy policy link.
Default: ''
$after(string)
Display after privacy policy link.
Default: ''

Changelog

Since 4.9.6 Introduced.

Code of get the privacy policy link: wp-includes/link-template.php WP 5.2.2

<?php
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 '';
}
No comments
    Hello, !     Log In . Register