Quick Page/Post Redirect Plugin - Version 1.9

Version Description

  • Added 'Open in New Window' Feature. (2/20/2010)
  • Added 'rel="nofollow"' attribute option for links that will redirect. (2/20/2010)
  • Added 'rewrite url/permalink' option to hide the regular link and replace it with the new re-write link anywhere the link is displayed on the site. (2/20/2010)
  • Hid the Custom Field Meta Data that the plugin uses - this is just to clean up the custom fields box. (2/20/2010)
Download this release

Release Info

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

Code changes from version 1.8 to 1.9

Files changed (4) hide show
  1. page_post_redirect_plugin.php +210 -30
  2. readme.txt +27 -10
  3. screenshot-1.jpg +0 -0
  4. screenshot.jpg +0 -0
page_post_redirect_plugin.php CHANGED
@@ -5,9 +5,13 @@ Plugin URI: http://fischercreativemedia.com/wordpress-plugins/quick-pagepost-red
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.
6
Author: Don Fischer
7
Author URI: http://www.fischercreativemedia.com/
8
- Version: 1.8
9
10
Version info:
11
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)
12
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)
13
1.6.1 - Small fix to correct the same problem as 1.6 for Category and Archive pages (9/1/2009)
@@ -93,12 +97,10 @@ Version info:
93
if (!empty($redirects)) {
94
foreach ($redirects as $request => $destination) {
95
$output .= '
96
-
97
<tr>
98
<td><input type="text" name="quickppr_redirects[request][]" value="'.$request.'" style="width:35em" />&nbsp;&raquo;&nbsp;</td>
99
<td><input type="text" name="quickppr_redirects[destination][]" value="'.$destination.'" style="width:35em;" /></td>
100
</tr>
101
-
102
';
103
}
104
} // end if
@@ -156,13 +158,21 @@ Version info:
156
//----------
157
add_action('admin_menu', 'add_edit_box_ppr');
158
add_action('save_post', 'ppr_save_postdata', 1, 2); // save the custom fields
159
- add_action('wp','ppr_do_redirect', 1, 2);
160
if (isset($redirect_plugin)) {
161
add_action('init', array($redirect_plugin,'redirect'), 1); // add the redirect action, high priority
162
add_action('admin_menu', array($redirect_plugin,'create_menu')); // create the menu
163
if (isset($_POST['submit_301'])) {$redirect_plugin->save_redirects($_POST['quickppr_redirects']);} //if submitted, process the data
164
}
165
-
166
// Variables
167
//----------
168
global $wpdb;
@@ -170,6 +180,115 @@ Version info:
170
171
// Functions
172
//----------
173
function addmetatohead_theme(){
174
global $ppr_url;
175
$meta_code = '<meta http-equiv="refresh" content="0; URL='.$ppr_url.'" />';
@@ -181,9 +300,9 @@ Version info:
181
global $post,$wp_query,$ppr_url,$ppr_active,$ppr_url,$ppr_type;
182
if($wp_query->is_single || $wp_query->is_page ):
183
$thisidis_current= $post->ID;
184
- $ppr_active=get_post_meta($thisidis_current,'pprredirect_active',true);
185
- $ppr_url=get_post_meta($thisidis_current,'pprredirect_url',true);
186
- $ppr_type=get_post_meta($thisidis_current,'pprredirect_type',true);
187
188
if( $ppr_active==1 && $ppr_url!='' ):
189
if($ppr_type===0){$ppr_type='200';}
@@ -234,8 +353,8 @@ Version info:
234
// Adds a custom section to the Post and Page edit screens
235
function add_edit_box_ppr() {
236
if( function_exists( 'add_meta_box' )) {
237
- add_meta_box( 'edit-box-ppr', __( 'Quick Page/Post Redirect', 'sp' ), 'edit_box_ppr_1', 'page', 'normal', 'high' ); //for page
238
- add_meta_box( 'edit-box-ppr', __( 'Quick Page/Post Redirect', 'sp' ), 'edit_box_ppr_1', 'post', 'normal', 'high' ); //for post
239
}
240
}
241
@@ -248,18 +367,19 @@ Version info:
248
$ppr_option4='';
249
$ppr_option5='';
250
// Use nonce for verification ... ONLY USE ONCE!
251
- echo '<input type="hidden" name="pprredirect_noncename" id="pprredirect_noncename" value="' . wp_create_nonce( plugin_basename(__FILE__) ) . '" />';
252
// The actual fields for data entry
253
- if(get_post_meta($post->ID, 'pprredirect_active', true)!=''){$pprediractive="checked";}else{$pprediractive="";}
254
- echo '<input type="checkbox" name="pprredirect_active" value="1" '.$pprediractive.' /> ';
255
- echo '<label for="pprredirect_active">' . __(" Active?", 'sp' ) . '</label> (check to turn on) <b>NOTE:</b> The page or post needs to be published for the redirect to happen <i><b>UNLESS</b></i> you publish it first, then save it as a Draft..<br /><br />';
256
-
257
- echo '<label for="pprredirect_url">' . __(" Redirect URL:", 'sp' ) . '</label><br />';
258
- if(get_post_meta($post->ID, 'pprredirect_url', true)!=''){$pprredirecturl=get_post_meta($post->ID, 'pprredirect_url', true);}else{$pprredirecturl="";}
259
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 />';
260
261
- echo '<label for="pprredirect_type">' . __(" Type of Redirect:", 'sp' ) . '</label> ';
262
- if(get_post_meta($post->ID, 'pprredirect_type', true)!=''){$pprredirecttype=get_post_meta($post->ID, 'pprredirect_type', true);}else{$pprredirecttype="";}
263
switch($pprredirecttype):
264
case "":
265
$ppr_option2=" selected";//default
@@ -278,15 +398,18 @@ Version info:
278
break;
279
endswitch;
280
281
- echo '<select style="margin-top:2px;margin-bottom:2px;" name="pprredirect_type"><option value="301" '.$ppr_option1.'>301 Permanent</option><option value="302" '.$ppr_option2.'>302 Temporary</option><option value="307" '.$ppr_option3.'>307 Temporary</option><option value="meta" '.$ppr_option5.'>Meta Redirect</option></select> (Default is 302)<br /><br />';
282
-
283
}
284
// When the post is saved, saves our custom data
285
function ppr_save_postdata($post_id, $post) {
286
- if(isset($_POST['pprredirect_active']) || isset($_POST['pprredirect_url']) || isset($_POST['pprredirect_type']) ):
287
// verify authorization
288
if(isset($_POST['pprredirect_noncename'])){
289
- if ( !wp_verify_nonce( $_POST['pprredirect_noncename'], plugin_basename(__FILE__) )) {
290
return $post->ID;
291
}
292
}
@@ -300,26 +423,83 @@ Version info:
300
return $post->ID;
301
}
302
303
- // find & save the form data
304
- // Put it into an array
305
- $mydata['pprredirect_active'] = $_POST['pprredirect_active'];
306
- $mydata['pprredirect_url'] = $_POST['pprredirect_url'];
307
- if($mydata['pprredirect_url']!=''){
308
- $mydata['pprredirect_type'] = $_POST['pprredirect_type'];
309
- }
310
311
// Add values of $mydata as custom fields
312
foreach ($mydata as $key => $value) { //Let's cycle through the $mydata array!
313
if( $post->post_type == 'revision' ) return; //don't store custom data twice
314
$value = implode(',', (array)$value); //if $value is an array, make it a CSV (unlikely)
315
if(get_post_meta($post->ID, $key, FALSE)) { //if the custom field already has a value
316
update_post_meta($post->ID, $key, $value);
317
} else { //if the custom field doesn't have a value
318
add_post_meta($post->ID, $key, $value);
319
}
320
if(!$value) delete_post_meta($post->ID, $key); //delete if blank
321
}
322
endif;
323
}
324
325
?>
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.
6
Author: Don Fischer
7
Author URI: http://www.fischercreativemedia.com/
8
+ Version: 1.9
9
10
Version info:
11
+ 1.9 - Add 'Open in New Window' Feature. (2/20/2010)
12
+ - Add 'rel=nofollow' option for links that will redirect. (2/20/2010)
13
+ - Add 'rewrite url/permalink' option to hide the regular link and replace it with the new re-write link. (2/20/2010)
14
+ - Hide Custom Field Meta Data to clean up the custom fields.
15
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)
16
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)
17
1.6.1 - Small fix to correct the same problem as 1.6 for Category and Archive pages (9/1/2009)
97
if (!empty($redirects)) {
98
foreach ($redirects as $request => $destination) {
99
$output .= '
100
<tr>
101
<td><input type="text" name="quickppr_redirects[request][]" value="'.$request.'" style="width:35em" />&nbsp;&raquo;&nbsp;</td>
102
<td><input type="text" name="quickppr_redirects[destination][]" value="'.$destination.'" style="width:35em;" /></td>
103
</tr>
104
';
105
}
106
} // end if
158
//----------
159
add_action('admin_menu', 'add_edit_box_ppr');
160
add_action('save_post', 'ppr_save_postdata', 1, 2); // save the custom fields
161
+ //add_action('wp','ppr_do_redirect', 1, 2);
162
+ add_action('template_redirect','ppr_do_redirect', 1, 2);
163
+ add_action('init', 'ppr_init_metaclean', 1);
164
+ //add_action( 'template_redirect', 'ppr_redirecto');
165
+ add_filter('page_link','ppr_filter_pages',20, 2 );
166
+ add_filter('post_link','ppr_filter_pages',20, 2 );
167
+ add_filter('wp_list_pages','ppr_fix_targetsandrels', 9);
168
+
169
if (isset($redirect_plugin)) {
170
add_action('init', array($redirect_plugin,'redirect'), 1); // add the redirect action, high priority
171
add_action('admin_menu', array($redirect_plugin,'create_menu')); // create the menu
172
if (isset($_POST['submit_301'])) {$redirect_plugin->save_redirects($_POST['quickppr_redirects']);} //if submitted, process the data
173
}
174
+
175
+
176
// Variables
177
//----------
178
global $wpdb;
180
181
// Functions
182
//----------
183
+ // For WordPress < 2.8 function compatibility
184
+ if (!function_exists('esc_attr')) {
185
+ function esc_attr($attr){return attribute_escape( $attr );}
186
+ function esc_url($url){return clean_url( $url );}
187
+ }
188
+
189
+ // used to get the meta_value and ID of a post with specific meta_key.
190
+ function ppr_get_metavalfromkey($key) {
191
+ global $wpdb;
192
+ return $wpdb->get_results( $wpdb->prepare( "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = %s", $key ) );
193
+ }
194
+
195
+ //clean up the Custom Fields to make it prettier on the Edit Page
196
+ function ppr_init_metaclean() {
197
+ if ( get_option('ppr_version') != '1.9' ) {
198
+ global $wpdb;
199
+ $wpdb->query( "UPDATE $wpdb->postmeta SET meta_key = '_pprredirect_active' WHERE meta_key = 'pprredirect_active'" );
200
+ $wpdb->query( "UPDATE $wpdb->postmeta SET meta_key = '_pprredirect_newwindow' WHERE meta_key = 'pprredirect_newwindow'" );
201
+ $wpdb->query( "UPDATE $wpdb->postmeta SET meta_key = '_pprredirect_relnofollow' WHERE meta_key = 'pprredirect_relnofollow'" );
202
+ $wpdb->query( "UPDATE $wpdb->postmeta SET meta_key = '_pprredirect_type' WHERE meta_key = 'pprredirect_type'" );
203
+ $wpdb->query( "UPDATE $wpdb->postmeta SET meta_key = '_pprredirect_url' WHERE meta_key = 'pprredirect_url'" );
204
+ wp_cache_flush();
205
+ update_option( 'ppr_version', '1.9' );
206
+ }
207
+ }
208
+
209
+ function ppr_redirectto() {//alternate redirect function - old version
210
+ global $wp_query;
211
+ if (!is_single()&&!is_page()){
212
+ return;
213
+ }
214
+ $link = get_post_meta($wp_query->post->ID, '_pprredirect_url', true);
215
+ if(!$link){
216
+ return;
217
+ }
218
+ $redirect_type = get_post_meta( $wp_query->post->ID, '_pprredirect_type', true );
219
+ $redirect_type = ( $redirect_type = '302' ) ? '302' : '301';
220
+ wp_redirect( $link, $redirect_type );
221
+ exit;
222
+ }
223
+
224
+ function ppr_filter_pages ($link, $post) {
225
+ $ppr_cache = ppr_linktometa();
226
+ $id = ($post->ID) ? $post->ID : $post;
227
+ $ppr_rewrite = get_post_meta($id,'_pprredirect_rewritelink',true);
228
+ if ($ppr_cache[$id] ){
229
+ if($ppr_rewrite==='1'){ //only change the link if they want - otherwise, we will redirect the old way.
230
+ 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){
231
+ $link = esc_url( $ppr_cache[$id] );
232
+ }else{
233
+ $link = esc_url( get_bloginfo('url').'/'. $ppr_cache[$id] );
234
+ }
235
+ }
236
+ }
237
+ return $link;
238
+ }
239
+
240
+ function ppr_linktometa () {
241
+ global $wpdb, $ppr_cache, $blog_id;
242
+ if (!isset($ppr_cache[$blog_id])){
243
+ $links_to = ppr_get_metavalfromkey('_pprredirect_url');
244
+ }else{
245
+ return $ppr_cache[$blog_id];
246
+ }
247
+ if (!$links_to) {
248
+ $ppr_cache[$blog_id] = false;
249
+ return false;
250
+ }
251
+ foreach((array) $links_to as $link){
252
+ $ppr_cache[$blog_id][$link->post_id] = $link->meta_value;
253
+ }
254
+ return $ppr_cache[$blog_id];
255
+ }
256
+
257
+ function ppr_linktotarget () {
258
+ global $wpdb, $ppr_target, $blog_id;
259
+ if (!isset( $ppr_target[$blog_id])){
260
+ $links_to = ppr_get_metavalfromkey('_pprredirect_newwindow');
261
+ }else{
262
+ return $ppr_target[$blog_id];
263
+ }
264
+ if (!$links_to) {
265
+ $ppr_target[$blog_id] = false;
266
+ return false;
267
+ }
268
+ foreach ((array) $links_to as $link){
269
+ $ppr_target[$blog_id][$link->post_id] = $link->meta_value;
270
+ }
271
+ return $ppr_target[$blog_id];
272
+ }
273
+
274
+ function ppr_linktonorel () {
275
+ global $wpdb, $ppr_norel, $blog_id;
276
+ if (!isset($ppr_norel[$blog_id])){
277
+ $links_to = ppr_get_metavalfromkey('_pprredirect_relnofollow');
278
+ }else{
279
+ return $ppr_norel[$blog_id];
280
+ }
281
+ if (!$links_to) {
282
+ $ppr_norel[$blog_id] = false;
283
+ return false;
284
+ }
285
+ foreach((array) $links_to as $link){
286
+ $ppr_norel[$blog_id][$link->post_id] = $link->meta_value;
287
+ }
288
+ //print_r($ppr_norel[$blog_id]);
289
+ return $ppr_norel[$blog_id];
290
+ }
291
+
292
function addmetatohead_theme(){
293
global $ppr_url;
294
$meta_code = '<meta http-equiv="refresh" content="0; URL='.$ppr_url.'" />';
300
global $post,$wp_query,$ppr_url,$ppr_active,$ppr_url,$ppr_type;
301
if($wp_query->is_single || $wp_query->is_page ):
302
$thisidis_current= $post->ID;
303
+ $ppr_active = get_post_meta($thisidis_current,'_pprredirect_active',true);
304
+ $ppr_url = get_post_meta($thisidis_current,'_pprredirect_url',true);
305
+ $ppr_type = get_post_meta($thisidis_current,'_pprredirect_type',true);
306
307
if( $ppr_active==1 && $ppr_url!='' ):
308
if($ppr_type===0){$ppr_type='200';}
353
// Adds a custom section to the Post and Page edit screens
354
function add_edit_box_ppr() {
355
if( function_exists( 'add_meta_box' )) {
356
+ add_meta_box( 'edit-box-ppr', __( 'Quick Page/Post Redirect', 'ppr_plugin' ), 'edit_box_ppr_1', 'page', 'normal', 'high' ); //for page
357
+ add_meta_box( 'edit-box-ppr', __( 'Quick Page/Post Redirect', 'ppr_plugin' ), 'edit_box_ppr_1', 'post', 'normal', 'high' ); //for post
358
}
359
}
360
367
$ppr_option4='';
368
$ppr_option5='';
369
// Use nonce for verification ... ONLY USE ONCE!
370
+ wp_nonce_field( 'pprredirect_noncename', 'pprredirect_noncename', false, true );
371
+
372
// The actual fields for data entry
373
+ 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 />';
374
+ 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 />';
375
+ 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 />';
376
+ 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 />';
377
+ echo '<label for="pprredirect_url">' . __(" <b>Redirect URL:</b>", 'ppr_plugin' ) . '</label><br />';
378
+ if(get_post_meta($post->ID, '_pprredirect_url', true)!=''){$pprredirecturl=get_post_meta($post->ID, '_pprredirect_url', true);}else{$pprredirecturl="";}
379
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 />';
380
381
+ echo '<label for="pprredirect_type">' . __(" Type of Redirect:", 'ppr_plugin' ) . '</label> ';
382
+ if(get_post_meta($post->ID, '_pprredirect_type', true)!=''){$pprredirecttype=get_post_meta($post->ID, '_pprredirect_type', true);}else{$pprredirecttype="";}
383
switch($pprredirecttype):
384
case "":
385
$ppr_option2=" selected";//default
398
break;
399
endswitch;
400
401
+ echo '<select style="margin-top:2px;margin-bottom:2px;width:40%;" name="pprredirect_type"><option value="301" '.$ppr_option1.'>301 Permanent</option><option value="302" '.$ppr_option2.'>302 Temporary</option><option value="307" '.$ppr_option3.'>307 Temporary</option><option value="meta" '.$ppr_option5.'>Meta Redirect</option></select> (Default is 302)<br /><br />';
402
+ echo '<b>NOTE:</b> For This Option to work, the page or post needs to be published for the redirect to happen <i><b>UNLESS</b></i> you publish it first, then save it as a Draft. If you want to add a redirect without adding a page/post or having it published, use the <a href="./options-general.php?page=redirects-options">Quick Redirects</a> method.';
403
}
404
+
405
// When the post is saved, saves our custom data
406
function ppr_save_postdata($post_id, $post) {
407
+
408
+ if(isset($_REQUEST['pprredirect_noncename']) && (isset($_POST['pprredirect_active']) || isset($_POST['pprredirect_url']) || isset($_POST['pprredirect_type']) || isset($_POST['pprredirect_newwindow']) || isset($_POST['pprredirect_relnofollow']))):
409
// verify authorization
410
if(isset($_POST['pprredirect_noncename'])){
411
+ //if ( !wp_verify_nonce( $_POST['pprredirect_noncename'], plugin_basename(__FILE__) )) {
412
+ if ( !wp_verify_nonce( $_REQUEST['pprredirect_noncename'], 'pprredirect_noncename' )) {
413
return $post->ID;
414
}
415
}
423
return $post->ID;
424
}
425
426
+ // find & save the form data & put it into an array
427
+ $mydata['_pprredirect_active'] = $_POST['pprredirect_active'];
428
+ $mydata['_pprredirect_newwindow'] = $_POST['pprredirect_newwindow'];
429
+ $mydata['_pprredirect_relnofollow'] = $_POST['pprredirect_relnofollow'];
430
+ $mydata['_pprredirect_type'] = $_POST['pprredirect_type'];
431
+ $mydata['_pprredirect_rewritelink'] = $_POST['pprredirect_rewritelink'];
432
+ $mydata['_pprredirect_url'] = stripslashes( $_POST['pprredirect_url']);
433
434
+ if ( 0 === strpos($mydata['_pprredirect_url'], 'www.'))
435
+ $mydata['_pprredirect_url'] = 'http://' . $mydata['_pprredirect_url'] ; // Starts with www., so add http://
436
+
437
+ if($mydata['_pprredirect_url'] === ''){
438
+ $mydata['_pprredirect_type'] = NULL; //clear Type if no URL is set.
439
+ $mydata['_pprredirect_active'] = NULL; //turn it off if no URL is set
440
+ }
441
// Add values of $mydata as custom fields
442
foreach ($mydata as $key => $value) { //Let's cycle through the $mydata array!
443
if( $post->post_type == 'revision' ) return; //don't store custom data twice
444
$value = implode(',', (array)$value); //if $value is an array, make it a CSV (unlikely)
445
+
446
if(get_post_meta($post->ID, $key, FALSE)) { //if the custom field already has a value
447
update_post_meta($post->ID, $key, $value);
448
} else { //if the custom field doesn't have a value
449
add_post_meta($post->ID, $key, $value);
450
}
451
+
452
if(!$value) delete_post_meta($post->ID, $key); //delete if blank
453
}
454
endif;
455
}
456
+
457
+ function ppr_fix_targetsandrels($pages) {
458
+ global $post;
459
+ $ppr_cache = ppr_linktometa();
460
+ $ppr_target = ppr_linktotarget();
461
+ $ppr_norel = ppr_linktonorel();
462
+
463
+ if (!$ppr_cache && !$ppr_target){
464
+ return $pages;
465
+ }
466
+
467
+ $this_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
468
+ $targets = array();
469
+ $norels = array();
470
+
471
+ foreach ((array) $ppr_cache as $id => $page ) {
472
+ if (isset( $ppr_target[$id])){
473
+ $targets[$page] = $ppr_target[$id];
474
+ }
475
+ if (isset( $ppr_norel[$id])){
476
+ $norels[$page] = $id;
477
+ //$norels[$id] = $ppr_norel[$id];
478
+ }
479
+ }
480
481
+ if(count($norels)>=1) {
482
+ foreach($norels as $rel => $relid){
483
+ if(strpos($pages,' href="'.$rel.'" rel="nofollow" ')>0) {
484
+ $pages = $pages; //do nothing 'cause it is already a rel=nofollow.
485
+ }else{
486
+ $pages = str_replace(' href="'.$rel.'"',' href="'.$rel.'" rel="nofollow" ', $pages); //add no follow.
487
+ }
488
+ }
489
+ }
490
+
491
+ if(count($targets)>=1) {
492
+ foreach($targets as $p => $t){
493
+ $p = esc_url($p);
494
+ $t = esc_attr($t);
495
+ if(strpos($pages,' href="'.$p.'" target="'.$t.'" ')>0){
496
+ $pages = $pages; //already has a target
497
+ }else{
498
+ $pages = str_replace(' href="'.$p.'" ',' href="'.$p.'" target="'.$t.'" ', $pages);
499
+ }
500
+ }
501
+ }
502
+
503
+ return $pages;
504
+ }
505
?>
readme.txt CHANGED
@@ -1,17 +1,18 @@
1
=== Quick Page/Post Redirect ===
2
Contributors: Don Fischer
3
Donate link: http://fischercreativemedia.com/
4
- Tags: redirect, 301, 302, meta, post, plugin, page, forward, re-direct, wpmu, WordPress MU
5
Requires at least: 2.5
6
- Tested up to: 2.9.1
7
- Stable tag: 1.8
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.
14
15
*NEW* - Version 1.8 adds a new feature to allow you to add redirects without needing to create a Page or Post to do so. This is very useful for sites that were converted to WordPress and have old links that create 404 errors (see FAQs for more information).
16
17
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.
@@ -22,11 +23,13 @@ This plugin is also not compatible with WordPress versions less than 2.5.
22
23
Tested in MU 2.8.4a (9/8/2009)
24
25
- TROUBLESHOOTING:
26
- If your page or post is not redirecting, this is most likely because something else like the theme functions file or another plugin is outputting the header BEFORE the plugin can perform the redirect. This can be tested by turning off all plugins except the Quick Page/Post Redirect Plugin and testing if the redirect works. 9 out of 10 times, a plugin or bad code is the culprit.
27
- We have tested the plugin in dozens of themes and alongside a whole lot more plugins. In our experience, (with exception to a few bugs) most of the time another plugin is the problem. If you do notice a problem, please let us know at plugins@fischercreativemedia.com - along with the WP version, theme you are using and plugins you have installed - and we will try to troubleshoot the problem.
28
29
- If you are using the new Quick 301 Redirects method to do your redirects, be sure that your Request URL starts with a / and is releative to the root (i.e., http://mysite.com/test/ would have /test/ in the request field).
30
== Installation ==
31
32
= If you downloaded this plugin: =
@@ -48,6 +51,15 @@ If you had a link on a site that went to http://yoursite.com/aboutme.html you ca
48
49
The new fuctionality is located in the Admin under Settings/Quick Redirects. The olde URL goes in the Request field and the to new URL goes in the Destination field. Simple and Quick!
50
51
= I have Business Cards/Postcards/Ads that say my website is http://something.com/my-name/ or http://something.com/my-product/, can I set that up with this? =
52
YES! Just set up a redirect (see above) and set the Request field to /my-name/ or /my-product/ and the Destination field to the place you want it to go. The destination doesn't even need to be on the same site - it can go anywhere you want it to go!
53
@@ -82,11 +94,16 @@ Yes, you can, but you do not always need to. If you are redirecting to an extern
82
83
== Screenshots ==
84
85
- 1. Sample admin Post/Page edit box screenshot.
86
- 2. New Quick 301 Redirects Page.
87
3. Menu for the Quick 301 Redirects page - located in the settings menu.
88
89
== Changelog ==
90
= 1.8 =
91
* Added a new Quick 301 Redirects 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)
92
= 1.7 =
1
=== Quick Page/Post Redirect ===
2
Contributors: Don Fischer
3
Donate link: http://fischercreativemedia.com/
4
+ Tags: redirect, 301, 302, meta, post, plugin, page, forward, re-direct, nofollow, wpmu, menu links, WordPress MU
5
Requires at least: 2.5
6
+ Tested up to: 2.9.2
7
+ Stable tag: 1.9
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
+ *NEW* - Version 1.9 adds 3 new features: 1. you can now open a redirect link in a new window, 2. You can add a *rel="nofollow"* attribute to the link of a redirect, and 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).
16
*NEW* - Version 1.8 adds a new feature to allow you to add redirects without needing to create a Page or Post to do so. This is very useful for sites that were converted to WordPress and have old links that create 404 errors (see FAQs for more information).
17
18
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
Tested in MU 2.8.4a (9/8/2009)
25
26
+ = TROUBLESHOOTING: =
27
+ * 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').
28
+ * If your browser tells you that your are in an infinite loop, check to make sure you do not have pages redirecting to another page that redirects back to the initial page. That WILL cause an infinate loop.
29
+ * If you are using the new Quick 301 Redirects method to do your redirects, be sure that your Request URL starts with a / and is releative to the root (i.e., http://mysite.com/test/ would have /test/ in the request field).
30
+ * If your page or post is not redirecting, this is most likely because something else like the theme functions file or another plugin is outputting the header BEFORE the plugin can perform the redirect. This can be tested by turning off all plugins except the Quick Page/Post Redirect Plugin and testing if the redirect works. 9 out of 10 times, a plugin or bad code is the culprit.
31
+ * We have tested the plugin in dozens of themes and alongside a whole lot more plugins. In our experience, (with exception to a few bugs) most of the time another plugin is the problem. If you do notice a problem, please let us know at plugins@fischercreativemedia.com - along with the WP version, theme you are using and plugins you have installed - and we will try to troubleshoot the problem.
32
33
== Installation ==
34
35
= If you downloaded this plugin: =
51
52
The new fuctionality is located in the Admin under Settings/Quick Redirects. The olde URL goes in the Request field and the to new URL goes in the Destination field. Simple and Quick!
53
54
+ = Can I add 'rel="nofollow" attribute to the redirect link? =
55
+ YES! New in 1.9, you can now add a ' rel="nofollow" ' attribute for the redirect link. Simply check the "add rel=nofollow" box when setting up the redirect on the page/post edit page. Note - this option is not available for the Quick Redirects method.
56
+
57
+ = Can I make the redirect open in a new window? =
58
+ YES! New in 1.9, you can now make the redirect link open in a new window. Simply check the "Open in a new window" box when setting up the redirect on the page/post edit page. Note - this option is not available for the Quick Redirects method.
59
+
60
+ = I want to just have the link for the redirecting page/post show the new redirect link in the link, not the old one, can I do that? =
61
+ YES! New in 1.9, you can now hide the original page link and have it replaced with the redirect link. Any place the theme calls either "wp_page_links", "post_links" or "page_links" functions, the plugin can replace the original link with the new one. Simply check the "Show Redirect URL" box when setting up the redirect on the page/post edit page. Note - this option is not available for the Quick Redirects method.
62
+
63
= I have Business Cards/Postcards/Ads that say my website is http://something.com/my-name/ or http://something.com/my-product/, can I set that up with this? =
64
YES! Just set up a redirect (see above) and set the Request field to /my-name/ or /my-product/ and the Destination field to the place you want it to go. The destination doesn't even need to be on the same site - it can go anywhere you want it to go!
65
94
95
== Screenshots ==
96
97
+ 1. Sample admin Post/Page edit box screenshot (updated for version 1.9).
98
+ 2. Quick 301 Redirects Page (Added in version 1.8).
99
3. Menu for the Quick 301 Redirects page - located in the settings menu.
100
101
== Changelog ==
102
+ = 1.9 =
103
+ * Added 'Open in New Window' Feature. (2/20/2010)
104
+ * Added 'rel="nofollow"' attribute option for links that will redirect. (2/20/2010)
105
+ * Added 'rewrite url/permalink' option to hide the regular link and replace it with the new re-write link anywhere the link is displayed on the site. (2/20/2010)
106
+ * Hid the Custom Field Meta Data that the plugin uses - this is just to clean up the custom fields box. (2/20/2010)
107
= 1.8 =
108
* Added a new Quick 301 Redirects 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)
109
= 1.7 =
screenshot-1.jpg CHANGED
Binary file
screenshot.jpg DELETED
Binary file