Using WordPress ‘privacy_on_link_text’ PHP filter

The ‘privacy_on_link_text’ filter allows you to customize the link label for the “Search engines discouraged” message displayed in the “At a Glance” dashboard widget in WordPress.

Usage

To use this filter, simply add a function to your theme’s functions.php file or your custom plugin file, and hook it to the privacy_on_link_text filter. Here’s a code example:

function custom_privacy_on_link_text( $content ) {
    // Your custom code goes here
}
add_filter( 'privacy_on_link_text', 'custom_privacy_on_link_text' );

Parameters

  • $content (string): The default text for the link label.

Examples

Scenario: You want to change the link label text.

function change_link_text( $content ) {
    return 'Custom link text';
}
add_filter( 'privacy_on_link_text', 'change_link_text' );

This code changes the link label text to “Custom link text”.

Scenario: You want to translate the link label text to another language.

function translate_link_text( $content ) {
    return __( 'Translated link text', 'your-text-domain' );
}
add_filter( 'privacy_on_link_text', 'translate_link_text' );

This code translates the link label text using the specified text domain.

Scenario: You want to add an icon before the link label text.

function add_icon_before_link_text( $content ) {
    return '<i class="icon-class"></i> ' . $content;
}
add_filter( 'privacy_on_link_text', 'add_icon_before_link_text' );

This code adds an icon with the specified class before the link label text.

Scenario: You want to display the link label text in uppercase.

function uppercase_link_text( $content ) {
    return strtoupper( $content );
}
add_filter( 'privacy_on_link_text', 'uppercase_link_text' );

This code converts the link label text to uppercase.

Scenario: You want to add custom HTML attributes to the link.

function add_custom_attributes_to_link( $content ) {
    return sprintf( '<span class="custom-class" data-attr="custom-value">%s</span>', $content );
}
add_filter( 'privacy_on_link_text', 'add_custom_attributes_to_link' );

This code adds a custom HTML class and a data attribute to the link label.