function ultimate_the_content_filter($thecontent = '') { global $post, $utw, $lzndomainvar, $starttag, $endtag, $starttags, $endtags, $embedtags; $tagStartMarker = $starttag; $tagEndMarker = $endtag; $tags = $utw->GetTagsForPost($post->ID); $findTagRegEx = '/(' . UltimateTagWarriorActions::regExEscape($starttag) . '(.*?)' . UltimateTagWarriorActions::regExEscape($endtag) . ')/i'; $findTagsRegEx = '/(' . UltimateTagWarriorActions::regExEscape($starttags) . '(.*?)' . UltimateTagWarriorActions::regExEscape($endtags) . ')/i'; if ($embedtags == 'yes') { $thecontent = preg_replace($findTagsRegEx, '', $thecontent); $thecontent = preg_replace_callback($findTagRegEx, array("UltimateTagWarriorActions", "replaceTagWithLink"), $thecontent); } if (!is_feed() && get_option('utw_include_local_links') != 'No' && get_option('utw_include_local_links') != 'no') { if (get_option('utw_primary_automagically_included_link_format') != '') { $custom = array(); if (get_option('utw_primary_automagically_included_prefix') != '') { $custom['pre'] = stripslashes(get_option('utw_primary_automagically_included_prefix')); } if (get_option('utw_primary_automagically_included_suffix') != '') { $custom['post'] = stripslashes(get_option('utw_primary_automagically_included_suffix')); } $format = $utw->GetFormat(get_option('utw_primary_automagically_included_link_format'), $custom); $tagHTML = '<span class="UTWPrimaryTags">' . $utw->FormatTags($tags, $format) . '</span>'; if (get_option('utw_include_local_links') == 'Before Content') { $thecontent = $tagHTML . $thecontent; } else { $thecontent = $thecontent . $tagHTML; } } else { // This is a throwback to when the format wasn't specified. // $thecontent = $thecontent . $utw->FormatTags($tags, array("first"=>"<span class=\"localtags\">%taglink% ","default"=>"%taglink% ", "last"=>"%taglink%</span>")); } } if (!is_feed() && get_option('utw_include_technorati_links') != 'No' && get_option('utw_include_technorati_links') != 'no') { if (get_option('utw_secondary_automagically_included_link_format') != '') { $custom = array(); if (get_option('utw_secondary_automagically_included_prefix') != '') { $custom['pre'] = stripslashes(get_option('utw_secondary_automagically_included_prefix')); } if (get_option('utw_secondary_automagically_included_suffix') != '') { $custom['post'] = stripslashes(get_option('utw_secondary_automagically_included_suffix')); } $format = $utw->GetFormat(get_option('utw_secondary_automagically_included_link_format'), $custom); $tagHTML = '<span class="UTWSecondaryTags">' . $utw->FormatTags($tags, $format) . '</span>'; if (get_option('utw_include_technorati_links') == 'Before Content') { $thecontent = $tagHTML . $thecontent; } else { $thecontent = $thecontent . $tagHTML; } } else { // This is a throwback to when the format wasn't specified. // $thecontent = $thecontent . $utw->FormatTags($tags, array("pre"=>__("<span class=\"technoratitags\">Technorati Tags", $lzndomain) . ": ","default"=>"%technoratitag% ", "last"=>"%technoratitag%","none"=>"","post"=>"</span>")); } } if (is_feed() && get_option('utw_append_tag_links_to_feed')) { $thecontent = $thecontent . $utw->FormatTags($tags, $utw->GetFormatForType('commalist')); } // Don't include anything on 'page' posts if there are no tags. There's a check for no tags in case people have tinkered with the page editing thing to allow it. if (count($tags) == 0 && $post->post_status == 'static') { return $thecontent; } return $thecontent; }
/** * Parses a string looking for tags in single and multiple tag blocks. * @param string $text a block of text * @param array an array of tag names */ function ParseEmbeddedTags($text) { global $starttag, $endtag, $starttags, $endtags; $tags = array(); $findTagsRegEx = '/(' . UltimateTagWarriorActions::regExEscape($starttags) . '(.*?)' . UltimateTagWarriorActions::regExEscape($endtags) . ')/i'; preg_match_all($findTagsRegEx, $text, $matches); foreach ($matches[2] as $match) { foreach (explode(',', $match) as $tag) { $tags[] = $tag; } } $findTagRegEx = '/(' . UltimateTagWarriorActions::regExEscape($starttag) . '(.*?)' . UltimateTagWarriorActions::regExEscape($endtag) . ')/i'; preg_match_all($findTagRegEx, $text, $matches); foreach ($matches[2] as $match) { foreach (explode(',', $match) as $tag) { $tags[] = $tag; } } return $tags; }