YOURLS (Your Own URL Shortener) is a URL shortener, like TinyURL, except it's all GPL and you can run it on your own server, publicly or for your own use only. It was made by Lester Chan and myself. Learn more about YOURLS.
This plugin, YOURLS: WordPress to Twitter, is the bridge between YOURLS and your blog: when you publish a post or a page, it will use your own YOURLS install, either hosted on the same webserver, or another server, to create a short URL for your post.
Download
Extract and upload to your blog, preserving directory structure.
Enjoy.
Note: the plugin requires PHP 5 to run.
Template Tags for you theme
The plugin comes with two template tags:
wp_ozh_yourls_url()
Will echo a HTML link with short URL (will generate it on the fly if needed) for the current post.
Example output:
<a href="http://ozh.in/j5" rel="nofollow alternate shorter" title="short URL">http://ozh.in/j5</a>
Suggested use: in the loop, in single.php, in page.php
wp_ozh_yourls_head_linkrel()
Will output a <link/> in <head> for the current post (see revcanonical.appspot.com and shorturl.appjet.net for more info)
Example output:
<link rel="alternate short shorter shorturl" href="http://ozh.in/j5" />\n
Note that WordPress echoes this <link> out of the box so you mostly won't need this one.
You can also use two other functions in your code and plugins:
wp_ozh_yourls_raw_url()
Will return (or echo if you pass true to it) the short URL, with no HTML tag or anything else. Just the raw URL.
wp_ozh_yourls_geturl( $id )
Will return (and generate on the fly if necessary) the short URL for post with id $id
Easy custom keyword
If you want your post to have a custom short URL instead of the random/sequential generated one, when you write a new post add a new custom field to it (button: "Add Custom Field") with name "yourls-keyword" and your custom keyword as a value.
Filters all over the place
If you're a coder and want to interact with the plugin, there are a lot of filters for you to do so. Just read the source and look for what you need (and if you cannot find what you need because you'd like another filter somewhere else, please tell me!)
Shorter URL
Want to share or tweet this page? Please use this short URL: http://ozh.in/m7
Would the WPplugin work with 3.0 Multisite?
CincauHangus » Probably. You tell me :)
Hi Ozh,
As you know everything as been working smoothly with the plug-in until tonite.
I can't shorten links via the admin area anymore. It simply refuses to shorten any link i type in. Luckily all my past shortened links are still working.
Any ideas? Thanks man.
havign the same problem as Udegbunam Chukwudi – same as issue 23 for the full version of Yourls.
Fix is to delete any leading http:// in the url you ar going to be shortening (including the one put in the box by default) and it works again.
Have seen this behaviour on 1.43 and 1.5
Thanks, you're right. Removing http:// did indeed fix this problem. Awesome.
@Andrew Grill et Tuinslak: Thanks guys. It actually worked. I wasn't even aware that 1.5 was out. I'll go download that now ;-).
Cheers
Hi Ozh,
Thanks for the wonderful plugin. I created a tiny patch for the plugin so that it can have an additional filter using which one can control what URL is fed into yourls. This can be useful to add Google Analytics tags to the permalink etc. The patch can be found here:
http://humbug.in/z/20
Do check it to see if you can accept the patch.
Pratik Sinha » I'm currently working on the next version of the plugin (well, not *currently*, I'm in holidays, but will finish it early august) and I've added a number of filters here and there to allow more control.
my configuration of the plugin will not work. I cannot figure out why.. I have yourls installed on natr.in/u/ and the plugin installed at battleshyyouths.com/blog – are there any special file permissions that I need to set? My host is nearlyfreespeech.net ; do I need to include the signature token? blog posts update to twitter but don't include the shortened link..
First, thanks Ozh for the great plugins & to those whose comments helped me get some of my issues fixed.
Couldn't get tweets to work until I read AGb's comment #172 and removed the & from my password.
Then couldn't get URLs to shrink through the Admin page until Andrew Grill posted #204.
Now everything is working fine except the bookmarklets. Both of them return:
"403 Forbidden You don't have permission to access /admin/index.php on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."
I can access /admin/index.php just fine directly, but bookmarklets always return that error.
Any ideas on how to fix those would be greatly appreciated.
@CincauHangus – I can confirm it does work with Multi-site 3.0 however the settings are still independent per blog meaning you would have to re-enter the settings for each blog you wanted to use it
I'm not able to register with Twitter. I press the twitter sign in button and get a PIN code. When I return to my site (WP Panel) there still is a Twitter sign in button.
What am I doing wrong?
I found the problem.
I missed to enter the Callback URL when I registered the application.
I've got an error once I updated to version 1.4. This is what I get on the edit post page:
Warning: Missing argument 3 for wp_ozh_yourls_maketweet(), called in /home/content/x/d/r/xdreamwalker/html/wp/wp-content/plugins/yourls-wordpress-to-twitter/inc/options.php on line 487 and defined in /home/content/x/d/r/xdreamwalker/html/wp/wp-content/plugins/yourls-wordpress-to-twitter/inc/core.php on line 322
Warning: array_slice() expects parameter 1 to be array, boolean given in /home/content/x/d/r/xdreamwalker/html/wp/wp-content/plugins/yourls-wordpress-to-twitter/inc/core.php on line 360
Warning: Invalid argument supplied for foreach() in /home/content/x/d/r/xdreamwalker/html/wp/wp-content/plugins/yourls-wordpress-to-twitter/inc/core.php on line 362
I am using WordPress 3.0
xdreamwalker & Jeff » just pushed version 1.4.1 which should fix all these bugs, thanks for reporting.
Jeff » for the nag: in your theme's functions.php (or a custom plugin, anywhere the code would be executed) add the following:
add_filter( 'ozh_yourls_notice', 'omg_plz_remove_nag' );
function omg_plz_remove_nag() { return "; }
Ozh, Done and done. That was quick. I love my install of YOURLS and the WordPress integration is awesome.
Love the nag removal function!
Since the latest update to the WP plugin, I can't seem to complete the Twitter Settings configuration. I believe I followed the instructions, correctly. The "Sign in with Twitter" button results in a blank page.
Ed Coyne » check server logs for additional info on this "blank page"
Looks like my last two comments were deleted. I can't see that any server logs or errors are being generated.
The Sign In With Twitter button goes to the following blank page: *****/?oauth_start=1&yourls_callback=/wp-admin/options-general.php?page=ozh_yourls&oauth_connected=1&type=authorize&yourls_callback_action
Ed Coyne » I tend to suspect an incorrect plugin configuration. Also, try adding define('WP_DEBUG', true) to wp-config.php and see if it echoes something
Ozh,
There were errors, but nothing specific to YOURLS. The errors had to do with other plugins.
I'm also having a problem when clicking "Sign in to Twitter" but in my case the page it takes me to isn't blank. It says:
Fatal error: Cannot redeclare class OAuthException in ****/wp-content/plugins/yourls-wordpress-to-twitter/inc/oauth_lib/OAuth.php on line 8
I've triple checked the Twitter Application settings against the sample provided.
Any ideas?
Thanks,
7
7lowe » use latest
Hi, I too am having problems authenticating with Twitter. Have
– done a fresh install of the plugin
– registered my app on Twitter (though could you confirm what the Callback URL should ideally be)
– entered key and secret in plugin settings
– when I save I get prompted 'Please connect with Twitter first'
– I do this and get a Twitter message prompting me to 'allow' the app
– but when I go back to the settings page nothing appears to have happened – I still see the 'sign in with Twitter' button
All help gratefully received!
The error actually started when I updated to the latest version 1.4.1. To be double sure I downloaded it again from the link on this page and copied over the top of the existing install. Still get the same message. Will try completely removing and doing a totally fresh install.
One thing I forgot to add was that I am using the latest 1.5 release from Subversion, checked out last night.
James » use the callback URL that is mentioned in the helper screen (should be your blog URL). It may also have to do with sessions, so in doubt just close your browser and restart it.
Did a completely fresh install and still getting the same error. Is the 1.4.1 not the latest version? If not, where can I get the latest?
7Lowe » the guy is talking about his YOURLS version, not the plugin.
Hi! I'm from Japan.
I'm setting up YOURLS version 1.4.2.
But I also have the same trouble as 7lowe.
Fatal error: Cannot redeclare class OAuthConsumer in /home/***/wp-content/plugins/yourls-wordpress-to-twitter/inc/oauth_lib/OAuth.php on line 10
What can I do?
I need your help.
Would you please HELP us?
Hi! I'm again.
My Trouble's gone!
7lowe
Is there any other Wordpres to Twitter Plugin in your blog?
In my case,I had.
After I stoped the Plugin I tried set up YOURLS, YOURLS's work! :)
I hope, you'll try it.
I'm looking forward to use YOURLS :)
Thanks!
Iri
No, my site is brand new and I only have 2 other plugins (WPAudio & WP Touch iPhone Theme).
When I went to check that this morning I saw the 1.4.2 update was available & tried that, but I got the exact same error.
By teh way, on the plugin settings page there's a link to "in this help screen" but for me it's returning an empty window. In Firebug I can see it's trying to load http://www.catchingtherain.com/wp-content/plugins/yourls-wordpress-to-twitter/res/fake_twitter/frame.php?base=http://www.catchingtherain.com/wp-content/plugins/yourls-wordpress-to-twitter&name=YOURLS+on+Catching+The+Rain&org=Catching+The+Rain&url=http://www.catchingtherain.com&desc=Mainly+just+a+place+to+test+things+out.+Powered+by+YOURLS.&tb_iframe=1&width=600&height=600&random=1281707860078
Hi,
Was just wondering if I could manually change the name of what the tweet was posted from. ex. Twitter for iPhone. Would like to use my yourls powered wp.ly site..
JoeM » just edit the application settings in Twitter….
Hi together, first to Ozh, thanks for this wounderfull plugin. I have no problems with install and its work perfect. Ok, almost perfect ;)
If the plugin is active, my WP-Backend is extremly slow. For example, I'm on Dashboard and I will change to "Article" or "Plugin" or "Design", I have to wait round about 4 or 5 minutes. If I disable the plugin, all works fine.
Any idea? I use WP 3.0.1
Ozh, I think your theory about caching was correct – I've just cleared everything and retried and all is working perfectly. Many thanks – great tool, and really handy plugin.
Updated to 1.4.2 and still having the sign in problems. On the bright side the bookmarklets in YOURLS (1.4.3) now work correctly.
7
Since the error I was getting was on Line 8 of …//oauth_lib/OAuth.php
So I checked it out and that's the last line:
class OAuthException extends Exception {
// pass
}
Since the error was saying it couldn't Redeclare it I tried just commenting that whole statement out and then it worked and I got authenticated. Hope that wasn't a really bad thing to do. LOL
Thanks,
7
Any chance of adding the ability to create your own "Custom short URL" from WP just as you would in the YOURLS interface?
I tried setting up my own YOURLS install under http://bella.my, set everything up as instructed, made the database, etc. But every time I tried posting something to the blog (http://bellamybudiman.com/blog), the tweet only goes like this:
New post: title –
Where it should've been New post: title – url
For some reason, the URL is not generated when I'm using my own domain. It works perfectly normal when using bit.ly or others, though.
Is there anything I can do? Thanks in advanced.
hi, I setup the plugin and it works well with yourls, all fine. but i've the problem that i cannot use the button "tweet this" in post's edit mode. the page just reloads and the message "post updated" appears, but i never get a new tweet on my twitter account. is this a known issue, could you help me? regards lu
Trying to get this to work, I've created an application via twitter and posted keys into the settings and still get this when I click the sign in with twitter button:
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /nfs/c07/h01/mnt/102623/domains/skelephant.com/html/wp-content/plugins/yourls-wordpress-to-twitter/inc/oauth_lib/twitterOAuth.php on line 24
When I click "Sign in with Twitter" it sends me to this URL http://www.blakehelms.net/?oauth_start=1&yourls_callback=/wp-admin/options-general.php?page=ozh_yourls&updated=true&oauth_connected=1&type=authorize&yourls_callback_action
and it just shows the homepage. Any ideas?
Blake Helms » plugin configuration… PHP5… dunno.
Running WP 3.0.1. PHP 5.3.0 just updated the plugin today
For those who may have used other plugins in the past too tweet their posts and already have URL's generated, is it possible to edit the old shorturls in instead of having it generate a new one?
Also, does this support j.mp, as well as any others using bit.ly pro?
Matt » Short URLs are stored as a custom field named yourls_shorturl. It's probably doable to get the old short URLs for your posts and convert them (but not out of the box, that will need a custom script). Support for j.mp or bitly pro custom domain: no, but that could be an option (although I'm hesitating to simply remove support for all other URL shortener as this is kind of not the point of the *YOURLS* plugin)
Hi,
I'm also fond of custom url creating from WP's new entry page BEFORE publishing.
For now you have to save the draft, copy the url that will be assigned (under the title field), go to yourls' admin page, short the url, go back and publish the post… Kinda too many steps, huh?
But the plugin is really great! Thanks for your work!