Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

preg_replace is deprecated - (my solution) #211

Open
aonzzung opened this issue Jul 29, 2014 · 1 comment
Open

preg_replace is deprecated - (my solution) #211

aonzzung opened this issue Jul 29, 2014 · 1 comment

Comments

@aonzzung
Copy link

Hi there,

I found that preg_replace is deprecated warning is showing on sidebar.
So, here is what I modified the code to fix deprecation issue.
You can also commit my solution below.

functions.php

// filter tag clould output so that it can be styled by CSS
function wp_bootstrap_add_tag_class( $taglinks ) {
    $tags = explode('', $taglinks);
//    $regex = "#(.*tag-link[-])(.*)(' title.*)#e";
    $regex = "#(.*tag-link[-])(.*)(' title.*)#";
    
    foreach( $tags as $tag ) {
//      $tagn[] = preg_replace($regex, "('$1$2 label tag-'.get_tag($2)->slug.'$3')", $tag );
        $tagn[] = preg_replace_callback($regex, function ($matches) {
            return $matches[1].$matches[2].' label tag-'.get_tag($matches[2])->slug.$matches[3];
        }, $tag );
        
    }

    $taglinks = implode('', $tagn);

    return $taglinks;
}
@chrisbarnes
Copy link
Collaborator

@aonzzung can you submit a pull request with this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants