get_the_privacy_policy_link

The timeline below displays how wordpress function get_the_privacy_policy_link has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.2

/**
 * Returns the privacy policy link with formatting, when applicable.
 *
 * @since 4.9.6
 * @since 6.2.0 Added 'privacy-policy' rel attribute.
 *
 * @param string $before Optional. Display before privacy policy link. Default empty.
 * @param string $after  Optional. Display after privacy policy link. Default empty.
 * @return string Markup for the link and surrounding elements. Empty string if it
 *                doesn't exist.
 */
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" rel="privacy-policy">%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 '';
}

WordPress Version: 5.5

/**
 * Returns the privacy policy link with formatting, when applicable.
 *
 * @since 4.9.6
 *
 * @param string $before Optional. Display before privacy policy link. Default empty.
 * @param string $after  Optional. Display after privacy policy link. Default empty.
 * @return string Markup for the link and surrounding elements. Empty string if it
 *                doesn't exist.
 */
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 '';
}

WordPress Version: 9.8

/**
 * Returns the privacy policy link with formatting, when applicable.
 *
 * @since 4.9.6
 *
 * @param string $before Optional. Display before privacy policy link. Default empty.
 * @param string $after  Optional. Display after privacy policy link. Default empty.
 *
 * @return string Markup for the link and surrounding elements. Empty string if it
 *                doesn't exist.
 */
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 '';
}

WordPress Version: 9.6

/**
 * Returns the privacy policy link with formatting, when applicable.
 *
 * @since 4.9.6
 *
 * @param string $before Optional. Display before privacy policy link. Default empty.
 * @param string $after  Optional. Display after privacy policy link. Default empty.
 *
 * @return string Markup for the link and surrounding elements. Empty string if it
 *                doesn't exist.
 */
function get_the_privacy_policy_link($before = '', $after = '')
{
    $link = '';
    $privacy_policy_url = get_privacy_policy_url();
    if ($privacy_policy_url) {
        $link = sprintf('<a class="privacy-policy-link" href="%s">%s</a>', esc_url($privacy_policy_url), __('Privacy Policy'));
    }
    /**
     * 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 '';
}

WordPress Version: .10

/**
 * Returns the privacy policy link with formatting, when applicable.
 *
 * @since 4.9.6
 *
 * @param string $before Optional. Display before privacy policy link. Default empty.
 * @param string $after  Optional. Display after privacy policy link. Default empty.
 *
 * @return string Markup for the link and surrounding elements. Empty string if it
 *                doesn't exist.
 */
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 '';
}