Quick Page/Post Redirect Plugin - Version 5.0.4

Version Description

  • Minor bug cleanup
  • Security fixes: fixed possible cross-scripting vulnerability in saving of data to options.
  • Changed the hook call level for the redirects hook on normal redirects so it will not interfere with some other plugins.
Download this release

Release Info

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

Code changes from version 5.0.3 to 5.0.4

page_post_redirect_plugin.php CHANGED
@@ -6,13 +6,13 @@ Description: Redirect Pages, Posts or Custom Post Types to another location quic
6
  Author: Don Fischer
7
  Author URI: http://www.fischercreativemedia.com/
8
  Donate link: http://www.fischercreativemedia.com/donations/
9
- Version: 5.0.3
10
 
11
  Version info:
12
  See change log in readme.txt file.
13
  Version 3.2.4 to 4.0.1 are testing versions only
14
 
15
- Copyright (C) 2009-2012 Donald J. Fischer
16
 
17
  This program is free software: you can redistribute it and/or modify
18
  it under the terms of the GNU General Public License as published by
@@ -26,15 +26,8 @@ Version 3.2.4 to 4.0.1 are testing versions only
26
 
27
  You should have received a copy of the GNU General Public License
28
  along with this program. If not, see <http://www.gnu.org/licenses/>.
29
- */
30
-
31
- if (!function_exists('esc_attr')) {
32
- // For WordPress < 2.8 function compatibility
33
- function esc_attr($attr){return attribute_escape( $attr );}
34
- function esc_url($url){return clean_url( $url );}
35
- }
36
- add_action('init','start_ppr_class',0);
37
 
 
38
  //you can use the following action hooks with this plugin:
39
  // *** Quick Rediects function: use to take over redirect
40
  // add_action('qppr_redirect','some_callback_function',10,2);
@@ -66,6 +59,7 @@ Version 3.2.4 to 4.0.1 are testing versions only
66
  // arg 1. Meta Tag (fully generated)
67
  // arg 2. Page HTML Message (wrapped in a <div> tag)
68
  // Example:
 
69
  add_filter('ppr_meta_head_hook_filter','override_ppr_metahead_new');
70
  function override_ppr_metahead_new($meta_tag='',$meta_message=''){
71
  $meta = $meta_tag;
@@ -75,7 +69,14 @@ Version 3.2.4 to 4.0.1 are testing versions only
75
  add_filter('get_title',$function2,100,1);
76
  return $meta;
77
  }
78
- // *******************************
 
 
 
 
 
 
 
79
 
80
 
81
  //=======================================
