Quick Page/Post Redirect Plugin - Version 3.2.2

Version Description

  • Fix meta tag redirect method. Was broken because of new method of checking redirects with less query calls. (12/16/10)
  • Fix php code errors - still had some debugging code live that will cause some users to have problems.(12/16/10)
Download this release

Release Info

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

Code changes from version 3.2 to 3.2.2

Files changed (2) hide show
  1. page_post_redirect_plugin.php +128 -138
  2. readme.txt +22 -13
page_post_redirect_plugin.php CHANGED
@@ -6,38 +6,10 @@ 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
10
 
11
  Version info:
12
- 3.2 - remove functions ppr_linktotarget, ppr_linktonorel, ppr_redirectto and ppr_linktometa.(12/10/2010)
13
- - re-write functions to consolidate queries. (12/10/2010)
14
- - added new filters for New menu structure to filter wp_nav_menu menus as well as old wp_page_menus functions. (12/10/2010)
15
- - cleaned up new window and nofollow code to work more consistently. (12/10/2010)
16
- 3.1 - Re-issue of 2.1 for immediate fix of issue with the 3.0 version.(6/21/2010)
17
- 3.0 - Enhance Filter to reduce number of DB calls. (06/20/10)
18
- 2.1 - Fix Bug - Open in New Window would not work unless Show Link URL was also selected. (3/12/2010)
19
- - Fix Bug - Add rel=nofollow would not work if Open in a New Window was not selected. (3/13/2010)
20
- - Fix Bug - Show Link, Add nofollow and Open in New Window would still work when redirect not active. (3/13/2010)
21
- - Added new preg_match_all and preg_replace calls to add target and nofollow links - more effecient and accuarte - noticed some cases where old funtion would add the items if a redirect link had the same URL. (3/13/2010)
22
- 2.0 - Code Cleanup. (2/28/2010)
23
- - Fix WARNING and NOTICE messages that some people may have been receiving about objects and undefined variables. (2/28/2010)
24
- 1.9 - Add 'Open in New Window' Feature. (2/20/2010)
25
- - Add 'rel=nofollow' option for links that will redirect. (2/20/2010)
26
- - Add 'rewrite url/permalink' option to hide the regular link and replace it with the new re-write link. (2/20/2010)
27
- - Hide Custom Field Meta Data to clean up the custom fields.
28
- 1.8 - Added a new 301 Redirect Page to allow adding of additional redirects that do not have Pages or Posts created for them. Based on Scott Nelle's Simple 301 Redirects plugin.(12/28/2009)
29
- 1.7 - Small fix to correct the Meta Redirect - moved "exit" command to end of "addmetatohead_theme" function. And also fix Page redirect. (9/8/2009)
30
- 1.6.1 - Small fix to correct the same problem as 1.6 for Category and Archive pages (9/1/2009)
31
- 1.6 - Fix wrongful redirect when the first blog post on home page (main blog page) has a redirect set up - this was redirecting the
32
- entire page incorrectly. (9/1/2009)
33
- 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.
34
- Can have page/post as draft and still redirect - but ONLY after the post/page has first been published and
35
- then re-saved as draft (this will hopefully be a fix for a later version). (8/31/2009)
36
- 1.4 - Add exit after header redirect function - needed on some servers and browsers. (8/19/2009)
37
- 1.3 - Add Meta Re-fresh option (7/26/2009)
38
- 1.2 - Add easy Post/Page Edit Box (7/25/2009)
39
- 1.1 - Fix redirect for off site links (7/7/2009)
40
- 1.0 - Plugin Release (7/1/2009)
41
 
42
  Copyright (C) 2009/2010 Donald J. Fischer
43
 
@@ -54,10 +26,6 @@ Version info:
54
  You should have received a copy of the GNU General Public License
55
  along with this program. If not, see <http://www.gnu.org/licenses/>.
56
  */
