Version Description
- Re-issue of 2.1 for immediate fix of issue with the 3.0 version.(6/21/2010)
Download this release
Release Info
Developer | prophecy2040 |
Plugin | Quick Page/Post Redirect Plugin |
Version | 3.1 |
Comparing to | |
See all releases |
Code changes from version 3.0 to 3.1
- page_post_redirect_plugin.php +19 -20
- readme.txt +3 -1
page_post_redirect_plugin.php
CHANGED
@@ -2,12 +2,13 @@
|
|
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.
|
6 |
Author: Don Fischer
|
7 |
Author URI: http://www.fischercreativemedia.com/
|
8 |
-
Version: 3.
|
9 |
|
10 |
Version info:
|
|
|
11 |
3.0 - Enhance Filter to reduce number of DB calls. (06/20/10)
|
12 |
2.1 - Fix Bug - Open in New Window would not work unless Show Link URL was also selected. (3/12/2010)
|
13 |
- Fix Bug - Add rel=nofollow would not work if Open in a New Window was not selected. (3/13/2010)
|
@@ -185,9 +186,6 @@ Version info:
|
|
185 |
//----------
|
186 |
global $wpdb;
|
187 |
global $wp_query;
|
188 |
-
global $pprpagemetakeypairs;
|
189 |
-
$pprpagemetakeypairs = array();
|
190 |
-
|
191 |
|
192 |
// Functions
|
193 |
//----------
|
@@ -199,20 +197,17 @@ Version info:
|
|
199 |
|
200 |
// used to get the meta_value and ID of a post with specific meta_key.
|
201 |
function ppr_get_metavalfromkey($key) {
|
202 |
-
global $wpdb
|
203 |
-
|
204 |
-
$pprpagemetakeypairs[$key] = $wpdb->get_results( $wpdb->prepare( "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key=%s and post_id in (SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_pprredirect_active')", $key ) );
|
205 |
-
}
|
206 |
-
return $pprpagemetakeypairs[$key];
|
207 |
}
|
208 |
|
209 |
//clean up the Custom Fields to make it prettier on the Edit Page
|
210 |
function ppr_init_metaclean() {
|
211 |
$thepprversion = get_option('ppr_version');
|
212 |
-
if ($thepprversion=='3.
|
213 |
//nothing;
|
214 |
-
}else if ($thepprversion == '1.9' || $thepprversion == '2.0' || $thepprversion == '2.1') {
|
215 |
-
update_option( 'ppr_version', '3.
|
216 |
}else{
|
217 |
global $wpdb;
|
218 |
//want to make sure older version upgrading still
|
@@ -223,7 +218,7 @@ Version info:
|
|
223 |
$wpdb->query( "UPDATE $wpdb->postmeta SET meta_key = '_pprredirect_url' WHERE meta_key = 'pprredirect_url'" );
|
224 |
wp_cache_flush();
|
225 |
//end remove
|
226 |
-
update_option( 'ppr_version', '3.
|
227 |
}
|
228 |
}
|
229 |
|
@@ -249,12 +244,7 @@ Version info:
|
|
249 |
}else{
|
250 |
$id = $post;
|
251 |
}
|
252 |
-
$
|
253 |
-
$pprvals=array();
|
254 |
-
foreach($ppr_rewrite_temp as $pprrew){
|
255 |
-
$pprvals[$pprrew->post_id] = $pprrew->meta_value;
|
256 |
-
}
|
257 |
-
$ppr_rewrite = $pprvals[$id];
|
258 |
if (isset($ppr_cache[$id]) ){
|
259 |
if($ppr_rewrite==='1'){ //only change the link if they want - otherwise, we will redirect the old way.
|
260 |
if(strpos($ppr_cache[$id],get_bloginfo('url'))>=0 || strpos($ppr_cache[$id],'www.')>=0 || strpos($ppr_cache[$id],'http://')>=0 || strpos($ppr_cache[$id],'https://')>=0){
|
@@ -264,6 +254,7 @@ Version info:
|
|
264 |
}
|
265 |
}
|
266 |
}
|
|
|
267 |
}
|
268 |
|
269 |
function ppr_linktometa() {
|
@@ -274,7 +265,9 @@ Version info:
|
|
274 |
$links_to = ppr_get_metavalfromkey('_pprredirect_url');
|
275 |
if(count($links_to)>0){
|
276 |
foreach((array) $links_to as $link){
|
|
|
277 |
$ppr_cache[$blog_id][$link->post_id] = $link->meta_value;
|
|
|
278 |
}
|
279 |
return $ppr_cache[$blog_id];
|
280 |
}else{
|
@@ -315,6 +308,7 @@ Version info:
|
|
315 |
foreach((array) $links_to as $link){
|
316 |
$ppr_norel[$blog_id][$link->post_id] = $link->meta_value;
|
317 |
}
|
|
|
318 |
return $ppr_norel[$blog_id];
|
319 |
}
|
320 |
|
@@ -509,10 +503,12 @@ Version info:
|
|
509 |
foreach($norels as $relid => $rel){
|
510 |
$validexp="/page-item-".$relid."\"><a(?:.*)rel=\"nofollow\"(?:.*?)>/i";
|
511 |
$found = preg_match_all($validexp, $pages, $matches);
|
|
|
512 |
if($found!=0){
|
513 |
$pages = $pages; //do nothing 'cause it is already a rel=nofollow.
|
514 |
}else{
|
515 |
$pages = preg_replace('/page-item-'.$relid.'"><a(.*?)>/i', 'page-item-'.$relid.'"><a\1 rel="nofollow">', $pages);
|
|
|
516 |
}
|
517 |
}
|
518 |
}
|
@@ -523,10 +519,13 @@ Version info:
|
|
523 |
$t = esc_url($t);
|
524 |
$validexp="/page-item-".$p."\"><a(?:.*)target=\"_blank\"(?:.*?)>/i";
|
525 |
$found = preg_match_all($validexp, $pages, $matches);
|
|
|
|
|
526 |
if($found!=0){
|
527 |
$pages = $pages; //do nothing 'cause it is already a rel=nofollow.
|
528 |
}else{
|
529 |
$pages = preg_replace('/page-item-'.$p.'"><a(.*?)>/i', 'page-item-'.$p.'"><a\1 target="_blank">', $pages);
|
|
|
530 |
}
|
531 |
}
|
532 |
}
|
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 which can be to another WordPress page/post or an external URL. Additional 301 Redirects can also be added for non-existant posts or pages - helpful for sites converted to WordPress. Version 1.9 and up allows for redirects to open in a new window as well as giving you the ability to add the rel=nofollow to redirected links.
|
6 |
Author: Don Fischer
|
7 |
Author URI: http://www.fischercreativemedia.com/
|
8 |
+
Version: 3.1
|
9 |
|
10 |
Version info:
|
11 |
+
3.1 - Re-issue of 2.1 for immediate fix of issue with the 3.0 version.(6/21/2010)
|
12 |
3.0 - Enhance Filter to reduce number of DB calls. (06/20/10)
|
13 |
2.1 - Fix Bug - Open in New Window would not work unless Show Link URL was also selected. (3/12/2010)
|
14 |
- Fix Bug - Add rel=nofollow would not work if Open in a New Window was not selected. (3/13/2010)
|
186 |
//----------
|
187 |
global $wpdb;
|
188 |
global $wp_query;
|
|
|
|
|
|
|
189 |
|
190 |
// Functions
|
191 |
//----------
|
197 |
|
198 |
// used to get the meta_value and ID of a post with specific meta_key.
|
199 |
function ppr_get_metavalfromkey($key) {
|
200 |
+
global $wpdb;
|
201 |
+
return $wpdb->get_results( $wpdb->prepare( "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key=%s and post_id in (SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_pprredirect_active')", $key ) );
|
|
|
|
|
|
|
202 |
}
|
203 |
|
204 |
//clean up the Custom Fields to make it prettier on the Edit Page
|
205 |
function ppr_init_metaclean() {
|
206 |
$thepprversion = get_option('ppr_version');
|
207 |
+
if ($thepprversion=='3.1') {
|
208 |
//nothing;
|
209 |
+
}else if ($thepprversion == '1.9' || $thepprversion == '2.0' || $thepprversion == '2.1' || $thepprversion == '3.0') {
|
210 |
+
update_option( 'ppr_version', '3.1' );
|
211 |
}else{
|
212 |
global $wpdb;
|
213 |
//want to make sure older version upgrading still
|
218 |
$wpdb->query( "UPDATE $wpdb->postmeta SET meta_key = '_pprredirect_url' WHERE meta_key = 'pprredirect_url'" );
|
219 |
wp_cache_flush();
|
220 |
//end remove
|
221 |
+
update_option( 'ppr_version', '3.1' );
|
222 |
}
|
223 |
}
|
224 |
|
244 |
}else{
|
245 |
$id = $post;
|
246 |
}
|
247 |
+
$ppr_rewrite = get_post_meta($id,'_pprredirect_rewritelink',true);
|
|
|
|
|
|
|
|
|
|
|
248 |
if (isset($ppr_cache[$id]) ){
|
249 |
if($ppr_rewrite==='1'){ //only change the link if they want - otherwise, we will redirect the old way.
|
250 |
if(strpos($ppr_cache[$id],get_bloginfo('url'))>=0 || strpos($ppr_cache[$id],'www.')>=0 || strpos($ppr_cache[$id],'http://')>=0 || strpos($ppr_cache[$id],'https://')>=0){
|
254 |
}
|
255 |
}
|
256 |
}
|
257 |
+
return $link;
|
258 |
}
|
259 |
|
260 |
function ppr_linktometa() {
|
265 |
$links_to = ppr_get_metavalfromkey('_pprredirect_url');
|
266 |
if(count($links_to)>0){
|
267 |
foreach((array) $links_to as $link){
|
268 |
+
//if(get_post_meta($link->post_id,'_pprredirect_active',true)!=''){
|
269 |
$ppr_cache[$blog_id][$link->post_id] = $link->meta_value;
|
270 |
+
//}
|
271 |
}
|
272 |
return $ppr_cache[$blog_id];
|
273 |
}else{
|
308 |
foreach((array) $links_to as $link){
|
309 |
$ppr_norel[$blog_id][$link->post_id] = $link->meta_value;
|
310 |
}
|
311 |
+
//print_r($ppr_norel[$blog_id]);
|
312 |
return $ppr_norel[$blog_id];
|
313 |
}
|
314 |
|
503 |
foreach($norels as $relid => $rel){
|
504 |
$validexp="/page-item-".$relid."\"><a(?:.*)rel=\"nofollow\"(?:.*?)>/i";
|
505 |
$found = preg_match_all($validexp, $pages, $matches);
|
506 |
+
//if(strpos($pages,'page-item-'.$relid.'">a href="'.$rel.'" rel="nofollow" ')>0) {
|
507 |
if($found!=0){
|
508 |
$pages = $pages; //do nothing 'cause it is already a rel=nofollow.
|
509 |
}else{
|
510 |
$pages = preg_replace('/page-item-'.$relid.'"><a(.*?)>/i', 'page-item-'.$relid.'"><a\1 rel="nofollow">', $pages);
|
511 |
+
//$pages = str_replace(' href="'.$rel.'"',' href="'.$rel.'" rel="nofollow" ', $pages); //add no follow.
|
512 |
}
|
513 |
}
|
514 |
}
|
519 |
$t = esc_url($t);
|
520 |
$validexp="/page-item-".$p."\"><a(?:.*)target=\"_blank\"(?:.*?)>/i";
|
521 |
$found = preg_match_all($validexp, $pages, $matches);
|
522 |
+
//if(strpos($pages,' href="'.$t.'" target="'.$p.'" ')>0){
|
523 |
+
//$pages = $pages; //already has a target
|
524 |
if($found!=0){
|
525 |
$pages = $pages; //do nothing 'cause it is already a rel=nofollow.
|
526 |
}else{
|
527 |
$pages = preg_replace('/page-item-'.$p.'"><a(.*?)>/i', 'page-item-'.$p.'"><a\1 target="_blank">', $pages);
|
528 |
+
//$pages = str_replace(' href="'.$p.'" ',' href="'.$p.'" target="'.$t.'" ', $pages);
|
529 |
}
|
530 |
}
|
531 |
}
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://fischercreativemedia.com/
|
|
4 |
Tags: redirect, 301, 302, meta, post, plugin, page, forward, re-direct, nofollow, wpmu, menu links, WordPress MU, posts, pages, admin, 404
|
5 |
Requires at least: 2.5
|
6 |
Tested up to: 3.1 alpha
|
7 |
-
Stable tag: 3.
|
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 |
|
@@ -109,6 +109,8 @@ Yes, you can, but you do not always need to. If you are redirecting to an extern
|
|
109 |
3. Menu for the Quick 301 Redirects page - located in the settings menu.
|
110 |
|
111 |
== Changelog ==
|
|
|
|
|
112 |
= 3.0 =
|
113 |
* Enhance filter function in main class to reduce Database calls. (06/20/2010)
|
114 |
= 2.1 =
|
4 |
Tags: redirect, 301, 302, meta, post, plugin, page, forward, re-direct, nofollow, wpmu, menu links, WordPress MU, posts, pages, admin, 404
|
5 |
Requires at least: 2.5
|
6 |
Tested up to: 3.1 alpha
|
7 |
+
Stable tag: 3.1
|
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 |
|
109 |
3. Menu for the Quick 301 Redirects page - located in the settings menu.
|
110 |
|
111 |
== Changelog ==
|
112 |
+
= 3.1 =
|
113 |
+
* Re-issue of 2.1 for immediate fix of issue with the 3.0 version.(6/21/2010)
|
114 |
= 3.0 =
|
115 |
* Enhance filter function in main class to reduce Database calls. (06/20/2010)
|
116 |
= 2.1 =
|