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

deprecated callbacks in preg_replace. replace with preg_replace_callback #260

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,12 @@ function wp_bootstrap_my_widget_tag_cloud_args( $args ) {
// filter tag clould output so that it can be styled by CSS
function wp_bootstrap_add_tag_class( $taglinks ) {
$tags = explode('</a>', $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('</a>', $tagn);
Expand Down