WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 6 years ago

#3878 closed enhancement (invalid)

Press IT Bookmarklet updated

Reported by: DD32 Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.2
Component: Administration Keywords: Press IT has-patch
Focuses: Cc:

Description

Follow up to http://trac.wordpress.org/ticket/3731

Since no-one else has done it, I've written up 2 bookmarklets for Wordpress 2.2-svn.
I've tested under Opera9/IE6/FF2, i dont have access to any other browsers to test, however from what i can tell, it should work.

Here is an expanded form of the bookmarklet

//javascript:
function A(b){return (encodeURIComponent)?encodeURIComponent(b):escape(b);}
Q='';
if(window.getSelection){
	Q=window.getSelection();
}else if (document.getSelection){
	Q=document.getSelection();
}else if(document.selection){
	Q=document.selection.createRange().text;
}
location.href='http://*URL*/wp-admin/post-new.php?text='+A(Q)+'&popupurl='+A(location.href)+'&popuptitle='+A(document.title);

The last line can also be writen as:

void(window.open('http://*URL*/wp-admin/post-new.php?text='+A(Q)+'&popupurl='+A(location.href)+'&popuptitle='+A(document.title)));

to open in a new window, Both bookmarklets are listed in the post page.

As to getting the current selected text:
window.getSelection should work for Safari
document.getSelection() should work for mozilla/opera
document.selection.createRange().text should work for IE variants

The total length is 388 characters for the location.href version, which leaves 100 characters spare for the domain name, and any other small fixes which get added. (IE6 SP2 has a maximum limit of 488 characters for bookmarklets: http://subsimple.com/bookmarklets/rules.asp )
The window.open version has less space for the domain name, however most should still fit.

The function A() had to be used to pull the totalsize of the bookmarklet down to within limits allowed by IE6.

A Patch has been attached (Patch against SVN 4915).

Finally, Here are the 2 bookmarklets(with PHP and HTML):

<a href="javascript:function A(b){return (encodeURIComponent)?encodeURIComponent(b):escape(b);}Q='';if(window.getSelection){Q=window.getSelection();}else if (document.getSelection){Q=document.getSelection()}else if(document.selection){Q=document.selection.createRange().text;}void(window.open('<?php echo get_option('siteurl') ?>/wp-admin/post-new.php?text='+A(Q)+'&amp;popupurl='+A(location.href)+'&amp;popuptitle='+A(document.title)));" title="<?php printf(__('Press It - %s'), wp_specialchars(get_option('blogname'))); ?>"><?php printf(__('Press It - %s'), wp_specialchars(get_option('blogname'))); ?></a> <?php echo __('New Window/tab') ?><br/>
<a href="javascript:function A(b){return (encodeURIComponent)?encodeURIComponent(b):escape(b);}Q='';if(window.getSelection){Q=window.getSelection();}else if (document.getSelection){Q=document.getSelection()}else if(document.selection){Q=document.selection.createRange().text;}location.href='<?php echo get_option('siteurl') ?>/wp-admin/post-new.php?text='+A(Q)+'&amp;popupurl='+A(location.href)+'&amp;popuptitle='+A(document.title);" title="<?php printf(__('Press It - %s'), wp_specialchars(get_option('blogname'))); ?>"><?php printf(__('Press It - %s'), wp_specialchars(get_option('blogname'))); ?></a> <?php echo __('Current Window') ?>

Attachments (1)

new-post-bookmarklet.patch (3.9 KB) - added by DD32 7 years ago.
Bookmarklet Patch

Download all attachments as: .zip

Change History (6)

DD327 years ago

Bookmarklet Patch

comment:1 DD327 years ago

(Patch against SVN 4915).
Actually, my mistake, it seems to be against revision 4950, Which is the latest in the SVN repos as of a few hours ago.

comment:2 DD327 years ago

  • Version set to 2.2

comment:3 foolswisdom7 years ago

  • Milestone changed from 2.2 to 2.3

comment:4 ryan7 years ago

  • Milestone changed from 2.3 to 2.4

comment:5 westi6 years ago

  • Milestone 2.5 deleted
  • Resolution set to invalid
  • Status changed from new to closed

Closing as invalid - there is no bookmarklet anymore

Note: See TracTickets for help on using tickets.