) with links to that URL
$url_replace = true;
// Replace username in @replies with a link to that user's twitter page
$reply_replace = true;
$url_regex = '{
\b
# Match the leading part (proto://hostname, or just hostname)
(
# ftp://, http://, or https:// leading part
(http)://[-\w]+(\.\w[-\w]*)+
|
# or, try to find a hostname with more specific sub-expression
(?i: [a-z0-9] (?:[-a-z0-9]*[a-z0-9])? \. )+ # sub domains
# Now ending .com, etc. For these, require lowercase
(?-i: com\b
| edu\b
| biz\b
| gov\b
| in(?:t|fo)\b # .int or .info
| mil\b
| net\b
| org\b
| [a-z][a-z]\.[a-z][a-z]\b # two-letter country code
)
)
# Allow an optional port number
( : \d+ )?
# The rest of the URL is optional, and begins with /
(
/
# The rest are heuristics for what seems to work well
[^.!,?;"\'<>()\[\]\{\}\s\x7F-\xFF]*
(
[.!,?]+ [^.!,?;"\'<>()\[\]\{\}\s\x7F-\xFF]+
)*
)?
}ix';
if (!function_exists('MagpieRSS')) { // Check if another plugin is using RSS, may not work
include_once (ABSPATH . WPINC . '/rss.php');
error_reporting(E_ERROR);
}
# get rss file
$rss = @fetch_rss($rss_url);
if ($rss) {
$descmatches = "";
# specifies number of entries
$items = array_slice($rss->items, 0, $num_items);
$username = $username .": ";
# builds html from array
foreach ( $items as $item ) {
$description = $item['description'];
if ($hide_username) {
$twitter = str_replace($username,'', $description);
}
$twitter = htmlspecialchars(stripslashes($twitter));
if($trim) {
$t = mb_strimwidth($twitter, 0, $trim_count - strlen(html_entity_decode($trim_marker)), '', 'UTF-8');
// Trim last word, replace with trim marker...
if($t != $twitter) {
// Trim link only works if you're hiding your link
if($trim_link && $hide_links) {
$url = $item['link'];
$trim_marker = "$trim_marker";
}
$t = preg_replace('/[\W\s]*\w*[\W\s]*$/', '', $t);
$trimmed = true;
}
$twitter = $t;
}
// URL Replace only works if you're hiding your link
if($url_replace && $hide_links) {
$twitter = preg_replace($url_regex, '$0', $twitter);
}
// Reply replace only works if you're hiding links
if($reply_replace && $hide_links) {
$twitter = preg_replace('!^@([^ ]+)!', '@$1', $twitter);
}
// Add the trim marker (couldn't add before b/c url_replace would do a double href)
if($trimmed) {
$twitter .= $trim_marker;
}
if (!$hide_links) {
$url = $item['link'];
print $before . "$twitter" . $after;
} else {
print $before . $twitter . $after;
}
} // end foreach
} else {
#print "Something went wrong.";
}
} # end get_twitterRSS() function
?>