Plugin Directory

Changeset 561032


Ignore:
Timestamp:
06/20/2012 10:38:06 AM (14 years ago)
Author:
akrabat
Message:

update to allow 4 digit short codes

Location:
shorter-links/trunk
Files:
2 edited

Legend:

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

    r314129 r561032  
    44Tags: revcanonical links url shorter shorturl shortlink
    55Requires at least: 3.0
    6 Tested up to: 3.0.1
    7 Stable tag: 2.0.0
     6Tested up to: 3.4
     7Stable tag: 2.0.1
    88
    99Override the default WordPress "shortlink" URL with one that
     
    6161== History ==
    6262
     63
     64**2.0.1 - 20 June 2012**
     65Updated to handle 4 digit short links that look like a year to WordPress.
     66
    6367**2.0.0 - 21 November 2010**
    6468Updated to be WordPress 3.0 or above, so we only need to hook into the WordPress
  • shorter-links/trunk/shorter_links.php

    r314129 r561032  
    44Plugin URI: http://wordpress.org/extend/plugins/shorter-links/
    55Description: Overrides WordPress' shortlink functionality to allow custom shortcodes per post.
    6 Version: 2.0.0
     6Version: 2.0.1
    77Author: Rob Allen
    88Author URI: http://akrabat.com
     
    2424            $shortLink = $query_vars['category_name'];
    2525        }
     26        if (array_key_exists('year', $query_vars)) {
     27            $shortLink = $query_vars['year'];
     28        }
    2629        if (empty($shortLink)) {
    2730            return $query_vars;
    2831        }
    2932
    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)) {
    3235            $link = get_permalink($shortLink);
    3336            if ($link) {
     
    3538                exit;
    3639            }
     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;
    3748        } 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);
    4352                exit;
    44             } else {
    45                 $pages = get_pages($query);
    46                 if (count($pages) > 0) {
    47                     wp_redirect(get_permalink($pages[0]), 301);
    48                     exit;
    49                 }
    5053            }
    5154        }
Note: See TracChangeset for help on using the changeset viewer.