Redirect - Version 4.0.3

Version Description

Download this release

Release Info

Developer willshouse
Plugin Icon wp plugin Redirect
Version 4.0.3
Comparing to
See all releases

Code changes from version 4.0.1 to 4.0.3

Files changed (2) hide show
  1. readme.txt +1 -1
  2. simple-redirect.php +15 -2
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: Get on Social
3
  Tags: redirect, redirects, headers, posts, redirection, simple, easy, SEO, 301
4
  Requires at least: 2.5
5
  Tested up to: 4.0
6
- Stable tag: 4.0.1
7
 
8
  Easily 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.
9
 
3
  Tags: redirect, redirects, headers, posts, redirection, simple, easy, SEO, 301
4
  Requires at least: 2.5
5
  Tested up to: 4.0
6
+ Stable tag: 4.0.3
7
 
8
  Easily 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.
9
 
simple-redirect.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  * Plugin Name: Simple Redirect
4
- * Version: 4.0.1
5
  * 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.
6
  * Author: Get on Social
7
  * Contributors: Get on Social, khromov
@@ -20,6 +20,9 @@ class GosSimpleRedirect
20
  var $context = 'side';
21
  var $priority = 'default';
22
 
 
 
 
23
  function __construct()
24
  {
25
 
@@ -46,6 +49,7 @@ class GosSimpleRedirect
46
  // for the actual redirect
47
  add_action('template_redirect',array($this,'template_redirect'), 10 );
48
 
 
49
  // rewrite links to 301'd pages preemptively
50
  add_filter('post_link',array($this,'post_link'),20,2);
51
  add_filter('post_type_link',array($this,'post_link'),20,2);
@@ -57,6 +61,8 @@ class GosSimpleRedirect
57
  // prevent an extra 301 "hop"
58
  add_filter('wp_nav_menu_objects',array($this,'wp_nav_menu_objects'));
59
 
 
 
60
  }
61
 
62
 
@@ -84,8 +90,12 @@ class GosSimpleRedirect
84
  function post_link($link)
85
  {
86
 
87
- global $post;
 
 
 
88
 
 
89
 
90
  if(!empty($post->ID))
91
  {
@@ -123,6 +133,7 @@ class GosSimpleRedirect
123
  function get_redirect_info($post_id)
124
  {
125
 
 
126
  $redirect_info = array();
127
  $redirect = get_post_meta( $post_id, $this->namespace, true );
128
  if(!empty($redirect['type']))
@@ -150,6 +161,8 @@ class GosSimpleRedirect
150
  break;
151
  }
152
  }
 
 
153
  return $redirect_info;
154
  }
155
 
1
  <?php
2
  /*
3
  * Plugin Name: Simple Redirect
4
+ * Version: 4.0.3
5
  * 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.
6
  * Author: Get on Social
7
  * Contributors: Get on Social, khromov
20
  var $context = 'side';
21
  var $priority = 'default';
22
 
23
+ // used to prevent internal recursion
24
+ var $looking_up_link = false;
25
+
26
  function __construct()
27
  {
28
 
49
  // for the actual redirect
50
  add_action('template_redirect',array($this,'template_redirect'), 10 );
51
 
52
+
53
  // rewrite links to 301'd pages preemptively
54
  add_filter('post_link',array($this,'post_link'),20,2);
55
  add_filter('post_type_link',array($this,'post_link'),20,2);
61
  // prevent an extra 301 "hop"
62
  add_filter('wp_nav_menu_objects',array($this,'wp_nav_menu_objects'));
63
 
64
+
65
+
66
  }
67
 
68
 
90
  function post_link($link)
91
  {
92
 
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
 
98
+ global $post;
99
 
100
  if(!empty($post->ID))
101
  {
133
  function get_redirect_info($post_id)
134
  {
135
 
136
+ $this->looking_up_link = true;
137
  $redirect_info = array();
138
  $redirect = get_post_meta( $post_id, $this->namespace, true );
139
  if(!empty($redirect['type']))
161
  break;
162
  }
163
  }
164
+
165
+ $this->looking_up_link = false;
166
  return $redirect_info;
167
  }
168