Quick Page/Post Redirect Plugin - Version 3.2.3

Version Description

  • Fix New Window and No Follow attributes in themes with older menu calls. (12/29/10)
Download this release

Release Info

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

Code changes from version 3.2.2 to 3.2.3

Files changed (2) hide show
  1. page_post_redirect_plugin.php +108 -9
  2. readme.txt +5 -1
page_post_redirect_plugin.php CHANGED
@@ -6,7 +6,7 @@ Description: Redirect Pages or Posts to another page or post or external locatio
6
  Author: Don Fischer
7
  Author URI: http://www.fischercreativemedia.com/
8
  Donate link: http://www.fischercreativemedia.com/wordpress-plugins/donate/
9
- Version: 3.2.2
10
 
11
  Version info:
12
  See change log in readme.txt file.
@@ -41,8 +41,31 @@ See change log in readme.txt file.
41
 
42
  //generate the options page in the wordpress admin
43
  function options_page(){
 
 
44
  ?>
45
  <div class="wrap">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  <h2>Quick 301 Redirects</h2>
47
  <br/>This section is useful if you have links from an old site and need to have them redirect to a new location on the current site, or if you have an existing URL that you need to send some place else and you don't want to have a Page or Post created to use the other Page/Post Redirect option.
48
  <br/>
@@ -55,15 +78,18 @@ See change log in readme.txt file.
55
  <tr>
56
  <th align="left">Request</th>
57
  <th align="left">Destination</th>
 
58
  </tr>
59
  <tr>
60
  <td><small>example: <code>/about.htm</code> or <code>/test-directory/landing-zone/</code></small></td>
61
  <td><small>example: <code><?php echo get_option('home'); ?>/about/</code> or <code><?php echo get_option('home'); ?>/landing/</code></small></td>
 
62
  </tr>
63
  <?php echo $this->expand_redirects(); ?>
64
  <tr>
65
  <td><input type="text" name="quickppr_redirects[request][]" value="" style="width:35em" />&nbsp;&raquo;&nbsp;</td>
66
  <td><input type="text" name="quickppr_redirects[destination][]" value="" style="width:35em;" /></td>
 
67
  </tr>
68
  </table>
69
 
@@ -81,13 +107,16 @@ See change log in readme.txt file.
81
  $redirects = get_option('quickppr_redirects');
82
  $output = '';
83
  if (!empty($redirects)) {
 
84
  foreach ($redirects as $request => $destination) {
85
  $output .= '
86
- <tr>
87
  <td><input type="text" name="quickppr_redirects[request][]" value="'.$request.'" style="width:35em" />&nbsp;&raquo;&nbsp;</td>
88
  <td><input type="text" name="quickppr_redirects[destination][]" value="'.$destination.'" style="width:35em;" /></td>
 
89
  </tr>
90
  ';
 
91
  }
92
  } // end if
93
  return $output;
@@ -166,6 +195,8 @@ See change log in readme.txt file.
166
  add_action('init', 'ppr_init_metaclean', 1);
167
  add_action('wp','ppr_new_nav_menu');
168
  add_action('plugin_action_links_' . plugin_basename(__FILE__), 'ppr_filter_plugin_actions');
 
 
169
  add_filter('plugin_row_meta', 'ppr_filter_plugin_links', 10, 2);
170
  if (isset($redirect_plugin)) {
171
  add_action('init', array($redirect_plugin,'redirect'), 1); // add the redirect action, high priority
@@ -175,6 +206,43 @@ See change log in readme.txt file.
175
 
176
  // Functions
177
  //----------
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  function ppr_filter_plugin_actions($links){
179
  $new_links = array();
180
  $fcmlink = 'http://www.fischercreativemedia.com/wordpress-plugins';
@@ -183,7 +251,7 @@ See change log in readme.txt file.
183
  }
184
  function ppr_filter_plugin_links($links, $file){
185
  if ( $file == plugin_basename(__FILE__) ){
186
- $adminlink = WP_HOME.'/wp-admin/';
187
  $fcmlink = 'http://www.fischercreativemedia.com/wordpress-plugins';
188
  $links[] = '<a href="'.$adminlink.'options-general.php?page=redirects-options">Quick Redirects</a>';
189
  $links[] = '<a target="_blank" href="'.$fcmlink.'/quick-pagepost-redirect-plugin/">FAQ</a>';
@@ -251,6 +319,8 @@ See change log in readme.txt file.
251
  }
252
  if(in_array($ppd->object_id,$ppr_url_rewrite)){
253
  $ppd->url = $ppr_url[$ppd->object_id]['URL'];
 
 
254
  }
255
  $newmenu[] = $ppd;
256
  }
@@ -401,9 +471,9 @@ See change log in readme.txt file.
401
 
402
  // The actual fields for data entry
403
  echo '<label for="pprredirect_active" style="padding:2px 0;"><input type="checkbox" name="pprredirect_active" value="1" '. checked('1',get_post_meta($post->ID,'_pprredirect_active',true),0).' />'. __(" Make Redirect <b>Active</b>. (check to turn on)", 'ppr_plugin' ) . '</label><br />';
404
- echo '<label for="pprredirect_newwindow" style="padding:2px 0;"><input type="checkbox" name="pprredirect_newwindow" id="pprredirect_newwindow" value="_blank" '. checked('_blank',get_post_meta($post->ID,'_pprredirect_newwindow',true),0).'>'. __(" Open redirect link in a <b>new window</b>. <span style=\"color:#800000;\"><i>NEW in version 1.9</i></span>", 'ppr_plugin' ) . '</label><br />';
405
- echo '<label for="pprredirect_relnofollow" style="padding:2px 0;"><input type="checkbox" name="pprredirect_relnofollow" id="pprredirect_relnofollow" value="1" '. checked('1',get_post_meta($post->ID,'_pprredirect_relnofollow',true),0).'>'. __(" Add <b>rel=\"nofollow\"</b> to redirect link. <span style=\"color:#800000;\"><i>NEW in version 1.9</i></span>", 'ppr_plugin' ) . '</label><br />';
406
- echo '<label for="pprredirect_rewritelink" style="padding:2px 0;"><input type="checkbox" name="pprredirect_rewritelink" id="pprredirect_rewritelink" value="1" '. checked('1',get_post_meta($post->ID,'_pprredirect_rewritelink',true),0).'>'. __(" <b>Show</b> the Redirect URL below in the link instead of this page URL. <b>NOTE: Use <u>FULL</u> URL below!</b> <span style=\"color:#800000;\"><i>NEW in version 1.9</i></span>", 'ppr_plugin' ) . '</label><br /><br />';
407
  echo '<label for="pprredirect_url">' . __(" <b>Redirect URL:</b>", 'ppr_plugin' ) . '</label><br />';
408
  if(get_post_meta($post->ID, '_pprredirect_url', true)!=''){$pprredirecturl=get_post_meta($post->ID, '_pprredirect_url', true);}else{$pprredirecturl="";}
409
  echo '<input type="text" style="width:75%;margin-top:2px;margin-bottom:2px;" name="pprredirect_url" value="'.$pprredirecturl.'" /><br />(i.e., <code>http://example.com</code> or <code>/somepage/</code> or <code>p=15</code> or <code>155</code>. Use <b>FULL URL</b> <i>including</i> <code>http://</code> for all external <i>and</i> meta redirects. )<br /><br />';
@@ -491,9 +561,38 @@ See change log in readme.txt file.
491
  global $ppr_newindow;
492
  global $ppr_url;
493
  global $ppr_url_rewrite;
 
494
 
495
  if (!$ppr_url && !$ppr_newindow && !$ppr_nofollow){
496
- return $pages;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
497
  }
498
 
499
  $this_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
@@ -515,13 +614,13 @@ See change log in readme.txt file.
515
  $validexp="@\<li(?:.*?)".$p."(?:.*?)\>\<a(?:.*?)target\=(?:.*?)\>@i";
516
  $found = preg_match_all($validexp, $pages, $matches);
517
  if($found!=0){
518
- $pages = $pages; //do nothing 'cause it is already a rel=nofollow.
519
  }else{
520
  $pages = preg_replace('@<li(.*?)-'.$p.'(.*?)\>\<a(.*?)\>@i', '<li\1-'.$p.'\2><a\3 target="_blank">', $pages);
521
  }
522
  }
523
  }
