Using WordPress ‘privacy_on_link_title’ PHP filter

The ‘privacy_on_link_title’ filter allows you to modify the link title attribute for the ‘Search engines discouraged’ message displayed in the ‘At a Glance’ dashboard widget in WordPress.

Usage

To use this filter, you will need to create a custom function and hook it to the privacy_on_link_title filter. Here’s a code example:

function custom_privacy_on_link_title( $title ) {
    // Your custom code here
    return $title;
}
add_filter( 'privacy_on_link_title', 'custom_privacy_on_link_title' );

Parameters

  • $title (string) – The default attribute text for the link title.

Examples

Scenario: You want to change the link title text to something more meaningful.

function change_link_title_text( $title ) {
    $title = "Custom search engines discouraged message";
    return $title;
}
add_filter( 'privacy_on_link_title', 'change_link_title_text' );

This code changes the link title text to “Custom search engines discouraged message”.

Scenario: You want to include the site name in the link title.

function add_site_name_to_link_title( $title ) {
    $site_name = get_bloginfo( 'name' );
    $title = $title . ' - ' . $site_name;
    return $title;
}
add_filter( 'privacy_on_link_title', 'add_site_name_to_link_title' );

This code appends the site name to the link title.

Scenario: You want to display the link title in uppercase.

function uppercase_link_title( $title ) {
    $title = strtoupper( $title );
    return $title;
}
add_filter( 'privacy_on_link_title', 'uppercase_link_title' );

This code converts the link title to uppercase.

Scenario: You want to include the current date and time in the link title.

function add_timestamp_to_link_title( $title ) {
    $timestamp = current_time( 'mysql' );
    $title = $title . ' - Last checked: ' . $timestamp;
    return $title;
}
add_filter( 'privacy_on_link_title', 'add_timestamp_to_link_title' );

This code adds the current date and time to the link title.

Scenario: You want to translate the link title to Spanish.

function translate_link_title( $title ) {
    $title = 'Los motores de búsqueda están desalentados';
    return $title;
}
add_filter( 'privacy_on_link_title', 'translate_link_title' );

This code replaces the link title with its Spanish translation.