Changeset 561032
- Timestamp:
- 06/20/2012 10:38:06 AM (14 years ago)
- Location:
- shorter-links/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (2 diffs)
-
shorter_links.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
shorter-links/trunk/readme.txt
r314129 r561032 4 4 Tags: revcanonical links url shorter shorturl shortlink 5 5 Requires at least: 3.0 6 Tested up to: 3. 0.17 Stable tag: 2.0. 06 Tested up to: 3.4 7 Stable tag: 2.0.1 8 8 9 9 Override the default WordPress "shortlink" URL with one that … … 61 61 == History == 62 62 63 64 **2.0.1 - 20 June 2012** 65 Updated to handle 4 digit short links that look like a year to WordPress. 66 63 67 **2.0.0 - 21 November 2010** 64 68 Updated to be WordPress 3.0 or above, so we only need to hook into the WordPress -
shorter-links/trunk/shorter_links.php
r314129 r561032 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. 06 Version: 2.0.1 7 7 Author: Rob Allen 8 8 Author URI: http://akrabat.com … … 24 24 $shortLink = $query_vars['category_name']; 25 25 } 26 if (array_key_exists('year', $query_vars)) { 27 $shortLink = $query_vars['year']; 28 } 26 29 if (empty($shortLink)) { 27 30 return $query_vars; 28 31 } 29 32 30 if ((int) $shortLink > 0) {31 // As we have a number, ssume that it is the post's id.33 // try for permalink first 34 if (is_numeric($shortLink)) { 32 35 $link = get_permalink($shortLink); 33 36 if ($link) { … … 35 38 exit; 36 39 } 40 } 41 42 // Look up the post or page with this shorter link 43 $query = array('meta_key' => self::META_FIELD_NAME, 'meta_value' => $shortLink); 44 $posts = get_posts($query); 45 if (count($posts) > 0) { 46 wp_redirect(get_permalink($posts[0]), 301); 47 exit; 37 48 } else { 38 // Look up the post or page with this shorter link 39 $query = array('meta_key' => self::META_FIELD_NAME, 'meta_value' => $shortLink); 40 $posts = get_posts($query); 41 if (count($posts) > 0) { 42 wp_redirect(get_permalink($posts[0]), 301); 49 $pages = get_pages($query); 50 if (count($pages) > 0) { 51 wp_redirect(get_permalink($pages[0]), 301); 43 52 exit; 44 } else {45 $pages = get_pages($query);46 if (count($pages) > 0) {47 wp_redirect(get_permalink($pages[0]), 301);48 exit;49 }50 53 } 51 54 }
Note: See TracChangeset
for help on using the changeset viewer.