Changeset 1215493
- Timestamp:
- 08/08/2015 08:20:11 AM (11 years ago)
- Location:
- shorter-links/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (5 diffs)
-
shorter_links.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
shorter-links/trunk/readme.txt
r1215441 r1215493 2 2 Contributors: akrabat 3 3 Donate link: http://akrabat.com 4 Tags: revcanonical links url shorter shorturlshortlink4 Tags: revcanonical, links, url shortener, shorturl, shortlink 5 5 Requires at least: 3.0 6 6 Tested up to: 4.3 7 Stable tag: 2.0.5 7 Stable tag: 2.0.6 8 License: New-BSD 9 License URI: http://akrabat.com/license/new-bsd 8 10 9 11 Override the default WordPress "shortlink" URL with one that … … 40 42 ** Is there a bookmarklet to extract shorturl links? ** 41 43 42 T his is a bookmarklet based on [Shorten](http://swtiny.eu/EZa):44 Try this bookmarklet: [Short URL][1] 43 45 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");}})(); 47 47 48 48 (Just drag to your bookmarks bar) 49 49 50 In Safari 5, I use the "[Short URL](http://clintecker.com/safari/extensions/shorturl/)"extension by Clink Ecker.50 There's also the "[Short URL](http://github.com/clintecker/Shorturl-Safari-Extension)" Safari extension by Clink Ecker. 51 51 52 52 53 == Screenshots == 53 == Screenshots == 54 54 55 55 None. … … 59 59 This plugin is licensed under the [New BSD license](http://akrabat.com/license/new-bsd). 60 60 61 == History == 61 == History == 62 62 63 64 **2.0.6 - 8 August 2015** 65 Ensure that the short_link is correct when using a post id. 66 67 **2.0.5 - 8 August 2015** 68 Updated Tested up to 4.3 63 69 64 70 **2.0.3 - 9 July 2012** … … 83 89 84 90 **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. 91 use shortlink rather than shorturl for WordPress less than 3. 92 For WordPress 3 or higher, hook into the new shortlink system. 87 93 Fix the admin page so that it displays in WordPress 3. 88 94 … … 102 108 Add support for setting the base URL. Patch by [Dave Marshall](davemastergeneral@gmail.com). 103 109 104 **1.2 - 13 April 2009** 110 **1.2 - 13 April 2009** 105 111 Only send the `Link` HTTP header as recommended by [Shiflett](http://shiflett.org/blog/2009/apr/a-rev-canonical-http-header). 106 112 107 **1.1 - 13 April 2009** 113 **1.1 - 13 April 2009** 108 114 Fixed output of HTTP headers. Patch by [Jeff Waugh](http://bethesignal.org/). 109 115 110 **1.0 - 11 April 2009** 116 **1.0 - 11 April 2009** 111 117 Initial release. 112 118 -
shorter-links/trunk/shorter_links.php
r569345 r1215493 4 4 Plugin URI: http://wordpress.org/extend/plugins/shorter-links/ 5 5 Description: Overrides WordPress' shortlink functionality to allow custom shortcodes per post. 6 Version: 2.0. 36 Version: 2.0.6 7 7 Author: Rob Allen 8 8 Author URI: http://akrabat.com … … 29 29 if(empty($shortLink) && isset($_SERVER['REQUEST_URI'])) { 30 30 $shortLink = trim($_SERVER['REQUEST_URI'], '/'); 31 } 31 } 32 32 if (empty($shortLink)) { 33 33 return $query_vars; … … 46 46 } 47 47 48 // Look up the post or page with this shorter link 48 // Look up the post or page with this shorter link 49 49 $query = array('meta_key' => self::META_FIELD_NAME, 'meta_value' => $shortLink); 50 50 $posts = get_posts($query); … … 76 76 $short_link = get_post_meta($post_id, self::META_FIELD_NAME, true); 77 77 if('' == $short_link) { 78 // Set shortlink to /{post id} as it looks nicer than ?p={post id} 78 79 $short_link = $post_id; 79 80 } 81 $short_link = '/' . ltrim($short_link, '/'); 80 82 81 83 $url = trim(get_option('akrabat_sl_base_url'), "/\t\r\n "); 82 84 if (!empty($url)) { 83 $short_link = rtrim($url, '/') . '/' .$short_link;85 $short_link = rtrim($url, '/') . $short_link; 84 86 } else { 85 87 $short_link = home_url($short_link);
Note: See TracChangeset
for help on using the changeset viewer.