524
-
525
  return $pages;
526
  }
527
  ?>
6
  Author: Don Fischer
7
  Author URI: http://www.fischercreativemedia.com/
8
  Donate link: http://www.fischercreativemedia.com/wordpress-plugins/donate/
9
+ Version: 3.2.3
10
 
11
  Version info:
12
  See change log in readme.txt file.
41
 
42
  //generate the options page in the wordpress admin
43
  function options_page(){
44
+ $tohash = get_bloginfo('url').'/';
45
+
46
  ?>
47
  <div class="wrap">
48
+ <script type="text/javascript">
49
+ jQuery(document).ready(function() {
50
+ jQuery(".delete-qppr").click(function(){
51
+ var mainurl = '<?php echo get_bloginfo('url');?>/';
52
+ var thepprdel = jQuery(this).attr('id');
53
+ if(confirm('Are you sure you want to delete this redirect?')){
54
+ jQuery.ajax({
55
+ url: mainurl+"/",
56
+ data : "pprd="+thepprdel+"&scid=<?php echo md5($tohash);?>",
57
+ success: function(data){
58
+ jQuery('#row'+thepprdel).remove();
59
+ },
60
+ complete: function(){}
61
+ });
62
+ return false;
63
+ }else{
64
+ return false;
65
+ }
66
+ });
67
+ });
68
+ </script>
69
  <h2>Quick 301 Redirects</h2>
70
  <br/>This section is useful if you have links from an old site and need to have them redirect to a new location on the current site, or if you have an existing URL that you need to send some place else and you don't want to have a Page or Post created to use the other Page/Post Redirect option.
71
  <br/>
78
  <tr>
79
  <th align="left">Request</th>
80
  <th align="left">Destination</th>
81
+ <th align="left">&nbsp;</th>
82
  </tr>
83
  <tr>
84
  <td><small>example: <code>/about.htm</code> or <code>/test-directory/landing-zone/</code></small></td>
85
  <td><small>example: <code><?php echo get_option('home'); ?>/about/</code> or <code><?php echo get_option('home'); ?>/landing/</code></small></td>
86
+ <td>&nbsp;</td>
87
  </tr>
88
  <?php echo $this->expand_redirects(); ?>
89
  <tr>
90
  <td><input type="text" name="quickppr_redirects[request][]" value="" style="width:35em" />&nbsp;&raquo;&nbsp;</td>
91
  <td><input type="text" name="quickppr_redirects[destination][]" value="" style="width:35em;" /></td>
92
+ <td></td>
93
  </tr>
94
  </table>
95
 
107
  $redirects = get_option('quickppr_redirects');
108
  $output = '';
109
  if (!empty($redirects)) {
110
+ $ww=1;
111
  foreach ($redirects as $request => $destination) {
112
  $output .= '
113
+ <tr id="rowpprdel-'.$ww.'">
114
  <td><input type="text" name="quickppr_redirects[request][]" value="'.$request.'" style="width:35em" />&nbsp;&raquo;&nbsp;</td>
115
  <td><input type="text" name="quickppr_redirects[destination][]" value="'.$destination.'" style="width:35em;" /></td>
116
+ <td>&nbsp;<a href="javascript:void();" id="pprdel-'.$ww.'" class="delete-qppr">x</a>&nbsp;</td>
117
  </tr>
118
  ';
119
+ $ww++;
120
  }
121
  } // end if
122
  return $output;
195
  add_action('init', 'ppr_init_metaclean', 1);
196
  add_action('wp','ppr_new_nav_menu');
197
  add_action('plugin_action_links_' . plugin_basename(__FILE__), 'ppr_filter_plugin_actions');
198
+ add_action('wp','ppr_parse_request');
199
+ add_filter('query_vars','ppr_queryhook');
200
  add_filter('plugin_row_meta', 'ppr_filter_plugin_links', 10, 2);
201
  if (isset($redirect_plugin)) {
202
  add_action('init', array($redirect_plugin,'redirect'), 1); // add the redirect action, high priority
206
 
207
  // Functions
208
  //----------
209
+ function ppr_queryhook($vars) {
210
+ $vars[] = 'pprd';
211
+ $vars[] = 'scid';
212
+ return $vars;
213
+ }
214
+
215
+ //Hook into the Query Parse and get our vars to see if the page is the one we want.
216
+ function ppr_parse_request($wp) {
217
+ global $wp;
218
+ $quickppr_redirects = array();
219
+ if(array_key_exists('pprd', $wp->query_vars) && array_key_exists('scid', $wp->query_vars)){
220
+ $tohash = get_bloginfo('url').'/';
221
+ if( $wp->query_vars['pprd'] !='' && $wp->query_vars['scid'] == md5(get_bloginfo('url').'/')){
222
+ $theDel = str_replace('pprdel-','',$wp->query_vars['pprd']);
223
+ $redirects = get_option('quickppr_redirects');
224
+ if (!empty($redirects)) {
225
+ $ww=1;
226
+ foreach ($redirects as $request => $destination) {
227
+ if($ww != (int)$theDel){
228
+ $quickppr_redirects[$request]=$destination;
229
+ }
230
+ $ww++;
231
+ }
232
+ } // end if
233
+ update_option('quickppr_redirects',$quickppr_redirects);
234
+ echo 1;
235
+ exit;
236
+ }else{
237
+ echo 0;
238
+ exit;
239
+ }
240
+ }else{
241
+ return;
242
+ }
243
+
244
+ }
245
+
246
  function ppr_filter_plugin_actions($links){
247
  $new_links = array();
248
  $fcmlink = 'http://www.fischercreativemedia.com/wordpress-plugins';
251
  }
252
  function ppr_filter_plugin_links($links, $file){
253
  if ( $file == plugin_basename(__FILE__) ){
254
+ $adminlink = get_bloginfo('url').'/wp-admin/';
255
  $fcmlink = 'http://www.fischercreativemedia.com/wordpress-plugins';
256
  $links[] = '<a href="'.$adminlink.'options-general.php?page=redirects-options">Quick Redirects</a>';
257
  $links[] = '<a target="_blank" href="'.$fcmlink.'/quick-pagepost-redirect-plugin/">FAQ</a>';
319
  }
320
  if(in_array($ppd->object_id,$ppr_url_rewrite)){
321
  $ppd->url = $ppr_url[$ppd->object_id]['URL'];
322
+ $ppd->classes[] = 'ppr-rewrite';
323
+
324
  }
325
  $newmenu[] = $ppd;
326
  }
471
 
472
  // The actual fields for data entry
473
  echo '<label for="pprredirect_active" style="padding:2px 0;"><input type="checkbox" name="pprredirect_active" value="1" '. checked('1',get_post_meta($post->ID,'_pprredirect_active',true),0).' />'. __(" Make Redirect <b>Active</b>. (check to turn on)", 'ppr_plugin' ) . '</label><br />';
474
+ echo '<label for="pprredirect_newwindow" style="padding:2px 0;"><input type="checkbox" name="pprredirect_newwindow" id="pprredirect_newwindow" value="_blank" '. checked('_blank',get_post_meta($post->ID,'_pprredirect_newwindow',true),0).'>'. __(" Open redirect link in a <b>new window</b>.", 'ppr_plugin' ) . '</label><br />';
475
+ echo '<label for="pprredirect_relnofollow" style="padding:2px 0;"><input type="checkbox" name="pprredirect_relnofollow" id="pprredirect_relnofollow" value="1" '. checked('1',get_post_meta($post->ID,'_pprredirect_relnofollow',true),0).'>'. __(" Add <b>rel=\"nofollow\"</b> to redirect link.", 'ppr_plugin' ) . '</label><br />';
476
+ echo '<label for="pprredirect_rewritelink" style="padding:2px 0;"><input type="checkbox" name="pprredirect_rewritelink" id="pprredirect_rewritelink" value="1" '. checked('1',get_post_meta($post->ID,'_pprredirect_rewritelink',true),0).'>'. __(" <b>Show</b> the Redirect URL below in the link instead of this page URL. <b>NOTE: You may have to use the <u>FULL</u> URL below!</b>", 'ppr_plugin' ) . '</label><br /><br />';
477
  echo '<label for="pprredirect_url">' . __(" <b>Redirect URL:</b>", 'ppr_plugin' ) . '</label><br />';
478
  if(get_post_meta($post->ID, '_pprredirect_url', true)!=''){$pprredirecturl=get_post_meta($post->ID, '_pprredirect_url', true);}else{$pprredirecturl="";}
479
  echo '<input type="text" style="width:75%;margin-top:2px;margin-bottom:2px;" name="pprredirect_url" value="'.$pprredirecturl.'" /><br />(i.e., <code>http://example.com</code> or <code>/somepage/</code> or <code>p=15</code> or <code>155</code>. Use <b>FULL URL</b> <i>including</i> <code>http://</code> for all external <i>and</i> meta redirects. )<br /><br />';
561
  global $ppr_newindow;
562
  global $ppr_url;
563
  global $ppr_url_rewrite;
564
+ global $wpdb;
565
 
566
  if (!$ppr_url && !$ppr_newindow && !$ppr_nofollow){
567
+ $thefirstppr = array();
568
+ $select_tiems = $wpdb->get_results("SELECT post_id,meta_key,meta_value FROM $wpdb->postmeta WHERE (meta_key='_pprredirect_type' OR meta_key='_pprredirect_url' OR meta_key='_pprredirect_rewritelink' OR meta_key = '_pprredirect_active' OR meta_key='_pprredirect_newwindow' OR meta_key='_pprredirect_relnofollow') AND meta_value!='' ORDER BY post_id ASC;");
569
+ if(!empty($select_tiems)){
570
+ foreach($select_tiems as $pprs){
571
+ $thefirstppr[$pprs->post_id][$pprs->meta_key] = $pprs->meta_value;
572
+ $thefirstppr[$pprs->post_id]['post_id'] = $pprs->post_id;
573
+ }
574
+ }
575
+ if(!empty($thefirstppr)){
576
+ foreach($thefirstppr as $ppitems){
577
+ if(isset($ppitems['_pprredirect_active']) && isset($ppitems['_pprredirect_newwindow'])){
578
+ $ppr_newindow[] = $ppitems['post_id'];
579
+ }
580
+ if(isset($ppitems['_pprredirect_active']) && isset($ppitems['_pprredirect_relnofollow'])){
581
+ $ppr_nofollow[] = $ppitems['post_id'];
582
+ }
583
+ if(isset($ppitems['_pprredirect_active']) && isset($ppitems['_pprredirect_rewritelink']) && isset($ppitems['_pprredirect_url'])){
584
+ $ppr_url_rewrite[] = $ppitems['post_id'];
585
+ $ppr_url[$ppitems['post_id']]['URL'] = $ppitems['_pprredirect_url'];
586
+ }
587
+ if(isset($ppitems['_pprredirect_active']) && isset($ppitems['_pprredirect_type'])){
588
+ $ppr_type[$ppitems['post_id']]['type'] = $ppitems['_pprredirect_type'];
589
+ }
590
+ }
591
+ }
592
+
593
+ if (!$ppr_url && !$ppr_newindow && !$ppr_nofollow){
594
+ return $pages;
595
+ }
596
  }
597
 
598
  $this_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
614
  $validexp="@\<li(?:.*?)".$p."(?:.*?)\>\<a(?:.*?)target\=(?:.*?)\>@i";
615
  $found = preg_match_all($validexp, $pages, $matches);
616
  if($found!=0){
617
+ $pages = $pages; //do nothing 'cause it is already a target=_blank.
618
  }else{
619
  $pages = preg_replace('@<li(.*?)-'.$p.'(.*?)\>\<a(.*?)\>@i', '<li\1-'.$p.'\2><a\3 target="_blank">', $pages);
620
  }
621
  }
622
  }
