customization – how to filter upper and lower case characters in Auto tag link code?

Question

enter image description here
Question:
How to filter uppercase and lowercase when the word ‘tag’ is written in lowercase?

and vice versa, how to filter the word ‘tag’ which is written in capital letters?

Here’s the code I got from a plugin that hasn’t been updated in a few years.

function auto_link_tags($content){

//$post_id = get_the_ID();
$post_tags = get_the_tags();

if ($post_tags) {
    $i = 0;
    foreach($post_tags as $tag) {
        $tags[$i] = "~<(?:a\\s.*?</a>|[^>]+>)(*SKIP)(*FAIL)|\\b(?:\\b(" . $tag->name . ")\\b(?=[^>]*(<|$)))\\b~i";
        $tag_url = get_tag_link($tag->term_id);
        $tag_html[$i] = '<a href="' . $tag_url . '" title="$1">$1</a>';
        $i++;
    }
    $content = preg_replace($tags, $tag_html, $content);
}

return $content;}

0
mazdar 3 months 2022-06-02T22:36:27-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse