Posts Tagged ‘twitter’

Saving Link Juice With Nofollow For The “Twitter for WordPress” Plugin

Wednesday, May 20th, 2009

I have just recently enabled the Firefox Addon SearchStatus while on my blog’s homepage. I was amazed that the Twitter For WordPress plugin doesn’t add rel=”nofollow” to the My Latest Tweets widget (see on the right in the sidebar).

Therefore I have just added the corresponding code to the plugin’s PHP file and thought I should share this information because it might really be useful for other people.

Adding rel=”nofollow” to the Twitter links

First make a backup of the file wp-content/plugins/twitter-for-wordpress/twitter.php and save it as twitter.org.php in the same directory. Afterwards open the file twitter.php and modify the code as highlighted here. You need to scroll to the right to see the highlighted code:

function hyperlinks($text) {
    // match protocol://address/path/file.extension?some=variable&another=asf%
    $text = preg_replace("/\s([a-zA-Z]+:\/\/[a-z][a-z0-9\_\.\-]*[a-z]{2,6}[a-zA-Z0-9\/\*\-\?\&\%]*)([\s|\.|\,])/i"," <a rel=\"nofollow\" href=\"$1\" class=\"twitter-link\">$1</a>$2", $text);
    // match www.something.domain/path/file.extension?some=variable&another=asf%
    $text = preg_replace("/\s(www\.[a-z][a-z0-9\_\.\-]*[a-z]{2,6}[a-zA-Z0-9\/\*\-\?\&\%]*)([\s|\.|\,])/i"," <a rel=\"nofollow\" href=\"http://$1\" class=\"twitter-link\">$1</a>$2", $text);
    // match name@address
    $text = preg_replace("/\s([a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]*\@[a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]{2,6})([\s|\.|\,])/i"," <a rel=\"nofollow\" href=\"mailto://$1\" class=\"twitter-link\">$1</a>$2", $text);
    return $text;
}

function twitter_users($text) {
       $text = preg_replace('/([\.|\,|\:|\¡|\¿|\>|\{|\(]?)@{1}(\w*)([\.|\,|\:|\!|\?|\>|\}|\)]?)\s/i', "$1<a rel=\"nofollow\" href=\"http://twitter.com/$2\" class=\"twitter-user\">@$2</a>$3 ", $text);
       return $text;
}

After you have added the code save the file, upload it you your server and you’re done.

If you are using the WP Super Cache plugin be sure to empty the cache so that all pages are updated.

tweetthis-15

Free “Tweet This” Buttons For Your Homepage

Wednesday, May 6th, 2009

It’s a bit funny. When I wrote the articles regarding how to create “Tweet This” buttons with PHP and with JavaScript I was pretty sure that I had already created “Tweet This” buttons for your homepage but in fact I simply had forgotten it.

So I have just created some new buttons just for that purpose. You can download the full package below for free. As always I’d appreciate a link back to this page but this is not required.

Just follow the instructions in the articles linked above. A working JavaScript demo is included in the download.

These are the images that are contained in this package:

Tweet This Buttons

Tweet This Buttons

downloadnow-free

If you like the graphics included in the package I’d appreciate if you’d retweet it by clicking on the “Tweet This” button below. Download the full package with many more graphics here.

tweetthis-15

How To Create A Dynamic “Tweet This” Button With JavaScript

Wednesday, May 6th, 2009

Yesterday I posted some code on how to create dynamic Tweet This buttons with PHP, today I’m going to share a short code snippet you can really drag and drop into your editor to create a “Tweet This” button on your website.

You just need to copy and paste this code and adjust the src attribute of the image to point to your button:

1
2
3
4
5
6
7
8
9
10
<script type="text/javascript">
var twtTitle  = document.title;
var twtUrl    = location.href;
var maxLength = 140 - (twtUrl.length + 1);
if (twtTitle.length > maxLength) {
twtTitle = twtTitle.substr(0, (maxLength - 3))+'...';
}
var twtLink = 'http://twitter.com/home?status='+encodeURIComponent(twtTitle + ' ' + twtUrl);
document.write('<a href="'+twtLink+'" target="_blank"'+'><img src="tweetthis.gif"  border="0" alt="Tweet This!" /'+'><'+'/a>');
</script>

tweetthis-15

How To Create A Dynamic “Tweet This Button” With PHP

Tuesday, May 5th, 2009

Yesterday I have just released some of my graphics for Twitter that I have designed myself.

This time I will show you how can easily create links to your own pages on your website or different articles whenever you have both a page URL and a page title available.
This code automatically removes characters from the end of the title so that in addition to the URL itself and a space character between the maximum length of 140 characters will not be exceeded. If the title is too long it will be truncated and three dots will be appended to show that it has been shortened.

When clicking on the link the user is taken to the Twitter homepage with the message already preset so that he can tweet it immediately with just a single click.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function getTweetUrl($url, $title)
{
$maxTitleLength = 140 - (strlen($url)+1);
if (strlen($title) > $maxTitleLength) {
$title = substr($title, 0, ($maxTitleLength-3)).'...';
}

$output = "$title $url";

return 'http://twitter.com/home?status='.urlencode($output);
}

?>

Example usage:

<a href="<?php echo $url; ?>" target="_blank"><img src="tweetthis.gif" border="0" alt="Tweet This!" /></a>

tweetthis-15

Free Twitter Follow Me Buttons And Graphics

Monday, May 4th, 2009

I just thought I’d share some of the Twitter graphics I have created with you as a way of saying thank you for visiting my blog. Hope you like it by the way. If you do why not follow me on Twitter?

The complete package contains these and some more Twitter buttons you can add to your homepage or blog for free – I always appreciate a link back to this blog (or this specific page) however. If you like these graphics why not retweet by clicking on the “TWEET THIS ARTICLE” button below?

Here is a preview of the graphics contained in the package:

Free Twitter Graphics and Buttons

Free Twitter Graphics and Buttons

Simply click below to download the free graphics package:

downloadnow-free

Download the full package with many more graphics here.

tweetthis-15

Get More Followers – tweet.ms Bar Now Publicly Available

Tuesday, April 28th, 2009

I have just released the new tweet.ms bar. tweet.ms already allows you to create short URLs which redirect to the target page. Now you can also select to add a tweet.ms bar to your link as well which will result in the link page being displayed under the bar (if the result page has no frame breaker that is).

Now anyone who likes your shared link can directly follow you on Twitter by entering his user name and password in the bar. The user will then follow you immediately. Furthermore not only is the Twitter user name and the password never stored on the tweet.ms servers but the user can actually opt in to have an encrypted cookie stored on his PC that contains his Twitter user name and password so that he can use the tweet.ms service easily by being logged in yet never has to enter his credentials again. And his login data is stored only on the local PC – never on the server itself.

Of course the user can also retweet the message directly from within the bar or share the (original) link via various social bookmark services like del.icio.us, digg and so on.

Just see for yourself and try it out – I’m sure you’ll like it:

http://tweet.ms/6n

Comments and feedback are always appreciated – I like to hear from you.

tweetthis-15

tweet.ms URL Shortening Service Features New Graphical Statistics

Thursday, April 23rd, 2009

I just finished adding the new statistics feature to the tweet.ms URL shortening service.

Every link has a unique statistics URL that is shown after the short tweet.ms URL has been created and shows the number of visitors (both bots and humans are distinguished), the countries the visitors are coming from and a timeline showing the visits within the last days as a line chart.

Additionally pie charts are available for both browser names (Firefox, Internet Explorer and so on) and operating systems. A list of all the different referrers (100 maximum) is also included.

New cool features are coming soon. I have many new and exclusive features in store so stay tuned and most of all: use tweet.ms often in your tweets as your URL shortening service and support this free service.

See some statistics here

tweetthis-15

“Tweet This” WordPress Plugin Phones Home

Sunday, April 19th, 2009

Before installing any WordPress plugin for security reasons I always examine the plugin source code which is not a problem for me given my ten years developing in PHP. However I don’t expect the usual WordPress user to have this kind of knowledge most of which don’t even have any experience in PHP at all.

Thus when I was just reading the source code for the Tweet This plugin I was shocked to see that on both activation and deactivation of the plugin it  automatically transfers the following information to the developer’s website:

  • URL of your blog
  • Tweet This version
  • status (activated, deactivated)
  • number of posts in your blog
  • title of your blog
  • description of your blog
  • language of your blog
  • your email address
  • Tweet This plugin settings
  • WordPress version

This is actually the code snippet taken directly from the source code – no, I didn’t add the “Big brother” there, that’s how it’s written in the code:

// Big brother is watching.
function tt_phone_home($status) {
    global $current_site; global $wpdb; $wpv = get_bloginfo('version');
    $siteURL = $current_site->domain; $blogURL = get_bloginfo('url');
    $title = get_bloginfo('name'); $email = get_bloginfo('admin_email');
    $description = get_bloginfo('description');
    $lang = get_bloginfo('language');
    $posts = number_format($wpdb->get_var("SELECT COUNT(*)
    FROM $wpdb->posts WHERE post_status = 'publish'"));
    $settings = $wpdb->get_var("SELECT option_value
    FROM $wpdb->options WHERE option_name = 'tweet_this_settings'");
    $phone = tt_read_file('http://th8.us/ttph.php?s=' . $siteURL . '&b=' .
        $blogURL . '&v=1.3.9&u=' . $status . '&p=' . $posts . '&t=' .
        urlencode($title) . '&d=' . urlencode($description) . '&l=' .
        urlencode($lang) . '&e=' . urlencode($email) . '&w=' . $wpv .
        '&x=' . urlencode($settings));
}

So if you don’t want all this information to be transferred to the developer prior to activating the plugin you should simply add a “return;” right after the function definition leaving the rest untouched.

function tt_phone_home($status) {
  return;

That way the function will return right away and not calling any URL at all. I’m not telling that the developer is doing anything harmful with that plugin yet I don’t see any reason in transferring this information to his server.

tweetthis-15