623
+
624
  return $pages;
625
  }
626
  ?>
readme.txt CHANGED
@@ -4,14 +4,16 @@ Donate link: http://www.fischercreativemedia.com/wordpress-plugins/donate/
4
  Tags: redirect, 301, 302, meta, post, plugin, page, forward, re-direct, nofollow, wpmu, menu links, posts, pages, admin, 404
5
  Requires at least: 2.5
6
  Tested up to: 3.1 beta 2
7
- Stable tag: 3.2.2
8
 
9
  Redirect Pages/Posts to another page/post or external URL. Adds edit box to admin edit area so user can specify the redirect Location and type.
10
 
11
  == Upgrade Notice ==
 
12
  = Version 3.2.2 fixes some minor code errors and the meta redirect function =
13
 
14
  == Description ==
 
15
  = Version 3.2.2 fixes some minor code errors and the meta redirect function =
16
 
17
  Quick Page/Post Redirect Plugin redirects WordPress Pages or Posts to another location quickly.
@@ -113,6 +115,8 @@ Yes, you can, but you do not always need to. If you are redirecting to an extern
113
  3. Menu for the Quick 301 Redirects page - located in the settings menu.
114
 
115
  == Changelog ==
 
 
116
  = 3.2.2 =
117
  * Fix meta tag redirect method. Was broken because of new method of checking redirects with less query calls. (12/16/10)
