Quick Page/Post Redirect Plugin - Version 1.6

Version Description

  • Fixed wrongfull redirect when the first blog post on home page (main blog page) has a redirect set up - this was redirecting the entire page incorrectly. This was only an issue with the first post on a page. (9/1/2009)
Download this release

Release Info

Developer prophecy2040
Plugin Icon 128x128 Quick Page/Post Redirect Plugin
Version 1.6
Comparing to
See all releases

Code changes from version 1.5 to 1.6

Files changed (2) hide show
  1. page_post_redirect_plugin.php +45 -41
  2. readme.txt +3 -1
page_post_redirect_plugin.php CHANGED
@@ -2,12 +2,14 @@
2
  /*
3
  Plugin Name: Quick Page/Post Redirect
4
  Plugin URI: http://fischercreativemedia.com/wordpress-plugins/quick-pagepost-redirct-plugin/
5
- Description: Redirect Pages or Posts to another location quickly. Adds a redirect box to the page or post edit page where you can specify the redirect Location and type. Location can be to another WordPress page/post or an external URL. UPDATE: Page or post NO LONGER needs to be published for this to work correctly.
6
  Author: Don Fischer
7
  Author URI: http://www.fischercreativemedia.com/
8
- Version: 1.5
9
 
10
  Version info:
 
 
11
  1.5 - Re-Write plugin core function to hook WP at a later time to take advantage of the POST function - no sense re-creating the wheel.
12
  Can have page/post as draft and still redirect - but ONLY after the post/page has first been published and
13
  then re-saved as draft (this will hopefully be a fix for a later version). (8/31/2009)
@@ -54,50 +56,52 @@ Version info:
54
 
55
  function ppr_do_redirect(){
56
  global $post,$wp_query,$ppr_url,$ppr_active,$ppr_url,$ppr_type;
57
- $thisidis_current= $post->ID;
58
- $ppr_active=get_post_meta($thisidis_current,'pprredirect_active',true);
59
- $ppr_url=get_post_meta($thisidis_current,'pprredirect_url',true);
60
- $ppr_type=get_post_meta($thisidis_current,'pprredirect_type',true);
61
-
62
- if( $ppr_active==1 && $ppr_url!='' ):
63
- if($ppr_type===0){$ppr_type='200';}
64
- if($ppr_type===''){$ppr_type='302';}
65
- if($ppr_type=='meta'):
66
- //metaredirect
67
- add_action('wp_head', "addmetatohead_theme",1);
68
- exit; //stop loading page so meta can do it's job without rest of page loading.
69
- elseif($ppr_url!=''):
70
- //check for http:// - as full url - then we can just redirect if it is //
71
- if( strpos($ppr_url, 'http://')=== 0 || strpos($ppr_url, 'https://')=== 0){
72
- $offsite=$ppr_url;
73
- header('Status: '.$ppr_type);
74
- header('Location: '.$offsite, true, $ppr_type);
75
- exit; //stop loading page
76
- }elseif(strpos($ppr_url, 'www')=== 0){ // check if they have full url but did not put http://
77
- $offsite='http://'.$ppr_url;
78
- header("Status: $ppr_type");
79
- header("Location: $offsite", true, $ppr_type);
80
- exit; //stop loading page
81
- }elseif(is_numeric($ppr_url)){ // page/post number
82
- if($ppr_postpage=='page'){ //page
83
- $onsite=get_bloginfo('url').'/?page_id='.$ppr_url;
84
- header("Status: $ppr_type");
85
- header("Location: $onsite", true, $ppr_type);
86
  exit; //stop loading page
87
- }else{ //post
88
- $onsite=get_bloginfo('url').'/?p='.$ppr_url;
89
  header("Status: $ppr_type");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  header("Location: $onsite", true, $ppr_type);
91
  exit; //stop loading page
92
  }
93
- //check permalink or local page redirect
94
- }else{ // we assume they are using the permalink / page name??
95
- $onsite=get_bloginfo('url'). $ppr_url;
96
- header("Location: $onsite", true, $ppr_type);
97
- exit; //stop loading page
98
- }
99
-
100
- endif;
101
  endif;
102
  }
103
 
2
  /*
3
  Plugin Name: Quick Page/Post Redirect
4
  Plugin URI: http://fischercreativemedia.com/wordpress-plugins/quick-pagepost-redirct-plugin/
5
+ Description: Redirect Pages or Posts to another location quickly. Adds a redirect box to the page or post edit page where you can specify the redirect Location and type. Location can be to another WordPress page/post or an external URL. UPDATE: Page or post NO LONGER needs to be published for this to work correctly - however you do need to publish it and then save it as a draft so WordPress creates the proper meta for it.
6
  Author: Don Fischer
7
  Author URI: http://www.fischercreativemedia.com/
8
+ Version: 1.6
9
 
10
  Version info:
11
+ 1.6 - Fix wrongfull redirect when the first blog post on home page (main blog page) has a redirect set up - this was redirecting the
12
+ entire page incorrectly. (9/1/2009)
13
  1.5 - Re-Write plugin core function to hook WP at a later time to take advantage of the POST function - no sense re-creating the wheel.
14
  Can have page/post as draft and still redirect - but ONLY after the post/page has first been published and
15
  then re-saved as draft (this will hopefully be a fix for a later version). (8/31/2009)
56
 
57
  function ppr_do_redirect(){
58
  global $post,$wp_query,$ppr_url,$ppr_active,$ppr_url,$ppr_type;
59
+ if(!$wp_query->is_home):
60
+ $thisidis_current= $post->ID;
61
+ $ppr_active=get_post_meta($thisidis_current,'pprredirect_active',true);
62
+ $ppr_url=get_post_meta($thisidis_current,'pprredirect_url',true);
63
+ $ppr_type=get_post_meta($thisidis_current,'pprredirect_type',true);
64
+
65
+ if( $ppr_active==1 && $ppr_url!='' ):
66
+ if($ppr_type===0){$ppr_type='200';}
67
+ if($ppr_type===''){$ppr_type='302';}
68
+ if($ppr_type=='meta'):
69
+ //metaredirect
70
+ add_action('wp_head', "addmetatohead_theme",1);
71
+ exit; //stop loading page so meta can do it's job without rest of page loading.
72
+ elseif($ppr_url!=''):
73
+ //check for http:// - as full url - then we can just redirect if it is //
74
+ if( strpos($ppr_url, 'http://')=== 0 || strpos($ppr_url, 'https://')=== 0){
75
+ $offsite=$ppr_url;
76
+ header('Status: '.$ppr_type);
77
+ header('Location: '.$offsite, true, $ppr_type);
 
 
 
 
 
 
 
 
 
 
78
  exit; //stop loading page
79
+ }elseif(strpos($ppr_url, 'www')=== 0){ // check if they have full url but did not put http://
80
+ $offsite='http://'.$ppr_url;
81
  header("Status: $ppr_type");
82
+ header("Location: $offsite", true, $ppr_type);
83
+ exit; //stop loading page
84
+ }elseif(is_numeric($ppr_url)){ // page/post number
85
+ if($ppr_postpage=='page'){ //page
86
+ $onsite=get_bloginfo('url').'/?page_id='.$ppr_url;
87
+ header("Status: $ppr_type");
88
+ header("Location: $onsite", true, $ppr_type);
89
+ exit; //stop loading page
90
+ }else{ //post
91
+ $onsite=get_bloginfo('url').'/?p='.$ppr_url;
92
+ header("Status: $ppr_type");
93
+ header("Location: $onsite", true, $ppr_type);
94
+ exit; //stop loading page
95
+ }
96
+ //check permalink or local page redirect
97
+ }else{ // we assume they are using the permalink / page name??
98
+ $onsite=get_bloginfo('url'). $ppr_url;
99
  header("Location: $onsite", true, $ppr_type);
100
  exit; //stop loading page
101
  }
102
+
103
+ endif;
104
+ endif;
 
 
 
 
 
105
  endif;
106
  }
107
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://fischercreativemedia.com/
4
  Tags: redirect, 301, 302, meta, post, plugin, page, forward, re-direct
5
  Requires at least: 2.5
6
  Tested up to: 2.8.4
7
- Stable tag: 1.5
8
 
9
  Redirect Pages/Posts to another page/post or external URL. Adds edit box to admin edit so user can specify the redirect Location and type.
10
 
@@ -67,6 +67,8 @@ Yes, you can, but you do not always need to. If you are redirecting to an extern
67
 
68
 
69
  == Changelog ==
 
 
70
  = 1.5 =
71
  * Major re-Write of the plugin core function to hook WP at a later time to take advantage of the POST function - no sense re-creating the wheel.
72
  * Removed the 'no code' redirect, as it turns out, many browsers will not redirect properly without a code - sorry guys.
4
  Tags: redirect, 301, 302, meta, post, plugin, page, forward, re-direct
5
  Requires at least: 2.5
6
  Tested up to: 2.8.4
7
+ Stable tag: 1.6
8
 
9
  Redirect Pages/Posts to another page/post or external URL. Adds edit box to admin edit so user can specify the redirect Location and type.
10
 
67
 
68
 
69
  == Changelog ==
70
+ = 1.6 =
71
+ * Fixed wrongfull redirect when the first blog post on home page (main blog page) has a redirect set up - this was redirecting the entire page incorrectly. This was only an issue with the first post on a page. (9/1/2009)
72
  = 1.5 =
73
  * Major re-Write of the plugin core function to hook WP at a later time to take advantage of the POST function - no sense re-creating the wheel.
74
  * Removed the 'no code' redirect, as it turns out, many browsers will not redirect properly without a code - sorry guys.