57
- ini_set('display_errors', 0);
58
- ini_set('log_errors', 1);
59
- ini_set('error_log', dirname(__FILE__) . '/error_log.txt');
60
- error_reporting( E_ALL & ~E_NOTICE );
61
 
62
  //=======================================
63
  // Redirect Class (for non page post redirects).
@@ -182,6 +150,13 @@ Version info:
182
  global $ppr_url;
183
  global $ppr_url_rewrite;
184
  global $ppr_type;
 
 
 
 
 
 
 
185
 
186
  // Actions & Filters
187
  //----------
@@ -190,6 +165,8 @@ Version info:
190
  add_action('template_redirect','ppr_do_redirect', 1, 2);
191
  add_action('init', 'ppr_init_metaclean', 1);
192
  add_action('wp','ppr_new_nav_menu');
 
 
193
  if (isset($redirect_plugin)) {
194
  add_action('init', array($redirect_plugin,'redirect'), 1); // add the redirect action, high priority
195
  add_action('admin_menu', array($redirect_plugin,'create_menu')); // create the menu
@@ -198,66 +175,96 @@ Version info:
198
 
199
  // Functions
200
  //----------
201
- function ppr_new_nav_menu($items){
202
- global $ppr_nofollow;
203
- global $ppr_newindow;
204
- global $ppr_url;
205
- global $ppr_url_rewrite;
206
- global $ppr_type;
207
- add_filter( 'wp_get_nav_menu_items','ppr_new_nav_menu_fix',1,1);
208
- add_filter( 'wp_list_pages','ppr_fix_targetsandrels');
209
- add_filter( 'page_link','ppr_filter_pages',20, 2 );
210
- add_filter( 'post_link','ppr_filter_pages',20, 2 );
211
- return $items;
212
- }
213
-
214
- function ppr_new_nav_menu_fix($ppr){
215
- global $ppr_nofollow;
216
- global $ppr_newindow;
217
- global $ppr_url;
218
- global $ppr_url_rewrite;
219
- global $ppr_type;
220
- global $wpdb;
221
- $thefirstppr = array();
222
- $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;");
223
- foreach($select_tiems as $pprs){
224
- $thefirstppr[$pprs->post_id][$pprs->meta_key] = $pprs->meta_value;
225
- $thefirstppr[$pprs->post_id]['post_id'] = $pprs->post_id;
226
  }
227
- foreach($thefirstppr as $ppitems){
228
- if(isset($ppitems['_pprredirect_active']) && isset($ppitems['_pprredirect_newwindow'])){
229
- $ppr_newindow[] = $ppitems['post_id'];
230
- }
231
- if(isset($ppitems['_pprredirect_active']) && isset($ppitems['_pprredirect_relnofollow'])){
232
- $ppr_nofollow[] = $ppitems['post_id'];
 
233
  }
234
- if(isset($ppitems['_pprredirect_active']) && isset($ppitems['_pprredirect_rewritelink']) && isset($ppitems['_pprredirect_url'])){
235
- $ppr_url_rewrite[] = $ppitems['post_id'];
236
- $ppr_url[$ppitems['post_id']]['URL'] = $ppitems['_pprredirect_url'];
237
- }
238
- if(isset($ppitems['_pprredirect_active']) && isset($ppitems['_pprredirect_type'])){
239
- $ppr_type[$ppitems['post_id']]['type'] = $ppitems['_pprredirect_type'];
240
- }
241
-
242
  }
243
-
244
- $newmenu = array();
245
- foreach($ppr as $ppd){
246
- if(in_array($ppd->object_id,$ppr_newindow)){
247
- $ppd->target = '_blank';
248
- $ppd->classes[] = 'ppr-new-window';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
249
  }
250
- if(in_array($ppd->object_id,$ppr_nofollow)){
251
- $ppd->xfn = 'nofollow';
252
- $ppd->classes[] = 'ppr-nofollow';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
  }
254
- if(in_array($ppd->object_id,$ppr_url_rewrite)){
255
- $ppd->url = $ppr_url[$ppd->object_id]['URL'];
 
 
 
 
 
 
256
  }
257
- $newmenu[] = $ppd;
258
  }
259
- return $newmenu;
260
- }
261
 
262
  // For WordPress < 2.8 function compatibility
263
  if (!function_exists('esc_attr')) {
@@ -265,30 +272,6 @@ function ppr_new_nav_menu_fix($ppr){
265
  function esc_url($url){return clean_url( $url );}
266
  }
267
 
268
- //clean up the Custom Fields to make it prettier on the Edit Page
269
- function ppr_init_metaclean() {
270
- $thepprversion = get_option('ppr_version');
271
- //echo $thepprversion;
272
- if ($thepprversion=='3.2') {
273
- update_option( 'ppr_version', '3.2' );
274
- }else if(in_array($thepprversion,array('1.9','2.0','2.1','3.0','3.1'))) {
275
- update_option( 'ppr_version', '3.2' );
276
- }else{
277
- global $wpdb;
278
- //want to make sure older version upgrading still
279
- /* //not needed any more
280
- $wpdb->query( "UPDATE $wpdb->postmeta SET meta_key = '_pprredirect_active' WHERE meta_key = 'pprredirect_active'" );
281
- $wpdb->query( "UPDATE $wpdb->postmeta SET meta_key = '_pprredirect_newwindow' WHERE meta_key = 'pprredirect_newwindow'" );
282
- $wpdb->query( "UPDATE $wpdb->postmeta SET meta_key = '_pprredirect_relnofollow' WHERE meta_key = 'pprredirect_relnofollow'" );
283
- $wpdb->query( "UPDATE $wpdb->postmeta SET meta_key = '_pprredirect_type' WHERE meta_key = 'pprredirect_type'" );
284
- $wpdb->query( "UPDATE $wpdb->postmeta SET meta_key = '_pprredirect_url' WHERE meta_key = 'pprredirect_url'" );
285
- wp_cache_flush();
286
- */
287
-
288
- update_option( 'ppr_version', '3.2' );
289
- }
290
- }
291
-
292
  function ppr_filter_pages ($link, $post) {
293
  global $ppr_nofollow;
294
  global $ppr_newindow;
@@ -317,8 +300,8 @@ function ppr_new_nav_menu_fix($ppr){
317
  }
318
 
319
  function addmetatohead_theme(){
320
- global $ppr_url;
321
- $meta_code = '<meta http-equiv="refresh" content="0; URL='.$ppr_url.'" />';
322
  echo $meta_code;
323
  exit;//stop loading page so meta can do it's job without rest of page loading.
324
  }
@@ -326,31 +309,36 @@ function ppr_new_nav_menu_fix($ppr){
326
  function ppr_do_redirect(){
327
  global $post,$wp_query,$ppr_active,$wpdb;
328
  $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_active') AND meta_value!='' ORDER BY post_id ASC;");
329
- foreach($select_tiems as $pprs){
330
- $thefirstppr[$pprs->post_id][$pprs->meta_key] = $pprs->meta_value;
331
- $thefirstppr[$pprs->post_id]['post_id'] = $pprs->post_id;
332
- }
333
- foreach($thefirstppr as $ppitems){
334
- if(isset($ppitems['_pprredirect_active']) && isset($ppitems['_pprredirect_url'])){
335
- $ppr_url_rewrite[] = $ppitems['post_id'];
336
- $ppr_url[$ppitems['post_id']]['URL'] = $ppitems['_pprredirect_url'];
337
  }
338
- if(isset($ppitems['_pprredirect_active']) && isset($ppitems['_pprredirect_type'])){
339
- $ppr_type[$ppitems['post_id']]['type'] = $ppitems['_pprredirect_type'];
340
- }
341
-
342
  }
343
-
 
 
 
 
 
 
 
 
 
 
 
344
  if($wp_query->is_single || $wp_query->is_page ):
345
  $thisidis_current = $post->ID;
 
346
  if(isset($ppr_type[$thisidis_current]['type'])){$ppr_types = $ppr_type[$thisidis_current]['type'];}else{$ppr_types = '';}
347
  if(isset($ppr_url[$thisidis_current]['URL'])){$ppr_urls = $ppr_url[$thisidis_current]['URL'];}else{$ppr_urls='';}
348
-
349
  if( $ppr_urls!=''):
350
  if($ppr_types===0){$ppr_types='200';}
351
  if($ppr_types===''){$ppr_types='302';}
352
  if($ppr_types=='meta'):
353
  //metaredirect
 
354
  add_action('wp_head', "addmetatohead_theme",1);
355
  else:
356
  //check for http:// - as full url - then we can just redirect if it is //
@@ -359,7 +347,7 @@ function ppr_new_nav_menu_fix($ppr){
359
  header('Status: '.$ppr_types);
360
  header('Location: '.$offsite, true, $ppr_types);
361
  exit; //stop loading page
362
- }elseif(strpos($ppr_urls, 'www')=== 0){ // check if they have full url but did not put http://
363
  $offsite='http://'.$ppr_urls;
364
  header("Status: $ppr_types");
365
  header("Location: $offsite", true, $ppr_types);
@@ -480,17 +468,19 @@ function ppr_new_nav_menu_fix($ppr){
480
  $mydata['_pprredirect_active'] = NULL; //turn it off if no URL is set
481
  }
482
  // Add values of $mydata as custom fields
483
- foreach ($mydata as $key => $value) { //Let's cycle through the $mydata array!
484
- if( $post->post_type == 'revision' ) return; //don't store custom data twice
485
- $value = implode(',', (array)$value); //if $value is an array, make it a CSV (unlikely)
486
-
487
- if(get_post_meta($post->ID, $key, FALSE)) { //if the custom field already has a value
488
- update_post_meta($post->ID, $key, $value);
489
- } else { //if the custom field doesn't have a value
490
- add_post_meta($post->ID, $key, $value);
 
 
 
 
491
  }
492
-
493
- if(!$value) delete_post_meta($post->ID, $key); //delete if blank
494
  }
495
  endif;
496
  }
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.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  Copyright (C) 2009/2010 Donald J. Fischer
15
 
26
  You should have received a copy of the GNU General Public License
27
  along with this program. If not, see <http://www.gnu.org/licenses/>.
28
  */
 
 
 
 
29
 
30
  //=======================================
31
  // Redirect Class (for non page post redirects).
150
  global $ppr_url;
151
  global $ppr_url_rewrite;
152
  global $ppr_type;
153
+ global $ppr_curr_version;
154
+ global $ppr_metaurl;
155
+ $ppr_curr_version = '3.2.1';
156
+ $ppr_nofollow = array();
157
+ $ppr_newindow = array();
158
+ $ppr_url = array();
159
+ $ppr_url_rewrite = array();
160
 
161
  // Actions & Filters
162
  //----------
165
  add_action('template_redirect','ppr_do_redirect', 1, 2);
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
172
  add_action('admin_menu', array($redirect_plugin,'create_menu')); // create the menu
175
 
176
  // Functions
177
  //----------
178
+ function ppr_filter_plugin_actions($links){
179
+ $new_links = array();
180
+ $fcmlink = 'http://www.fischercreativemedia.com/wordpress-plugins';
181
+ $new_links[] = '<a href="'.$fcmlink.'/donate/">Donate</a>';
182
+ return array_merge($links,$new_links );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>';
190
+ $links[] = '<a target="_blank" href="'.$fcmlink.'/donate/">Donate</a>';
191
  }
192
+ return $links;
 
 
 
 
 
 
 
193
  }
194
+
195
+ function ppr_new_nav_menu($items){
196
+ global $ppr_nofollow;
197
+ global $ppr_newindow;
198
+ global $ppr_url;
199
+ global $ppr_url_rewrite;
200
+ global $ppr_type;
201
+ add_filter( 'wp_get_nav_menu_items','ppr_new_nav_menu_fix',1,1);
202
+ add_filter( 'wp_list_pages','ppr_fix_targetsandrels');
203
+ add_filter( 'page_link','ppr_filter_pages',20, 2 );
204
+ add_filter( 'post_link','ppr_filter_pages',20, 2 );
205
+ return $items;
206
+ }
207
+
208
+ function ppr_new_nav_menu_fix($ppr){
209
+ global $ppr_nofollow;
210
+ global $ppr_newindow;
211
+ global $ppr_url;
212
+ global $ppr_url_rewrite;
213
+ global $ppr_type;
214
+ global $wpdb;
215
+ $thefirstppr = array();
216
+
217
+ $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;");
218
+ if(!empty($select_tiems)){
219
+ foreach($select_tiems as $pprs){
220
+ $thefirstppr[$pprs->post_id][$pprs->meta_key] = $pprs->meta_value;
221
+ $thefirstppr[$pprs->post_id]['post_id'] = $pprs->post_id;
222
+ }
223
  }
224
+ if(!empty($thefirstppr)){
225
+ foreach($thefirstppr as $ppitems){
226
+ if(isset($ppitems['_pprredirect_active']) && isset($ppitems['_pprredirect_newwindow'])){
227
+ $ppr_newindow[] = $ppitems['post_id'];
228
+ }
229
+ if(isset($ppitems['_pprredirect_active']) && isset($ppitems['_pprredirect_relnofollow'])){
230
+ $ppr_nofollow[] = $ppitems['post_id'];
231
+ }
232
+ if(isset($ppitems['_pprredirect_active']) && isset($ppitems['_pprredirect_rewritelink']) && isset($ppitems['_pprredirect_url'])){
233
+ $ppr_url_rewrite[] = $ppitems['post_id'];
234
+ $ppr_url[$ppitems['post_id']]['URL'] = $ppitems['_pprredirect_url'];
235
+ }
236
+ if(isset($ppitems['_pprredirect_active']) && isset($ppitems['_pprredirect_type'])){
237
+ $ppr_type[$ppitems['post_id']]['type'] = $ppitems['_pprredirect_type'];
238
+ }
239
+ }
240
+ }
241
+ $newmenu = array();
242
+ if(!empty($ppr)){
243
+ foreach($ppr as $ppd){
244
+ if(in_array($ppd->object_id,$ppr_newindow)){
245
+ $ppd->target = '_blank';
246
+ $ppd->classes[] = 'ppr-new-window';
247
+ }
248
+ if(in_array($ppd->object_id,$ppr_nofollow)){
249
+ $ppd->xfn = 'nofollow';
250
+ $ppd->classes[] = 'ppr-nofollow';
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
+ }
257
  }
258
+ return $newmenu;
259
+ }
260
+
261
+ function ppr_init_metaclean() {
262
+ global $ppr_curr_version;
263
+ $thepprversion = get_option('ppr_version');
264
+ if($thepprversion != $ppr_curr_version){
265
+ update_option( 'ppr_version', $ppr_curr_version );
266
  }
 
267
  }
 
 
268
 
269
  // For WordPress < 2.8 function compatibility
270
  if (!function_exists('esc_attr')) {
272
  function esc_url($url){return clean_url( $url );}
273
  }
274
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
275
  function ppr_filter_pages ($link, $post) {
276
  global $ppr_nofollow;
277
  global $ppr_newindow;
300
  }
301
 
302
  function addmetatohead_theme(){
303
+ global $ppr_metaurl;
304
+ $meta_code = '<meta http-equiv="refresh" content="0; URL='.$ppr_metaurl.'" />';
305
  echo $meta_code;
306
  exit;//stop loading page so meta can do it's job without rest of page loading.
307
  }
309
  function ppr_do_redirect(){
310
  global $post,$wp_query,$ppr_active,$wpdb;
311
  $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_active') AND meta_value!='' ORDER BY post_id ASC;");
312
+ if(!empty($select_tiems)){
313
+ foreach($select_tiems as $pprs){
314
+ $thefirstppr[$pprs->post_id][$pprs->meta_key] = $pprs->meta_value;
315
+ $thefirstppr[$pprs->post_id]['post_id'] = $pprs->post_id;
 
 
 
 
316
  }
 
 
 
 
317
  }
318
+ if(!empty($thefirstppr)){
319
+ foreach($thefirstppr as $ppitems){
320
+ if(isset($ppitems['_pprredirect_active']) && isset($ppitems['_pprredirect_url'])){
321
+ $ppr_url_rewrite[] = $ppitems['post_id'];
322
+ $ppr_url[$ppitems['post_id']]['URL'] = $ppitems['_pprredirect_url'];
323
+ }
324
+ if(isset($ppitems['_pprredirect_active']) && isset($ppitems['_pprredirect_type'])){
325
+ $ppr_type[$ppitems['post_id']]['type'] = $ppitems['_pprredirect_type'];
326
+ }
327
+
328
+ }
329
+ }
330
  if($wp_query->is_single || $wp_query->is_page ):
331
  $thisidis_current = $post->ID;
332
+ global $ppr_metaurl;
333
  if(isset($ppr_type[$thisidis_current]['type'])){$ppr_types = $ppr_type[$thisidis_current]['type'];}else{$ppr_types = '';}
334
  if(isset($ppr_url[$thisidis_current]['URL'])){$ppr_urls = $ppr_url[$thisidis_current]['URL'];}else{$ppr_urls='';}
335
+
336
  if( $ppr_urls!=''):
337
  if($ppr_types===0){$ppr_types='200';}
338
  if($ppr_types===''){$ppr_types='302';}
339
  if($ppr_types=='meta'):
340
  //metaredirect
341
+ $ppr_metaurl = $ppr_urls;
342
  add_action('wp_head', "addmetatohead_theme",1);
343
  else:
344
  //check for http:// - as full url - then we can just redirect if it is //
347
  header('Status: '.$ppr_types);
348
  header('Location: '.$offsite, true, $ppr_types);
349
  exit; //stop loading page
350
+ }elseif(strpos($ppr_urls, 'www')=== 0){ //check if they have full url but did not put http://
351
  $offsite='http://'.$ppr_urls;
352
  header("Status: $ppr_types");
353
  header("Location: $offsite", true, $ppr_types);
468
  $mydata['_pprredirect_active'] = NULL; //turn it off if no URL is set
469
  }
470
  // Add values of $mydata as custom fields
471
+ if(!empty($mydata)){
472
+ foreach ($mydata as $key => $value) { //Let's cycle through the $mydata array!
473
+ if( $post->post_type == 'revision' ) return; //don't store custom data twice
474
+ $value = implode(',', (array)$value); //if $value is an array, make it a CSV (unlikely)
475
+
476
+ if(get_post_meta($post->ID, $key, FALSE)) { //if the custom field already has a value
477
+ update_post_meta($post->ID, $key, $value);
478
+ } else { //if the custom field doesn't have a value
479
+ add_post_meta($post->ID, $key, $value);
480
+ }
481
+
482
+ if(!$value) delete_post_meta($post->ID, $key); //delete if blank
483
  }
 
 
484
  }
485
  endif;
486
  }
readme.txt CHANGED
@@ -3,27 +3,31 @@ Contributors: Don Fischer
3
  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
7
- Stable tag: 3.2
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
 
11
  == Description ==
 
 
12
  Quick Page/Post Redirect Plugin redirects WordPress Pages or Posts to another location quickly.
13
- It adds an option box to the edit section where you can specify the redirect location and type of redirect that you want, temporary, permanent, or meta. See blow for additional features added in each new version.
14
 
15
  = Features: =
16
- * 1. you can open a redirect link in a new window
17
- * 2. You can add a *rel="nofollow"* attribute to the link of a redirect
18
- * 3. You can completely re-write the URL for the redirct so it takes the place of the default page URL (rewrite the href link)
19
- * 4. You can redirect without needing to create a Page or Post. This is very useful for sites that were converted to WordPress and have old links that create 404 errors (see FAQs for more information).
20
- * 5. Works with new WordPress menus as of plugin version 3.2
21
-
22
- The redirect Location can be to another WordPress page/post or any other website with an external URL. It allows the use of a full URL path, the post or page ID, permalink or page-name.
23
-
24
- PLEASE NOTE: At this time, the a new page or post needs to be Published in order for the redirect to happen. It WILL work on a DRAFT Status Post/Page ONLY, and I mean ONLY, if the Post/Page has FIRST been Published and the re-saved as a Draft - WordPress does not set up the post meta for the permalink until after first publish for some reason - will hopefully fix this in the future.
25
 
26
  This plugin is also not compatible with WordPress versions less than 2.5.
 
27
 
28
  = TROUBLESHOOTING: =
29
  * If you check the box for "Show Redirect URL below" on the edit page, please note that you MUST use the full URL in the Redirect URL box. If you do not, you may experience some odd links and 404 pages, as this option cahnges the Permalink for the page/post to the EXACT URL you eneter in that field. (i.e., if you enter '2' in the field, it will redirect to 'http://2' which is not the same as 'http://yoursite.com/?p=2').
@@ -109,6 +113,11 @@ 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.2 =
113
  * remove functions ppr_linktotarget, ppr_linktonorel, ppr_redirectto and ppr_linktometa.(12/10/2010)
114
  * re-write functions to consolidate queries. (12/10/2010)
3
  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.
18
+ It adds an option box to the edit section where you can specify the redirect location and type of redirect that you want, temporary, permanent, or meta. See below for additional features added.
19
 
20
  = Features: =
21
+ * Works with new WordPress menus as of plugin version 3.2
22
+ * you can open a redirect a page or menu link to open in a new window
23
+ * You can add a *rel="nofollow"* attribute to the page or menu link of the redirect
24
+ * You can completely re-write the URL for the redirct so it takes the place of the default page URL (rewrite the href link)
25
+ * You can redirect without needing to create a Page or Post. This is very useful for sites that were converted to WordPress and have old links that create 404 errors (see FAQs for more information). This option does not allow for open in a new window or nofollow functions.
26
+ * redirect Location can be to another WordPress page/post or any other website with an external URL.
27
+ * Redirect can use a full URL path, the post or page ID, permalink or page-name (not available for Quick Redirects method).
 
 
28
 
29
  This plugin is also not compatible with WordPress versions less than 2.5.
30
+ =PLEASE NOTE:= A new page or post needs to be Published in order for the redirect to happen. It WILL work on a DRAFT Status Post/Page ONLY, and I mean ONLY, if the Post/Page has FIRST been Published and the re-saved as a Draft.
31
 
32
  = TROUBLESHOOTING: =
33
  * If you check the box for "Show Redirect URL below" on the edit page, please note that you MUST use the full URL in the Redirect URL box. If you do not, you may experience some odd links and 404 pages, as this option cahnges the Permalink for the page/post to the EXACT URL you eneter in that field. (i.e., if you enter '2' in the field, it will redirect to 'http://2' which is not the same as 'http://yoursite.com/?p=2').
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)
119
+ = 3.2.1 =
120
+ * limited test release - testing for some of 3.2.2 release fixes. (12/14/10)
121
  = 3.2 =
122
  * remove functions ppr_linktotarget, ppr_linktonorel, ppr_redirectto and ppr_linktometa.(12/10/2010)
123
  * re-write functions to consolidate queries. (12/10/2010)