Disable WordPress Link Security

WordPress’ native link security is really great, but can interfere, especially when you’re selling guest posts or banners. You can disable the link security features (nofollow, noreferrer) by implementing this code to your functions.php file, or via a Code Snippet Plugin. Be careful though, as this can interfere with your Website’s Security.

// Remove default WordPress filtering
remove_filter('pre_user_description', 'wp_filter_kses');

// Add custom filtering to allow specific HTML tags with classes
add_filter('pre_user_description', 'custom_bio_kses');

function custom_bio_kses($content) {
    $allowed_tags = array(
        'a' => array(
            'href' => array(),
            'title' => array(),
            'target' => array(),
            'class' => array()
        ),
        'i' => array(
            'class' => array()
        ),
        'strong' => array(
            'class' => array()
        ),
        'br' => array(),
        'p' => array(
            'class' => array()
        ),
        'span' => array(
            'class' => array()
        ),
        'div' => array(
            'class' => array()
        )
    );
    return wp_kses($content, $allowed_tags);
}

Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *