I love WordPress and there is no reason not to. I also love bookmarklets. A bookmarklet is a piece of JavaScript code that execute whenever you click it in your browser. Bookmarklets normally live in your browser's bookmark toolbar and form a way of further customizing its functionality without an over-the-top amount of code.
Bookmarklets are great for sharing and curation. Facebook, Tumblr and others provide them, essentially popping open a new browser window on their site, giving you the ability to comment and then post a link to the currently viewed content. WordPress has a tool for that built in, 'Press This'. Only problem is that it often times breaks and leads to a 404 error page. It appears the issue stems from the encoding of the protocol portion of the URL (e.g. http://, https:// etc.). It appears that a truly minor tweak can fix this issue. All you need to do is modify the JavaScript code in the 'Press This' bookmarklet generated by your WordPress blog.
For example, the original code is:
javascript:var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='http://<YOUR BLOG URL>/wp-admin/press-this.php',l=d.location,e=encodeURIComponent,u=f+'?u='+e(l.href)+'&t='+e(d.title)+'&s='+e(s)+'&v=4';a=function(){if(!w.open(u,'t','toolbar=0,resizable=1,scrollbars=1,status=1,width=720,height=570'))l.href=u;};if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); else a();void(0)
with
javascript:var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='<YOUR BLOG URL>/wp-admin/press-this.php',l=d.location,e=encodeURIComponent,u=f+'?u='+e(document.location.host + document.location.pathname)+'&t='+e(d.title)+'&s='+e(s)+'&v=4';a=function(){if(!w.open(u,'t','toolbar=0,resizable=1,scrollbars=1,status=1,width=720,height=570'))l.href=u;};if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); else a();void(0)
Try it out. Tell me if it works.
12 replies on “WordPress Post Bookmarklet: a fix for ‘Press This’”
It works great on Chrome, also on the iPad. Thanks for sharing.
[…] WordPress Post Bookmarklet: a fix for ‘Press This’ Posted on July 7, 2011 by materialsdave WordPress Post Bookmarklet: a fix for ‘Press This’. […]
It works by Firefox 5.
Thanks
Hey,
where ist the script located?
And is it possible, to change the "Press This"-Button with a custom image?
Thanks,
ticle
Ticle, just copy and paste the code in the post above.
I am unsure whether you can customize a bookmarklet's icon.
[…] WordPress Post Bookmarklet: a fix for ‘Press This’ « Enavigo. Share this:TwitterFacebookLike this:LikeBe the first to like this post. This entry was posted in […]
[…] WordPress Post Bookmarklet: a fix for ‘Press This’ « Enavigo. This entry was posted in Public. Bookmark the permalink. ? How to Change the Default Web Page that is Shown When Someone Goes to Your Domain Name thesitewizard.com […]
[…] WordPress Post Bookmarklet: a fix for ‘Press This’ | Enavigo :: Technology Evangelism and Execut…. […]
This is such an awesome fix. I dont understand why it hasn't been incorporated into the default wordpress installation.
AT LAST ! a fix for the press this, what a relief that I can actually use it again 🙂
thanks
Thanks. It works great! They haven't still fixed this in WordPress 3.4.2!
I just add this code to my iPad and tested it out. It works like a charm. Thanks for sharing!!!