/** * 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; }
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; }
function utw_options() { global $lzndomain, $utw, $wpdb, $tableposts, $tabletags, $tablepost2tag, $install_directory; $siteurl = get_option('siteurl'); echo '<div class="wrap">'; $configValues = array(); $configValues[] = array("setting" => "", "label" => __("URL settings", $lzndomain), "type" => "label"); $configValues[] = array("setting" => "utw_use_pretty_urls", "label" => __("Use url rewriting for local tag urls (/tag/tag instead of index.php?tag=tag)", $lzndomain), "type" => "boolean"); $configValues[] = array("setting" => "utw_base_url", "label" => __("Base url", $lzndomain), "type" => "string"); $configValues[] = array("setting" => "utw_trailing_slash", 'label' => __("Include trailing slash on tag urls", $lzndomain), 'type' => 'boolean'); $configValues[] = array("setting" => "", "label" => __("Debugging", $lzndomain), "type" => "label"); $configValues[] = array("setting" => "utw_debug", 'label' => __("Include debugging information", $lzndomain), 'type' => 'boolean'); $configValues[] = array("setting" => "", "label" => __("Automatic Tag Link Inclusion", $lzndomain), "type" => "label"); $configValues[] = array("setting" => "utw_append_tag_links_to_feed", 'label' => __("Include local tag links in feeds", $lzndomain), 'type' => 'boolean'); $configValues[] = array("setting" => "utw_include_local_links", "label" => __("Automatically include primary tag links", $lzndomain), "type" => "boolean"); $configValues[] = array("setting" => 'utw_primary_automagically_included_link_format', 'label' => __('Format for primary tag links'), 'type' => 'dropdown', 'options' => $utw->GetPredefinedFormatNames()); $configValues[] = array("setting" => "utw_include_technorati_links", "label" => __("Automatically include secondary tag links", $lzndomain), "type" => "boolean"); $configValues[] = array("setting" => 'utw_secondary_automagically_included_link_format', 'label' => __('Format for secondary tag links'), 'type' => 'dropdown', 'options' => $utw->GetPredefinedFormatNames()); $configValues[] = array("setting" => "", "label" => __("Global Formatting Settings", $lzndomain), "type" => "label"); $configValues[] = array("setting" => "utw_tag_cloud_max_color", "label" => __("Most popular color", $lzndomain), "type" => "color"); $configValues[] = array("setting" => "utw_tag_cloud_max_font", "label" => __("Most popular size", $lzndomain), "type" => "color"); $configValues[] = array("setting" => "utw_tag_cloud_min_color", "label" => __("Least popular color", $lzndomain), "type" => "color"); $configValues[] = array("setting" => "utw_tag_cloud_min_font", "label" => __("Least popular size", $lzndomain), "type" => "color"); $configValues[] = array("setting" => 'utw_tag_cloud_font_units', 'label' => __('Font size units', $lzndomain), "type" => "dropdown", "options" => array('%', 'pt', 'px', 'em')); $configValues[] = array("setting" => 'utw_icons', 'label' => __('Icons to display in icon formats', $lzndomain), "type" => "multiselect", "options" => array('Technorati', 'Flickr', 'delicious', 'Wikipedia', 'gadabe', 'Zniff', 'RSS')); $configValues[] = array("setting" => "", "label" => __("Editing Options", $lzndomain), "type" => "label"); $configValues[] = array("setting" => "utw_always_show_links_on_edit_screen", "label" => __("Show existing tags on post editing page", $lzndomain), "type" => "dropdown", "options" => array('none', 'dropdown', 'tag list')); $configValues[] = array("setting" => "utw_include_categories_as_tags", "label" => __("Automatically add categories as tags", $lzndomain), "type" => "boolean"); if ($_POST["action"] == "saveconfiguration") { foreach ($configValues as $setting) { if ($setting['type'] == 'multiselect') { $options = '|'; foreach ($setting['options'] as $option) { $options .= $_POST[$setting['setting'] . ":" . $option] . '|'; } update_option($setting['setting'], $options); } else { if ($setting['type'] != 'label') { update_option($setting['setting'], $_POST[$setting['setting']]); } } } echo "<div class=\"updated\"><p>Updated settings</p></div>"; } echo "<fieldset class=\"options\"><legend>" . __("Help!", $lzndomain) . "</legend><a href=\"{$siteurl}/wp-content/plugins{$install_directory}/ultimate-tag-warrior-help.html\" target=\"_new\">" . __("Local help", $lzndomain) . "</a> | <a href=\"http://www.neato.co.nz/ultimate-tag-warrior\" target=\"_new\">" . __("Author help", $lzndomain) . "</a> | <a href=\"./edit.php?page=ultimate-tag-warrior-actions.php\">Manage Tags</a></fieldset>"; echo '<fieldset class="options"><legend>' . __('Configuration', $lzndomain) . '</legend>'; echo "<form method=\"POST\">"; echo "<table width=\"100%\">"; foreach ($configValues as $setting) { if ($setting['type'] == 'boolean') { UltimateTagWarriorActions::show_toggle($setting['setting'], $setting['label'], get_option($setting['setting'])); } if ($setting['type'] == 'string') { UltimateTagWarriorActions::show_string($setting['setting'], $setting['label'], get_option($setting['setting'])); } if ($setting['type'] == 'color') { UltimateTagWarriorActions::show_color($setting['setting'], $setting['label'], get_option($setting['setting'])); } if ($setting['type'] == 'label') { UltimateTagWarriorActions::show_label($setting['setting'], $setting['label'], get_option($setting['setting'])); } if ($setting['type'] == 'dropdown') { UltimateTagWarriorActions::show_dropdown($setting['setting'], $setting['label'], get_option($setting['setting']), $setting['options']); } if ($setting['type'] == 'multiselect') { UltimateTagWarriorActions::show_multiselect($setting['setting'], $setting['label'], get_option($setting['setting']), $setting['options']); } } echo <<<CONFIGFOOTER \t</table> \t\t\t<input type="hidden" name="action" value="saveconfiguration"> \t\t\t<input type="hidden" name="page" value="ultimate-tag-warrior-actions.php"> \t\t\t<input type="submit" value="Save"> \t\t</form> \t</fieldset> CONFIGFOOTER; }