@@ -113,200 +114,75 @@ class quick_page_post_reds {
113
  public $pprptypes_ok;
114
 
115
  function __construct() {
116
- $this->ppr_curr_version = '5.0.3';
117
- $this->ppr_nofollow = array();
118
- $this->ppr_newindow = array();
119
- $this->ppr_url = array();
120
- $this->ppr_url_rewrite = array();
121
- $this->thepprversion = get_option( 'ppr_version');
122
- $this->thepprmeta = get_option( 'ppr_meta_clean');
123
- $this->quickppr_redirects = get_option( 'quickppr_redirects');
124
- $this->quickppr_redirectsmeta= get_option('quickppr_redirects_meta');
125
- $this->homelink = get_option( 'home');
126
- $this->pproverride_nofollow = get_option( 'ppr_override-nofollow' );
127
- $this->pproverride_newwin = get_option( 'ppr_override-newwindow' );
128
- $this->ppruse_jquery = get_option( 'ppr_use-jquery' );
129
- $this->pprptypes_ok = array();
130
- $this->pproverride_type = get_option( 'ppr_override-redirect-type' );
131
- $this->pproverride_active = get_option( 'ppr_override-active' );
132
- $this->pproverride_URL = get_option( 'ppr_override-URL' );
133
- $this->pproverride_rewrite = get_option( 'ppr_override-rewrite' );
134
- $this->pprmeta_message = get_option( 'ppr_meta-message' );
135
- $this->pprmeta_seconds = get_option( 'ppr_meta-seconds' );
136
- $this->pproverride_casesensitive = get_option( 'ppr_override-casesensitive' );
137
- $this->adminlink = admin_url('/', 'admin');
138
- $this->fcmlink = 'http://www.fischercreativemedia.com/plugins';
139
- $this->ppr_metaurl = '';
140
- $this->quickppr_jquerycache = ''; //get_option( 'qppr_jQuery_cache' );
141
- $this->updatemsg = '';
142
  if($this->pprmeta_seconds==''){$this->pprmeta_seconds='0';}
143
 
144
  //these are for all the time - even if there are overrides
145
- add_action( 'init', array($this,'ppr_init_check_version'), 1 ); // checks version of plugin in DB and updates if needed.
146
- add_action( 'save_post', array($this,'ppr_save_metadata'),20,2 ); // save the custom fields
147
- add_action( 'wp',array($this,'ppr_parse_request') ); // parse query vars
148
- add_action( 'init',array($this,'ppr_parse_request_new') ); // parse query vars
149
- //add_action( 'wp_enqueue_scripts',array($this,'ppr_do_jQuery'), 1, 2); // do the jQuery in site header
150
- add_action( 'admin_menu', array($this,'ppr_add_menu') ); // add the menu items needed
151
- add_action( 'admin_menu', array($this,'ppr_add_metabox') ); // add the metaboxes where needed
152
  add_action( 'plugin_action_links_' . plugin_basename(__FILE__), array($this,'ppr_filter_plugin_actions') );
153
- add_filter( 'query_vars',array($this,'ppr_queryhook') );
154
- add_filter( 'plugin_row_meta', array($this,'ppr_filter_plugin_links'), 10, 2 );
155
- //add_filter( 'wp_feed_cache_transient_lifetime','ppr_wp_feed_options',10, 2);
 
156
 
157
- if($this->pproverride_active!='1' && !is_admin()){ // don't run these if override active is set
158
- add_action( 'init', array($this,'redirect'), 1 ); // add the 301 redirect action, high priority
159
- add_action( 'init', array($this,'redirect_post_type'), 1 ); // add the normal redirect action, high priority
160
- add_action( 'template_redirect',array($this,'ppr_do_redirect'), 1, 2); // do the redirects
161
- add_filter( 'wp_get_nav_menu_items',array($this,'ppr_new_nav_menu_fix'),1,1 );
162
- add_filter( 'wp_list_pages',array($this,'ppr_fix_targetsandrels') );
163
- add_filter( 'page_link',array($this,'ppr_filter_page_links'),20, 2 );
164
- add_filter( 'post_link',array($this,'ppr_filter_page_links'),20, 2 );
165
- add_filter( 'post_type_link', array($this, 'ppr_filter_page_links'), 20, 2 );
166
- add_filter( 'get_permalink', array($this, 'ppr_filter_links'), 20, 2 );
167
  }
168
- if (isset( $_POST['submit_301']) ) {$this->quickppr_redirects = $this->save_redirects($_POST['quickppr_redirects']);$this->updatemsg ='Quick Redirects Updated.';} //if submitted, process the data
169
- if (isset( $_REQUEST['settings-updated'] ) && $_REQUEST['settings-updated']=='true'){/*$this->updatemsg ='Settings Updated.';*/}
170
  }
171
 
172
  function ppr_add_menu(){
173
- add_menu_page('Redirect Options', 'Redirect Options', 'administrator', 'redirect-options', array($this,'ppr_settings_page'),plugins_url( 'settings-16-icon.png' , __FILE__));
174
  add_submenu_page( 'redirect-options', 'Quick Redirects', 'Quick Redirects', 'manage_options', 'redirect-updates', array($this,'ppr_options_page') );
175
  add_submenu_page( 'redirect-options', 'Redirect Summary', 'Redirect Summary', 'manage_options', 'redirect-summary', array($this,'ppr_summary_page') );
176
  add_submenu_page( 'redirect-options', 'FAQs/Help', 'FAQs/Help', 'manage_options', 'redirect-faqs', array($this,'ppr_faq_page') );
177
  add_action( 'admin_init', array($this,'register_pprsettings') );
178
  }
179
-
180
- function ppr_do_jQuery($wphead){
181
- $this->build_jQueryCache();
182
- wp_enqueue_script( 'pprjquery', get_bloginfo('url').'/', array('jquery'), 'pprjq1');
183
- }
184
-
185
- function build_jQueryCache(){
186
- return;
187
- $redirects = $this->quickppr_redirects;
188
- $redirectsmeta = $this->quickppr_redirectsmeta;
189
- $ppr_newWindowArray = array();
190
- $ppr_noFollowArray = array();
191
- $ppr_newwin = $this->ppr_newwindow;
192
- $ppr_nofoll = $this->ppr_nofollow;
193
-
194
- //quick redirects
195
- if (!empty($redirects)) {
196
- foreach ($redirects as $request => $destination) {
197
- if($redirectsmeta[$request]['nofollow'] == '1' || $this->pproverride_nofollow =='1'){$ppr_noFollowArray[] = str_replace(array(get_bloginfo('url'),'/'),array('',''),$request);}
198
- if($redirectsmeta[$request]['newwindow'] == '1' || $this->pproverride_newwin =='1'){$ppr_newWindowArray[] = str_replace(array(get_bloginfo('url'),'/'),array('',''),$request);}
199
- }
200
  }
201
-
202
- //New Window Array
203
- if (!empty($ppr_newwin)) {
204
- foreach ($ppr_newwin as $request) {
205
- if($ppr_newwin != ''){$ppr_newWindowArray[] = str_replace(array(get_bloginfo('url'),'/'),array('',''),$request);}
206
- }
207
- }
208
-
209
- //No Follow Array
210
- if (!empty($ppr_nofoll)) {
211
- foreach ($ppr_nofoll as $request) {
212
- if($ppr_nofoll != ''){$ppr_noFollowArray[] = str_replace(array(get_bloginfo('url'),'/'),array('',''),$request);}
213
- }
214
- }
215
-
216
- $newWin = implode('", "',$ppr_newWindowArray);
217
- if($newWin!=''){$newWin = '"'.$newWin.'"';}
218
- $newFoll = implode('", "',$ppr_noFollowArray);
219
- if($newFoll!=''){$newFoll = '"'.$newFoll.'"';}
220
- $pprextrajqrw = '0';
221
- $pprextrajqurl = '';
222
- if($this->pproverride_rewrite == '1'){
223
- $pprextrajqrw = '1';
224
- $pprextrajqurl = $this->pproverride_URL;
225
- }
226
- $theScript ="
227
- jQuery(document).ready(function() {
228
- var pprrewrite = '".$pprextrajqrw."';
229
- var pprrewriteurl = '".$pprextrajqurl."';
230
- var pprNoFollArr = new Array(".$newFoll.");
231
- var pprNewWinArr = new Array(".$newWin.");
232
- var pprchechhref = '';
233
- var pprchechhref2 = '';
234
- var pprspoturl = '".get_bloginfo('url')."';
235
- var tempdf = '';
236
- var jqvers = parseFloat(jQuery().jquery, 3);
237
- //this checks for jQuery version and serves correct script (i.e., prop vs attr)
238
- //alert(jqvers);
239
- if(jqvers >= 1.6){
240
- jQuery('a').each(function (i) {
241
- var tempfga = jQuery(this).attr('href');
242
- if(tempfga == '' || typeof tempfga == 'undefined' || tempfga === undefined ){
243
- // do nothing
244
- }else{
245
- var tempfg = tempfga.replace(pprspoturl,'');
246
- var tempfg2 = tempfg.replace(/\//gi,'');
247
- var tempfg3 = tempfga.replace(/\//gi,'');
248
- var tempfh = jQuery(this).prop('rel');
249
- var tempfi = jQuery(this).prop('target');
250
- if(pprrewrite == '1'){
251
- //pprnewurl = jQuery(this).attr('href',pprrewriteurl);
252
- // Temp Remove as it causes the all links to be redirected in 5.0.1
253
- }
254
- if(jQuery.inArray(tempfg2, pprNoFollArr) >= 0 || jQuery.inArray(tempfg3, pprNoFollArr) >= 0){
255
- if(tempfh =='' || tempfh =='undefined' || tempfh === undefined || typeof tempfh == 'undefined' ){
256
- jQuery(this).prop('rel','nofollow');
257
- }else{
258
- if(tempfh != 'nofollow' && tempfh.indexOf('nofollow') == -1){
259
- jQuery(this).prop('rel','nofollow '+tempfh);
260
- }
261
- }
262
- jQuery(this).addClass('qppr-nf');
263
- }
264
- if(jQuery.inArray(tempfg2,pprNewWinArr) >= 0 || jQuery.inArray(tempfg3, pprNewWinArr) >= 0){
265
- jQuery(this).addClass('qppr-nw');
266
- if(tempfi =='' || tempfi =='undefined' || tempfi === undefined || typeof tempfi == 'undefined'){jQuery(this).prop('target','_blank');}
267
- }
268
- }
269
- });
270
- }else{
271
- jQuery('a').each(function (i) {
272
- var tempfga = jQuery(this).attr('href');
273
- if(tempfga == '' || typeof tempfga == 'undefined' || tempfga === undefined ){
274
- // do nothing
275
- }else{
276
- var tempfg = tempfga.replace(pprspoturl,'');
277
- var tempfg2 = tempfg.replace(/\//gi,'');
278
- var tempfg3 = tempfga.replace(/\//gi,'');
279
- var tempfh = jQuery(this).attr('rel');
280
- var tempfi = jQuery(this).attr('target');
281
- if(pprrewrite == '1'){
282
- //pprnewurl = jQuery(this).attr('href',pprrewriteurl);
283
- // Temp Remove as it causes the all links to be redirected in 5.0.1
284
- }
285
- if(jQuery.inArray(tempfg2, pprNoFollArr) >= 0 || jQuery.inArray(tempfg3, pprNoFollArr) >= 0){
286
- if(tempfh =='' || tempfh =='undefined' || tempfh === undefined || typeof tempfh == 'undefined' ){
287
- jQuery(this).attr('rel','nofollow');
288
- }else{
289
- if(tempfh != 'nofollow' && tempfh.indexOf('nofollow') == -1){
290
- jQuery(this).attr('rel','nofollow '+tempfh);
291
- }
292
- }
293
- jQuery(this).addClass('qppr-nf');
294
- }
295
- if(jQuery.inArray(tempfg2,pprNewWinArr) >= 0 || jQuery.inArray(tempfg3, pprNewWinArr) >= 0){
296
- jQuery(this).addClass('qppr-nw');
297
- if(tempfi =='' || tempfi =='undefined' || tempfi === undefined || typeof tempfi == 'undefined' ){jQuery(this).attr('target','_blank');}
298
- }
299
- }
300
- });
301
- }
302
- });
303
- ";
304
- //temp fix until this is resolved:
305
- $theScript = '';
306
- update_option('qppr_jQuery_cache',$theScript);
307
- $this->quickppr_jquerycache = get_option('qppr_jQuery_cache');
308
- }
309
-
310
  function register_pprsettings() {
311
  register_setting( 'ppr-settings-group', 'ppr_use-custom-post-types' );
312
  register_setting( 'ppr-settings-group', 'ppr_override-nofollow' );
@@ -417,7 +293,6 @@ jQuery(document).ready(function() {
417
  $tempReportArray = array();
418
  $tempa = array();
419
  $tempQTReportArray = array();
420
- $this->build_jQueryCache();
421
  if( !empty( $this->quickppr_redirects)){
422
  foreach($this->quickppr_redirects as $key=>$redir){
423
  $tempQTReportArray = array('url'=>$key,'destinaition'=>$redir);
@@ -653,9 +528,9 @@ jQuery(document).ready(function() {
653
  <tr valign="top">
654
  <td><label><span style="color:#FF0000;font-weight:bold;font-size:100%;margin-left:0px;">Hide</span> meta box for following Post Types:</label><?php echo $ptypeHTML;?></td>
655
  </tr>
656
- <tr valign="top">
657
  <td><label>Use with jQuery? <i><font size="2" color="#FF0000">(unavailable at this time)</font></i></label> <!--input type="checkbox" name="ppr_use-jquery" value="1"<?php if(get_option('ppr_use-jquery')=='1'){echo ' checked="checked" ';} ?>/--> <input type="checkbox" name="ppr_use-jquery" value="0" disabled /><span>disabled in current version<!--Increases effectiveness of plugin. If you have a jQuery conflict, try turning this off.--></span></td>
658
- </tr>
659
  <tr valign="top">
660
  <td><label>Meta Refresh Time (in seconds):</label> <input type="text" size="5" name="ppr_meta-seconds" value="<?php echo get_option('ppr_meta-seconds');?>" /> <span>Only needed for Meta Refresh. 0=default (instant)</span></td>
661
  </tr>
@@ -678,10 +553,10 @@ jQuery(document).ready(function() {
678
  <td><label>Make ALL Redirects this type: </label>
679
  <select name="ppr_override-redirect-type">
680
  <option value="0">Use Individual Settings</option>
681
- <option value="301" <?php if( get_option('ppr_override-redirect-type')=='301') {echo ' selected="selected" ';} ?>/>301 Permanant Redirect</option>
682
- <option value="302" <?php if( get_option('ppr_override-redirect-type')=='302') {echo ' selected="selected" ';} ?>/>302 Temporary Redirect</option>
683
- <option value="307" <?php if( get_option('ppr_override-redirect-type')=='307') {echo ' selected="selected" ';} ?>/>307 Temporary Redirect</option>
684
- <option value="meta" <?php if(get_option('ppr_override-redirect-type')=='meta'){echo ' selected="selected" ';} ?>/>Meta Refresh Redirect</option>
685
  </select>
686
  <span> (Quick 301 Redirects will always be 301)</span></td>
687
  </tr>
@@ -713,7 +588,6 @@ jQuery(document).ready(function() {
713
  ?>
714
  <div class="wrap">
715
  <div class="icon32" style="<?php echo 'background: url('.plugins_url( 'settings-icon.png' , __FILE__ ).') no-repeat transparent;';?>"><br></div>
716
- <!--script type="text/javascript">jQuery(document).ready(function() { var mainurl = '<?php echo get_bloginfo('url');?>'; jQuery(".delete-qppr").click(function(){ var thepprdel = jQuery(this).attr('id'); if(confirm('Are you sure you want to delete this redirect?')){ jQuery.ajax({ url: mainurl+"/",data : "pprd="+thepprdel+"&scid=<?php echo md5($tohash);?>", success: function(data){ jQuery('#row'+thepprdel).remove(); }, complete: function(){ jQuery(".pprnewwin").each(function (i) { jQuery(this).attr('name','quickppr_redirects[newwindow]['+jQuery(".pprnewwin").index(this)+']'); }); jQuery(".pprnofoll").each(function (i) { jQuery(this).attr('name','quickppr_redirects[nofollow]['+jQuery(".pprnofoll").index(this)+']'); }); } }); return false; }else{ return false; } }); jQuery("#hidepprjqmessage").click(function(){ jQuery.ajax({ url: mainurl+"/",data : "pprhidemessage=1", success: function(data){ jQuery('#usejqpprmessage').remove(); } }); return false; }); jQuery("#hidepprjqmessage2").click(function(){ jQuery.ajax({ url: mainurl+"/",data : "pprhidemessage=2", success: function(data){ jQuery('#usejqpprmessage2').remove(); } }); return false; }); });</script-->
717
  <script type="text/javascript">jQuery(document).ready(function() { var mainurl = '<?php echo site_url('/', 'admin') ;?>'; jQuery(".delete-qppr").click(function(){ var thepprdel = jQuery(this).attr('id'); if(confirm('Are you sure you want to delete this redirect?')){ jQuery.ajax({ url: mainurl,data : "pprd="+thepprdel+"&scid=<?php echo md5($tohash);?>", success: function(data, textStatus){ jQuery('#row'+thepprdel).remove(); }, complete: function(){ jQuery(".pprnewwin").each(function (i) { jQuery(this).attr('name','quickppr_redirects[newwindow]['+jQuery(".pprnewwin").index(this)+']'); }); jQuery(".pprnofoll").each(function (i) { jQuery(this).attr('name','quickppr_redirects[nofollow]['+jQuery(".pprnofoll").index(this)+']'); }); } }); return false; }else{ return false; } }); jQuery("#hidepprjqmessage").click(function(){ jQuery.ajax({ url: mainurl,data : "pprhidemessage=1", success: function(data){ jQuery('#usejqpprmessage').remove(); } }); return false; }); jQuery("#hidepprjqmessage2").click(function(){ jQuery.ajax({ url: mainurl,data : "pprhidemessage=2", success: function(data){ jQuery('#usejqpprmessage2').remove(); } }); return false; }); });</script>
718
  <style type="text/css">div.info{background-color:#dceff8;border-color:#c00;margin: 5px 0 15px;padding: 5px;border:1px solid #2e92c1;border-radius: 3px;}div.info a{color:#2e92c1;}.usejqpprmessage{overflow:hidden;}.hidepprjqmessage{float:right;font-size:11px;}.delete-qppr{border: 1px solid #FFBBBB;display: inline-block;font-weight: bold;padding: 0 5px;text-decoration: none;text-transform: uppercase;}</style>
719
  <h2>Quick 301 Redirects</h2>
@@ -786,21 +660,20 @@ jQuery(document).ready(function() {
786
  $redirects = array();
787
  $redirectsmeta = array();
788
  for($i = 0; $i < sizeof($data['request']); ++$i) {
789
- $request = trim($data['request'][$i]);
790
- $destination = trim($data['destination'][$i]);
791
- $newwin = trim($data['newwindow'][$i]);
792
- $nofoll = trim($data['nofollow'][$i]);
793
  if(strpos($request,'/',0) !== 0 && strpos($request,'http',0) !== 0){$request = '/'.$request;} // adds root marker to front if not there
794
  if((strpos($request,'.') === false && strpos($request,'?') === false) && strpos($request,'/',strlen($request)-1) === false){$request = $request.'/';} // adds end folder marker if not a file end
795
  if (($request == '' || $request == '/') && $destination == '') { continue;} elseif($request != '' && $request != '/' && $destination == '' ){$redirects[$request] = $this->homelink.'/';}else { $redirects[$request] = $destination; }
796
- $redirectsmeta[$request]['newwindow'] = $newwin;
797
- $redirectsmeta[$request]['nofollow'] = $nofoll;
798
  }
799
- update_option('quickppr_redirects', $redirects);
800
- update_option('quickppr_redirects_meta', $redirectsmeta);
801
  $this->quickppr_redirectsmeta = get_option('quickppr_redirects_meta');
802
  $this->quickppr_redirects = get_option('quickppr_redirects');
803
- $this->build_jQueryCache();
804
  return $redirects;
805
  }
806
 
@@ -816,8 +689,8 @@ jQuery(document).ready(function() {
816
  if($noFollow == '1'){$noChecked = ' checked="checked"';}else{$noChecked = '';}
817
  $output .= '
818
  <tr id="rowpprdel-'.$ww.'">
819
- <td><input type="text" name="quickppr_redirects[request][]" value="'.$request.'" style="width:27em" />&nbsp;&raquo;&nbsp;</td>
820
- <td><input type="text" name="quickppr_redirects[destination][]" value="'.$destination.'" style="width:27em;" /></td>
821
  <td align="center"><input class="pprnewwin" type="checkbox" name="quickppr_redirects[newwindow]['.($ww - 1).']" value="1"'.$newChecked.' title="open in a New Window" /></td>
822
  <td align="center"><input class="pprnofoll" type="checkbox" name="quickppr_redirects[nofollow]['.($ww - 1).']" value="1"'.$noChecked.' title="add No Follow" /></td>
823
  <td align="center">&nbsp;&nbsp;<a href="javascript:void();" id="pprdel-'.$ww.'" class="delete-qppr">X</a>&nbsp;</td>
@@ -918,7 +791,7 @@ jQuery(document).ready(function() {
918
  if(!isset($theArray[$key->post_id]['_pprredirect_url'])){$theArray[$key->post_id]['_pprredirect_url'] = '';}
919
  if(!isset($theArray[$key->post_id]['_pprredirect_type'] )){$theArray[$key->post_id]['_pprredirect_type'] = 302;}
920
  if(!isset($theArray[$key->post_id]['_pprredirect_relnofollow'])){$theArray[$key->post_id]['_pprredirect_relnofollow'] = 0;}
921
- if(!isset($theArray[$key->post_id]['_pprredirect_newwindow'] )) {$theArray[$key->post_id]['_pprredirect_newwindow'] = 0;}
922
  if(!isset($theArray[$key->post_id]['_pprredirect_active'] )){$theArray[$key->post_id]['_pprredirect_active'] = 0;}
923
 
924
  if($theArray[$key->post_id]['_pprredirect_newwindow']!= '0' || $this->pproverride_newwin =='1'){
@@ -937,71 +810,7 @@ jQuery(document).ready(function() {
937
  }
938
 
939
  function get_value($theval='none'){
940
- if($theval==''){return;}
941
- switch($theval){
942
- case 'ppr_all_redir_array':
943
- return $this->ppr_all_redir_array;
944
- break;
945
- case 'ppr_nofollow':
946
- return $this->ppr_all_redir_array;
947
- break;
948
- case 'ppr_newindow':
949
- return $this->ppr_newindow;
950
- break;
951
- case 'ppr_url':
952
- return $this->ppr_url;
953
- break;
954
- case 'ppr_url_rewrite':
955
- return $this->ppr_url_rewrite;
956
- break;
957
- case 'ppr_type':
958
- return $this->ppr_type;
959
- break;
960
- case 'ppr_curr_version':
961
- return $this->ppr_curr_version;
962
- break;
963
- case 'ppr_metaurlnew':
964
- return $this->ppr_metaurlnew;
965
- break;
966
- case 'ppr_casesensitive':
967
- return $this->pproverride_casesensitive;
968
- break;
969
- case 'hepprversion':
970
- return $this->hepprversion;
971
- break;
972
- case 'thepprmeta':
973
- return $this->thepprmeta;
974
- break;
975
- case 'quickppr_redirects':
976
- return $this->quickppr_redirects;
977
- break;
978
- case 'tohash':
979
- return $this->tohash;
980
- break;
981
- case 'fcmlink':
982
- return $this->fcmlink;
983
- break;
984
- case 'adminlink':
985
- return $this->adminlink;
986
- break;
987
- case 'homelink':
988
- return $this->homelink;
989
- break;
990
- case 'updatemsg':
991
- return $this->updatemsg;
992
- break;
993
- case 'pprmeta_seconds':
994
- return $this->pprmeta_seconds;
995
- break;
996
- case 'pprmeta_message':
997
- return $this->pprmeta_message;
998
- break;
999
- case 'none':
1000
- return 0;
1001
- break;
1002
- }
1003
-
1004
- return '';
1005
  }
1006
 
1007
  function ppr_addmetatohead_theme(){
@@ -1112,7 +921,7 @@ jQuery(document).ready(function() {
1112
  foreach($text as $nl){
1113
  if($nl!=''){
1114
  $elem = explode('|',$nl);
1115
- $newfile1['quickppr_redirects'][$elem[0]] = $elem[1];
1116
  $nw = isset($elem[2]) && $elem[2] == '1' ? '1' : '';
1117
  $nf = isset($elem[3]) && $elem[3] == '1' ? '1' : '';
1118
  $newfile1['quickppr_redirects_meta'][$elem[0]]['newwindow'] = $nw;
@@ -1163,7 +972,7 @@ jQuery(document).ready(function() {
1163
  if($qrtoadd != '' && strpos($qrtoadd,'|') !== false){
1164
  $item = explode('|',str_replace(array("\r","\n"), array('',''),$qrtoadd));
1165
  if(is_array($item) && !empty($item)){
1166
- $tempArr[$item[0]] = $item[1];
1167
  if(isset( $item[2]) || isset( $item[3])){
1168
  $newwin = (isset($item[2]) && ($item[2] != '' && $item[2] != '0')) ? 1 : '';
1169
  $nofoll = (isset($item[3]) && ($item[3] != '' && $item[3] != '0')) ? 1 : '';
@@ -1219,26 +1028,12 @@ jQuery(document).ready(function() {
1219
  } // end if
1220
  update_option('quickppr_redirects',$quickppr_redirects);
1221
  update_option('quickppr_redirects_meta',$quickppr_redirectsmeta);
1222
- $this->build_jQueryCache();
1223
  echo 1;
1224
  exit;
1225
  }else{
1226
  echo 0;
1227
  exit;
1228
  }
1229
- }elseif(array_key_exists('ver', $wp->query_vars)){
1230
- if( $wp->query_vars['ver'] =='pprjq1'){
1231
- if($this->ppruse_jquery == '1'){
1232
- $pprscript = get_option('qppr_jQuery_cache');
1233
- }else{
1234
- $pprscript = '//not set';
1235
- }
1236
- if($pprscript == ''){$pprscript = $this->build_jQueryCache();}
1237
- header('Content-type: text/javascript');
1238
- echo $pprscript;
1239
- exit;
1240
- }
1241
- return;
1242
  }elseif(array_key_exists('pprhidemessage', $wp->query_vars)){
1243
  if( $wp->query_vars['pprhidemessage'] =='1'){
1244
  update_option('qppr_jQuery_hide_message','1');
@@ -1299,19 +1094,19 @@ jQuery(document).ready(function() {
1299
  $ppr_option5='';
1300
  // Use nonce for verification ... ONLY USE ONCE!
1301
  wp_nonce_field( 'pprredirect_noncename', 'pprredirect_noncename', false, true );
1302
-
1303
  // The actual fields for data entry
1304
- 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).' />&nbsp;Make Redirect <b>Active</b>. (check to turn on)</label><br />';
1305
- 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).'>&nbsp;Open redirect link in a <b>new window.</b></label><br />';
1306
- 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).'>&nbsp;Add <b>rel=\"nofollow\"</b> to redirect link.</label><br />';
1307
- 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).'>&nbsp;<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></label><br /><br />';
 
 
 
1308
  //echo '<label for="pprredirect_casesensitive" style="padding:2px 0;"><input type="checkbox" name="pprredirect_casesensitive" id="pprredirect_casesensitive" value="1" '. checked('1',get_post_meta($post->ID,'_pprredirect_casesensitive',true),0).'>&nbsp;Make the Redirect Case Insensitive.</label><br /><br />';
1309
  echo '<label for="pprredirect_url"><b>Redirect URL:</b></label><br />';
1310
- if(get_post_meta($post->ID, '_pprredirect_url', true)!=''){$pprredirecturl=get_post_meta($post->ID, '_pprredirect_url', true);}else{$pprredirecturl="";}
1311
- 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 />';
1312
-
1313
- echo '<label for="pprredirect_type">Type of Redirect:</label> ';
1314
- if(get_post_meta($post->ID, '_pprredirect_type', true)!=''){$pprredirecttype=get_post_meta($post->ID, '_pprredirect_type', true);}else{$pprredirecttype="";}
1315
  switch($pprredirecttype):
1316
  case "":
1317
  $ppr_option2=" selected";//default
@@ -1330,51 +1125,89 @@ jQuery(document).ready(function() {
1330
  break;
1331
  endswitch;
1332
 
1333
- 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 />';
1334
- 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="./admin.php?page=redirect-updates">Quick Redirects</a> method.';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1335
  }
1336
 
1337
  function ppr_save_metadata($post_id, $post) {
1338
-
1339
  if($post->post_type == 'revision'){return;}
1340
- 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']))):
1341
- unset($my_meta_data);
1342
- $my_meta_data = array();
1343
- // verify authorization
1344
- if(isset($_POST['pprredirect_noncename'])){
1345
- if ( !wp_verify_nonce( $_REQUEST['pprredirect_noncename'], 'pprredirect_noncename' )) {
1346
- return $post_id;
1347
- }
1348
  }
1349
- // check allowed to editing
1350
- if ( !(current_user_can('edit_page', $post_id ) || current_user_can( 'edit_post', $post_id ))){
1351
- return $post_id;
1352
- }
1353
-
 
 
 
1354
  // find & save the form data & put it into an array
1355
- $my_meta_data['_pprredirect_active'] = isset($_REQUEST['pprredirect_active']) ? $_REQUEST['pprredirect_active'] : '';
1356
- $my_meta_data['_pprredirect_newwindow'] = isset($_REQUEST['pprredirect_newwindow']) ? $_REQUEST['pprredirect_newwindow'] : '';
1357
- $my_meta_data['_pprredirect_relnofollow'] = isset($_REQUEST['pprredirect_relnofollow']) ? $_REQUEST['pprredirect_relnofollow'] : '';
1358
- $my_meta_data['_pprredirect_type'] = isset($_REQUEST['pprredirect_type']) ? $_REQUEST['pprredirect_type'] : '';
1359
- $my_meta_data['_pprredirect_rewritelink'] = isset($_REQUEST['pprredirect_rewritelink']) ? $_REQUEST['pprredirect_rewritelink'] : '';
1360
- $my_meta_data['_pprredirect_url'] = isset($_REQUEST['pprredirect_url']) ? $_REQUEST['pprredirect_url'] : '';
1361
- //$my_meta_data['_pprredirect_casesensitive'] = isset($_REQUEST['pprredirect_casesensitive']) ? $_REQUEST['pprredirect_casesensitive']: '';
1362
-
1363
- if ( 0 === strpos($my_meta_data['_pprredirect_url'], 'www.'))
1364
- $my_meta_data['_pprredirect_url'] = 'http://' . $my_meta_data['_pprredirect_url'] ; // Starts with www., so add http://
1365
 
1366
- if($my_meta_data['_pprredirect_url'] == ''){
 
 
 
 
1367
  $my_meta_data['_pprredirect_type'] = NULL; //clear Type if no URL is set.
1368
  $my_meta_data['_pprredirect_active'] = NULL; //turn it off if no URL is set
 
 
 
1369
  }
1370
 
1371
  // Add values of $my_meta_data as custom fields
1372
  if(count($my_meta_data)>0){
1373
- foreach ($my_meta_data as $key => $value) { //Let's cycle through the $my_meta_data array!
1374
- if( $post->post_type == 'revision' ){ return; } //don't store custom data twice
1375
- $value = implode(',', (array)$value); //if $value is an array, make it a CSV (unlikely)
1376
-
1377
- if($value=='' || $value == NULL){
1378
  delete_post_meta($post->ID, $key);
1379
  }else{
1380
  if(get_post_meta($post->ID, $key, true) != '') {
@@ -1386,7 +1219,6 @@ jQuery(document).ready(function() {
1386
  }
1387
  }
1388
  endif;
1389
- $this->build_jQueryCache();
1390
  }
1391
 
1392
  function ppr_fix_targetsandrels($pages) {
@@ -1494,7 +1326,6 @@ jQuery(document).ready(function() {
1494
  $useURLQS = array();
1495
  if(count($_GET) >= 1){
1496
  foreach($_GET as $key => $value){$useURLQS[] = $key.'='.$value;}
1497
- //TODO: Make this an option?
1498
  $finalQS = '?'.implode('&',$useURLQS);
1499
  $userrequest = preg_replace('/\?.*/', '', $userrequest);
1500
  }
@@ -1524,12 +1355,14 @@ jQuery(document).ready(function() {
1524
  if($val) {
1525
  $useURL = $this->pproverride_URL != '' ? $this->pproverride_URL : $val;
1526
  $useURL .= $finalQS; //add QS back
1527
- do_action('qppr_redirect',$useURL,$this->pproverride_type);
1528
- if($this->pproverride_type == 'meta'){
 
 
1529
  $this->ppr_metaurl = $useURL;
1530
  add_action('wp_head', array($this,'ppr_addmetatohead_theme'),1);
1531
  }else{
1532
- wp_redirect($useURL,$this->pproverride_type);
1533
  exit();
1534
  }
1535
  }
@@ -1560,7 +1393,6 @@ jQuery(document).ready(function() {
1560
  }else{ // we assume they are using the permalink / page name??
1561
  $urlsite=$this->homelink.'/'.$redrurl;
1562
  }
1563
-
1564
  // check if override is set for all redirects to go to one URL
1565
  if($this->pproverride_URL !=''){$urlsite=$this->pproverride_URL;}
1566
  if($this->pproverride_type!='0' && $this->pproverride_type!=''){$redrtype = $this->pproverride_type;} //override check
6
  Author: Don Fischer
7
  Author URI: http://www.fischercreativemedia.com/
8
  Donate link: http://www.fischercreativemedia.com/donations/
9
+ Version: 5.0.4
10
 
11
  Version info:
12
  See change log in readme.txt file.
13
  Version 3.2.4 to 4.0.1 are testing versions only
14
 
15
+ Copyright (C) 2009-2014 Donald J. Fischer
16
 
17
  This program is free software: you can redistribute it and/or modify
18
  it under the terms of the GNU General Public License as published by
26
 
27
  You should have received a copy of the GNU General Public License
28
  along with this program. If not, see <http://www.gnu.org/licenses/>.
 
 
 
 
 
 
 
 
29
 
30
+ ==========
31
  //you can use the following action hooks with this plugin:
32
  // *** Quick Rediects function: use to take over redirect
33
  // add_action('qppr_redirect','some_callback_function',10,2);
59
  // arg 1. Meta Tag (fully generated)
60
  // arg 2. Page HTML Message (wrapped in a <div> tag)
61
  // Example:
62
+ /*
63
  add_filter('ppr_meta_head_hook_filter','override_ppr_metahead_new');
64
  function override_ppr_metahead_new($meta_tag='',$meta_message=''){
65
  $meta = $meta_tag;
69
  add_filter('get_title',$function2,100,1);
70
  return $meta;
71
  }
72
+ /*
73
+ // ********************************/
74
+ global $newqppr;
75
+ if (!function_exists('esc_attr')) { // For WordPress < 2.8 function compatibility
76
+ function esc_attr($attr){return attribute_escape( $attr );}
77
+ function esc_url($url){return clean_url( $url );}
78
+ }
79
+ $newqppr = new quick_page_post_reds();
80
 
81
 
82
  //=======================================
114
  public $pprptypes_ok;
115
 
116
  function __construct() {
117
+ $this->ppr_curr_version = '5.0.4';
118
+ $this->ppr_nofollow = array();
119
+ $this->ppr_newindow = array();
120
+ $this->ppr_url = array();
121
+ $this->ppr_url_rewrite = array();
122
+ $this->thepprversion = get_option( 'ppr_version');
123
+ $this->thepprmeta = get_option( 'ppr_meta_clean');
124
+ $this->quickppr_redirects = get_option( 'quickppr_redirects');
125
+ $this->quickppr_redirectsmeta = get_option('quickppr_redirects_meta');
126
+ $this->homelink = get_option( 'home');
127
+ $this->pproverride_nofollow = get_option( 'ppr_override-nofollow' );
128
+ $this->pproverride_newwin = get_option( 'ppr_override-newwindow' );
129
+ $this->ppruse_jquery = get_option( 'ppr_use-jquery' );
130
+ $this->pprptypes_ok = array();
131
+ $this->pproverride_type = get_option( 'ppr_override-redirect-type' );
132
+ $this->pproverride_active = get_option( 'ppr_override-active' );
133
+ $this->pproverride_URL = get_option( 'ppr_override-URL' );
134
+ $this->pproverride_rewrite = get_option( 'ppr_override-rewrite' );
135
+ $this->pprmeta_message = get_option( 'ppr_meta-message' );
136
+ $this->pprmeta_seconds = get_option( 'ppr_meta-seconds' );
137
+ $this->pproverride_casesensitive= get_option( 'ppr_override-casesensitive' );
138
+ $this->adminlink = admin_url('/', 'admin');
139
+ $this->fcmlink = 'http://www.fischercreativemedia.com/plugins';
140
+ $this->ppr_metaurl = '';
141
+ $this->quickppr_jquerycache = ''; //get_option( 'qppr_jQuery_cache' );
142
+ $this->updatemsg = '';
143
  if($this->pprmeta_seconds==''){$this->pprmeta_seconds='0';}
144
 
145
  //these are for all the time - even if there are overrides
146
+ add_action( 'init', array( $this,'ppr_init_check_version'), 1 ); // checks version of plugin in DB and updates if needed.
147
+ add_action( 'init', array( $this,'ppr_parse_request_new') ); // parse query vars
148
+ add_action( 'save_post', array( $this,'ppr_save_metadata'), 11, 2 ); // save the custom fields
149
+ add_action( 'wp', array( $this, 'ppr_parse_request') ); // parse query vars
150
+ add_action( 'admin_menu', array( $this,'ppr_add_menu' ) ); // add the menu items needed
151
+ add_action( 'admin_menu', array( $this,'ppr_add_metabox' ) ); // add the metaboxes where needed
 
152
  add_action( 'plugin_action_links_' . plugin_basename(__FILE__), array($this,'ppr_filter_plugin_actions') );
153
+ add_filter( 'query_vars', array( $this,'ppr_queryhook' ) );
154
+ add_filter( 'plugin_row_meta', array( $this,'ppr_filter_plugin_links' ), 10, 2 );
155
+ add_action( 'admin_enqueue_scripts' , array( $this,'qppr_admin_scripts' ) );
156
+ //add_filter( 'wp_feed_cache_transient_lifetime',array($this,'ppr_wp_feed_options',10, 2));
157
 
158
+ if( $this->pproverride_active!='1' && !is_admin() ){ // don't run these if override active is set
159
+ add_action( 'init', array( $this, 'redirect' ), 1 ); // add the 301 redirect action, high priority
160
+ add_action( 'init', array( $this, 'redirect_post_type' ), 1 ); // add the normal redirect action, high priority
161
+ add_action( 'template_redirect', array( $this, 'ppr_do_redirect' ), 1, 2); // do the redirects
162
+ add_filter( 'wp_get_nav_menu_items', array( $this, 'ppr_new_nav_menu_fix' ), 1, 1 );
163
+ add_filter( 'wp_list_pages', array( $this, 'ppr_fix_targetsandrels' ) );
164
+ add_filter( 'page_link', array( $this, 'ppr_filter_page_links' ), 20, 2 );
165
+ add_filter( 'post_link', array( $this, 'ppr_filter_page_links'), 20, 2 );
166
+ add_filter( 'post_type_link', array( $this, 'ppr_filter_page_links' ), 20, 2 );
167
+ add_filter( 'get_permalink', array( $this, 'ppr_filter_links' ), 20, 2 );
168
  }
169
+ if( isset( $_POST['submit_301'] ) ) {$this->quickppr_redirects = $this->save_redirects( $_POST['quickppr_redirects'] /* sanatized individually */ );$this->updatemsg ='Quick Redirects Updated.';} //if submitted, process the data
 
170
  }
171
 
172
  function ppr_add_menu(){
173
+ add_menu_page( 'Redirect Options', 'Redirect Options', 'administrator', 'redirect-options', array($this,'ppr_settings_page'),plugins_url( 'settings-16-icon.png' , __FILE__));
174
  add_submenu_page( 'redirect-options', 'Quick Redirects', 'Quick Redirects', 'manage_options', 'redirect-updates', array($this,'ppr_options_page') );
175
  add_submenu_page( 'redirect-options', 'Redirect Summary', 'Redirect Summary', 'manage_options', 'redirect-summary', array($this,'ppr_summary_page') );
176
  add_submenu_page( 'redirect-options', 'FAQs/Help', 'FAQs/Help', 'manage_options', 'redirect-faqs', array($this,'ppr_faq_page') );
177
  add_action( 'admin_init', array($this,'register_pprsettings') );
178
  }
179
+ function qppr_admin_scripts($hook){
180
+ if(in_array($hook, array('edit.php','post.php'))){
181
+ wp_enqueue_script( 'qppr_admin_meta_script', plugins_url('/qppr_admin_script.js', __FILE__ ) , array('jquery'),'5.0.4');
182
+ wp_enqueue_style( 'qppr_admin_meta_style', plugins_url('/qppr_admin_style.css', __FILE__ ) , null ,'5.0.4' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  }
184
+ return;
185
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
  function register_pprsettings() {
187
  register_setting( 'ppr-settings-group', 'ppr_use-custom-post-types' );
188
  register_setting( 'ppr-settings-group', 'ppr_override-nofollow' );
293
  $tempReportArray = array();
294
  $tempa = array();
295
  $tempQTReportArray = array();
 
296
  if( !empty( $this->quickppr_redirects)){
297
  foreach($this->quickppr_redirects as $key=>$redir){
298
  $tempQTReportArray = array('url'=>$key,'destinaition'=>$redir);
528
  <tr valign="top">
529
  <td><label><span style="color:#FF0000;font-weight:bold;font-size:100%;margin-left:0px;">Hide</span> meta box for following Post Types:</label><?php echo $ptypeHTML;?></td>
530
  </tr>
531
+ <!--tr valign="top">
532
  <td><label>Use with jQuery? <i><font size="2" color="#FF0000">(unavailable at this time)</font></i></label> <!--input type="checkbox" name="ppr_use-jquery" value="1"<?php if(get_option('ppr_use-jquery')=='1'){echo ' checked="checked" ';} ?>/--> <input type="checkbox" name="ppr_use-jquery" value="0" disabled /><span>disabled in current version<!--Increases effectiveness of plugin. If you have a jQuery conflict, try turning this off.--></span></td>
533
+ </tr-->
534
  <tr valign="top">
535
  <td><label>Meta Refresh Time (in seconds):</label> <input type="text" size="5" name="ppr_meta-seconds" value="<?php echo get_option('ppr_meta-seconds');?>" /> <span>Only needed for Meta Refresh. 0=default (instant)</span></td>
536
  </tr>
553
  <td><label>Make ALL Redirects this type: </label>
554
  <select name="ppr_override-redirect-type">
555
  <option value="0">Use Individual Settings</option>
556
+ <option value="301" <?php if( get_option('ppr_override-redirect-type')=='301') {echo ' selected="selected" ';} ?>>301 Permanant Redirect</option>
557
+ <option value="302" <?php if( get_option('ppr_override-redirect-type')=='302') {echo ' selected="selected" ';} ?>>302 Temporary Redirect</option>
558
+ <option value="307" <?php if( get_option('ppr_override-redirect-type')=='307') {echo ' selected="selected" ';} ?>>307 Temporary Redirect</option>
559
+ <option value="meta" <?php if(get_option('ppr_override-redirect-type')=='meta'){echo ' selected="selected" ';} ?>>Meta Refresh Redirect</option>
560
  </select>
561
  <span> (Quick 301 Redirects will always be 301)</span></td>
562
  </tr>
588
  ?>
589
  <div class="wrap">
590
  <div class="icon32" style="<?php echo 'background: url('.plugins_url( 'settings-icon.png' , __FILE__ ).') no-repeat transparent;';?>"><br></div>
 
591
  <script type="text/javascript">jQuery(document).ready(function() { var mainurl = '<?php echo site_url('/', 'admin') ;?>'; jQuery(".delete-qppr").click(function(){ var thepprdel = jQuery(this).attr('id'); if(confirm('Are you sure you want to delete this redirect?')){ jQuery.ajax({ url: mainurl,data : "pprd="+thepprdel+"&scid=<?php echo md5($tohash);?>", success: function(data, textStatus){ jQuery('#row'+thepprdel).remove(); }, complete: function(){ jQuery(".pprnewwin").each(function (i) { jQuery(this).attr('name','quickppr_redirects[newwindow]['+jQuery(".pprnewwin").index(this)+']'); }); jQuery(".pprnofoll").each(function (i) { jQuery(this).attr('name','quickppr_redirects[nofollow]['+jQuery(".pprnofoll").index(this)+']'); }); } }); return false; }else{ return false; } }); jQuery("#hidepprjqmessage").click(function(){ jQuery.ajax({ url: mainurl,data : "pprhidemessage=1", success: function(data){ jQuery('#usejqpprmessage').remove(); } }); return false; }); jQuery("#hidepprjqmessage2").click(function(){ jQuery.ajax({ url: mainurl,data : "pprhidemessage=2", success: function(data){ jQuery('#usejqpprmessage2').remove(); } }); return false; }); });</script>
592
  <style type="text/css">div.info{background-color:#dceff8;border-color:#c00;margin: 5px 0 15px;padding: 5px;border:1px solid #2e92c1;border-radius: 3px;}div.info a{color:#2e92c1;}.usejqpprmessage{overflow:hidden;}.hidepprjqmessage{float:right;font-size:11px;}.delete-qppr{border: 1px solid #FFBBBB;display: inline-block;font-weight: bold;padding: 0 5px;text-decoration: none;text-transform: uppercase;}</style>
593
  <h2>Quick 301 Redirects</h2>
660
  $redirects = array();
661
  $redirectsmeta = array();
662
  for($i = 0; $i < sizeof($data['request']); ++$i) {
663
+ $request = sanitize_text_field(trim($data['request'][$i]));
664
+ $destination = sanitize_text_field(trim($data['destination'][$i]));
665
+ $newwin = sanitize_text_field(trim($data['newwindow'][$i]));
666
+ $nofoll = sanitize_text_field(trim($data['nofollow'][$i]));
667
  if(strpos($request,'/',0) !== 0 && strpos($request,'http',0) !== 0){$request = '/'.$request;} // adds root marker to front if not there
668
  if((strpos($request,'.') === false && strpos($request,'?') === false) && strpos($request,'/',strlen($request)-1) === false){$request = $request.'/';} // adds end folder marker if not a file end
669
  if (($request == '' || $request == '/') && $destination == '') { continue;} elseif($request != '' && $request != '/' && $destination == '' ){$redirects[$request] = $this->homelink.'/';}else { $redirects[$request] = $destination; }
670
+ $redirectsmeta[$request]['newwindow'] = ($newwin == '1' || $newwin =='0') ? $newwin : '0' ;
671
+ $redirectsmeta[$request]['nofollow'] = ($nofoll == '1' || $nofoll == '0') ? $nofoll : '0' ;
672
  }
673
+ update_option('quickppr_redirects', sanitize_option('quickppr_redirects',$redirects));
674
+ update_option('quickppr_redirects_meta', sanitize_option('quickppr_redirects_meta',$redirectsmeta));
675
  $this->quickppr_redirectsmeta = get_option('quickppr_redirects_meta');
676
  $this->quickppr_redirects = get_option('quickppr_redirects');
 
677
  return $redirects;
678
  }
679
 
689
  if($noFollow == '1'){$noChecked = ' checked="checked"';}else{$noChecked = '';}
690
  $output .= '
691
  <tr id="rowpprdel-'.$ww.'">
692
+ <td><input type="text" name="quickppr_redirects[request][]" value="'.esc_attr($request).'" style="width:27em" />&nbsp;&raquo;&nbsp;</td>
693
+ <td><input type="text" name="quickppr_redirects[destination][]" value="'.esc_attr($destination).'" style="width:27em;" /></td>
694
  <td align="center"><input class="pprnewwin" type="checkbox" name="quickppr_redirects[newwindow]['.($ww - 1).']" value="1"'.$newChecked.' title="open in a New Window" /></td>
695
  <td align="center"><input class="pprnofoll" type="checkbox" name="quickppr_redirects[nofollow]['.($ww - 1).']" value="1"'.$noChecked.' title="add No Follow" /></td>
696
  <td align="center">&nbsp;&nbsp;<a href="javascript:void();" id="pprdel-'.$ww.'" class="delete-qppr">X</a>&nbsp;</td>
791
  if(!isset($theArray[$key->post_id]['_pprredirect_url'])){$theArray[$key->post_id]['_pprredirect_url'] = '';}
792
  if(!isset($theArray[$key->post_id]['_pprredirect_type'] )){$theArray[$key->post_id]['_pprredirect_type'] = 302;}
793
  if(!isset($theArray[$key->post_id]['_pprredirect_relnofollow'])){$theArray[$key->post_id]['_pprredirect_relnofollow'] = 0;}
794
+ if(!isset($theArray[$key->post_id]['_pprredirect_newwindow'] )) {$theArray[$key->post_id]['_pprredirect_newwindow'] = 0;}
795
  if(!isset($theArray[$key->post_id]['_pprredirect_active'] )){$theArray[$key->post_id]['_pprredirect_active'] = 0;}
796
 
797
  if($theArray[$key->post_id]['_pprredirect_newwindow']!= '0' || $this->pproverride_newwin =='1'){
810
  }
811
 
812
  function get_value($theval='none'){
813
+ return isset($this->$theval) ? $this->$theval : 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
814
  }
815
 
816
  function ppr_addmetatohead_theme(){
921
  foreach($text as $nl){
922
  if($nl!=''){
923
  $elem = explode('|',$nl);
924
+ $newfile1['quickppr_redirects'][sanitize_text_field($elem[0])] = sanitize_text_field($elem[1]);
925
  $nw = isset($elem[2]) && $elem[2] == '1' ? '1' : '';
926
  $nf = isset($elem[3]) && $elem[3] == '1' ? '1' : '';
927
  $newfile1['quickppr_redirects_meta'][$elem[0]]['newwindow'] = $nw;
972
  if($qrtoadd != '' && strpos($qrtoadd,'|') !== false){
973
  $item = explode('|',str_replace(array("\r","\n"), array('',''),$qrtoadd));
974
  if(is_array($item) && !empty($item)){
975
+ $tempArr[sanitize_text_field($item[0])] = sanitize_text_field($item[1]);
976
  if(isset( $item[2]) || isset( $item[3])){
977
  $newwin = (isset($item[2]) && ($item[2] != '' && $item[2] != '0')) ? 1 : '';
978
  $nofoll = (isset($item[3]) && ($item[3] != '' && $item[3] != '0')) ? 1 : '';
1028
  } // end if
1029
  update_option('quickppr_redirects',$quickppr_redirects);
1030
  update_option('quickppr_redirects_meta',$quickppr_redirectsmeta);
 
1031
  echo 1;
1032
  exit;
1033
  }else{
1034
  echo 0;
1035
  exit;
1036
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
1037
  }elseif(array_key_exists('pprhidemessage', $wp->query_vars)){
1038
  if( $wp->query_vars['pprhidemessage'] =='1'){
1039
  update_option('qppr_jQuery_hide_message','1');
1094
  $ppr_option5='';
1095
  // Use nonce for verification ... ONLY USE ONCE!
1096
  wp_nonce_field( 'pprredirect_noncename', 'pprredirect_noncename', false, true );
 
1097
  // The actual fields for data entry
1098
+ $pprredirecttype = get_post_meta($post->ID, '_pprredirect_type', true) !='' ? get_post_meta($post->ID, '_pprredirect_type', true) : "";
1099
+ $pprredirecturl = get_post_meta($post->ID, '_pprredirect_url', true)!='' ? get_post_meta($post->ID, '_pprredirect_url', true) : "";
1100
+ //echo $pprredirecttype.'|'.$pprredirecturl;
1101
+ 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).' />&nbsp;Make Redirect <b>Active</b>.<span class="qppr_meta_help_wrap"><span class="qppr_meta_help_icon">?</span><span class="qppr_meta_help">Check to turn on or redirect will not work.</span></span></label><br />';
1102
+ 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).'>&nbsp;Open redirect link in a <b>new window.</b><span class="qppr_meta_help_wrap"><span class="qppr_meta_help_icon">?</span><span class="qppr_meta_help">May not work in all cases.</span></span></label><br />';
1103
+ 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).'>&nbsp;Add <b>rel="nofollow"</b> to redirect link.<span class="qppr_meta_help_wrap"><span class="qppr_meta_help_icon">?</span><span class="qppr_meta_help">May not work in all cases.</span></span></label><br />';
1104
+ 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).'>&nbsp;<b>Show</b> the Redirect URL instead of original URL. <span class="qppr_meta_help_wrap"><span class="qppr_meta_help_icon">?</span><span class="qppr_meta_help">May not always work and will only show the link - <strong><em>NOT in the Address bar.</em></strong></span></span></label><br /><br />';
1105
  //echo '<label for="pprredirect_casesensitive" style="padding:2px 0;"><input type="checkbox" name="pprredirect_casesensitive" id="pprredirect_casesensitive" value="1" '. checked('1',get_post_meta($post->ID,'_pprredirect_casesensitive',true),0).'>&nbsp;Make the Redirect Case Insensitive.</label><br /><br />';
1106
  echo '<label for="pprredirect_url"><b>Redirect URL:</b></label><br />';
1107
+ echo '<input type="text" style="width:75%;margin-top:2px;margin-bottom:2px;" name="pprredirect_url" value="'.$pprredirecturl.'" /><span class="qppr_meta_help_wrap"><span class="qppr_meta_help_icon">?</span><span class="qppr_meta_help"><br />(i.e., <strong>http://example.com</strong> or <strong>/somepage/</strong> or <strong>p=15</strong> or <strong>155</strong>. Use <b>FULL URL</b> <i>including</i> <strong>http://</strong> for all external <i>and</i> meta redirects.)</span></span><br /><br />';
1108
+ echo '<label for="pprredirect_type"><b>Type of Redirect:</b></label><br />';
1109
+
 
 
1110
  switch($pprredirecttype):
1111
  case "":
1112
  $ppr_option2=" selected";//default
1125
  break;
1126
  endswitch;
1127
 
1128
+ echo '
1129
+ <select style="margin-top:2px;margin-bottom:2px;width:40%;" name="pprredirect_type">
1130
+ <option value="301" '.$ppr_option1.'>301 Permanent</option>
1131
+ <option value="302" '.$ppr_option2.'>302 Temporary</option>
1132
+ <option value="307" '.$ppr_option3.'>307 Temporary</option>
1133
+ <option value="meta" '.$ppr_option5.'>Meta Redirect</option>
1134
+ </select><span class="qppr_meta_help_wrap"><span class="qppr_meta_help_icon">?</span><span class="qppr_meta_help">Default is 302 (Temporary Redirect). </span></span><br /><br />
1135
+ ';
1136
+ echo '<b>NOTE:</b> For a Page or Post (or Custom Post) Redirect to work, it may need to be published first and then saved again as a Draft. If you do not already have a page/post created you can add a \'Quick\' redirect using the <a href="./admin.php?page=redirect-updates">Quick Redirects</a> method.';
1137
+ }
1138
+ function appip_parseURI($url){
1139
+ /*
1140
+ [scheme]
1141
+ [host]
1142
+ [user]
1143
+ [pass]
1144
+ [path]
1145
+ [query]
1146
+ [fragment]
1147
+ */
1148
+ if(substr($url,0,2) == 'p='){ // page or post id
1149
+ $url = network_site_url().'/?'.$url;
1150
+ }elseif(is_numeric($url)){ // page or post id
1151
+ $url = network_site_url().'/?'.$url;
1152
+ }elseif($url[0] == "/" ){ // root
1153
+ $url = network_site_url().'/';
1154
+ }elseif(strpos($url,"://") === false ){ // no protocol so add it
1155
+ $url = "http://".$url;
1156
+ }
1157
+ $info = parse_url($url);
1158
+ $info['url'] = $url;
1159
+ //echo $info['url'];
1160
+ return $info;
1161
+ }
1162
+ function isOne_none($val=''){ //true (1) or false =''
1163
+ if($val == '_blank'){
1164
+ return $val;
1165
+ }elseif($val == '1' || $val == 'true' || $val === true ){
1166
+ return 1;
1167
+ }
1168
+ return '';
1169
  }
1170
 
1171
  function ppr_save_metadata($post_id, $post) {
 
1172
  if($post->post_type == 'revision'){return;}
1173
+ // verify authorization
1174
+ if(isset($_POST['pprredirect_noncename'])){
1175
+ if ( !wp_verify_nonce( $_REQUEST['pprredirect_noncename'], 'pprredirect_noncename' )) {
1176
+ return $post_id;
 
 
 
 
1177
  }
1178
+ }
1179
+ // check allowed to editing
1180
+ if ( !current_user_can('edit_posts', $post_id)){
1181
+ return $post_id;
1182
+ }
1183
+ if(!empty($my_meta_data)){unset($my_meta_data);}
1184
+ $my_meta_data = array();
1185
+ if(isset($_POST['pprredirect_active']) || isset($_POST['pprredirect_url']) || isset($_POST['pprredirect_type']) || isset($_POST['pprredirect_newwindow']) || isset($_POST['pprredirect_relnofollow'])):
1186
  // find & save the form data & put it into an array
1187
+ $my_meta_data['_pprredirect_active'] = isset($_REQUEST['pprredirect_active']) ? sanitize_meta( '_pprredirect_active', $this->isOne_none(intval( $_REQUEST['pprredirect_active'])), 'post' ) : '';
1188
+ $my_meta_data['_pprredirect_newwindow'] = isset($_REQUEST['pprredirect_newwindow']) ? sanitize_meta( '_pprredirect_newwindow', $this->isOne_none( $_REQUEST['pprredirect_newwindow']), 'post' ) : '';
1189
+ $my_meta_data['_pprredirect_relnofollow'] = isset($_REQUEST['pprredirect_relnofollow']) ? sanitize_meta( '_pprredirect_relnofollow', $this->isOne_none(intval( $_REQUEST['pprredirect_relnofollow'])), 'post' ) : '';
1190
+ $my_meta_data['_pprredirect_type'] = isset($_REQUEST['pprredirect_type']) ? sanitize_meta( '_pprredirect_type', sanitize_text_field( $_REQUEST['pprredirect_type'] ), 'post' ) : '';
1191
+ $my_meta_data['_pprredirect_rewritelink'] = isset($_REQUEST['pprredirect_rewritelink']) ? sanitize_meta( '_pprredirect_rewritelink', $this->isOne_none(intval( $_REQUEST['pprredirect_rewritelink'])), 'post' ) : '';
1192
+ $my_meta_data['_pprredirect_url'] = isset($_REQUEST['pprredirect_url']) ? sanitize_meta( '_pprredirect_url', ( $_REQUEST['pprredirect_url'] ), 'post' ) : '';
 
 
 
 
1193
 
1194
+ $info = $this->appip_parseURI($my_meta_data['_pprredirect_url']);
1195
+
1196
+ $my_meta_data['_pprredirect_url'] = esc_url_raw($info['url']);
1197
+ if($my_meta_data['_pprredirect_url'] == 'http://' || $my_meta_data['_pprredirect_url'] == 'https://' || $my_meta_data['_pprredirect_url'] == ''){
1198
+ $my_meta_data['_pprredirect_url'] = ''; //reset to nothing
1199
  $my_meta_data['_pprredirect_type'] = NULL; //clear Type if no URL is set.
1200
  $my_meta_data['_pprredirect_active'] = NULL; //turn it off if no URL is set
1201
+ $my_meta_data['_pprredirect_rewritelink'] = NULL; //turn it off if no URL is set
1202
+ $my_meta_data['_pprredirect_newwindow'] = NULL; //turn it off if no URL is set
1203
+ $my_meta_data['_pprredirect_relnofollow'] = NULL; //turn it off if no URL is set
1204
  }
1205
 
1206
  // Add values of $my_meta_data as custom fields
1207
  if(count($my_meta_data)>0){
1208
+ foreach ($my_meta_data as $key => $value) {
1209
+ $value = implode(',', (array)$value);
1210
+ if($value == '' || $value == NULL || $value == ','){
 
 
1211
  delete_post_meta($post->ID, $key);
1212
  }else{
1213
  if(get_post_meta($post->ID, $key, true) != '') {
1219
  }
1220
  }
1221
  endif;
 
1222
  }
1223
 
1224
  function ppr_fix_targetsandrels($pages) {
1326
  $useURLQS = array();
1327
  if(count($_GET) >= 1){
1328
  foreach($_GET as $key => $value){$useURLQS[] = $key.'='.$value;}
 
1329
  $finalQS = '?'.implode('&',$useURLQS);
1330
  $userrequest = preg_replace('/\?.*/', '', $userrequest);
1331
  }
1355
  if($val) {
1356
  $useURL = $this->pproverride_URL != '' ? $this->pproverride_URL : $val;
1357
  $useURL .= $finalQS; //add QS back
1358
+ //$this->pproverride_type = 301;
1359
+ $qpprRedType = 301;
1360
+ do_action('qppr_redirect',$useURL,$qpprRedType);
1361
+ if($qpprRedType == 'meta'){
1362
  $this->ppr_metaurl = $useURL;
1363
  add_action('wp_head', array($this,'ppr_addmetatohead_theme'),1);
1364
  }else{
1365
+ wp_redirect($useURL,$qpprRedType);
1366
  exit();
1367
  }
1368
  }
1393
  }else{ // we assume they are using the permalink / page name??
1394
  $urlsite=$this->homelink.'/'.$redrurl;
1395
  }
 
1396
  // check if override is set for all redirects to go to one URL
1397
  if($this->pproverride_URL !=''){$urlsite=$this->pproverride_URL;}
1398
  if($this->pproverride_type!='0' && $this->pproverride_type!=''){$redrtype = $this->pproverride_type;} //override check
qppr_admin_script.js ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function($){
2
+ $(document).ready(function() {
3
+ $('span.qppr_meta_help').css('display','none');
4
+ $('span.qppr_meta_help_wrap').live('hover',function(e){
5
+ var $curdisp = $(this).find('span.qppr_meta_help').css('display');
6
+ if($curdisp == 'none'){
7
+ $(this).find('span.qppr_meta_help').css('display','inline');
8
+ }else{
9
+ $(this).find('span.qppr_meta_help').css('display','none');
10
+ }
11
+ e.preventDefault();
12
+ });
13
+ });
14
+ })(jQuery)
qppr_admin_style.css ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ span.qppr_meta_help{display:none;}
2
+ .qppr_meta_help_icon {
3
+ padding: 0;
4
+ background: #9ED5FA;
5
+ display: inline-block;
6
+ height: 1.15em;
7
+ width: 1.15em;
8
+ text-align: center;
9
+ font-weight: bold;
10
+ font-size: .95em;
11
+ line-height: 1.15em;
12
+ margin: 0 2px;
13
+ border: 1px solid #4D8ED6;
14
+ }
15
+ .qppr_meta_help_icon:hover {
16
+ color: aliceblue;
17
+ background: #1489D4;
18
+ }
19
+ .qppr_meta_help_wrap {
20
+ padding: 0;
21
+ font-size: 11px;
22
+ /*text-transform: uppercase;*/
23
+ background: #FFF8C8;
24
+ line-height: 1.15em;
25
+ }
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: Don Fischer
3
  Donate link: http://www.fischercreativemedia.com/donations/
4
  Tags: redirect, 301, 302, meta, post, plugin, page, forward, re-direct, nofollow, menu links, posts, pages, admin, 404, custom post types, nav menu, import, export, restore
5
  Requires at least: 3.1
6
- Tested up to: 3.5.1
7
  Stable tag: trunk
8
 
9
  Redirect Pages/Posts to another page/post or external URL. Has edit box as well as global options. Specify the redirect Location and type. For PHP5+
@@ -129,6 +129,12 @@ NO it isn't! Check the plugin FAQs/Help page for a more up to date list of Frequ
129
  5. Summary of redirects plugin page.
130
 
131
  == Changelog ==
 
 
 
 
 
 
132
  = 5.0.3 =
133
  * Minor bug cleanup update - (no new features added)
134
  * Bug fixes: Javascript ghost js file call fixed. Actions hooks not applying issue fixed. Querystring redirect issue addressed. Unset index errors addressed. Some Network/MU problems fixed.
3
  Donate link: http://www.fischercreativemedia.com/donations/
4
  Tags: redirect, 301, 302, meta, post, plugin, page, forward, re-direct, nofollow, menu links, posts, pages, admin, 404, custom post types, nav menu, import, export, restore
5
  Requires at least: 3.1
6
+ Tested up to: 3.8.2
7
  Stable tag: trunk
8
 
9
  Redirect Pages/Posts to another page/post or external URL. Has edit box as well as global options. Specify the redirect Location and type. For PHP5+
129
  5. Summary of redirects plugin page.
130
 
131
  == Changelog ==
132
+ = 5.0.4 =
133
+ * Minor bug cleanup
134
+ * Security fixes: fixed possible cross-scripting vulnerability in saving of data to options.
135
+ * Changed the hook call level for the redirects hook on normal redirects so it will not interfere with some other plugins.
136
+
137
+
138
  = 5.0.3 =
139
  * Minor bug cleanup update - (no new features added)
140
  * Bug fixes: Javascript ghost js file call fixed. Actions hooks not applying issue fixed. Querystring redirect issue addressed. Unset index errors addressed. Some Network/MU problems fixed.