.
(<|&(?:lt|\#60|\#x3c);) # $10: "<" start delimiter (or HTML entity).
((?:ht|f)tps?:\/\/[a-z0-9\-._~!$&\'()*+,;=:\/?#[\]@%]+) # $11: URL.
(>|&(?:gt|\#62|\#x3e);) # $12: ">" end delimiter (or HTML entity).
| # Alternative 5: URL not delimited by (), [], {} or <>.
( # $13: Prefix proving URL not already linked.
(?: ^ # Can be a beginning of line or string, or
| [^=\s\'"\]] # a non-"=", non-quote, non-"]", followed by
) \s*[\'"]? # optional whitespace and optional quote;
| [^=\s]\s+ # or a non-equals sign followed by whitespace.
) # End $13. Non-prelinkified-proof prefix.
( \b # $14: Other non-delimited URL.
(?:ht|f)tps?:\/\/ # Required http, https, ftp or ftps prefix.
[a-z0-9\-._~!$\'()*+,;=:\/?#[\]@%]+ # All URI chars except "&".
(?: # Either on a "&" or at the end of URI.
(?! # Allow a "&" char only if not start of an...
&(?:gt|\#0*62|\#x0*3e); # HTML ">" entity, or
| &(?:amp|apos|quot|\#0*3[49]|\#x0*2[27]); # a [&\'"] entity if
[.!&\',:?;]? # followed by optional punctuation then
(?:[^a-z0-9\-._~!$&\'()*+,;=:\/?#[\]@%]|$) # a non-URI char or EOS.
) & # If neg-assertion true, match "&" (special).
[a-z0-9\-._~!$\'()*+,;=:\/?#[\]@%]* # More non-& URI chars.
)* # Unroll-the-loop (special normal*)*.
[a-z0-9\-_~$()*+=\/#[\]@%] # Last char can\'t be [.!&\',;:?]
) # End $14. Other non-delimited URL.
/imx';
$url_replace = '$1$4$7$10$13' . $delimiter . '$2$5$8$11$14' .
$delimiter . '$3$6$9$12';
return trim(preg_replace($url_pattern, $url_replace, $text));
}
/**
* Shortens URLs in new tweets.
* Based on: http://www.phpclasses.org/browse/package/6114.html
* Ext-Conv-Links Copyright 2010 Muhammad Arfeen http://arfeen.net/
* @package tweet-this
* @since 1.7.3
*/
class tt_shorten_urls {
function tt_shorten_urls($bitlyLogin, $bitlyAPIKey) {
$this->_bitlyLogin = $bitlyLogin;
$this->_bitlyAPIKey = $bitlyAPIKey;}
function ExtractAndConvert($text = '') {
$text = trim(tt_delimit_urls($text, ' '));
$hyperlinksArray = array();
preg_match_all('(((f|ht){1}(tp://|tps://))' .
'[-a-zA-Z0-9@:%_+.~#?&//=]+)', $text,
$hyperlinksArray);
for($i = 0; $i < count($hyperlinksArray[0]); $i++) {
$ShortLink = $this->_GetSortenLinkViaAPI(
$hyperlinksArray[0][$i]);
if(tt_option('tt_j_mp') == 'true')
$ShortLink = str_replace('http://bit.ly/',
'http://j.mp/', $ShortLink);
$text = str_replace($hyperlinksArray[0][$i],
$ShortLink, $text);} return $text;}
function _GetSortenLinkViaAPI($URL) {
$service = tt_option('tt_admin_url_service');
if($service == 'same') $service = tt_option('tt_url_service');
if($service == '' || $service == 'same' || $service == 'local')
$service = 'bit.ly';
if($this->_bitlyLogin != '' && $this->_bitlyAPIKey != '' &&
$service == 'bit.ly')
$BitlyXML = tt_read_file('http://api.bit.ly/shorten?' .
'version=2.0.1&longUrl=' . urlencode(str_replace(
't9WGb5', '_', $URL)) . '&login=' .
$this->_bitlyLogin . '&apiKey=' . $this->_bitlyAPIKey .
'&format=xml');
else { $geturl = get_tweet_this_short_url(str_replace('_',
't9WGb5', $URL), '', true, true, '');
$BitlyXML = '0' .
'' .
'null' .
'null' .
$geturl . '' . $geturl .
'' .
'OK';}
$XMLtoArray = $this->_ConvXMLtoArray($BitlyXML);
if(isset($XMLtoArray['bitly']['results']['nodeKeyVal']
['shortUrl']['_value_'])) return $XMLtoArray['bitly']
['results']['nodeKeyVal']['shortUrl']['_value_'];}
function _ConvXMLtoArray($contents, $get_attributes = 1) {
if(!$contents || !function_exists('xml_parser_create'))
return array();
$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($parser, $contents, $xml_values);
xml_parser_free($parser); if(!$xml_values) return;
$xml_array = array(); $parents = array();
$opened_tags = array(); $arr = array(); $current = &$xml_array;
foreach($xml_values as $data) {unset($attributes, $value);
extract($data); $result = ''; if($get_attributes) {
$result = array();
if(isset($value)) $result['_value_'] = $value;
if(isset($attributes)) {
foreach($attributes as $attr => $val)
if($get_attributes == 1)
$result['_attr_'][$attr] = $val;}}
elseif(isset($value)) $result = $value;
if($type == 'open') {
$parent[$level - 1] = &$current;
if(!is_array($current) || (!in_array($tag,
array_keys($current)))) {
$current[$tag] = $result;
$current = &$current[$tag];} else {
if(isset($current[$tag][0]))
array_push($current[$tag], $result);
else $current[$tag] =
array($current[$tag], $result);
$last = count($current[$tag]) - 1;
$current = &$current[$tag][$last];}}
elseif($type == 'complete') {if(!isset($current[$tag]))
$current[$tag] = $result; else {
if((is_array($current[$tag]) && $get_attributes
== 0) || (isset($current[$tag][0]) &&
is_array($current[$tag][0]) && $get_attributes
== 1)) array_push($current[$tag], $result);
else $current[$tag] =
array($current[$tag], $result);}}
elseif($type == 'close') $current = &$parent[$level - 1];}
return($xml_array);}
}
/**
* Backward-compatible function to enqueue jQuery.
* @package tweet-this
* @since 1.7.7
*/
function get_tt_enqueue_script($script = 'jquery') {
if($script == 'jquery') {
if(function_exists('wp_enqueue_script') &&
version_compare($GLOBALS['wp_version'], '2.6', '>='))
wp_enqueue_script('jquery');
elseif(file_exists(TT_JQUERY_ABSPATH))
return '';
else return '';}
elseif($script != '' && function_exists('wp_enqueue_script'))
wp_enqueue_script($script);
else return;
}
/**
* Echoes the above function for convenience.
* @package tweet-this
* @since 1.7.7
*/
function tt_enqueue_script($script = 'jquery') {
echo get_tt_enqueue_script($script);
}
/**
* Handles key verification, forwarding, and new tweets.
* Based in part on: http://wordpress.org/extend/plugins/twitter-tools/
* Twitter Tools Copyright 2008 - 2010 Alex King http://alexking.org/
* @package tweet-this
* @since 1.6
*/
function tt_request_handler() {
if(isset($_REQUEST['ttaction'])) switch($_REQUEST['ttaction']) {
case 'tt_oauth_test':
$test = @tt_oauth_test($_POST['tt_app_consumer_key'],
$_POST['tt_app_consumer_secret'],
$_POST['tt_oauth_token'],
$_POST['tt_oauth_token_secret']);
die(__($test, 'tweet-this'));
break;
case 'tt_twitter_box':
$link = 'http://twitter.com/intent/tweet?text=' . urlencode(
@html_entity_decode(stripslashes(
$_REQUEST['tt_twitter_box_text']), ENT_COMPAT,
'UTF-8'));
die('' .
__('Sending you to Twitter...', 'tweet-this') . '' .
'' . __('Sending you to Twitter' .
'...', 'tweet-this') . '' .
__('Click here if nothing happens.', 'tweet-this') .
'
');
break;
case 'tt_write_tweet':
if($_POST['tt_app_consumer_secret'] !=
tt_option('tt_app_consumer_secret') &&
trim(tt_option('tt_app_consumer_secret')) != '')
die(' ' .
__('Cannot authenticate you as WordPress admin.',
'tweet-this') . '');
elseif(trim($_POST['tt_tweet_text']) == '')
die(' ' .
__('Cannot publish a blank tweet.', 'tweet-this') .
'');
elseif(tt_option('tt_app_consumer_key') != '' &&
tt_option('tt_app_consumer_secret') != '' &&
tt_option('tt_oauth_token') != '' &&
tt_option('tt_oauth_token_secret') != '') {
$ECLObj = new tt_shorten_urls(
tt_option('tt_bitly_username'),
tt_option('tt_bitly_api_key'));
$status = stripslashes(trim(str_replace(array("/^\s+/",
"/\s{2,}/", "/\s+\$/"), array('', ' ', ''),
$_POST['tt_tweet_text'])));
if(strlen($status) > 140)
$status = $ECLObj->ExtractAndConvert($status);
$connection = tt_oauth_connection();
$connection->decode_json = true;
$data = $connection->post(TT_API_POST_STATUS,
array('status' => $status, 'source' =>
'tweetthis'));
if($connection->http_code == '200')
die(' ' . __('Tweet published to Twitter ' .
'successfully.', 'tweet-this') . ' (user->screen_name . '/status/' .
$data->id_str . '" target="_blank">' .
$data->id_str . ')');
else die(printf(' ' . __('Tweet failed: Twitter returned HTTP ' .
'%1$s.', 'tweet-this') . '',
$connection->http_code));}
else die(' ' .
__('Tweet failed: OAuth key(s) missing.', 'tweet-this') .
'');
break;
case 'tt_shorten_urls':
$ECLObj = new tt_shorten_urls(tt_option('tt_bitly_username'),
tt_option('tt_bitly_api_key'));
$status = stripslashes(trim(preg_replace("/(\040)+/", " ",
$_POST['tt_tweet_text'])));
if($_POST['tt_app_consumer_secret'] !=
tt_option('tt_app_consumer_secret') &&
trim(tt_option('tt_app_consumer_secret')) != '')
die(' ' .
__('Cannot authenticate you as a WordPress admin.',
'tweet-this') . '');
elseif($status == '')
die(' ' .
__('No tweet text to preview.', 'tweet-this') .
'');
else { if(strlen($status) > 140) {
$status = $ECLObj->ExtractAndConvert(str_replace('_',
't9WGb5', $status));
$lenmsg = '.'; $lenbr = '';}
else { $lenmsg = __(', or more if your tweet ' .
'contains URLs.', 'tweet-this');
$lenbr = '
';}
if(strlen($status) < 141) {
$count = '' .
strlen($status) . '';
$remaining = '' .
(140 - strlen($status)) . '';
$message = $lenbr . __('You can add ',
'tweet-this') . $remaining .
__(' character(s)', 'tweet-this') . $lenmsg;}
else {$count = '' .
strlen($status) . '';
$remaining = '' . (strlen($status) -
140) . '';
$message = '' .
__('You must remove ', 'tweet-this') .
$remaining . __(' character(s).',
'tweet-this') . '';}
die('');}
break;
case 'tt_schedule_tweet':
$ECLObj = new tt_shorten_urls(tt_option('tt_bitly_username'),
tt_option('tt_bitly_api_key'));
$status = stripslashes(trim(str_replace(array("/^\s+/",
"/\s{2,}/", "/\s+\$/"), array('', ' ', ''),
$_POST['tt_tweet_text'])));
$date = trim($_POST['tt_schedule_date']);
if(strlen($date) == 10) $date .= ' 00:00:00';
if(strlen($status) > 140)
$status = $ECLObj->ExtractAndConvert($status);
if($_POST['tt_app_consumer_secret'] !=
tt_option('tt_app_consumer_secret') &&
trim(tt_option('tt_app_consumer_secret')) != '')
die(' ' .
__('Cannot authenticate you as a WordPress admin.',
'tweet-this') . '');
elseif($status == '')
die(' ' .
__('No tweet text to schedule.', 'tweet-this') .
'');
elseif(strlen($status) > 140)
die(' ' .
__('Tweet not scheduled because it is ',
'tweet-this') . strlen($status) . __(' ' .
'characters.', 'tweet-this') . '');
elseif(time() > strtotime($date))
die(' ' .
__('Tweet not scheduled because provided date is ' .
'invalid or in the past.', 'tweet-this') .
'');
else { global $wpdb;
if(!get_option('tweet_this_db_version')) {
tt_install_tables(); $table = 'true';}
if($table == 'true') $table_text = __('Created ' .
'database table `', 'tweet-this') .
$wpdb->rxtt . __('` successfully.',
'tweet-this') . '' .
'';
global $user_ID;
get_currentuserinfo();
$dupe = $wpdb->get_row("SELECT ID, tt_modified FROM
$wpdb->rxtt WHERE tt_date = '$date'");
if($dupe->ID != '') {
die('' . __('Tweet #',
'tweet-this') . $dupe->ID . __(', ' .
'added ', 'tweet-this') .
$dupe->tt_modified . __(', is also ' .
'scheduled for ', 'tweet-this') .
$date . __('. Please change dates.',
'tweet-this') . '
');}
else { $current_date = date("Y-m-d H:i:s");
if(version_compare($GLOBALS['wp_version'],
'2.0', '<')) $basefile = 'post.php';
else $basefile = 'edit.php';
$blog_url = get_bloginfo('url');
$plugin_file = constant('TT_FILE_LOC');
$status = addslashes(stripslashes($status));
$wpdb->query("INSERT INTO $wpdb->rxtt
(tt_author, tt_date, tt_content,
tt_status, tt_modified, tt_response)
VALUES ('$user_ID', '$date', '$status',
'future', '$current_date', '0')");
die('' . $table_text . __("Tweet " .
"scheduled for $date " .
"successfully. Click here to " .
"refresh.", 'tweet-this') .
'
');}}
break;}
}
/**
* Displays the options form under Settings > Tweet This.
* @package tweet-this
* @since 1.1
*/
function print_tt_form() {
if(file_exists(TT_OPTIONS)) {
tt_enqueue_script('jquery');
require(TT_OPTIONS);}
else echo '' . __('The file that constructs the options ' .
'form, /tweet-this/lib/tt-options.php, is missing.',
'tweet-this') . '
';
}
/**
* Array of the default options for installing Tweet This.
* @package tweet-this
* @since 1.8
*/
function get_tt_default_options($add_options = '') {
if($add_options == '' || strlen($add_options) < 100)
$add_options = array('tt_30' => 'false', 'tt_insert_before' => 'false',
'tt_insert_after' => 'true', 'tt_url_service' => 'is.gd',
'tt_admin_url_service' => 'is.gd', 'tt_alignment' => 'left',
'tt_limit_to_single' => 'false', 'tt_limit_to_posts' =>
'false', 'tt_hide_on_feeds' => 'false', 'tt_url_www' =>
'false', 'tt_footer' => 'false',
'tt_new_window' => 'true', 'tt_nofollow' => 'true',
'tt_img_css_class' => 'nothumb', 'tt_link_css_class' => 'tt',
'tt_css' => 'img.[IMG_CLASS]{border:0;}',
'tt_shortlink_filter' => 'true', 'tt_adjix_api_key' => '',
'tt_ad_vu' => 'true', 'tt_j_mp' => 'false',
'tt_bitly_username' => '', 'tt_bitly_api_key' => '',
'tt_snipurl_username' => '', 'tt_snipurl_api_key' => '',
'tt_supr_username' => '', 'tt_supr_api_key' => '',
'tt_snipurl_domain' => 'snipurl.com','tt_custom_url_service' =>
'http://tinyurl.com/api-create.php?url=[LONGURL]',
'tt_auto_tweet_display' => 'true',
'tt_auto_tweet_display_pages' => 'true',
'tt_auto_tweet' => 'false', 'tt_auto_tweet_pages' => 'false',
'tt_auto_tweet_text' => __('New blog post', 'tweet-this') .
': [TITLE] [URL]', 'tt_app_consumer_key' => '',
'tt_app_consumer_secret' => '', 'tt_oauth_token' => '',
'tt_oauth_token_secret' => '', 'tt_textbox_size' => '60',
'tt_auto_display' => 'true', 'tt_tweet_text' =>
'[TITLE] [URL]', 'tt_link_text' =>
__('Tweet This Post', 'tweet-this'), 'tt_title_text' =>
__('Post to Twitter', 'tweet-this'),
'tt_twitter_icon' => 'en/twitter/tt-twitter.png',
'tt_twitter_share' => 'false', 'tt_twitter_share_text' =>
'[TITLE_SHARE]', 'tt_twitter_share_via' =>
'tweetthisplugin', 'tt_twitter_share_rel' =>
'richardxthripp,tweetthisplugin',
'tt_plurk' => 'false', 'tt_plurk_text' => '[TITLE] [URL]',
'tt_plurk_link_text' => __('Plurk This Post',
'tweet-this'), 'tt_plurk_title_text' =>
__('Post to Plurk', 'tweet-this'), 'tt_plurk_icon' =>
'en/plurk/tt-plurk.png',
'tt_bebo' => 'false', 'tt_bebo_link_text' => __('Post to Bebo',
'tweet-this'), 'tt_bebo_title_text' =>
__('Post to Bebo', 'tweet-this'), 'tt_bebo_icon' =>
'en/bebo/tt-bebo.png',
'tt_buzz' => 'false', 'tt_buzz_link_text' =>
__('Buzz This Post', 'tweet-this'),
'tt_buzz_title_text' => __('Post to Yahoo Buzz',
'tweet-this'), 'tt_buzz_icon' => 'en/buzz/tt-buzz.png',
'tt_delicious' => 'false', 'tt_delicious_link_text' =>
__('Post to Delicious', 'tweet-this'),
'tt_delicious_title_text' => __('Post to Delicious',
'tweet-this'), 'tt_delicious_icon' =>
'en/delicious/tt-delicious.png',
'tt_digg' => 'false', 'tt_digg_link_text' =>
__('Digg This Post', 'tweet-this'),
'tt_digg_title_text' => __('Post to Digg',
'tweet-this'), 'tt_digg_icon' => 'en/digg/tt-digg.png',
'tt_diigo' => 'false', 'tt_diigo_link_text' =>
__('Post to Diigo', 'tweet-this'),
'tt_diigo_title_text' => __('Post to Diigo',
'tweet-this'), 'tt_diigo_icon' =>
'en/diigo/tt-diigo.png',
'tt_facebook' => 'false', 'tt_facebook_link_text' =>
__('Post to Facebook', 'tweet-this'),
'tt_facebook_title_text' => __('Post to Facebook',
'tweet-this'), 'tt_facebook_icon' =>
'en/facebook/tt-facebook.png',
'tt_ff' => 'false', 'tt_ff_link_text' =>
__('Post to FriendFeed', 'tweet-this'),
'tt_ff_title_text' => __('Post to FriendFeed',
'tweet-this'), 'tt_ff_icon' => 'en/ff/tt-ff.png',
'tt_gbuzz' => 'false', 'tt_gbuzz_link_text' =>
__('Post to Google Buzz', 'tweet-this'),
'tt_gbuzz_title_text' => __('Post to Google Buzz',
'tweet-this'), 'tt_gbuzz_icon' =>
'en/gbuzz/tt-gbuzz.png',
'tt_gmail' => 'false', 'tt_gmail_link_text' =>
__('Send Gmail', 'tweet-this'),
'tt_gmail_title_text' => __('Send Gmail',
'tweet-this'), 'tt_gmail_icon' =>
'en/gmail/tt-gmail.png',
'tt_linkedin' => 'false', 'tt_linkedin_link_text' =>
__('Post to LinkedIn', 'tweet-this'),
'tt_linkedin_title_text' => __('Post to LinkedIn',
'tweet-this'), 'tt_linkedin_icon' =>
'en/linkedin/tt-linkedin.png',
'tt_mixx' => 'false', 'tt_mixx_link_text' =>
__('Mixx This Post', 'tweet-this'),
'tt_mixx_title_text' => __('Mixx This Post',
'tweet-this'), 'tt_mixx_icon' => 'en/mixx/tt-mixx.png',
'tt_myspace' => 'false', 'tt_myspace_link_text' =>
__('Post to MySpace', 'tweet-this'),
'tt_myspace_title_text' =>
__('Post to MySpace', 'tweet-this'),
'tt_myspace_icon' => 'en/myspace/tt-myspace.png',
'tt_ping' => 'false', 'tt_ping_link_text' =>
__('Ping This Post', 'tweet-this'),
'tt_ping_title_text' => __('Post to Ping.fm',
'tweet-this'), 'tt_ping_icon' => 'en/ping/tt-ping.png',
'tt_reddit' => 'false', 'tt_reddit_link_text' =>
__('Post to Reddit', 'tweet-this'),
'tt_reddit_title_text' => __('Post to Reddit',
'tweet-this'), 'tt_reddit_icon' =>
'en/reddit/tt-reddit.png',
'tt_slashdot' => 'false', 'tt_slashdot_link_text' =>
__('Post to Slashdot', 'tweet-this'),
'tt_slashdot_title_text' => __('Post to Slashdot',
'tweet-this'), 'tt_slashdot_icon' =>
'en/slashdot/tt-slashdot.png',
'tt_squidoo' => 'false', 'tt_squidoo_link_text' =>
__('Post to Squidoo', 'tweet-this'),
'tt_squidoo_title_text' => __('Post to Squidoo',
'tweet-this'), 'tt_squidoo_icon' =>
'en/squidoo/tt-squidoo.png',
'tt_su' => 'false', 'tt_su_link_text' =>
__('Stumble This Post', 'tweet-this'),
'tt_su_title_text' => __('Post to StumbleUpon',
'tweet-this'), 'tt_su_icon' => 'en/su/tt-su.png',
'tt_technorati' => 'false', 'tt_technorati_link_text' =>
__('Post to Technorati', 'tweet-this'),
'tt_technorati_title_text' => __('Post to Technorati',
'tweet-this'), 'tt_technorati_icon' =>
'en/technorati/tt-technorati.png',
'tt_service_order' => 'twitter, plurk, bebo, buzz, ' .
'delicious, digg, diigo, facebook, ff, gbuzz, ' .
'gmail, linkedin, mixx, myspace, ping, reddit, ' .
'slashdot, squidoo, su, technorati');
return $add_options;
}
/**
* Same as tt_default_options($add_options).
* @package tweet-this
* @since 1.8
*/
function tt_default_options($add_options = '') {
return get_tt_default_options($add_options);
}
/**
* Deletes deprecated options left over from old versions of Tweet This.
* Usage: delete_tt_deprecated_options('alpha beta');
* @package tweet-this
* @since 1.8
*/
function delete_tt_deprecated_options($confirm = '') {
if($confirm == 'alpha beta') {
delete_option('tweet_this_password');
delete_option('tt_add_title');
delete_option('tt_big_icon');
delete_option('tt_icon');
delete_option('tt_small_icon');
delete_option('tweet_this_import_key');}
else return false;
}
/**
* Adds the default Tweet This options to the database.
* @package tweet-this
* @since 1.3
*/
function tweet_this_install($add_options = '') {
if($add_options == '')
$add_options = get_tt_default_options($add_options);
foreach($add_options as $key => $value) {
if($old = get_option($key)) {
$add_options[$key] = $old; delete_option($key);}}
if(version_compare($GLOBALS['wp_version'], '2.7', '<') ||
version_compare(PHP_VERSION, '5.0.0', '<')) {
$add_options['tt_auto_tweet_display'] = 'false';
$add_options['tt_auto_tweet_display_pages'] = 'false';}
if(!get_option('tweet_this_settings'))
add_option('tweet_this_settings', $add_options);
elseif(strlen(serialize(get_option('tweet_this_settings'))) < 100)
update_option('tweet_this_settings', $add_options);
delete_tt_deprecated_options('alpha beta');
}
/**
* Completely removes Tweet This.
* Usage: tweet_this_uninstall('alpha omega');
* @package tweet-this
* @since 1.8
*/
function tweet_this_uninstall($confirm = '') {
if($confirm == 'alpha omega') {
delete_option('tweet_this_settings');
delete_option('widget_tweet-this');
delete_tt_deprecated_options('alpha beta');
tt_uninstall_tables('delta kappa');
global $wpdb;
$wpdb->query("DELETE FROM $wpdb->postmeta WHERE
(meta_key = 'tweet_this_url' OR
meta_key = 'tt_auto_tweet' OR
meta_key = 'tt_auto_tweet_text' OR
meta_key = 'tt_tweeted' OR
meta_key = 'tt_tweeted_date' OR
meta_key = 'tt_http_code' OR
meta_key = 'tweet_this_hide')");
if(function_exists('unregister_widget'))
unregister_widget('Tweet_This_Widget');
return true;}
else return false;
}
/**
* Installs the MySQL table for scheduled tweets.
* @package tweet-this
* @since 1.7.3
*/
function tt_install_tables() {
global $wpdb; $cc = '';
if(version_compare(mysql_get_server_info(), '4.1.0', '>=')) {
if(!empty($wpdb->charset))
$cc .= " DEFAULT CHARACTER SET $wpdb->charset";
if(!empty($wpdb->collate)) $cc .= " COLLATE $wpdb->collate";}
$result = $wpdb->query("
CREATE TABLE IF NOT EXISTS `$wpdb->rxtt` (
`ID` bigint(20) unsigned NOT NULL auto_increment,
`tt_author` bigint(20) unsigned NOT NULL default '0',
`tt_date` datetime NOT NULL default '0000-00-00 00:00:00',
`tt_content` longtext NOT NULL,
`tt_status` varchar(20) NOT NULL default 'future',
`tt_modified` datetime NOT NULL default '0000-00-00 00:00:00',
`tt_response` varchar(20) NOT NULL default '0',
PRIMARY KEY (`ID`)
) $cc");
update_option('tweet_this_db_version', TT_DB_VERSION);
update_option('tweet_this_last_cron', (time() - 86400));
}
/**
* Drops the MySQL table for scheduled tweets.
* Usage: tt_uninstall_tables('delta kappa');
* @package tweet-this
* @since 1.8
*/
function tt_uninstall_tables($confirm = '') {
if($confirm == 'delta kappa') {
global $wpdb;
$wpdb->query("DROP TABLE IF EXISTS $wpdb->rxtt");
delete_option('tweet_this_db_version');
delete_option('tweet_this_last_cron');
return true;}
else return false;
}
/**
* Inserts the Options and Write Tweet pages.
* @package tweet-this
* @since 1.1
*/
function tweet_this_add_options() {
// WP 1.5 compatibility.
if(version_compare($GLOBALS['wp_version'], '2.0', '<')) {
$filename = __FILE__;
$postfile = 'post.php';
global $user_level;
if($user_level >= 5) {
$manage = true; $publish = true;}}
else { $filename = basename(__FILE__); $postfile = 'post-new.php';
if(current_user_can('manage_options')) $manage = true;
if(current_user_can('publish_posts')) $publish = true;}
if($manage == true && function_exists('add_options_page'))
add_options_page(__('Tweet This Options', 'tweet-this'),
__('Tweet This', 'tweet-this'), 8,
$filename, 'tweet_this_options');
if($publish == true && function_exists('add_submenu_page') &&
tt_option('tt_app_consumer_key') != '' &&
tt_option('tt_app_consumer_secret') != '' &&
tt_option('tt_oauth_token') != '' &&
tt_option('tt_oauth_token_secret') != '')
add_submenu_page($postfile, __('Write Tweet',
'tweet-this'), __('Write Tweet', 'tweet-this'), 2,
$filename, 'tt_admin_tweet_form');
}
/**
* Constructs the Write Tweet page.
* @package tweet-this
* @since 1.7.3
*/
function tt_admin_tweet_form() {
tweet_this_init(true);
tt_enqueue_script('jquery');
echo '';
printf(__('Tweet This v%1$s: Write Tweet', 'tweet-this'), TT_VERSION);
echo '
';
if(isset($_REQUEST['delete'])) {
$admin = false; $deleted = false;
if(version_compare($GLOBALS['wp_version'], '2.0', '<')) {
global $user_level;
if($user_level >= 5) $admin = true;}
else { if(current_user_can('publish_posts')) $admin = true;}
if($admin == true) {
global $wpdb; $delete_id = $_REQUEST['delete'];
$delete_content = $wpdb->get_var("SELECT tt_content " .
"FROM $wpdb->rxtt WHERE ID = '$delete_id'");
$wpdb->query("DELETE FROM $wpdb->rxtt WHERE " .
"ID = '$delete_id' LIMIT 1");
if($delete_content != '') $deleted = true;}
echo '
';
if($admin == false) _e("Scheduled tweet #$delete_id" .
" not deleted because you could not be " .
"verified as an administrator.", 'tweet-this');
elseif($deleted == true) _e("Scheduled tweet #" .
"$delete_id deleted successfully.",
'tweet-this');
else _e("Scheduled tweet #$delete_id could " .
"not be deleted because it does not exist.",
'tweet-this');
echo '
';}
echo '
' . __('This will ' .
'create a new tweet in Twitter using your OAuth connection.',
'tweet-this') . '
' .
'' .
'
';
if(function_exists('wp_nonce_field'))
wp_nonce_field('tt_new_tweet', '_wpnonce', true, false);
if(function_exists('wp_referer_field')) wp_referer_field(false);
echo ''; global $wpdb;
if(get_option('tweet_this_db_version') == '1.0')
$tweets = $wpdb->get_col("SELECT ID FROM $wpdb->rxtt ORDER BY
tt_date DESC LIMIT 100");
if($tweets) {
echo '';}
echo '
';
}
/**
* Constructs the options form and handles importing and resetting the options.
* @package tweet-this
* @since 1.1
*/
function tweet_this_options() {
$show_form = 'true';
if(isset($_REQUEST['submit'])) update_tt_options();
elseif(isset($_REQUEST['reset'])) {
delete_option('tweet_this_settings');
global_flush_tt_cache();
tweet_this_install();
// Resetting the options requires a page refresh on WP 1.5.
if(version_compare($GLOBALS['wp_version'], '2.0', '<')) {
update_option('tweet_this_import_key', 'reset2');
echo '
' . __('Resetting Tweet This options. ' .
'Please wait...', 'tweet-this') . '
';
$show_form = 'false';}}
elseif(get_option('tweet_this_import_key') == 'reset2') {
update_option('tweet_this_import_key', 'reset1');
echo '
' .
__('All Tweet This options reset successfully. URL ' .
'cache flushed.', 'tweet-this') . '
';}
elseif(isset($_REQUEST['partreset'])) {
$add_options = get_tt_default_options();
$keepers = array('tt_app_consumer_key',
'tt_app_consumer_secret', 'tt_oauth_token',
'tt_oauth_token_secret', 'tt_adjix_api_key',
'tt_bitly_username', 'tt_bitly_api_key',
'tt_snipurl_username', 'tt_snipurl_api_key',
'tt_supr_username', 'tt_supr_api_key');
foreach($keepers as $keeper)
$add_options[$keeper] = tt_option($keeper);
delete_option('tweet_this_settings');
global_flush_tt_cache();
tweet_this_install($add_options);
// Resetting the options requires a page refresh on WP 1.5.
if(version_compare($GLOBALS['wp_version'], '2.0', '<')) {
update_option('tweet_this_import_key', 'partreset2');
echo '
' . __('Resetting all Tweet This options ' .
'except API keys. Please wait...',
'tweet-this') . '
';
$show_form = 'false';}}
elseif(get_option('tweet_this_import_key') == 'partreset2') {
update_option('tweet_this_import_key', 'partreset1');
echo '
' .
__('All Tweet This options reset except API keys. ' .
'URL cache flushed.', 'tweet-this') . '
';}
elseif(isset($_REQUEST['flush'])) {
global $wpdb;
$count2 = number_format($wpdb->get_var("SELECT COUNT(*) FROM
$wpdb->postmeta WHERE meta_key = 'tweet_this_url' AND
meta_value != 'getnew'"));
global_flush_tt_cache();
echo '
' .
__("$count2 cached URL(s) flushed " .
"successfully.", 'tweet-this') . '
';}
elseif(isset($_REQUEST['uninstall'])) {
$tt_dir = constant('TT_DIR');
update_option('tweet_this_import_key', 'uninstall2');
echo '
' .
__("Are you sure? NOTE: You will have to delete the " .
"/plugins/$tt_dir/ directory to complete the removal.",
'tweet-this') . '
';
$show_form = 'false';}
elseif(isset($_REQUEST['uninstallcancel'])) {
update_option('tweet_this_import_key', 'uninstall1');
echo '
' . __('Uninstallation aborted.',
'tweet-this') . '
';}
elseif(isset($_REQUEST['uninstallfinal']) &&
get_option('tweet_this_import_key') == 'uninstall2') {
echo '
';
if(function_exists('deactivate_plugins'))
echo __('Uninstalling and deactivating Tweet ' .
'This. Please wait 3 seconds...',
'tweet-this');
else echo __('Uninstalling Tweet This. Cannot ' .
'deactivate because you are below WP 2.5. ' .
'Please wait 3 seconds...', 'tweet-this');
echo '
';
tweet_this_uninstall('alpha omega');
if(function_exists('deactivate_plugins'))
deactivate_plugins(__FILE__);
$show_form = 'false';}
elseif(isset($_REQUEST['uninstallfinal']) &&
get_option('tweet_this_import_key') != 'uninstall2') {
update_option('tweet_this_import_key', 'uninstall1');
echo '
' .
__('Uninstallation aborted because ' .
'tweet_this_import_key was not set to "uninstall2", ' .
'which suggests tampering.', 'tweet-this') .
'
';}
elseif(isset($_REQUEST['import'])) {
global $wpdb;
$import_options = $_POST['import_content'];
if(substr($import_options, 0, 1) == 'a') {
$wpdb->query("UPDATE $wpdb->options SET option_value =
'$import_options' WHERE option_name =
'tweet_this_settings'");
if(function_exists('wp_cache_flush'))
wp_cache_flush();
global_flush_tt_cache();
// Importing options requires a page refresh before WP 2.5.
if(version_compare($GLOBALS['wp_version'], '2.5', '<')) {
update_option('tweet_this_import_key', 'import2');
echo '
' . __('Importing Tweet This options. ' .
'Please wait...', 'tweet-this') . '
';
$show_form = 'false';}}
else echo '
' . __('There is something wrong with the' .
' provided options. Import aborted.',
'tweet-this') . '
';}
elseif(get_option('tweet_this_import_key') == 'import2') {
update_option('tweet_this_import_key', 'import1');
echo '
' .
__('Tweet This options imported successfully. URL ' .
'cache flushed.', 'tweet-this') . '
';}
if($show_form != 'false') print_tt_form();
}
/**
* Sets one cached URL to "getnew".
* @package tweet-this
* @since 1.1
*/
function flush_tt_cache($post_id) {
update_post_meta($post_id, 'tweet_this_url', 'getnew');
}
/**
* Deletes one cached URL.
* @package tweet-this
* @since 1.1
*/
function delete_tt_cache() {
global $id;
delete_post_meta($id, 'tweet_this_url');
}
/**
* Sets all cached URLs to "getnew".
* @package tweet-this
* @since 1.1
*/
function global_flush_tt_cache() {
global $wpdb;
$wpdb->query("UPDATE $wpdb->postmeta SET meta_value = 'getnew' WHERE
meta_key = 'tweet_this_url'");
}
/**
* Deletes all cached URLs.
* @package tweet-this
* @since 1.1
*/
function global_delete_tt_cache() {
global $wpdb;
$wpdb->query("DELETE FROM $wpdb->postmeta " .
"WHERE meta_key = 'tweet_this_url'");
delete_option('tweet_this_import_key');
}
/**
* Deletes the custom fields of one post.
* @package tweet-this
* @since 1.7.2
*/
function delete_tt_postmeta() {
global $id;
delete_post_meta($id, 'tt_auto_tweet');
delete_post_meta($id, 'tt_auto_tweet_text');
delete_post_meta($id, 'tt_http_code');
delete_post_meta($id, 'tt_tweeted');
delete_post_meta($id, 'tt_tweeted_date');
delete_post_meta($id, 'tweet_this_url');
}
/**
* Loads the textdomain and checks for scheduled tweets every ten minutes.
* @package tweet-this
* @since 1.3
*/
function tweet_this_init($force = false) {
if(function_exists('load_plugin_textdomain')) {
if(version_compare($GLOBALS['wp_version'], '2.6', '<'))
load_plugin_textdomain('tweet-this',
'wp-content/plugins/' . TT_DIR . '/languages');
else load_plugin_textdomain('tweet-this', false,
TT_DIR . '/languages');}
if(get_option('tweet_this_db_version') == '1.0') {
global $wpdb;
$last = get_option('tweet_this_last_cron', false);
if($force == true) $last -= 601;
if(($last != false && $last > (time() - 600)) ||
tt_option('tt_app_consumer_key') == '' ||
tt_option('tt_app_consumer_secret') == '' ||
tt_option('tt_oauth_token') == '' ||
tt_option('tt_oauth_token_secret') == '')
return;
update_option('tweet_this_last_cron', time());
$pending = $wpdb->get_col("SELECT ID FROM $wpdb->rxtt WHERE
(tt_date > 0 && tt_date <= CURRENT_TIMESTAMP() AND
tt_status = 'future')");
if(!count($pending)) return;
foreach($pending as $post) {
if(!$post) continue;
$content = $wpdb->get_row("SELECT * FROM $wpdb->rxtt
WHERE ID = '$post' LIMIT 1");
$connection = tt_oauth_connection();
$connection->decode_json = true;
$data = $connection->post(TT_API_POST_STATUS,
array('status' => $content->tt_content,
'source' => 'tweetthis'));
if($connection->http_code == '200') {
$status = 'publish';
$response = $data->id_str;}
else { $status = 'fail';
$response = $connection->http_code;}
$wpdb->query("UPDATE $wpdb->rxtt SET tt_status =
'$status', tt_response = '$response' WHERE ID =
'$post' AND tt_status = 'future' LIMIT 1");}}
}
/**
* Returns the cached URL for a post or page.
* @package tweet-this
* @since 1.7.4
*/
function get_tt_shortlink($post_id = '') {
global $post; if($post_id == '') $post_id = $post->ID;
if($post_id != '' && ($post->post_status == 'publish' ||
tt_option('tt_url_service') == 'local' ||
tt_option('tt_url_service') == '')) {
$get_cache = get_post_meta($post_id, 'tweet_this_url', true);
if(trim($get_cache) != '' && $get_cache != 'getnew')
$cache = $get_cache;
else $cache = get_tweet_this_short_url(
get_permalink($post_id), $post_id, true);
return str_replace('www.', 'http://',
str_replace('http://www.', 'http://', $cache));}
else return false;
}
/**
* Echoes the above function for convenience.
* @package tweet-this
* @since 1.7.4
*/
function tt_shortlink($post_id = '') {
global $post; if($post_id == '') $post_id = $post->ID;
if($post_id != '' && ($post->post_status == 'publish' ||
tt_option('tt_url_service') == 'local' ||
tt_option('tt_url_service') == ''))
echo get_tt_shortlink($post_id);
else return false;
}
/**
* Returns the cached URL HTML for insertion into wp_head.
* @package tweet-this
* @since 1.7.4
*/
function get_tt_shortlink_wp_head($post_id = '') {
global $post; if($post_id == '') $post_id = $post->ID;
if($post_id != '' && ($post->post_status == 'publish' ||
tt_option('tt_url_service') == 'local' ||
tt_option('tt_url_service') == ''))
return '';
else return false;
}
/**
* Echoes the above function for convenience.
* @package tweet-this
* @since 1.7.4
*/
function tt_shortlink_wp_head($post_id = '') {
global $post; if($post_id == '') $post_id = $post->ID;
if($post_id != '' && ($post->post_status == 'publish' ||
tt_option('tt_url_service') == 'local' ||
tt_option('tt_url_service') == ''))
echo get_tt_shortlink_wp_head($post_id) . "\n";
else return false;
}
/**
* HTML comment inserted using the wp_head hook, including the version,
* build number, and some debug info to help me answer support requests.
* @package tweet-this
* @since 1.7.7
*/
function get_tt_html_comment() {
$mode = ' mode';
if(version_compare($GLOBALS['wp_version'], '2.7', '<'))
$mode .= ' gamma';
if(version_compare(PHP_VERSION, '5.0.0', '<'))
$mode .= ' delta';
if($mode == ' mode') $mode .= ' alpha';
if(trim(tt_option('tt_app_consumer_key')) != '')
$mode .= ' zeta';
return '';
}
/**
* Echoes the above function for convenience.
* @package tweet-this
* @since 1.7.7
*/
function tt_html_comment() {
echo get_tt_html_comment() . "\n";
}
/**
* Footer message must be enabled in Advanced Options.
* @package tweet-this
* @since 1.3
*/
function tweet_this_footer() {
echo '' .
'
';
printf(__('Twitter links powered by Tweet This v%1$s' .
', a WordPress plugin for Twitter.', 'tweet-this'),
TT_VERSION); echo '
';
}
/**
* Converts an absolute date to a relative date.
* Based on: http://wordpress.org/extend/plugins/wickett-twitter-widget/
* Wickett Twitter Widget Copyright 2009 Automattic Inc.
* @package tweet-this
* @since 1.7.6
*/
function tt_relative_time($original, $do_more = 0) {
$chunks = array(array(31536000, 'year'), array(2592000, 'month'),
array(604800, 'week'), array(86400, 'day'),
array(3600, 'hour'), array(60, 'minute'));
$since = time() - $original;
for($i = 0, $j = count($chunks); $i < $j; $i++) {
$seconds = $chunks[$i][0];
$name = $chunks[$i][1];
if(($count = floor($since / $seconds)) != 0) break;}
$print = ($count == 1) ? '1 ' . $name : "$count {$name}s";
if($i + 1 < $j) {
$seconds2 = $chunks[$i + 1][0];
$name2 = $chunks[$i + 1][1];
if((($count2 = floor(($since - ($seconds * $count)) /
$seconds2)) != 0) && $do_more)
$print .= ($count2 == 1) ? ', 1 ' . $name2 :
", $count2 {$name2}s";}
return $print;
}
/**
* Adds a Tweet This widget to Appearance > Widgets. Requires WP 2.8 or newer.
* Based on: http://wordpress.org/extend/plugins/wickett-twitter-widget/
* Wickett Twitter Widget Copyright 2009 Automattic Inc.
* @package tweet-this
* @since 1.7.6
*/
if(version_compare($GLOBALS['wp_version'], '2.8', '>=')) :
class Tweet_This_Widget extends WP_Widget {
function Tweet_This_Widget() {
$widget_ops = array('classname' => 'tweet_this_widget',
'description' => __('Displays your latest Twitter ' .
'updates. Part of the Tweet This plugin.',
'tweet-this'));
$this->WP_Widget('tweet-this', __('Twitter Updates',
'tweet-this'), $widget_ops);}
function widget($args, $instance) {
extract($args);
$account = urlencode($instance['account']);
if(empty($account)) return;
$title = apply_filters('widget_title', $instance['title']);
if(empty($title)) $title = __('Twitter Updates', 'tweet-this');
$show = absint($instance['show']);
$hidereplies = $instance['hidereplies'];
$before_timesince = esc_html($instance['beforetimesince']);
if(empty($before_timesince)) $before_timesince = ' ';
$before_tweet = esc_html($instance['beforetweet']);
echo $before_widget . $before_title . '' . $title . '' . $after_title;
if(!$tweets = wp_cache_get('tweet-this-widget-' .
$this->number, 'widget')) {
$twitter_json_url = clean_url("http://twitter.com/" .
"statuses/user_timeline/$account.json", null, 'raw');
$response = wp_remote_get($twitter_json_url,
array('User-Agent' => 'Tweet This'));
$response_code =
wp_remote_retrieve_response_code($response);
if($response_code == 200) {
$tweets = wp_remote_retrieve_body($response);
$tweets = json_decode($tweets);
$expire = 900;
if(!is_array($tweets) ||
isset($tweets['error'])) {
$tweets = 'error'; $expire = 300;}}
else { $tweets = 'error'; $expire = 300;
wp_cache_add('tweet-this-widget-response-' .
'code-' . $this->number,
$response_code, 'widget', $expire);}
wp_cache_add('tweet-this-widget' . $this->number,
$tweets, 'widget', $expire);}
if($tweets != 'error') {
echo '';}
else { if(wp_cache_get('tweet-this-widget-response-code-' .
$this->number, 'widget') == 401) echo '' .
__('HTTP 401 Error: Please make sure the ' .
'Twitter account is public.', 'tweet-this') .
'
';
else echo '' . __('Error: Twitter did not ' .
'respond. Please wait a few minutes and ' .
'refresh this page.', 'tweet-this') . '
';}
echo $after_widget;}
function update($new_instance, $old_instance) {
$instance = $old_instance;
$instance['account'] =
strip_tags(stripslashes($new_instance['account']));
$instance['account'] = str_replace('http://twitter.com/', '',
$instance['account']);
$instance['account'] = str_replace('/', '',
$instance['account']);
$instance['account'] = str_replace('@', '',
$instance['account']);
$instance['title'] =
strip_tags(stripslashes($new_instance['title']));
$instance['show'] = absint($new_instance['show']);
$instance['hidereplies'] = isset($new_instance['hidereplies']);
$instance['beforetimesince'] =
$new_instance['beforetimesince'];
wp_cache_delete('tweet-this-widget-' . $this->number,
'widget');
wp_cache_delete('tweet-this-widget-response-code-' .
$this->number, 'widget');
return $instance;}
function form($instance) {
$instance = wp_parse_args((array) $instance, array('account' =>
'', 'title' => __('Twitter Updates', 'tweet-this'),
'show' => '3', 'hidereplies' => false));
$account = esc_attr($instance['account']);
$title = esc_attr($instance['title']);
$show = absint($instance['show']);
if($show < 1 || 20 < $show) $show = '3';
$hidereplies = (bool) $instance['hidereplies'];
$before_timesince = esc_attr($instance['beforetimesince']);
echo '' .
'' .
'
';}
function _tweet_this_widget_username($matches) {
return $matches[1] . '@' . $matches[2] . '';}
function _tweet_this_widget_hashtag( $matches ) {
return $matches[1] . '#' . $matches[2] .
'';}
} endif;
/**
* Initializes the Tweet This widget. Requires WP 2.8 or newer.
* @package tweet-this
* @since 1.7.6
*/
function tweet_this_widget_init() {
if(function_exists('register_widget') &&
class_exists('Tweet_This_Widget'))
register_widget('Tweet_This_Widget');
}
/**
* Initializes Tweet This options on the Write Post screen in WP 3.0 or newer.
* @package tweet-this
* @since 1.8
*/
function tt_post_options_init() {
// Unused version check.
if(version_compare($GLOBALS['wp_version'], '2.7', '>=')) {
$context = 'side'; $priority = 'low';}
else { $context = 'normal'; $priority = 'high';}
if(function_exists('add_meta_box')) {
if(tt_option('tt_auto_tweet_display') != 'false')
add_meta_box('tweetthis', __('Tweet This',
'tweet-this'), 'tt_post_options', 'post',
$context, $priority);
if(tt_option('tt_auto_tweet_display_pages') != 'false')
add_meta_box('tweetthis', __('Tweet This',
'tweet-this'), 'tt_post_options', 'page',
$context, $priority);}
else return false;
}
/**
* Actions for updating the database, tweeting posts, and displaying things.
*/
add_action('init', 'tweet_this_init');
add_action('init', 'tt_request_handler');
add_action('publish_post', 'flush_tt_cache');
add_action('save_post', 'flush_tt_cache');
add_action('delete_post', 'delete_tt_postmeta');
add_action('generate_rewrite_rules', 'global_flush_tt_cache');
add_action('draft_post', 'tt_store_post_options', 1, 2);
add_action('save_post', 'tt_store_post_options', 1, 2);
add_action('publish_post', 'tt_store_post_options', 1, 2);
add_action('publish_post', 'tt_auto_tweet', 99);
add_action('publish_page', 'tt_auto_tweet', 99);
add_filter('the_content', 'insert_tweet_this');
if(function_exists('add_shortcode'))
add_shortcode('tweet_this', 'tt_shortcode_handler');
if(version_compare($GLOBALS['wp_version'], '3.0', '>='))
add_action('add_meta_boxes', 'tt_post_options_init');
else { if(tt_option('tt_auto_tweet_display') != 'false')
add_action('edit_form_advanced', 'tt_post_options');
if(tt_option('tt_auto_tweet_display_pages') != 'false')
add_action('edit_page_form', 'tt_post_options');}
if(TT_HIDE_MENU != true)
add_action('admin_menu', 'tweet_this_add_options');
if(tt_option('tt_css') != '[BLANK]')
add_action('wp_head', 'tweet_this_css', 9);
if(tt_option('tt_footer') == 'true')
add_action('wp_footer', 'tweet_this_footer');
if(tt_option('tt_shortlink_filter') != 'false' && tt_option('tt_url_service')
!= 'local' && tt_option('tt_url_service') != '') {
if(version_compare($GLOBALS['wp_version'], '2.5', '<') ||
(function_exists('has_action') &&
!has_action('wp_head', 'wp_shortlink_wp_head')))
add_action('wp_head', 'tt_shortlink_wp_head', 9);
if(version_compare($GLOBALS['wp_version'], '3.0', '>='))
add_filter('get_shortlink', 'get_tt_shortlink');}
if(function_exists('tt_html_comment'))
add_action('wp_head', 'tt_html_comment', 9);
if(version_compare($GLOBALS['wp_version'], '2.8', '>='))
add_action('widgets_init', 'tweet_this_widget_init');
/**
* Activation / deactivation hooks.
*/
if(function_exists('register_activation_hook'))
register_activation_hook(__FILE__, 'tweet_this_install');
else add_action('activate_' . __FILE__, 'tweet_this_install');
if(function_exists('register_deactivation_hook'))
register_deactivation_hook(__FILE__, 'global_delete_tt_cache');
else add_action('deactivate_' . __FILE__, 'global_delete_tt_cache');
?>