Plugin Directory

Changeset 991236


Ignore:
Timestamp:
09/16/2014 04:42:34 PM (11 years ago)
Author:
willshouse
Message:

updates to prevent recursion

Location:
simple-redirect/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • simple-redirect/trunk/readme.txt

    r990782 r991236  
    44Requires at least: 2.5
    55Tested up to: 4.0
    6 Stable tag: 4.0.1
     6Stable tag: 4.0.2
    77
    88Easily redirect any post or page to another page with a dropdown menu or by manually typing in a URL. Check out the screenshots. This plugin also changes permalinks and menus to point directly to the new location of the redirect - this prevents bots from getting a redirect and helps boost your SEO.
  • simple-redirect/trunk/simple-redirect.php

    r990782 r991236  
    22/*
    33 * Plugin Name: Simple Redirect
    4  * Version: 4.0.1
     4 * Version: 4.0.2
    55 * Description: Easily redirect any post or page to another page with a dropdown menu or by manually typing in a URL. This plugin also changes permalinks and menus to point directly to the new location of the redirect - this prevents bots from getting a redirect and helps boost your SEO.
    66 * Author: Get on Social
     
    2121        var $priority = 'default';
    2222
     23        // used to prevent internal recursion
     24        var $looking_up_link = false;
     25
    2326        function __construct()
    2427        {
     
    4649            // for the actual redirect
    4750            add_action('template_redirect',array($this,'template_redirect'), 10 );
     51
    4852
    4953            // rewrite links to 301'd pages preemptively
     
    5862            add_filter('wp_nav_menu_objects',array($this,'wp_nav_menu_objects'));
    5963
     64
     65
    6066        }
    6167
     
    8591        {
    8692
     93            // used to prevent internal recursion
     94            // special thanks to @khromov for describing a situation where this
     95            // could cause errors
     96            if( $this->looking_up_link ){ return $link; }
     97
    8798            global $post;
    88 
    8999
    90100            if(!empty($post->ID))
     
    124134        {
    125135
     136            $this->looking_up_link = true;
    126137            $redirect_info = array();
    127138            $redirect = get_post_meta( $post_id, $this->namespace, true );
     
    151162                }
    152163            }
     164
     165            $this->looking_up_link = false;
    153166            return $redirect_info;
    154167        }
Note: See TracChangeset for help on using the changeset viewer.