118
  * Fix php code errors - still had some debugging code live that will cause some users to have problems.(12/16/10)
4
  Tags: redirect, 301, 302, meta, post, plugin, page, forward, re-direct, nofollow, wpmu, menu links, posts, pages, admin, 404
5
  Requires at least: 2.5
6
  Tested up to: 3.1 beta 2
7
+ Stable tag: 3.2.3
8
 
9
  Redirect Pages/Posts to another page/post or external URL. Adds edit box to admin edit area so user can specify the redirect Location and type.
10
 
11
  == Upgrade Notice ==
12
+ = Version 3.2.3 fixes New Window and No Follow attributes in wp_list_pages menu calls & fixed problem where Quick Redirects would not delete =
13
  = Version 3.2.2 fixes some minor code errors and the meta redirect function =
14
 
15
  == Description ==
16
+ = Version 3.2.3 fixes New Window and No Follow attributes in wp_list_pages menu calls =
17
  = Version 3.2.2 fixes some minor code errors and the meta redirect function =
18
 
19
  Quick Page/Post Redirect Plugin redirects WordPress Pages or Posts to another location quickly.
115
  3. Menu for the Quick 301 Redirects page - located in the settings menu.
116
 
117
  == Changelog ==
118
+ = 3.2.3 =
119
+ * Fix New Window and No Follow attributes in themes with older menu calls. (12/29/10)
120
  = 3.2.2 =
121
  * Fix meta tag redirect method. Was broken because of new method of checking redirects with less query calls. (12/16/10)
122
  * Fix php code errors - still had some debugging code live that will cause some users to have problems.(12/16/10)