Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter ( 'wp_tag_cloud', 'tag_cloud_widget_advanced_classes' );
- function tag_cloud_widget_advanced_classes( $taglinks ) {
- $tags = explode('</a>', $taglinks);
- $regex1 = "#(.*tag-link[-])(.*)(' title.*)#e";
- $regex2 = "#(.*style='font-size:)(.*)((pt|px|em|pc|%);'.*)#e";
- $regex3 = "#(style='font-size:)(.*)((pt|px|em|pc|%);')#e";
- $regex4 = "#(.*class=')(.*)(' title.*)#e";
- foreach( $tags as $tag ) {
- $tag = preg_replace($regex1, "('$1$2 tag-slug-'.get_tag($2)->slug.'$3')", $tag ); //add .tag-slug-{slug} class
- $size = preg_replace($regex2, "(''.round($2).'')", $tag ); //get the rounded font size
- $tag = preg_replace($regex3, "('')", $tag ); //remove the inline font-size style
- $tag = preg_replace($regex4, "('$1tag-size-'.($size).' $2$3')", $tag ); //add .tag-size-{nr} class
- $tagn[] = $tag;
- }
- $taglinks = implode('</a>', $tagn);
- return $taglinks;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement