Plugin Directory

Changeset 1215493


Ignore:
Timestamp:
08/08/2015 08:20:11 AM (11 years ago)
Author:
akrabat
Message:

Ensure that the short_link is correct when using a post id.
Fix bookmarklet so that it no longer references a dead link.
Update link for Safari extension.

Location:
shorter-links/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • shorter-links/trunk/readme.txt

    r1215441 r1215493  
    22Contributors: akrabat
    33Donate link: http://akrabat.com
    4 Tags: revcanonical links url shorter shorturl shortlink
     4Tags: revcanonical, links, url shortener, shorturl, shortlink
    55Requires at least: 3.0
    66Tested up to: 4.3
    7 Stable tag: 2.0.5
     7Stable tag: 2.0.6
     8License: New-BSD
     9License URI: http://akrabat.com/license/new-bsd
    810
    911Override the default WordPress "shortlink" URL with one that
     
    4042** Is there a bookmarklet to extract shorturl links? **
    4143
    42 This is a bookmarklet based on [Shorten](http://swtiny.eu/EZa):
     44Try this bookmarklet: [Short URL][1]
    4345
    44 [Short URL][1]
    45 
    46 [1]: javascript:(function(){var%20url=document.location;var%20links=document.getElementsByTagName('link');var%20found=0;for(var%20i%20=%200,%20l;%20l%20=%20links[i];%20i++){if(l.getAttribute('rel')=='shortlink'||(/alternateshort/).exec(l.getAttribute('rel')))%20{found=l.getAttribute('href');break;}}if%20(!found)%20{for%20(var%20i%20=%200;%20l%20=%20document.links[i];%20i++)%20{if%20(l.getAttribute('rel')%20==%20'shorturl')%20{found%20=%20l.getAttribute('href');break;}}}if%20(found)%20{prompt('URL:',%20found);}%20else%20{window.onTinyUrlGot%20=%20function(r)%20{if%20(r.ok)%20{prompt('URL:',%20r.tinyurl);}%20else%20{alert('Could%20not%20shorten%20with%20tinyurl');}};var%20s%20=%20document.createElement('script');s.type='text/javascript';s.src='http://json-tinyurl.appspot.com/?callback=onTinyUrlGot&url='%20+document.location;document.getElementsByTagName('head')[0].appendChild(s);}})();
     46[1]: javascript:(function(){var%20url=document.location;var%20links=document.getElementsByTagName('link');var%20found=0;for(var%20i=0,l;l=links[i];i++){if(l.getAttribute('rel')=='shortlink'||(/alternateshort/).exec(l.getAttribute('rel'))){found=l.getAttribute('href');break;}}if(!found){for(var%20i=0;l=document.links[i];i++){if(l.getAttribute('rel')=='shorturl'){found=l.getAttribute('href');break;}}}if(found){prompt('URL:',found);}else{alert("No%20shortlink%20found");}})();
    4747
    4848(Just drag to your bookmarks bar)
    4949
    50 In Safari 5, I use the "[Short URL](http://clintecker.com/safari/extensions/shorturl/)" extension by Clink Ecker.
     50There's also the "[Short URL](http://github.com/clintecker/Shorturl-Safari-Extension)" Safari extension by Clink Ecker.
    5151
    5252
    53 == Screenshots == 
     53== Screenshots ==
    5454
    5555None.
     
    5959This plugin is licensed under the [New BSD license](http://akrabat.com/license/new-bsd).
    6060
    61 == History == 
     61== History ==
    6262
     63
     64**2.0.6 - 8 August 2015**
     65Ensure that the short_link is correct when using a post id.
     66
     67**2.0.5 - 8 August 2015**
     68Updated Tested up to 4.3
    6369
    6470**2.0.3 - 9 July 2012**
     
    8389
    8490**1.8 - 1 September 2010**
    85 use shortlink rather than shorturl for WordPress less than 3. 
    86 For WordPress 3 or higher, hook into the new shortlink system. 
     91use shortlink rather than shorturl for WordPress less than 3.
     92For WordPress 3 or higher, hook into the new shortlink system.
    8793Fix the admin page so that it displays in WordPress 3.
    8894
     
    102108Add support for setting the base URL. Patch by [Dave Marshall](davemastergeneral@gmail.com).
    103109
    104 **1.2 - 13 April 2009** 
     110**1.2 - 13 April 2009**
    105111Only send the `Link` HTTP header as recommended by [Shiflett](http://shiflett.org/blog/2009/apr/a-rev-canonical-http-header).
    106112
    107 **1.1 - 13 April 2009** 
     113**1.1 - 13 April 2009**
    108114Fixed output of HTTP headers. Patch by [Jeff Waugh](http://bethesignal.org/).
    109115
    110 **1.0 - 11 April 2009** 
     116**1.0 - 11 April 2009**
    111117Initial release.
    112118
  • shorter-links/trunk/shorter_links.php

    r569345 r1215493  
    44Plugin URI: http://wordpress.org/extend/plugins/shorter-links/
    55Description: Overrides WordPress' shortlink functionality to allow custom shortcodes per post.
    6 Version: 2.0.3
     6Version: 2.0.6
    77Author: Rob Allen
    88Author URI: http://akrabat.com
     
    2929        if(empty($shortLink) && isset($_SERVER['REQUEST_URI'])) {
    3030            $shortLink = trim($_SERVER['REQUEST_URI'], '/');
    31         }       
     31        }
    3232        if (empty($shortLink)) {
    3333            return $query_vars;
     
    4646        }
    4747
    48         // Look up the post or page with this shorter link 
     48        // Look up the post or page with this shorter link
    4949        $query = array('meta_key' => self::META_FIELD_NAME, 'meta_value' => $shortLink);
    5050        $posts = get_posts($query);
     
    7676        $short_link = get_post_meta($post_id, self::META_FIELD_NAME, true);
    7777        if('' == $short_link) {
     78            // Set shortlink to /{post id} as it looks nicer than ?p={post id}
    7879            $short_link = $post_id;
    7980        }
     81        $short_link = '/' . ltrim($short_link, '/');
    8082
    8183        $url = trim(get_option('akrabat_sl_base_url'), "/\t\r\n ");
    8284        if (!empty($url)) {
    83             $short_link = rtrim($url, '/') . '/' . $short_link;
     85            $short_link = rtrim($url, '/') . $short_link;
    8486        } else {
    8587            $short_link = home_url($short_link);
Note: See TracChangeset for help on using the changeset viewer.