Version Description
- **Resolved potential nonce vulnerability issue
Download this release
Release Info
Developer | anadnet |
Plugin | Quick Page/Post Redirect Plugin |
Version | 5.2.0 |
Comparing to | |
See all releases |
Code changes from version 5.1.9 to 5.2.0
- js/qppr_admin_script.js +34 -34
- page_post_redirect_plugin.php +235 -193
- readme.txt +37 -34
js/qppr_admin_script.js
CHANGED
@@ -10,7 +10,7 @@
|
|
10 |
}
|
11 |
e.preventDefault();
|
12 |
});
|
13 |
-
var mainurl = z.ajaxurl;
|
14 |
$( '#pprredirect_type').on( 'change', function(e){
|
15 |
e.preventDefault();
|
16 |
$( '.qppr-meta-section-wrapper' ).removeClass( 'meta-selected meta-not-selected' );
|
@@ -23,7 +23,7 @@
|
|
23 |
});
|
24 |
$( '.qppr-delete-everything' ).on( 'click', function(e){
|
25 |
e.preventDefault();
|
26 |
-
if( confirm( z.msgAllDeleteConfirm ) ){
|
27 |
var remove_qppr_all_data = {'action' : 'qppr_delete_all_settings', 'security': z.securityDelete};
|
28 |
$.post(z.ajaxurl, remove_qppr_all_data, function( response ) {
|
29 |
if( response == 'success' ){
|
@@ -36,7 +36,7 @@
|
|
36 |
});
|
37 |
$( '.qppr-delete-regular' ).on( 'click', function(e){
|
38 |
e.preventDefault();
|
39 |
-
if( confirm( z.msgIndividualDeleteConfirm ) ){
|
40 |
var remove_qppr_all_indiviual_data = {'action' : 'qppr_delete_all_iredirects', 'security': z.securityDelete};
|
41 |
$.post(z.ajaxurl, remove_qppr_all_indiviual_data, function( response ) {
|
42 |
if( response == 'success' ){
|
@@ -47,10 +47,10 @@
|
|
47 |
});
|
48 |
}
|
49 |
});
|
50 |
-
|
51 |
$( '.qppr-delete-quick' ).on( 'click', function(e){
|
52 |
e.preventDefault();
|
53 |
-
if( confirm( z.msgQuickDeleteConfirm ) ){
|
54 |
var remove_qppr_all_quick_data = {'action' : 'qppr_delete_all_qredirects', 'security': z.securityDelete};
|
55 |
$.post(z.ajaxurl, remove_qppr_all_quick_data, function(response) {
|
56 |
if( response == 'success' ){
|
@@ -76,16 +76,16 @@
|
|
76 |
}
|
77 |
return true;
|
78 |
});
|
79 |
-
|
80 |
-
$('#qppr_quick_save_form').delegate('.delete-qppr','click', function(e){
|
81 |
-
e.preventDefault();
|
82 |
var rowID = $(this).data('rowid'),
|
83 |
request = $('#'+rowID).children('.table-qppr-req').children('.qppr-request').text(),
|
84 |
qrdata = {'action' : 'qppr_delete_quick_redirect','request': request,'security': z.security},
|
85 |
qr = 1;
|
86 |
-
if( confirm( z.msgDeleteConfirm ) ){
|
87 |
$.post(z.ajaxurl, qrdata, function(r) {
|
88 |
-
$('#'+rowID).remove();
|
89 |
}).done(function() {
|
90 |
$('.qppr-count-row').each(function(e){
|
91 |
$( this ).text( qr + '.' );
|
@@ -93,26 +93,26 @@
|
|
93 |
});
|
94 |
});
|
95 |
}
|
96 |
-
});
|
97 |
-
|
98 |
-
$(".edit-qppr").click(function(e){
|
99 |
-
e.preventDefault();
|
100 |
var r = $(this).data('rowid'),
|
101 |
-
x = $('#'+r),
|
102 |
-
v = $('#qppr-edit-row-holder').children('td');
|
103 |
$( '#' + r + ' td' ).addClass('editing');
|
104 |
x.addClass('editing-redirect');
|
105 |
v.clone().prependTo(x);
|
106 |
-
var aa = x.children('.table-qppr-nwn.editing').children( '.qppr-newindow' ).text() == 'X' ? true : false ,
|
107 |
-
bb = x.children('.table-qppr-nfl.editing').children( '.qppr-nofollow' ).text() == 'X' ? true : false ;
|
108 |
x.children('.table-qppr-req.cloned').children('.input-qppr-req').attr( 'value', x.children('.table-qppr-req.editing').children('.qppr-request').text());
|
109 |
x.children('.table-qppr-des.cloned').children('.input-qppr-dest').attr( 'value', x.children('.table-qppr-des.editing').children('.qppr-destination').text());
|
110 |
x.children('.table-qppr-nwn.cloned').children('.input-qppr-neww').prop( 'checked', aa );
|
111 |
x.children('.table-qppr-nfl.cloned').children('.input-qppr-nofo').prop( 'checked', bb );
|
112 |
x.children('.table-qppr-sav.cloned').children('.table-qppr-sav span').attr( 'data-rowid', r );
|
113 |
x.children('.table-qppr-can.cloned').children('.table-qppr-can span').attr( 'data-rowid', r );
|
114 |
-
});
|
115 |
-
|
116 |
$(".qppr_quick_redirects_wrapper").delegate('.table-qppr-sav span.qpprfont-save', 'hover', function(e){
|
117 |
if( $( '.active-saving' ).length != 0 && !$( this ).parent().parent().hasClass('active-saving'))
|
118 |
$( this ).css( {'cursor':'no-drop','color':'#ff0000'} );
|
@@ -149,8 +149,8 @@
|
|
149 |
$( '#qppr-edit-row-saving .qppr-saving-row' ).clone().prependTo( '#' + rowID );
|
150 |
editRow.addClass( 'active-saving' );
|
151 |
var save_data = {
|
152 |
-
'action' : 'qppr_save_quick_redirect',
|
153 |
-
'row' : rowID.replace('rowpprdel-',''),
|
154 |
'original' : requestOrig,
|
155 |
'request' : request,
|
156 |
'destination' : destination,
|
@@ -158,7 +158,7 @@
|
|
158 |
'nofollow' : noFoll,
|
159 |
'security' : z.security
|
160 |
};
|
161 |
-
|
162 |
$.post(z.ajaxurl, save_data, function(response) {
|
163 |
var err = 0;
|
164 |
if( response == 'error' ){
|
@@ -197,19 +197,19 @@
|
|
197 |
rowID.children('td').removeClass('editing');
|
198 |
rowID.removeClass('editing-redirect');
|
199 |
});
|
200 |
-
|
201 |
$("#hidepprjqmessage").click(function(e){
|
202 |
-
e.preventDefault();
|
203 |
var pprhidemessage_data = {'action' : 'qppr_pprhidemessage_ajax','pprhidemessage': 1,'scid': z.security};
|
204 |
$.post(z.ajaxurl, pprhidemessage_data, function(response) {$('#usejqpprmessage').remove();}).done(function() {});
|
205 |
});
|
206 |
-
|
207 |
-
$("#hidepprjqmessage2").click(function(e){
|
208 |
-
e.preventDefault();
|
209 |
var pprhidemessage_data = {'action' : 'qppr_pprhidemessage_ajax','pprhidemessage': 2,'scid': z.security};
|
210 |
$.post(z.ajaxurl, pprhidemessage_data, function(response) {$('#usejqpprmessage2').remove();}).done(function() {});
|
211 |
-
});
|
212 |
-
|
213 |
$("#qppr-import-quick-redirects-button").click(function(e){
|
214 |
e.preventDefault();
|
215 |
$('#qppr_addto_form').css({'display':'none'});
|
@@ -219,7 +219,7 @@
|
|
219 |
$('#qppr_import_form').css({'display':'block'});
|
220 |
}
|
221 |
});
|
222 |
-
|
223 |
$("#qppr_addto_qr_button").click(function(e){
|
224 |
$('#qppr_import_form').css({'display':'none'});
|
225 |
if($('#qppr_addto_form').css('display')=='block'){
|
@@ -229,7 +229,7 @@
|
|
229 |
}
|
230 |
e.preventDefault();
|
231 |
});
|
232 |
-
|
233 |
$("#import_redirects_add_qppr").click(function(e){
|
234 |
if($("[name|=qppr_file_add]").attr('value')==''){
|
235 |
e.preventDefault();
|
@@ -237,7 +237,7 @@
|
|
237 |
return false;
|
238 |
}
|
239 |
});
|
240 |
-
|
241 |
$("#import-quick-redrects-file").click(function(e){
|
242 |
if($("[name|=qppr_file]").attr('value')==''){
|
243 |
e.preventDefault();
|
@@ -261,4 +261,4 @@ function qppr_goOnConfirm(message, href) {
|
|
261 |
if( confirm( message ) ){
|
262 |
document.location.href = qpprData.adminURL+href;
|
263 |
}
|
264 |
-
}
|
10 |
}
|
11 |
e.preventDefault();
|
12 |
});
|
13 |
+
var mainurl = z.ajaxurl;
|
14 |
$( '#pprredirect_type').on( 'change', function(e){
|
15 |
e.preventDefault();
|
16 |
$( '.qppr-meta-section-wrapper' ).removeClass( 'meta-selected meta-not-selected' );
|
23 |
});
|
24 |
$( '.qppr-delete-everything' ).on( 'click', function(e){
|
25 |
e.preventDefault();
|
26 |
+
if( confirm( z.msgAllDeleteConfirm ) ){
|
27 |
var remove_qppr_all_data = {'action' : 'qppr_delete_all_settings', 'security': z.securityDelete};
|
28 |
$.post(z.ajaxurl, remove_qppr_all_data, function( response ) {
|
29 |
if( response == 'success' ){
|
36 |
});
|
37 |
$( '.qppr-delete-regular' ).on( 'click', function(e){
|
38 |
e.preventDefault();
|
39 |
+
if( confirm( z.msgIndividualDeleteConfirm ) ){
|
40 |
var remove_qppr_all_indiviual_data = {'action' : 'qppr_delete_all_iredirects', 'security': z.securityDelete};
|
41 |
$.post(z.ajaxurl, remove_qppr_all_indiviual_data, function( response ) {
|
42 |
if( response == 'success' ){
|
47 |
});
|
48 |
}
|
49 |
});
|
50 |
+
|
51 |
$( '.qppr-delete-quick' ).on( 'click', function(e){
|
52 |
e.preventDefault();
|
53 |
+
if( confirm( z.msgQuickDeleteConfirm ) ){
|
54 |
var remove_qppr_all_quick_data = {'action' : 'qppr_delete_all_qredirects', 'security': z.securityDelete};
|
55 |
$.post(z.ajaxurl, remove_qppr_all_quick_data, function(response) {
|
56 |
if( response == 'success' ){
|
76 |
}
|
77 |
return true;
|
78 |
});
|
79 |
+
|
80 |
+
$('#qppr_quick_save_form').delegate('.delete-qppr','click', function(e){
|
81 |
+
e.preventDefault();
|
82 |
var rowID = $(this).data('rowid'),
|
83 |
request = $('#'+rowID).children('.table-qppr-req').children('.qppr-request').text(),
|
84 |
qrdata = {'action' : 'qppr_delete_quick_redirect','request': request,'security': z.security},
|
85 |
qr = 1;
|
86 |
+
if( confirm( z.msgDeleteConfirm ) ){
|
87 |
$.post(z.ajaxurl, qrdata, function(r) {
|
88 |
+
$('#'+rowID).remove();
|
89 |
}).done(function() {
|
90 |
$('.qppr-count-row').each(function(e){
|
91 |
$( this ).text( qr + '.' );
|
93 |
});
|
94 |
});
|
95 |
}
|
96 |
+
});
|
97 |
+
|
98 |
+
$(".edit-qppr").click(function(e){
|
99 |
+
e.preventDefault();
|
100 |
var r = $(this).data('rowid'),
|
101 |
+
x = $('#'+r),
|
102 |
+
v = $('#qppr-edit-row-holder').children('td');
|
103 |
$( '#' + r + ' td' ).addClass('editing');
|
104 |
x.addClass('editing-redirect');
|
105 |
v.clone().prependTo(x);
|
106 |
+
var aa = x.children('.table-qppr-nwn.editing').children( '.qppr-newindow' ).text() == 'X' ? true : false ,
|
107 |
+
bb = x.children('.table-qppr-nfl.editing').children( '.qppr-nofollow' ).text() == 'X' ? true : false ;
|
108 |
x.children('.table-qppr-req.cloned').children('.input-qppr-req').attr( 'value', x.children('.table-qppr-req.editing').children('.qppr-request').text());
|
109 |
x.children('.table-qppr-des.cloned').children('.input-qppr-dest').attr( 'value', x.children('.table-qppr-des.editing').children('.qppr-destination').text());
|
110 |
x.children('.table-qppr-nwn.cloned').children('.input-qppr-neww').prop( 'checked', aa );
|
111 |
x.children('.table-qppr-nfl.cloned').children('.input-qppr-nofo').prop( 'checked', bb );
|
112 |
x.children('.table-qppr-sav.cloned').children('.table-qppr-sav span').attr( 'data-rowid', r );
|
113 |
x.children('.table-qppr-can.cloned').children('.table-qppr-can span').attr( 'data-rowid', r );
|
114 |
+
});
|
115 |
+
|
116 |
$(".qppr_quick_redirects_wrapper").delegate('.table-qppr-sav span.qpprfont-save', 'hover', function(e){
|
117 |
if( $( '.active-saving' ).length != 0 && !$( this ).parent().parent().hasClass('active-saving'))
|
118 |
$( this ).css( {'cursor':'no-drop','color':'#ff0000'} );
|
149 |
$( '#qppr-edit-row-saving .qppr-saving-row' ).clone().prependTo( '#' + rowID );
|
150 |
editRow.addClass( 'active-saving' );
|
151 |
var save_data = {
|
152 |
+
'action' : 'qppr_save_quick_redirect',
|
153 |
+
'row' : rowID.replace('rowpprdel-',''),
|
154 |
'original' : requestOrig,
|
155 |
'request' : request,
|
156 |
'destination' : destination,
|
158 |
'nofollow' : noFoll,
|
159 |
'security' : z.security
|
160 |
};
|
161 |
+
|
162 |
$.post(z.ajaxurl, save_data, function(response) {
|
163 |
var err = 0;
|
164 |
if( response == 'error' ){
|
197 |
rowID.children('td').removeClass('editing');
|
198 |
rowID.removeClass('editing-redirect');
|
199 |
});
|
200 |
+
|
201 |
$("#hidepprjqmessage").click(function(e){
|
202 |
+
e.preventDefault();
|
203 |
var pprhidemessage_data = {'action' : 'qppr_pprhidemessage_ajax','pprhidemessage': 1,'scid': z.security};
|
204 |
$.post(z.ajaxurl, pprhidemessage_data, function(response) {$('#usejqpprmessage').remove();}).done(function() {});
|
205 |
});
|
206 |
+
|
207 |
+
$("#hidepprjqmessage2").click(function(e){
|
208 |
+
e.preventDefault();
|
209 |
var pprhidemessage_data = {'action' : 'qppr_pprhidemessage_ajax','pprhidemessage': 2,'scid': z.security};
|
210 |
$.post(z.ajaxurl, pprhidemessage_data, function(response) {$('#usejqpprmessage2').remove();}).done(function() {});
|
211 |
+
});
|
212 |
+
|
213 |
$("#qppr-import-quick-redirects-button").click(function(e){
|
214 |
e.preventDefault();
|
215 |
$('#qppr_addto_form').css({'display':'none'});
|
219 |
$('#qppr_import_form').css({'display':'block'});
|
220 |
}
|
221 |
});
|
222 |
+
|
223 |
$("#qppr_addto_qr_button").click(function(e){
|
224 |
$('#qppr_import_form').css({'display':'none'});
|
225 |
if($('#qppr_addto_form').css('display')=='block'){
|
229 |
}
|
230 |
e.preventDefault();
|
231 |
});
|
232 |
+
|
233 |
$("#import_redirects_add_qppr").click(function(e){
|
234 |
if($("[name|=qppr_file_add]").attr('value')==''){
|
235 |
e.preventDefault();
|
237 |
return false;
|
238 |
}
|
239 |
});
|
240 |
+
|
241 |
$("#import-quick-redrects-file").click(function(e){
|
242 |
if($("[name|=qppr_file]").attr('value')==''){
|
243 |
e.preventDefault();
|
261 |
if( confirm( message ) ){
|
262 |
document.location.href = qpprData.adminURL+href;
|
263 |
}
|
264 |
+
}
|
page_post_redirect_plugin.php
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
-
<?php
|
2 |
/*
|
3 |
Plugin Name: Quick Page/Post Redirect Plugin
|
4 |
Plugin URI: http://www.anadnet.com/quick-pagepost-redirect-plugin/
|
5 |
Description: Redirect Pages, Posts or Custom Post Types to another location quickly (for internal or external URLs). Includes individual post/page options, redirects for Custom Post types, non-existant 301 Quick Redirects (helpful for sites converted to WordPress), New Window functionality, and rel=nofollow functionality.
|
6 |
Author: anadnet
|
7 |
Author URI: http://www.anadnet.com/
|
8 |
-
Donate link:
|
9 |
-
Version: 5.
|
10 |
Text Domain: quick-pagepost-redirect-plugin
|
11 |
Domain Path: /lang
|
12 |
License: GPLv2 or later
|
@@ -36,7 +36,7 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
|
36 |
global $newqppr, $redirect_plugin, $qppr_setting_links;
|
37 |
$qppr_setting_links = false;
|
38 |
start_ppr_class();
|
39 |
-
|
40 |
//=======================================
|
41 |
// Main Plugin Redirect Class.
|
42 |
//=======================================
|
@@ -69,9 +69,9 @@ class quick_page_post_reds {
|
|
69 |
public $pproverride_casesensitive;
|
70 |
public $ppruse_jquery;
|
71 |
public $pprptypes_ok;
|
72 |
-
|
73 |
function __construct() {
|
74 |
-
$this->ppr_curr_version = '5.
|
75 |
$this->ppr_nofollow = array();
|
76 |
$this->ppr_newindow = array();
|
77 |
$this->ppr_url = array();
|
@@ -98,7 +98,7 @@ class quick_page_post_reds {
|
|
98 |
$this->updatemsg = '';
|
99 |
$this->pprshowcols = get_option( 'ppr_show-columns', '1' );
|
100 |
//if($this->pprmeta_seconds==''){$this->pprmeta_seconds='0';}
|
101 |
-
|
102 |
//these are for all the time - even if there are overrides
|
103 |
add_action( 'admin_init', array( $this, 'save_quick_redirects_fields' ) );
|
104 |
add_action( 'admin_init', array( $this, 'ppr_init_check_version' ), 1 ); // checks version of plugin in DB and updates if needed.
|
@@ -123,7 +123,7 @@ class quick_page_post_reds {
|
|
123 |
add_filter( 'qppr_admin_pointers-quick-redirects_page_redirect-options', array( $this, 'qppr_register_pointer_use_jquery' ) ); // add pointers filter
|
124 |
add_filter( 'qppr_admin_pointers-quick-redirects_page_meta_addon', array( $this, 'qppr_register_pointer_meta' ) ); // add pointers filter
|
125 |
//add_filter( 'wp_feed_cache_transient_lifetime',array($this,'ppr_wp_feed_options',10, 2)); // for testing FAQ page only
|
126 |
-
|
127 |
if( $this->pproverride_active != '1' && !is_admin() ){ // don't run these if override active is set
|
128 |
add_action( 'init', array( $this, 'redirect' ), 1 ); // add the 301 redirect action, high priority
|
129 |
add_action( 'init', array( $this, 'redirect_post_type' ), 1 ); // add the normal redirect action, high priority
|
@@ -137,7 +137,7 @@ class quick_page_post_reds {
|
|
137 |
add_filter( 'get_permalink', array( $this, 'ppr_filter_links' ), 20, 2 ); // hook into get_permalink function
|
138 |
add_filter( 'redirect_canonical', array( $this, 'wordpress_no_guess_canonical' ) ); // stops 404 on canonical redirect as of 5.1.5
|
139 |
}
|
140 |
-
|
141 |
if( $this->pprshowcols == '1')
|
142 |
add_filter( 'pre_get_posts', array( $this,'add_custom_columns' ) ); // add custom columns
|
143 |
}
|
@@ -156,16 +156,16 @@ class quick_page_post_reds {
|
|
156 |
}
|
157 |
return $redirect_url;
|
158 |
}
|
159 |
-
|
160 |
/**
|
161 |
* Load plugin textdomain.
|
162 |
*
|
163 |
* @since 5.1.2
|
164 |
*/
|
165 |
function qppr_load_textdomain() {
|
166 |
-
load_plugin_textdomain( 'quick-pagepost-redirect-plugin', false, dirname( plugin_basename( __FILE__ ) ) . '/lang' );
|
167 |
}
|
168 |
-
|
169 |
/**
|
170 |
* Try to clear Cache files when certain plugins are present.
|
171 |
* Only happens after redirects or settings are saved or deleted.
|
@@ -190,8 +190,10 @@ class quick_page_post_reds {
|
|
190 |
$newCache->deleteCache();
|
191 |
}
|
192 |
}
|
193 |
-
|
194 |
function qppr_delete_all_settings_ajax(){
|
|
|
|
|
195 |
check_ajax_referer( 'qppr_ajax_delete_ALL_verify', 'security', true );
|
196 |
if( current_user_can( 'manage_options' ) ){
|
197 |
global $wpdb;
|
@@ -219,18 +221,20 @@ class quick_page_post_reds {
|
|
219 |
delete_option( 'ppr_override-casesensitive' );
|
220 |
delete_option( 'ppr_show-columns' );
|
221 |
delete_option( 'ppr_use-custom-post-types' );
|
222 |
-
delete_option( 'qppr_jQuery_hide_message2' );
|
223 |
delete_option( 'qppr_meta_addon_load' );
|
224 |
delete_option( 'qppr_meta_addon_trigger' );
|
225 |
delete_option( 'qppr_meta_append_to' );
|
226 |
$this->qppr_try_to_clear_cache_plugins();
|
227 |
echo 'success';
|
228 |
}else{
|
229 |
-
echo 'no permission';
|
230 |
}
|
231 |
exit;
|
232 |
}
|
233 |
function qppr_delete_all_ireds_ajax(){
|
|
|
|
|
234 |
check_ajax_referer( 'qppr_ajax_delete_ALL_verify', 'security', true );
|
235 |
if( current_user_can( 'manage_options' ) ){
|
236 |
global $wpdb;
|
@@ -239,12 +243,14 @@ class quick_page_post_reds {
|
|
239 |
$this->qppr_try_to_clear_cache_plugins();
|
240 |
echo 'success';
|
241 |
}else{
|
242 |
-
echo 'no permission';
|
243 |
}
|
244 |
exit;
|
245 |
}
|
246 |
-
|
247 |
function qppr_delete_all_qreds_ajax(){
|
|
|
|
|
248 |
check_ajax_referer( 'qppr_ajax_delete_ALL_verify', 'security', true );
|
249 |
if( current_user_can( 'manage_options' ) ){
|
250 |
delete_option( 'quickppr_redirects' );
|
@@ -252,11 +258,11 @@ class quick_page_post_reds {
|
|
252 |
$this->qppr_try_to_clear_cache_plugins();
|
253 |
echo 'success';
|
254 |
}else{
|
255 |
-
echo 'no permission';
|
256 |
}
|
257 |
exit;
|
258 |
}
|
259 |
-
|
260 |
function qppr_pointer_load( $hook_suffix ) {
|
261 |
if ( get_bloginfo( 'version' ) < '3.3' )
|
262 |
return;
|
@@ -280,7 +286,7 @@ class quick_page_post_reds {
|
|
280 |
wp_enqueue_script( 'qppr-pointer', plugins_url( 'js/qppr_pointers.min.js', __FILE__ ), array( 'wp-pointer' ) );
|
281 |
wp_localize_script( 'qppr-pointer', 'qpprPointer', $valid_pointers );
|
282 |
}
|
283 |
-
|
284 |
function qppr_register_pointer_meta( $p ) {
|
285 |
$p['qppr-meta-options'] = array(
|
286 |
'target' => '.wrap > h2:first-child',
|
@@ -309,7 +315,7 @@ class quick_page_post_reds {
|
|
309 |
);
|
310 |
return $p;
|
311 |
}
|
312 |
-
|
313 |
function qppr_register_pointer_use_jquery( $p ) {
|
314 |
$p['qppr-use-jquery'] = array(
|
315 |
'target' => '#ppr_use-jquery',
|
@@ -325,8 +331,10 @@ class quick_page_post_reds {
|
|
325 |
);
|
326 |
return $p;
|
327 |
}
|
328 |
-
|
329 |
function qppr_delete_quick_redirect_ajax(){
|
|
|
|
|
330 |
check_ajax_referer( 'qppr_ajax_verify', 'security', true );
|
331 |
$request = isset($_POST['request']) && esc_url($_POST['request']) != '' ? esc_url($_POST['request']) : '';
|
332 |
$curRedirects = get_option( 'quickppr_redirects', array() );
|
@@ -338,13 +346,16 @@ class quick_page_post_reds {
|
|
338 |
$this->qppr_try_to_clear_cache_plugins();
|
339 |
echo 'redirect deleted';
|
340 |
}else{
|
341 |
-
echo 'error';
|
342 |
}
|
343 |
exit;
|
344 |
}
|
345 |
-
|
346 |
function qppr_save_quick_redirect_ajax(){
|
|
|
|
|
347 |
check_ajax_referer( 'qppr_ajax_verify', 'security', true );
|
|
|
348 |
$protocols = apply_filters('qppr_allowed_protocols',array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn', 'tel', 'fax', 'xmpp'));
|
349 |
$request = isset($_POST['request']) && trim($_POST['request']) != '' ? esc_url(str_replace(' ','%20',trim($_POST['request'])), null, 'appip') : '';
|
350 |
$requestOrig = isset($_POST['original']) && trim($_POST['original']) != '' ? esc_url(str_replace(' ','%20',trim($_POST['original'])), null, 'appip') : '';
|
@@ -358,14 +369,14 @@ class quick_page_post_reds {
|
|
358 |
$mkeys = array_keys($curMeta);
|
359 |
if( $updateRow == -1 || $requestOrig == '' || $request == '' || $destination == '' || empty( $curRedirects ) || empty( $curMeta) ){
|
360 |
echo 'error';
|
361 |
-
exit;
|
362 |
}
|
363 |
$toDelete = array();
|
364 |
$newRedirects = array();
|
365 |
$newMeta = array();
|
366 |
$orkey = array_search($requestOrig, $rkeys);
|
367 |
$omkey = array_search($requestOrig, $mkeys);
|
368 |
-
|
369 |
if( is_array( $rkeys ) && ! empty( $rkeys ) ){
|
370 |
foreach( $rkeys as $key => $val ){
|
371 |
$newRedirects[] = array( 'request' => $val, 'destination' => $curRedirects[$val] );
|
@@ -396,10 +407,10 @@ class quick_page_post_reds {
|
|
396 |
}
|
397 |
}
|
398 |
if( $originalRowMetaKey == $request ){
|
399 |
-
//if row to udpate has same request value then just update data
|
400 |
$newMeta[$omkey]['key'] = $request;
|
401 |
$newMeta[$omkey]['newwindow'] = $newWin;
|
402 |
-
$newMeta[$omkey]['nofollow'] = $noFollow;
|
403 |
}else{
|
404 |
if( isset( $curMeta[$request] ) ){
|
405 |
echo 'duplicate';
|
@@ -424,7 +435,7 @@ class quick_page_post_reds {
|
|
424 |
echo 'saved';
|
425 |
exit;
|
426 |
}
|
427 |
-
|
428 |
function save_quick_redirects_fields(){
|
429 |
if( isset( $_POST['submit_301'] ) ) {
|
430 |
if( check_admin_referer( 'add_qppr_redirects' )){
|
@@ -443,9 +454,9 @@ class quick_page_post_reds {
|
|
443 |
$currMeta = get_option( 'quickppr_redirects_meta', array() );
|
444 |
//TODO: Add Back up Redirects
|
445 |
//TODO: Add New Redirects to TOP not Bottom.
|
446 |
-
|
447 |
$protocols = apply_filters( 'qppr_allowed_protocols', array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn', 'tel', 'fax', 'xmpp'));
|
448 |
-
|
449 |
for($i = 0; $i < sizeof($data['request']); ++$i) {
|
450 |
$request = esc_url(str_replace(' ','%20',trim($data['request'][$i])), null, 'appip');
|
451 |
$destination = esc_url(str_replace(' ','%20',trim($data['destination'][$i])), null, 'appip');
|
@@ -457,26 +468,26 @@ class quick_page_post_reds {
|
|
457 |
if((strpos($request,'.') === false && strpos($request,'?') === false) && strpos($request,'/',strlen($request)-1) === false){
|
458 |
$request = $request.'/';
|
459 |
} // adds end folder marker if not a file end
|
460 |
-
if (($request == '' || $request == '/') && $destination == '') {
|
461 |
continue; //if nothing there do nothing
|
462 |
} elseif ($request != '' && $request != '/' && $destination == '' ){
|
463 |
$currRedirects[$request] = '/';
|
464 |
-
} else {
|
465 |
$currRedirects[$request] = $destination;
|
466 |
}
|
467 |
$currMeta[$request]['newwindow'] = $newwin;
|
468 |
$currMeta[$request]['nofollow'] = $nofoll;
|
469 |
}
|
470 |
-
|
471 |
update_option( 'quickppr_redirects', sanitize_option( 'quickppr_redirects', $currRedirects ) );
|
472 |
update_option( 'quickppr_redirects_meta', sanitize_option( 'quickppr_redirects_meta', $currMeta ) );
|
473 |
$this->quickppr_redirectsmeta = get_option( 'quickppr_redirects_meta', array() );
|
474 |
$this->quickppr_redirects = get_option( 'quickppr_redirects', array() );
|
475 |
return $currRedirects;
|
476 |
}
|
477 |
-
|
478 |
function qppr_strposa($haystack, $needle, $offset = 0) {
|
479 |
-
if( !is_array( $needle ) )
|
480 |
$needle = array( $needle );
|
481 |
foreach( $needle as $key => $query ) {
|
482 |
if(strpos($haystack, $query, $offset) !== false) return true; // stop on first true result
|
@@ -530,9 +541,9 @@ class quick_page_post_reds {
|
|
530 |
add_filter( "manage_page_posts_columns", array( $this, 'set_custom_edit_qppr_columns' ) );
|
531 |
add_action( "manage_page_posts_custom_column" , array( $this, 'custom_qppr_column' ), 10, 2 );
|
532 |
}
|
533 |
-
|
534 |
}
|
535 |
-
|
536 |
function set_custom_edit_qppr_columns($columns) {
|
537 |
$columns['qppr_redirect'] = __( 'Redirect', 'quick-pagepost-redirect-plugin' );
|
538 |
return $columns;
|
@@ -541,13 +552,13 @@ class quick_page_post_reds {
|
|
541 |
function custom_qppr_column( $column, $post_id ) {
|
542 |
switch ( $column ) {
|
543 |
case 'qppr_redirect' :
|
544 |
-
$qppr_url = get_post_meta( $post_id , '_pprredirect_url', true ) != '' ? get_post_meta( $post_id , '_pprredirect_url', true ) : '';
|
545 |
if( $qppr_url != '' ){
|
546 |
-
$qppr_type = get_post_meta( $post_id , '_pprredirect_type', true );
|
547 |
-
$qppr_active = get_post_meta( $post_id , '_pprredirect_active', true );
|
548 |
-
$qppr_rewrite = get_post_meta( $post_id , '_pprredirect_rewritelink', true );
|
549 |
-
$qppr_newwin = get_post_meta( $post_id , '_pprredirect_newwindow', true );
|
550 |
-
$qppr_nofoll = get_post_meta( $post_id , '_pprredirect_relnofollow', true );
|
551 |
$rediricon = $qppr_newwin != '' ? '<span class="dashicons dashicons-external" title="New Window"></span>' : '<span class="dashicons dashicons-arrow-right-alt" title="Redirects to"></span>';
|
552 |
if($qppr_active == '1'){
|
553 |
echo '<div class="qpprfont-on" title="on">('.$qppr_type.') ' . $rediricon . ' <code>'.$qppr_url.'</code></div>';
|
@@ -558,7 +569,7 @@ class quick_page_post_reds {
|
|
558 |
break;
|
559 |
}
|
560 |
}
|
561 |
-
|
562 |
function ppr_add_menu_and_metaboxes(){
|
563 |
/* add menus */
|
564 |
$qppr_add_page = add_menu_page( 'Quick Redirects', 'Quick Redirects', 'manage_options', 'redirect-updates', array( $this, 'ppr_options_page' ), 'dashicons-external' );
|
@@ -595,31 +606,62 @@ class quick_page_post_reds {
|
|
595 |
'post' => 'post'
|
596 |
);
|
597 |
}
|
598 |
-
|
599 |
$ptypesNOTok = is_array( $this->pprptypes_ok ) ? $this->pprptypes_ok : array();
|
600 |
-
|
601 |
foreach( $post_types_temp as $type ){
|
602 |
if( !in_array( $type, $ptypesNOTok ) ){
|
603 |
$context = apply_filters('appip_metabox_context_filter','normal');
|
604 |
$priority = apply_filters('appip_metabox_priority_filter','high');
|
605 |
-
add_meta_box( 'edit-box-ppr', __( 'Quick Page/Post Redirect', 'quick-pagepost-redirect-plugin' ) , array( $this, 'edit_box_ppr_1' ), $type, $context, $priority );
|
606 |
}
|
607 |
}
|
608 |
}
|
609 |
-
|
610 |
function qppr_admin_scripts($hook){
|
611 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
612 |
$ajax_add_nonce = wp_create_nonce( 'qppr_ajax_verify' );
|
613 |
$secDeleteNonce = wp_create_nonce( 'qppr_ajax_delete_ALL_verify' );
|
614 |
$protocols = apply_filters( 'qppr_allowed_protocols', array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn', 'tel', 'fax', 'xmpp'));
|
|
|
615 |
wp_enqueue_style( 'qppr_admin_meta_style', plugins_url( '/css/qppr_admin_style.css', __FILE__ ) , null , $this->ppr_curr_version );
|
616 |
-
|
|
|
617 |
wp_enqueue_script( 'qppr_admin_meta_script', plugins_url( '/js/qppr_admin_script.min.js', __FILE__ ) , array('jquery'), $this->ppr_curr_version );
|
618 |
-
wp_localize_script( 'qppr_admin_meta_script', 'qpprData', array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
619 |
}
|
620 |
return;
|
621 |
-
}
|
622 |
-
|
623 |
function qppr_frontend_scripts(){
|
624 |
global $qppr_setting_links;
|
625 |
$qppr_setting_links = true;
|
@@ -670,13 +712,13 @@ class quick_page_post_reds {
|
|
670 |
$linkData[$redURL] = array( $newWin, $noFoll, $rewriteval );
|
671 |
}
|
672 |
}
|
673 |
-
|
674 |
$qppr_setting_links = false;
|
675 |
//wp_enqueue_script( 'qppr_frontend_scripts', plugins_url( '/js/qppr_frontend_script.js', __FILE__ ) , array('jquery'), $this->ppr_curr_version, true );
|
676 |
wp_enqueue_script( 'qppr_frontend_scripts', plugins_url( '/js/qppr_frontend_script.min.js', __FILE__ ) , array('jquery'), $this->ppr_curr_version, true );
|
677 |
wp_localize_script( 'qppr_frontend_scripts', 'qpprFrontData', array( 'linkData' => $linkData, 'siteURL' => site_url(), 'siteURLq' => $this->getQAddress() ) );
|
678 |
}
|
679 |
-
|
680 |
function register_pprsettings() {
|
681 |
register_setting( 'ppr-settings-group', 'ppr_use-custom-post-types' );
|
682 |
register_setting( 'ppr-settings-group', 'ppr_override-nofollow' );
|
@@ -705,7 +747,7 @@ class quick_page_post_reds {
|
|
705 |
$cache = '1';
|
706 |
return $cache;
|
707 |
}
|
708 |
-
|
709 |
function ppr_faq_page(){
|
710 |
include_once(ABSPATH . WPINC . '/feed.php');
|
711 |
echo '
|
@@ -717,14 +759,14 @@ class quick_page_post_reds {
|
|
717 |
$rss = fetch_feed( 'http://www.anadnet.com/?feed=qppr_faqs&ver=' . $this->ppr_curr_version . '&loc=' . urlencode( $this->homelink ) );
|
718 |
$linkfaq = array();
|
719 |
$linkcontent = array();
|
720 |
-
if (!is_wp_error( $rss ) ) :
|
721 |
-
$maxitems = $rss->get_item_quantity( 100 );
|
722 |
-
$rss_items = $rss->get_items( 0, $maxitems );
|
723 |
endif;
|
724 |
$aqr = 0;
|
725 |
if ($maxitems != 0){
|
726 |
foreach ( $rss_items as $item ) :
|
727 |
-
$aqr++;
|
728 |
$linkfaq[] = '<li class="faq-top-item"><a href="#faq-'.$aqr.'">'.esc_html( $item->get_title() ).'</a></li>';
|
729 |
$linkcontent[] = '<li class="faq-item"><a name="faq-'.$aqr.'"></a><h3 class="qa"><span class="qa">Q. </span>'.esc_html( $item->get_title() ).'</h3><div class="qa-content"><span class="qa answer">A. </span>'.$item->get_content().'</div><div class="toplink"><a href="#faq-top">top ↑</a></li>';
|
730 |
endforeach;
|
@@ -741,7 +783,7 @@ class quick_page_post_reds {
|
|
741 |
</div>
|
742 |
</div>';
|
743 |
}
|
744 |
-
|
745 |
function ppr_summary_page() {
|
746 |
?>
|
747 |
<div class="wrap">
|
@@ -756,7 +798,7 @@ class quick_page_post_reds {
|
|
756 |
<?php $this->updatemsg ='';?>
|
757 |
<h2 style="font-size:20px;"><?php echo __( 'Summary', 'quick-pagepost-redirect-plugin' );?></h2>
|
758 |
<div align="left">
|
759 |
-
<?php
|
760 |
if($this->pproverride_active =='1'){echo '<div class="ppr-acor" style="margin:1px 0;width: 250px;font-weight: bold;padding: 2px;">' . __( 'Acitve Override is on - All Redirects are OFF!', 'quick-pagepost-redirect-plugin' ) . '</div>';}
|
761 |
if($this->pproverride_nofollow =='1'){echo '<div class="ppr-nfor" style="margin:1px 0;width: 200px;font-weight: bold;padding: 2px;">' . __( 'No Follow Override is on!', 'quick-pagepost-redirect-plugin' ) . '</div>';}
|
762 |
if($this->pproverride_newwin =='1'){echo '<div class="ppr-nwor" style="margin:1px 0;width: 200px;font-weight: bold;padding: 2px;">' . __( 'New Window Override is on!', 'quick-pagepost-redirect-plugin' ) . '</div>';}
|
@@ -799,7 +841,7 @@ class quick_page_post_reds {
|
|
799 |
</tr>
|
800 |
</thead>
|
801 |
<tbody>
|
802 |
-
<?php
|
803 |
$tempReportArray = array();
|
804 |
$tempa = array();
|
805 |
$tempQTReportArray = array();
|
@@ -869,7 +911,7 @@ class quick_page_post_reds {
|
|
869 |
if($tredURL == 'http://www.example.com' || $tredURL == '<span class="ppr-rrlor">http://www.example.com</span>'){$tredURL='<strong>N/A - redirection will not occur</strong>';}
|
870 |
?>
|
871 |
<tr class="<?php echo $pclass;?>">
|
872 |
-
<?php if( $tpostid != 'N/A'){ ?>
|
873 |
<td align="left"><?php echo $labelsTD[0];?><a href="<?php echo admin_url('post.php?post='.$tpostid.'&action=edit');?>" title="edit"><?php echo $tpostid;?></a></td>
|
874 |
<?php }else{ ?>
|
875 |
<td align="left"><?php echo $labelsTD[0];?><?php echo $tpostid;?></td>
|
@@ -890,9 +932,9 @@ class quick_page_post_reds {
|
|
890 |
</table>
|
891 |
</div>
|
892 |
</div>
|
893 |
-
<?php
|
894 |
-
}
|
895 |
-
|
896 |
function ppr_import_export_page(){
|
897 |
if(isset($_GET['update'])){
|
898 |
if($_GET['update']=='4'){$this->updatemsg ='' . __( 'Quick Redirects Imported & Replaced.', 'quick-pagepost-redirect-plugin' ) . '';}
|
@@ -1132,7 +1174,7 @@ class quick_page_post_reds {
|
|
1132 |
<div class="clear-both"></div>
|
1133 |
</div>
|
1134 |
</div>
|
1135 |
-
<?php }
|
1136 |
|
1137 |
function qppr_options_help_tab(){
|
1138 |
//generate the options page in the wordpress admin
|
@@ -1140,7 +1182,7 @@ class quick_page_post_reds {
|
|
1140 |
$screen_id = $screen->id;
|
1141 |
if($screen_id == 'toplevel_page_redirect-updates' ){
|
1142 |
$content = '
|
1143 |
-
<div style="padding:10px 0;">
|
1144 |
<table border="0" cellspacing="0" cellpadding="0">
|
1145 |
<tr>
|
1146 |
<th align="left">Example Requests</th>
|
@@ -1166,16 +1208,16 @@ class quick_page_post_reds {
|
|
1166 |
|
1167 |
</div>
|
1168 |
';
|
1169 |
-
$screen->add_help_tab( array(
|
1170 |
'id' => 'qppr_sample_redirects',
|
1171 |
-
'title' => __( 'Examples', 'quick-pagepost-redirect-plugin' ),
|
1172 |
'content' => $content ,
|
1173 |
) );
|
1174 |
-
$screen->add_help_tab( array(
|
1175 |
'id' => 'qppr_add_redirects',
|
1176 |
-
'title' => __( 'Troubleshooting', 'quick-pagepost-redirect-plugin' ),
|
1177 |
'content' => '
|
1178 |
-
<div style="padding:10px 0;">
|
1179 |
<b style="color:red;">' . __( 'IMPORTANT TROUBLESHOOTING NOTES:', 'quick-pagepost-redirect-plugin' ) . '</b>
|
1180 |
<ol style="margin-top:5px;">
|
1181 |
<li style="color:#214070;margin-left:15px;list-style-type:disc;">' . __( 'At this time the New Window (NW) and No Follow (NF) features will not work for Quick Redirects unless "Use jQuery" is enabled in the options.', 'quick-pagepost-redirect-plugin' ) . '</li>
|
@@ -1194,48 +1236,48 @@ class quick_page_post_reds {
|
|
1194 |
</div>' ,
|
1195 |
) );
|
1196 |
}elseif( $screen_id == 'quick-redirects_page_redirect-import-export' ){
|
1197 |
-
$screen->add_help_tab( array(
|
1198 |
'id' => 'qppr_export_redirects',
|
1199 |
-
'title' => __( 'Export Redirects', 'quick-pagepost-redirect-plugin' ),
|
1200 |
'content' => '<div style="padding:10px 0;"><p>' . __( 'You can export redirects in two formats - Encoded or Delimited.', 'quick-pagepost-redirect-plugin' ) . '</p></div>' ,
|
1201 |
) );
|
1202 |
-
$screen->add_help_tab( array(
|
1203 |
'id' => 'qppr_import_redirects',
|
1204 |
-
'title' => __( 'Import Redirects', 'quick-pagepost-redirect-plugin' ),
|
1205 |
'content' => '<div style="padding:10px 0;"><p>Help content coming soon.</p></div>' ,
|
1206 |
) );
|
1207 |
}elseif( $screen_id == 'quick-redirects_page_meta_addon' ){
|
1208 |
-
$screen->add_help_tab( array(
|
1209 |
'id' => 'qppr-load-page-content',
|
1210 |
-
'title' => __( 'Load Content?', 'quick-pagepost-redirect-plugin' ),
|
1211 |
'content' => '<div style="padding:10px 0;"><p>' . __( 'Use the <strong>Load Content?</strong> option to allow the page content to load as normal or to only load a blank page or the content provided in the <strong>Page Content</strong> section. ', 'quick-pagepost-redirect-plugin' ) . '</p>
|
1212 |
<p>' . __( 'If checked, all of the original content will load, so keep this in mind when setting the <strong>Redirect Seconds</strong> - if set too low, the page will not compeletely load. ', 'quick-pagepost-redirect-plugin' ) . '</p></div>' ,
|
1213 |
) );
|
1214 |
-
$screen->add_help_tab( array(
|
1215 |
'id' => 'qppr-redirect-seconds',
|
1216 |
-
'title' => __( 'Redirect Seconds', 'quick-pagepost-redirect-plugin' ),
|
1217 |
'content' => '<div style="padding:10px 0;"><p>' . __( 'Enter the nuber of seconds to wait before the redirect happens. Enter 0 to have an instant redirect*.', 'quick-pagepost-redirect-plugin' ) . '</p>
|
1218 |
<p>' . __( '*Keep in mind that the redirect seconds will start counting only AFTER the <strong>Redirect Trigger</strong> element is loaded - so 0 may be slightly longer than instant, depending on how much content needs to load before the trigger happens.', 'quick-pagepost-redirect-plugin' ) . '</p></div>' ,
|
1219 |
) );
|
1220 |
-
$screen->add_help_tab( array(
|
1221 |
'id' => 'qppr-redirect-trigger',
|
1222 |
-
'title' => __( 'Redirect Trigger', 'quick-pagepost-redirect-plugin' ),
|
1223 |
'content' => '<div style="padding:10px 0;"><p>' . __( 'The class or id or tag name of the element to load before the redirect starts counting down. If nothing is used, it will default to the body tag as a trigger.', 'quick-pagepost-redirect-plugin' ) . '</p>
|
1224 |
<p>' . __( 'If you use a class, the class name should have the "." in the name, i.e., <strong>.my-class-name</strong>', 'quick-pagepost-redirect-plugin' ) . '</p>
|
1225 |
<p>' . __( 'If you use an id, the id should have the "#" in the name, i.e., <strong>#my-id-name</strong>.', 'quick-pagepost-redirect-plugin' ) . '</p>
|
1226 |
<p>' . __( 'If you use a tag name, the name should NOT have the "<" or ">" characters in the name, i.e., <body> would just be <strong>body</strong>.', 'quick-pagepost-redirect-plugin' ) . '</p>
|
1227 |
<p>' . __( 'Do not use a tag name that is common, like "a" or "div" as it will trigger on all events.', 'quick-pagepost-redirect-plugin' ) . '</p></div>' ,
|
1228 |
) );
|
1229 |
-
$screen->add_help_tab( array(
|
1230 |
'id' => 'qppr-redirect-append',
|
1231 |
-
'title' => __( 'Append Content To', 'quick-pagepost-redirect-plugin' ),
|
1232 |
'content' => '<div style="padding:10px 0;"><p>' . __( 'The class, id or tag name that you want the content in the <strong>Page Content</strong> to be loading into.', 'quick-pagepost-redirect-plugin' ) . '</p>
|
1233 |
<p>' . __( 'If you are loading the content of the page, use an existing class or id for an existing element (i.e., .page-content) so your additional page content (if any) is loaded into that element.', 'quick-pagepost-redirect-plugin' ) . '</p>
|
1234 |
<p>' . __( 'When no class, id or tag name is used, the <strong>body</strong> tag will be used.', 'quick-pagepost-redirect-plugin' ) . '</p></div>' ,
|
1235 |
) );
|
1236 |
-
$screen->add_help_tab( array(
|
1237 |
'id' => 'qppr-redirect-content',
|
1238 |
-
'title' => __( 'Page Content', 'quick-pagepost-redirect-plugin' ),
|
1239 |
'content' => '<div style="padding:10px 0;"><p>' . __( 'This is your page content you want to add. If you have a "tracking pixel" script or image tag you want to use, add it here.', 'quick-pagepost-redirect-plugin' ) . '</p>
|
1240 |
<p>' . __( 'A good example of use, is adding a tracking script (or Facebook Conversion Pixel) to the <strong>Page Content box</strong> and unchecking the <strong>Load Content?</strong> box. Then set the <strong>Redirect Seconds</strong> to 1 or 2 so the script has a chance to load and set <strong>Append Content</strong> To to "body" and <strong>Redirect Trigger</strong> to "body".', 'quick-pagepost-redirect-plugin' ) . '</p>
|
1241 |
<p>' . __( 'Additionally, you can add the redirect counter to the page by adding the code sample under the <strong>Page Content</strong> box.', 'quick-pagepost-redirect-plugin' ) . '</p></div>' ,
|
@@ -1251,7 +1293,7 @@ class quick_page_post_reds {
|
|
1251 |
<div class="updated settings-error" id="setting-error-settings_updated"><p><strong><?php echo $this->updatemsg;?></strong></p></div>
|
1252 |
<?php } ?>
|
1253 |
<?php $this->updatemsg ='';//reset message;?>
|
1254 |
-
<?php
|
1255 |
$isJQueryOn = get_option('ppr_use-jquery');
|
1256 |
$isJQueryMsgHidden = get_option('qppr_jQuery_hide_message');
|
1257 |
$isJQueryMsgHidden2 = get_option('qppr_jQuery_hide_message2');?>
|
@@ -1353,7 +1395,7 @@ class quick_page_post_reds {
|
|
1353 |
<table id="qppr-temp-table-holder"><tr><td></td></tr></table>
|
1354 |
</div>
|
1355 |
<?php
|
1356 |
-
}
|
1357 |
|
1358 |
function expand_redirects(){
|
1359 |
//utility function to return the current list of redirects as form fields
|
@@ -1372,7 +1414,7 @@ class quick_page_post_reds {
|
|
1372 |
$newCheckedAjax = 'X';
|
1373 |
}
|
1374 |
if($noFollow == 1){
|
1375 |
-
$noChecked = ' checked="checked"';
|
1376 |
$noCheckedAjax = 'X';
|
1377 |
}
|
1378 |
$output .= '
|
@@ -1398,12 +1440,12 @@ class quick_page_post_reds {
|
|
1398 |
}
|
1399 |
return $output;
|
1400 |
}
|
1401 |
-
|
1402 |
function ppr_filter_links ($link = '', $post = array()) {
|
1403 |
global $qppr_setting_links;
|
1404 |
if( $qppr_setting_links)
|
1405 |
return $link;
|
1406 |
-
if(isset($post->ID)){
|
1407 |
$id = $post->ID;
|
1408 |
}else{
|
1409 |
$id = $post;
|
@@ -1426,7 +1468,7 @@ class quick_page_post_reds {
|
|
1426 |
}
|
1427 |
return $link;
|
1428 |
}
|
1429 |
-
|
1430 |
function ppr_filter_page_links ($link, $post) {
|
1431 |
global $qppr_setting_links;
|
1432 |
if( $qppr_setting_links)
|
@@ -1453,10 +1495,10 @@ class quick_page_post_reds {
|
|
1453 |
}
|
1454 |
return $link;
|
1455 |
}
|
1456 |
-
|
1457 |
function get_main_array(){
|
1458 |
global $wpdb;
|
1459 |
-
$this->pprptypes_ok = get_option( 'ppr_qpprptypeok', array() );
|
1460 |
if( is_array( $this->ppr_all_redir_array ) && ! empty( $this->ppr_all_redir_array ) )
|
1461 |
return $this->ppr_all_redir_array;
|
1462 |
$theArray = array();
|
@@ -1489,17 +1531,17 @@ class quick_page_post_reds {
|
|
1489 |
$this->ppr_nofollow = $theArrayNF;
|
1490 |
return $theArray;
|
1491 |
}
|
1492 |
-
|
1493 |
function get_value($theval='none'){
|
1494 |
return isset($this->$theval) ? $this->$theval : 0;
|
1495 |
}
|
1496 |
-
|
1497 |
function ppr_queryhook($vars) {
|
1498 |
$vars[] = 'qppr-file-type';
|
1499 |
return $vars;
|
1500 |
}
|
1501 |
-
|
1502 |
-
function ppr_parse_request_new($wp) {
|
1503 |
global $wp, $wpdb;
|
1504 |
$this->ppr_all_redir_array = $this->get_main_array();
|
1505 |
$this->pprptypes_ok = get_option( 'ppr_qpprptypeok', array() );
|
@@ -1508,11 +1550,11 @@ class quick_page_post_reds {
|
|
1508 |
$newQPPR_Array = array();
|
1509 |
check_admin_referer( 'export-redirects-qppr' );
|
1510 |
$type = isset( $_GET['qppr-file-type'] ) && sanitize_text_field( $_GET['qppr-file-type'] ) == 'encoded' ? 'encoded' : 'pipe' ; // can be 'encoded' or 'pipe';
|
1511 |
-
header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' );
|
1512 |
-
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
|
1513 |
-
header( 'Cache-Control: no-store, no-cache, must-revalidate' );
|
1514 |
-
header( 'Cache-Control: post-check=0, pre-check=0', false );
|
1515 |
-
header( 'Pragma: no-cache' );
|
1516 |
header( "Content-Type: application/force-download" );
|
1517 |
header( "Content-Type: application/octet-stream" );
|
1518 |
header( "Content-Type: application/download" );
|
@@ -1537,7 +1579,7 @@ class quick_page_post_reds {
|
|
1537 |
}else{
|
1538 |
$newfile = $newtext;
|
1539 |
}
|
1540 |
-
die( $newfile );
|
1541 |
}
|
1542 |
exit;
|
1543 |
} elseif( isset( $_POST['import-quick-redrects-file'] ) && isset( $_FILES['qppr_file'] ) ) {
|
@@ -1558,7 +1600,7 @@ class quick_page_post_reds {
|
|
1558 |
$delim = false;
|
1559 |
}
|
1560 |
if($delim != false){
|
1561 |
-
$config_file = str_replace("\r\n", "\n", $config_file);
|
1562 |
$config_file = str_replace("\r", "\n", $config_file);
|
1563 |
$text = explode( "\n", $config_file );
|
1564 |
$newfile1 = array();
|
@@ -1628,14 +1670,14 @@ class quick_page_post_reds {
|
|
1628 |
} else {
|
1629 |
$tempArr = array();
|
1630 |
$tempMArr = array();
|
1631 |
-
$config_file = str_replace("\r\n", "\n", $config_file);
|
1632 |
$config_file = str_replace("\r", "\n", $config_file);
|
1633 |
$QR_Array = explode( "\n", $config_file );
|
1634 |
$newfile1 = array();
|
1635 |
if( !empty( $QR_Array ) && is_array( $QR_Array )):
|
1636 |
foreach( $QR_Array as $qrtoadd ):
|
1637 |
if( $qrtoadd != '' && $delim != false && strpos( $qrtoadd, $delim ) !== false ){
|
1638 |
-
$elem = explode( $delim, str_replace( array( "\r", "\n" ), array( '', '' ), $qrtoadd ) );
|
1639 |
if( isset( $elem[0] ) && isset( $elem[1] ) ){
|
1640 |
$newfile1['quickppr_redirects'][esc_url($elem[0])] = esc_url($elem[1]);
|
1641 |
$nw = isset($elem[2]) && $elem[2] == '1' ? '1' : '0';
|
@@ -1644,7 +1686,7 @@ class quick_page_post_reds {
|
|
1644 |
$newfile1['quickppr_redirects_meta'][$elem[0]]['nofollow'] = $nf;
|
1645 |
}
|
1646 |
}
|
1647 |
-
endforeach;
|
1648 |
if(is_array($newfile1) && !empty( $newfile1 )){
|
1649 |
if( isset( $newfile1['quickppr_redirects'] ) ){
|
1650 |
$currQRs = get_option( 'quickppr_redirects', array() );
|
@@ -1669,7 +1711,7 @@ class quick_page_post_reds {
|
|
1669 |
} return;
|
1670 |
} return;
|
1671 |
}
|
1672 |
-
|
1673 |
function qppr_pprhidemessage_ajax(){
|
1674 |
check_ajax_referer( 'qppr_ajax_verify', 'scid', true );
|
1675 |
$msg = isset($_POST['pprhidemessage']) ? (int)$_POST['pprhidemessage'] : 0;
|
@@ -1680,7 +1722,7 @@ class quick_page_post_reds {
|
|
1680 |
update_option('qppr_jQuery_hide_message2','1');
|
1681 |
echo '1';
|
1682 |
}else{
|
1683 |
-
echo '0';
|
1684 |
}
|
1685 |
exit;
|
1686 |
}
|
@@ -1688,7 +1730,7 @@ class quick_page_post_reds {
|
|
1688 |
function ppr_init_check_version() {
|
1689 |
// checks version of plugin in DB and updates if needed.
|
1690 |
global $wpdb;
|
1691 |
-
//$this->pprptypes_ok = get_option( 'ppr_qpprptypeok', array() );
|
1692 |
if( is_array( $this->ppr_all_redir_array ) && ! empty( $this->ppr_all_redir_array ) )
|
1693 |
$this->ppr_all_redir_array = $this->get_main_array();
|
1694 |
|
@@ -1697,7 +1739,7 @@ class quick_page_post_reds {
|
|
1697 |
$metaMsgNew = get_option( 'qppr_meta_addon_content', 'not-set' );
|
1698 |
if( $metaMsgNew == 'not-set' && $metaMsg != 'not-set' ){
|
1699 |
update_option( 'qppr_meta_addon_content', $metaMsg );
|
1700 |
-
$this->pprmeta_message = $metaMsg;
|
1701 |
}
|
1702 |
$metaSec = get_option( 'ppr_meta-seconds', 'not-set' );
|
1703 |
$metaSecNew = get_option( 'qppr_meta_addon_sec', 'not-set');
|
@@ -1718,7 +1760,7 @@ class quick_page_post_reds {
|
|
1718 |
}elseif( version_compare( $this->thepprversion, $this->ppr_curr_version, '<' ) ){
|
1719 |
update_option( 'ppr_version', $this->ppr_curr_version );
|
1720 |
}
|
1721 |
-
|
1722 |
if( $this->thepprmeta != '1' && version_compare( $this->ppr_curr_version, '5.0.7', '<' )){
|
1723 |
update_option( 'ppr_meta_clean', '1' );
|
1724 |
$wpdb->query("UPDATE $wpdb->postmeta SET `meta_key` = CONCAT('_',`meta_key`) WHERE `meta_key` = 'pprredirect_active' OR `meta_key` = 'pprredirect_rewritelink' OR `meta_key` = 'pprredirect_newwindow' OR `meta_key` = 'pprredirect_relnofollow' OR `meta_key` = 'pprredirect_type' OR `meta_key` = 'pprredirect_url';");
|
@@ -1729,7 +1771,7 @@ class quick_page_post_reds {
|
|
1729 |
$links[] = '<a href="'.$this->adminlink.'admin.php?page=redirect-options"><span class="dashicons dashicons-admin-settings"></span> ' . __( 'Settings', 'quick-pagepost-redirect-plugin' ) . '</a>';
|
1730 |
return $links;
|
1731 |
}
|
1732 |
-
|
1733 |
function ppr_filter_plugin_links($links, $file){
|
1734 |
if ( $file == plugin_basename(__FILE__) ){
|
1735 |
$links[] = '<a href="'.$this->adminlink.'admin.php?page=redirect-updates"><span class="dashicons dashicons-external"></span> ' . __( 'Quick Redirects', 'quick-pagepost-redirect-plugin' ) . '</a>';
|
@@ -1738,9 +1780,9 @@ class quick_page_post_reds {
|
|
1738 |
}
|
1739 |
return $links;
|
1740 |
}
|
1741 |
-
|
1742 |
function edit_box_ppr_1() {
|
1743 |
-
// Prints the inner fields for the custom post/page section
|
1744 |
global $post;
|
1745 |
$ppr_option1='';
|
1746 |
$ppr_option2='';
|
@@ -1760,7 +1802,7 @@ class quick_page_post_reds {
|
|
1760 |
echo '<label for="pprredirect_url"><b>' . __( 'Redirect / Destination URL:', 'quick-pagepost-redirect-plugin' ) . '</b></label><br />';
|
1761 |
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 dashicons dashicons-editor-help"></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.)', 'quick-pagepost-redirect-plugin' ) . '</span></span><br /><br />';
|
1762 |
echo '<label for="pprredirect_type"><b>' . __( 'Type of Redirect:', 'quick-pagepost-redirect-plugin' ) . '</b></label><br />';
|
1763 |
-
|
1764 |
switch($pprredirecttype):
|
1765 |
case "":
|
1766 |
$ppr_option1=" selected"; //default is 301 (as of 5.1.1)
|
@@ -1778,7 +1820,7 @@ class quick_page_post_reds {
|
|
1778 |
$ppr_option5=" selected";
|
1779 |
break;
|
1780 |
endswitch;
|
1781 |
-
|
1782 |
echo '
|
1783 |
<select style="margin-top:2px;margin-bottom:2px;width:40%;" name="pprredirect_type" id="pprredirect_type">
|
1784 |
<option value="301" '.$ppr_option1.'>301 ' . __( 'Permanent', 'quick-pagepost-redirect-plugin' ) . '</option>
|
@@ -1790,13 +1832,13 @@ class quick_page_post_reds {
|
|
1790 |
$metasel = ' meta-not-selected';
|
1791 |
if( $ppr_option5 == ' selected' )
|
1792 |
$metasel = ' meta-selected';
|
1793 |
-
|
1794 |
echo '<div class="qppr-meta-section-wrapper'.$metasel.'">';
|
1795 |
echo ' <label for="pprredirect_meta_secs" style="padding:2px 0;"><strong>' . __( 'Redirect Seconds (ONLY for meta redirects).', 'quick-pagepost-redirect-plugin' ) . '</strong></label><br /><input type="text" name="pprredirect_meta_secs" id="pprredirect_meta_secs" value="'. (get_post_meta($post->ID,'_pprredirect_meta_secs',true) != '' ? get_post_meta($post->ID,'_pprredirect_meta_secs',true ): '' ).'" size="3"><span class="qppr_meta_help_wrap"><span class="qppr_meta_help_icon dashicons dashicons-editor-help"></span><span class="qppr_meta_help">' . __( 'Leave blank to use options setting. 0 = instant.', 'quick-pagepost-redirect-plugin' ) . ' </span></span><br /><br />';
|
1796 |
echo '</div>';
|
1797 |
echo __( '<strong>NOTE:</strong> 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', 'quick-pagepost-redirect-plugin' ) . ' <a href="./admin.php?page=redirect-updates">' . __( 'Quick Redirects', 'quick-pagepost-redirect-plugin' ) . '</a> ' . __( 'method.', 'quick-pagepost-redirect-plugin' );
|
1798 |
}
|
1799 |
-
|
1800 |
function isOne_none($val=''){ //true (1) or false =''
|
1801 |
if($val == '_blank'){
|
1802 |
return $val;
|
@@ -1805,7 +1847,7 @@ class quick_page_post_reds {
|
|
1805 |
}
|
1806 |
return '';
|
1807 |
}
|
1808 |
-
|
1809 |
function ppr_save_metadata($post_id, $post) {
|
1810 |
if($post->post_type == 'revision' || ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) )
|
1811 |
return;
|
@@ -1817,10 +1859,10 @@ class quick_page_post_reds {
|
|
1817 |
// check allowed to editing
|
1818 |
if ( !current_user_can('edit_posts', $post_id))
|
1819 |
return $post_id;
|
1820 |
-
|
1821 |
if(!empty($my_meta_data))
|
1822 |
unset($my_meta_data);
|
1823 |
-
|
1824 |
$my_meta_data = array();
|
1825 |
if( isset( $_POST['pprredirect_active'] ) || isset( $_POST['pprredirect_url'] ) || isset( $_POST['pprredirect_type'] ) || isset( $_POST['pprredirect_newwindow'] ) || isset($_POST['pprredirect_relnofollow']) || isset($_POST['pprredirect_meta_secs'])):
|
1826 |
$protocols = apply_filters( 'qppr_allowed_protocols', array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn', 'tel', 'fax', 'xmpp'));
|
@@ -1830,8 +1872,8 @@ class quick_page_post_reds {
|
|
1830 |
$my_meta_data['_pprredirect_relnofollow'] = isset($_REQUEST['pprredirect_relnofollow']) ? sanitize_meta( '_pprredirect_relnofollow', $this->isOne_none(intval( $_REQUEST['pprredirect_relnofollow'])), 'post' ) : '';
|
1831 |
$my_meta_data['_pprredirect_type'] = isset($_REQUEST['pprredirect_type']) ? sanitize_meta( '_pprredirect_type', sanitize_text_field( $_REQUEST['pprredirect_type'] ), 'post' ) : '';
|
1832 |
$my_meta_data['_pprredirect_rewritelink'] = isset($_REQUEST['pprredirect_rewritelink']) ? sanitize_meta( '_pprredirect_rewritelink', $this->isOne_none(intval( $_REQUEST['pprredirect_rewritelink'])), 'post' ) : '';
|
1833 |
-
$my_meta_data['_pprredirect_url'] = isset($_REQUEST['pprredirect_url']) ? esc_url_raw( $_REQUEST['pprredirect_url'], $protocols ) : '';
|
1834 |
-
$my_meta_data['_pprredirect_meta_secs'] = isset($_REQUEST['pprredirect_meta_secs']) && $_REQUEST['pprredirect_meta_secs'] != '' ? (int) $_REQUEST['pprredirect_meta_secs'] : '';
|
1835 |
|
1836 |
$info = $this->appip_parseURI($my_meta_data['_pprredirect_url']);
|
1837 |
//$my_meta_data['_pprredirect_url'] = esc_url_raw($info['url']);
|
@@ -1845,17 +1887,17 @@ class quick_page_post_reds {
|
|
1845 |
$my_meta_data['_pprredirect_newwindow'] = NULL; //turn it off if no URL is set
|
1846 |
$my_meta_data['_pprredirect_relnofollow'] = NULL; //turn it off if no URL is set
|
1847 |
}
|
1848 |
-
|
1849 |
// Add values of $my_meta_data as custom fields
|
1850 |
if(count($my_meta_data)>0){
|
1851 |
-
foreach ($my_meta_data as $key => $value) {
|
1852 |
$value = implode(',', (array)$value);
|
1853 |
-
if($value == '' || $value == NULL || $value == ','){
|
1854 |
-
delete_post_meta($post->ID, $key);
|
1855 |
}else{
|
1856 |
if(get_post_meta($post->ID, $key, true) != '') {
|
1857 |
update_post_meta($post->ID, $key, $value);
|
1858 |
-
} else {
|
1859 |
add_post_meta($post->ID, $key, $value);
|
1860 |
}
|
1861 |
}
|
@@ -1864,7 +1906,7 @@ class quick_page_post_reds {
|
|
1864 |
$this->qppr_try_to_clear_cache_plugins();
|
1865 |
endif;
|
1866 |
}
|
1867 |
-
|
1868 |
function appip_parseURI($url){
|
1869 |
/*
|
1870 |
[scheme]
|
@@ -1877,21 +1919,21 @@ class quick_page_post_reds {
|
|
1877 |
*/
|
1878 |
$strip_protocol = 0;
|
1879 |
$tostrip = '';
|
1880 |
-
if(substr($url,0,2) == 'p=' || substr($url,0,8) == 'page_id='){
|
1881 |
// page or post id
|
1882 |
$url = network_site_url().'/?'.$url;
|
1883 |
-
}elseif(is_numeric($url)){
|
1884 |
// page or post id
|
1885 |
$url = network_site_url().'/?'.$url;
|
1886 |
-
}elseif($url == "/" ){
|
1887 |
// root
|
1888 |
$url = network_site_url().'/';
|
1889 |
-
}elseif(substr($url,0,1) == '/' ){
|
1890 |
// relative to root
|
1891 |
$url = network_site_url().$url;
|
1892 |
$strip_protocol = 1;
|
1893 |
-
$tostrip = network_site_url();
|
1894 |
-
}elseif(substr($url,0,7) != 'http://' && substr($url,0,8) != 'https://' ){
|
1895 |
//no protocol so add it
|
1896 |
//NOTE: desided not to add it automatically - too iffy.
|
1897 |
}
|
@@ -1903,12 +1945,12 @@ class quick_page_post_reds {
|
|
1903 |
}
|
1904 |
return $info;
|
1905 |
}
|
1906 |
-
|
1907 |
function ppr_fix_targetsandrels($pages) {
|
1908 |
$ppr_url = array();
|
1909 |
$ppr_newindow = array();
|
1910 |
$ppr_nofollow = array();
|
1911 |
-
|
1912 |
if (empty($ppr_url) && empty($ppr_newindow) && empty($ppr_nofollow)){
|
1913 |
$thefirstppr = array();
|
1914 |
if(!empty($this->ppr_all_redir_array)){
|
@@ -1922,7 +1964,7 @@ class quick_page_post_reds {
|
|
1922 |
}
|
1923 |
if(!empty($thefirstppr)){
|
1924 |
foreach($thefirstppr as $ppitems){
|
1925 |
-
if($ppitems['_pprredirect_active'] == 1 && $this->pproverride_newwin =='1'){
|
1926 |
// check override of NEW WINDOW
|
1927 |
$ppr_newindow[] = $ppitems['post_id'];
|
1928 |
}else{
|
@@ -1930,8 +1972,8 @@ class quick_page_post_reds {
|
|
1930 |
$ppr_newindow[] = $ppitems['post_id'];
|
1931 |
}
|
1932 |
}
|
1933 |
-
|
1934 |
-
if($ppitems['_pprredirect_active']==1 && $this->pproverride_nofollow =='1'){
|
1935 |
//check override of NO FOLLOW
|
1936 |
$ppr_nofollow[] = $ppitems['post_id'];
|
1937 |
}else{
|
@@ -1939,8 +1981,8 @@ class quick_page_post_reds {
|
|
1939 |
$ppr_nofollow[] = $ppitems['post_id'];
|
1940 |
}
|
1941 |
}
|
1942 |
-
|
1943 |
-
if($ppitems['_pprredirect_active']==1 && $this->pproverride_rewrite =='1'){
|
1944 |
//check override of REWRITE
|
1945 |
if($this->pproverride_URL!=''){
|
1946 |
$ppr_url_rewrite[] = $ppitems['post_id'];
|
@@ -1961,7 +2003,7 @@ class quick_page_post_reds {
|
|
1961 |
return $pages;
|
1962 |
}
|
1963 |
}
|
1964 |
-
|
1965 |
//$this_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
1966 |
if(count($ppr_nofollow)>=1) {
|
1967 |
foreach($ppr_nofollow as $relid){
|
@@ -1974,7 +2016,7 @@ class quick_page_post_reds {
|
|
1974 |
}
|
1975 |
}
|
1976 |
}
|
1977 |
-
|
1978 |
if(count($ppr_newindow)>=1) {
|
1979 |
foreach($ppr_newindow as $p){
|
1980 |
$validexp="@\<li(?:.*?)".$p."(?:.*?)\>\<a(?:.*?)target\=(?:.*?)\>@i";
|
@@ -1988,12 +2030,12 @@ class quick_page_post_reds {
|
|
1988 |
}
|
1989 |
return $pages;
|
1990 |
}
|
1991 |
-
|
1992 |
function redirect_post_type(){
|
1993 |
return;
|
1994 |
//not needed at this time
|
1995 |
}
|
1996 |
-
|
1997 |
function getAddress($home = ''){
|
1998 |
// utility function to get the full address of the current request - credit: http://www.phpro.org/examples/Get-Full-URL.html
|
1999 |
if( !isset( $_SERVER['HTTPS'] ) ){
|
@@ -2002,15 +2044,15 @@ class quick_page_post_reds {
|
|
2002 |
$protocol = $_SERVER['HTTPS'] !== '' && strpos( $home, 'http:' ) === false ? 'https' : 'http'; //check for https
|
2003 |
return $protocol.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; //return the full address
|
2004 |
}
|
2005 |
-
|
2006 |
function getQAddress($home = ''){
|
2007 |
// utility function to get the protocol and host of the current request
|
2008 |
if( !isset( $_SERVER['HTTPS'] ) )
|
2009 |
$_SERVER['HTTPS'] = '';
|
2010 |
$protocol = $_SERVER['HTTPS'] !== '' && strpos( $home, 'http:' ) === false ? 'https' : 'http'; //check for https
|
2011 |
-
return $protocol.'://'.$_SERVER['HTTP_HOST'];
|
2012 |
}
|
2013 |
-
|
2014 |
function ppr_new_nav_menu_fix($ppr){
|
2015 |
$newmenu = array();
|
2016 |
if(!empty($ppr)){
|
@@ -2040,7 +2082,7 @@ class quick_page_post_reds {
|
|
2040 |
}
|
2041 |
return $newmenu;
|
2042 |
}
|
2043 |
-
|
2044 |
function redirect(){
|
2045 |
//bypass for testing.
|
2046 |
if(isset($_GET['action']) && $_GET['action'] == 'no-redirect' )
|
@@ -2051,7 +2093,7 @@ class quick_page_post_reds {
|
|
2051 |
$homeURL = get_option( 'home' );
|
2052 |
$getAddress = $this->getAddress( $homeURL ); // gets just the protocol and full URL of request. for cases when the setting for Site URL has a subfolder but a request may not.
|
2053 |
$getQAddress = $this->getQAddress( $homeURL ); // gets just the protocol and domain (host) of the request.
|
2054 |
-
|
2055 |
//get the query string if there is one so that it can be preserved
|
2056 |
// patch submitted for version 5.0.7 by Romulo De Lazzari <romulodelazzari@gmail.com> - THANKS!
|
2057 |
$finalQS = (filter_input(INPUT_SERVER, 'QUERY_STRING'));
|
@@ -2062,7 +2104,7 @@ class quick_page_post_reds {
|
|
2062 |
}
|
2063 |
$userrequest = str_replace( $homeURL, '', $getAddress );
|
2064 |
$userrequest = preg_replace('/\?.*/', '', $userrequest);
|
2065 |
-
// end patch
|
2066 |
//end QS preservation
|
2067 |
|
2068 |
$needle = $this->pproverride_casesensitive ? $userrequest : strtolower($userrequest);
|
@@ -2073,17 +2115,17 @@ class quick_page_post_reds {
|
|
2073 |
$finalQS = $this->pproverride_casesensitive ? $finalQS : strtolower( $finalQS ); //added 5.1.4 to fix URL needle being converted to lower, but not Query (as it never matches unless user enters lower)
|
2074 |
$finalQS = apply_filters( 'appip_filter_testing_finalQS', $finalQS, $needle, $haystack); // added 5.1.4 to allow filtering of QS data prior to matching.
|
2075 |
$index = false;
|
2076 |
-
|
2077 |
/* These are the URL matching checks to see if the request should be redirected.
|
2078 |
-
* They trickle down to the less likely scenarios last - tries to recover a redirect if the
|
2079 |
* user just forgot things like ending slash or used wrong protocol, etc.
|
2080 |
*/
|
2081 |
|
2082 |
-
if( array_key_exists( ($needle . $finalQS), $haystack ) ){
|
2083 |
//check if QS data might be part of the redirect URL and not supposed to be added back.
|
2084 |
$index = $needle . $finalQS;
|
2085 |
$finalQS = ''; //remove it
|
2086 |
-
}elseif( array_key_exists( urldecode($needle . $finalQS), $haystack ) ){
|
2087 |
//check if QS data might be part of the encoded redirect URL and not supposed to be added back.
|
2088 |
$index = $needle . $finalQS;
|
2089 |
$finalQS = ''; //remove it
|
@@ -2120,27 +2162,27 @@ class quick_page_post_reds {
|
|
2120 |
$index = $needle . '/';
|
2121 |
}
|
2122 |
$index = apply_filters('qppr_filter_quickredirect_index', $index, $finalQS);
|
2123 |
-
|
2124 |
if($index != false && $index != ''){
|
2125 |
// Finally, if we have a matched request URL, get ready to redirect.
|
2126 |
-
$val = isset($haystack[$index]) ? $haystack[$index] : false;
|
2127 |
if($val) {
|
2128 |
// if global setting to make all redirects go to a specific URL is set, that takes priority.
|
2129 |
$useURL = $this->pproverride_URL != '' ? $this->pproverride_URL : $val;
|
2130 |
$useURL .= apply_filters( 'qppr_filter_quickredirect_append_QS_data', $finalQS ); //add QS back or use filter to set to blank.
|
2131 |
$useURL = apply_filters( 'qppr_filter_quickredirect_url', $useURL, $index ); // final URL filter
|
2132 |
-
|
2133 |
$qpprRedType = apply_filters( 'qppr_filter_quickredirect_type', 301 ) ; // filter for redirect type (301 is default here).
|
2134 |
$qpprMetaSec = apply_filters( 'qppr_filter_quickredirect_secs', $this->pprmeta_seconds ) ; // filter for redirect seconds if type is changed to meta).
|
2135 |
if( strpos( $useURL, '/' ) !== false && strpos( $useURL, '/' ) === 0 ){
|
2136 |
-
// $addback refers to adding back the site home link back to the front of the request URL that is relative to the root.
|
2137 |
// by default it will, but this can be filtered to never add it back (or based on URL).
|
2138 |
$addback = (bool) apply_filters( 'qppr_filter_quickredirect_add_home_link_to_destination_url', true, $useURL);
|
2139 |
$useURL = $addback ? $homeURL . $useURL : $useURL;
|
2140 |
}
|
2141 |
// action to allow take over.
|
2142 |
do_action( 'qppr_redirect', $useURL, $qpprRedType );
|
2143 |
-
|
2144 |
if( $useURL != '' ){
|
2145 |
// and now the redirect (meta or type set).
|
2146 |
if( $qpprRedType == 'meta' ){
|
@@ -2152,18 +2194,18 @@ class quick_page_post_reds {
|
|
2152 |
exit();
|
2153 |
}
|
2154 |
}
|
2155 |
-
}
|
2156 |
}
|
2157 |
}
|
2158 |
}
|
2159 |
-
|
2160 |
function ppr_do_redirect( $var1='var1', $var2 = 'var2'){
|
2161 |
//bypass for testing.
|
2162 |
if(isset($_GET['action']) && $_GET['action'] == 'no-redirect' )
|
2163 |
return;
|
2164 |
// Individual Redirects Redirect.
|
2165 |
// Read the list of redirects and if the current page is found in the list, send the visitor on her way
|
2166 |
-
|
2167 |
global $post;
|
2168 |
if ( count( $this->ppr_all_redir_array ) > 0 && ( is_single() || is_singular() || is_page() ) ) {
|
2169 |
if( isset( $this->ppr_all_redir_array[$post->ID] ) ){
|
@@ -2180,13 +2222,13 @@ class quick_page_post_reds {
|
|
2180 |
$urlsite = 'http://'.$redrurl;
|
2181 |
}elseif(is_numeric($redrurl)){ // page/post number
|
2182 |
$urlsite = $this->homelink.'/?p='.$redrurl;
|
2183 |
-
}elseif(strpos($redrurl,'/') === 0){ // relative to root
|
2184 |
$urlsite = $this->homelink.$redrurl;
|
2185 |
}else{ // we assume they are using the permalink / page name??
|
2186 |
$urlsite=$this->homelink.'/'.$redrurl;
|
2187 |
}
|
2188 |
// check if override is set for all redirects to go to one URL
|
2189 |
-
if($this->pproverride_URL !=''){$urlsite=$this->pproverride_URL;}
|
2190 |
if($this->pproverride_type!='0' && $this->pproverride_type!=''){$redrtype = $this->pproverride_type;} //override check
|
2191 |
if($redrtype == 'meta'){
|
2192 |
$this->ppr_metaurl = $redrurl;
|
@@ -2247,7 +2289,7 @@ class quick_page_post_reds {
|
|
2247 |
$pcontent = '';
|
2248 |
$appMsgTo = 'body';
|
2249 |
if( is_object( $post ) && !empty( $post )){
|
2250 |
-
$psecs = get_post_meta($post->ID, '_pprredirect_meta_secs', true);
|
2251 |
$ptrigger = get_post_meta($post->ID, 'qppr_meta_trigger', true) != '' ? get_post_meta($post->ID, 'qppr_meta_trigger', true) : '';
|
2252 |
$pload = (bool) get_post_meta($post->ID, 'qppr_meta_load', true) === true ? '1' : '';
|
2253 |
$pcontent = get_post_meta($post->ID, 'qppr_meta_content', true) != '' ? get_post_meta($post->ID, 'qppr_meta_content', true) : '';
|
@@ -2331,16 +2373,16 @@ class quick_page_post_reds {
|
|
2331 |
</table>
|
2332 |
<p class="submit"><input type="submit" class="button-primary" value="<?php echo __( 'Save Changes', 'quick-pagepost-redirect-plugin' );?>" /></p>
|
2333 |
</form>
|
2334 |
-
</div>
|
2335 |
<?php
|
2336 |
}
|
2337 |
-
|
2338 |
function qppr_meta_plugin_has_addon() {
|
2339 |
if ( ( defined('DOING_AJAX') && DOING_AJAX ) || ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) )
|
2340 |
return;
|
2341 |
if ( is_admin() && is_plugin_active( 'qppr-meta-redirect-add-on/qppr-meta-redirect-add-on.php' ) ) {
|
2342 |
add_action( 'admin_notices', array( $this, 'qppr_meta_addon_admin_notice' ) );
|
2343 |
-
deactivate_plugins( 'qppr-meta-redirect-add-on/qppr-meta-redirect-add-on.php' );
|
2344 |
}
|
2345 |
}
|
2346 |
|
@@ -2370,13 +2412,13 @@ function start_ppr_class(){
|
|
2370 |
* newwindow int 1 or 0
|
2371 |
* nofollow int 1 or 0
|
2372 |
* rewrite int 1 or 0
|
2373 |
-
* @return bool true on success
|
2374 |
* @example:
|
2375 |
* *****************
|
2376 |
$atts = array(
|
2377 |
'post_id' => $post->ID,
|
2378 |
'url' => 'http://example.com/',
|
2379 |
-
'active' => 0,
|
2380 |
'type' => '301',
|
2381 |
'newwindow' => 1,
|
2382 |
'nofollow' => 0,
|
@@ -2388,9 +2430,9 @@ function start_ppr_class(){
|
|
2388 |
function qppr_create_individual_redirect( $atts = array() ){
|
2389 |
if( !is_array( $atts ) )
|
2390 |
return false;
|
2391 |
-
$defaults = array(
|
2392 |
-
'post_id' => '0',
|
2393 |
-
'active' => 1,
|
2394 |
'url' => '',
|
2395 |
'type' => '301',
|
2396 |
'newwindow' => 0,
|
@@ -2406,7 +2448,7 @@ function qppr_create_individual_redirect( $atts = array() ){
|
|
2406 |
$newwindow = (int) $newwindow == 1 ? 1 : 0;
|
2407 |
$nofollow = (int) $nofollow == 1 ? 1 : 0;
|
2408 |
$rewrite = (int) $rewrite == 1 ? 1 : 0;
|
2409 |
-
// set required meta
|
2410 |
add_post_meta( $post_id, '_pprredirect_url', $url );
|
2411 |
add_post_meta( $post_id, '_pprredirect_type', $type );
|
2412 |
add_post_meta( $post_id, '_pprredirect_active', $active );
|
@@ -2416,13 +2458,13 @@ function qppr_create_individual_redirect( $atts = array() ){
|
|
2416 |
if( $newwindow == 1 )
|
2417 |
add_post_meta( $post_id, '_pprredirect_newwindow', '_blank' );
|
2418 |
if( $nofollow == 1 )
|
2419 |
-
add_post_meta( $post_id, '_pprredirect_relnofollow', 1 );
|
2420 |
return true;
|
2421 |
}
|
2422 |
/**
|
2423 |
* qppr_delete_individual_redirect - helper function to delete Individual Redirect programatically.
|
2424 |
* @param post_id int|string the post id
|
2425 |
-
* @return bool true on success
|
2426 |
* @example:
|
2427 |
* *****************
|
2428 |
qppr_delete_individual_redirect( $post_id );
|
@@ -2437,15 +2479,15 @@ function qppr_delete_individual_redirect( $post_id = 0){
|
|
2437 |
$ok = current_user_can( 'edit_pages' );
|
2438 |
else
|
2439 |
$ok = current_user_can( 'edit_posts' );
|
2440 |
-
|
2441 |
-
if( $ok ){
|
2442 |
// delete meta fields
|
2443 |
delete_post_meta( $post_id, '_pprredirect_url' );
|
2444 |
delete_post_meta( $post_id, '_pprredirect_type');
|
2445 |
delete_post_meta( $post_id, '_pprredirect_active' );
|
2446 |
delete_post_meta( $post_id, '_pprredirect_rewritelink' );
|
2447 |
delete_post_meta( $post_id, '_pprredirect_newwindow' );
|
2448 |
-
delete_post_meta( $post_id, '_pprredirect_relnofollow' );
|
2449 |
return true;
|
2450 |
}else{
|
2451 |
return false;
|
@@ -2459,7 +2501,7 @@ function qppr_delete_individual_redirect( $post_id = 0){
|
|
2459 |
* destination_url string redirect URL
|
2460 |
* newwindow int 1 or 0
|
2461 |
* nofollow int 1 or 0
|
2462 |
-
* @return bool true on success
|
2463 |
* @example:
|
2464 |
* *****************
|
2465 |
$atts = array(
|
@@ -2474,7 +2516,7 @@ function qppr_delete_individual_redirect( $post_id = 0){
|
|
2474 |
function qppr_create_quick_redirect( $atts = array() ){
|
2475 |
if( !is_array( $atts ) )
|
2476 |
return false;
|
2477 |
-
$defaults = array(
|
2478 |
'request_url' => '',
|
2479 |
'destination_url' => '',
|
2480 |
'newwindow' => 0,
|
@@ -2483,7 +2525,7 @@ function qppr_create_quick_redirect( $atts = array() ){
|
|
2483 |
extract( shortcode_atts($defaults, $atts) );
|
2484 |
if( $request_url == '' || $destination_url == '' )
|
2485 |
return false;
|
2486 |
-
|
2487 |
global $newqppr, $redirect_plugin;
|
2488 |
$currRedirects = get_option( 'quickppr_redirects', array() );
|
2489 |
$currMeta = get_option( 'quickppr_redirects_meta', array() );
|
@@ -2514,7 +2556,7 @@ function qppr_create_quick_redirect( $atts = array() ){
|
|
2514 |
/**
|
2515 |
* qppr_delete_quick_redirect - helper function to delete Quick Redirect programatically.
|
2516 |
* @param request_url string redirect URL
|
2517 |
-
* @return bool true on success
|
2518 |
* @example:
|
2519 |
* *****************
|
2520 |
qppr_delete_quick_redirect( '/some-url/' );
|
@@ -2530,7 +2572,7 @@ function qppr_delete_quick_redirect( $request_url = '' ){
|
|
2530 |
$request_url = esc_url( str_replace( ' ', '%20', trim( $request_url ) ), null, 'appip' );
|
2531 |
if( !isset( $currRedirects[$request_url] ) )
|
2532 |
return false;
|
2533 |
-
if( !isset( $currMeta[$request_url] ) )
|
2534 |
return false;
|
2535 |
unset( $currRedirects[$request_url], $currMeta[$request_url] );
|
2536 |
update_option( 'quickppr_redirects', sanitize_option( 'quickppr_redirects', $currRedirects ) );
|
@@ -2580,9 +2622,9 @@ function qppr_get_browser_family( $type = 'class' ){ //name or class
|
|
2580 |
}else if( $is_lynx ){
|
2581 |
$name = 'Lynx';
|
2582 |
}else{
|
2583 |
-
$name = 'Unknown';
|
2584 |
}
|
2585 |
if($type == 'name')
|
2586 |
return $name;
|
2587 |
return sanitize_title_with_dashes( 'browser-'.$name );
|
2588 |
-
}
|
1 |
+
<?php
|
2 |
/*
|
3 |
Plugin Name: Quick Page/Post Redirect Plugin
|
4 |
Plugin URI: http://www.anadnet.com/quick-pagepost-redirect-plugin/
|
5 |
Description: Redirect Pages, Posts or Custom Post Types to another location quickly (for internal or external URLs). Includes individual post/page options, redirects for Custom Post types, non-existant 301 Quick Redirects (helpful for sites converted to WordPress), New Window functionality, and rel=nofollow functionality.
|
6 |
Author: anadnet
|
7 |
Author URI: http://www.anadnet.com/
|
8 |
+
Donate link:
|
9 |
+
Version: 5.2.0
|
10 |
Text Domain: quick-pagepost-redirect-plugin
|
11 |
Domain Path: /lang
|
12 |
License: GPLv2 or later
|
36 |
global $newqppr, $redirect_plugin, $qppr_setting_links;
|
37 |
$qppr_setting_links = false;
|
38 |
start_ppr_class();
|
39 |
+
|
40 |
//=======================================
|
41 |
// Main Plugin Redirect Class.
|
42 |
//=======================================
|
69 |
public $pproverride_casesensitive;
|
70 |
public $ppruse_jquery;
|
71 |
public $pprptypes_ok;
|
72 |
+
|
73 |
function __construct() {
|
74 |
+
$this->ppr_curr_version = '5.2.0';
|
75 |
$this->ppr_nofollow = array();
|
76 |
$this->ppr_newindow = array();
|
77 |
$this->ppr_url = array();
|
98 |
$this->updatemsg = '';
|
99 |
$this->pprshowcols = get_option( 'ppr_show-columns', '1' );
|
100 |
//if($this->pprmeta_seconds==''){$this->pprmeta_seconds='0';}
|
101 |
+
|
102 |
//these are for all the time - even if there are overrides
|
103 |
add_action( 'admin_init', array( $this, 'save_quick_redirects_fields' ) );
|
104 |
add_action( 'admin_init', array( $this, 'ppr_init_check_version' ), 1 ); // checks version of plugin in DB and updates if needed.
|
123 |
add_filter( 'qppr_admin_pointers-quick-redirects_page_redirect-options', array( $this, 'qppr_register_pointer_use_jquery' ) ); // add pointers filter
|
124 |
add_filter( 'qppr_admin_pointers-quick-redirects_page_meta_addon', array( $this, 'qppr_register_pointer_meta' ) ); // add pointers filter
|
125 |
//add_filter( 'wp_feed_cache_transient_lifetime',array($this,'ppr_wp_feed_options',10, 2)); // for testing FAQ page only
|
126 |
+
|
127 |
if( $this->pproverride_active != '1' && !is_admin() ){ // don't run these if override active is set
|
128 |
add_action( 'init', array( $this, 'redirect' ), 1 ); // add the 301 redirect action, high priority
|
129 |
add_action( 'init', array( $this, 'redirect_post_type' ), 1 ); // add the normal redirect action, high priority
|
137 |
add_filter( 'get_permalink', array( $this, 'ppr_filter_links' ), 20, 2 ); // hook into get_permalink function
|
138 |
add_filter( 'redirect_canonical', array( $this, 'wordpress_no_guess_canonical' ) ); // stops 404 on canonical redirect as of 5.1.5
|
139 |
}
|
140 |
+
|
141 |
if( $this->pprshowcols == '1')
|
142 |
add_filter( 'pre_get_posts', array( $this,'add_custom_columns' ) ); // add custom columns
|
143 |
}
|
156 |
}
|
157 |
return $redirect_url;
|
158 |
}
|
159 |
+
|
160 |
/**
|
161 |
* Load plugin textdomain.
|
162 |
*
|
163 |
* @since 5.1.2
|
164 |
*/
|
165 |
function qppr_load_textdomain() {
|
166 |
+
load_plugin_textdomain( 'quick-pagepost-redirect-plugin', false, dirname( plugin_basename( __FILE__ ) ) . '/lang' );
|
167 |
}
|
168 |
+
|
169 |
/**
|
170 |
* Try to clear Cache files when certain plugins are present.
|
171 |
* Only happens after redirects or settings are saved or deleted.
|
190 |
$newCache->deleteCache();
|
191 |
}
|
192 |
}
|
193 |
+
|
194 |
function qppr_delete_all_settings_ajax(){
|
195 |
+
if ( !current_user_can( 'manage_options' ) ) exit('no permission');
|
196 |
+
|
197 |
check_ajax_referer( 'qppr_ajax_delete_ALL_verify', 'security', true );
|
198 |
if( current_user_can( 'manage_options' ) ){
|
199 |
global $wpdb;
|
221 |
delete_option( 'ppr_override-casesensitive' );
|
222 |
delete_option( 'ppr_show-columns' );
|
223 |
delete_option( 'ppr_use-custom-post-types' );
|
224 |
+
delete_option( 'qppr_jQuery_hide_message2' );
|
225 |
delete_option( 'qppr_meta_addon_load' );
|
226 |
delete_option( 'qppr_meta_addon_trigger' );
|
227 |
delete_option( 'qppr_meta_append_to' );
|
228 |
$this->qppr_try_to_clear_cache_plugins();
|
229 |
echo 'success';
|
230 |
}else{
|
231 |
+
echo 'no permission';
|
232 |
}
|
233 |
exit;
|
234 |
}
|
235 |
function qppr_delete_all_ireds_ajax(){
|
236 |
+
if ( !current_user_can( 'manage_options' ) ) exit('no permission');
|
237 |
+
|
238 |
check_ajax_referer( 'qppr_ajax_delete_ALL_verify', 'security', true );
|
239 |
if( current_user_can( 'manage_options' ) ){
|
240 |
global $wpdb;
|
243 |
$this->qppr_try_to_clear_cache_plugins();
|
244 |
echo 'success';
|
245 |
}else{
|
246 |
+
echo 'no permission';
|
247 |
}
|
248 |
exit;
|
249 |
}
|
250 |
+
|
251 |
function qppr_delete_all_qreds_ajax(){
|
252 |
+
if ( !current_user_can( 'manage_options' ) ) exit('no permission');
|
253 |
+
|
254 |
check_ajax_referer( 'qppr_ajax_delete_ALL_verify', 'security', true );
|
255 |
if( current_user_can( 'manage_options' ) ){
|
256 |
delete_option( 'quickppr_redirects' );
|
258 |
$this->qppr_try_to_clear_cache_plugins();
|
259 |
echo 'success';
|
260 |
}else{
|
261 |
+
echo 'no permission';
|
262 |
}
|
263 |
exit;
|
264 |
}
|
265 |
+
|
266 |
function qppr_pointer_load( $hook_suffix ) {
|
267 |
if ( get_bloginfo( 'version' ) < '3.3' )
|
268 |
return;
|
286 |
wp_enqueue_script( 'qppr-pointer', plugins_url( 'js/qppr_pointers.min.js', __FILE__ ), array( 'wp-pointer' ) );
|
287 |
wp_localize_script( 'qppr-pointer', 'qpprPointer', $valid_pointers );
|
288 |
}
|
289 |
+
|
290 |
function qppr_register_pointer_meta( $p ) {
|
291 |
$p['qppr-meta-options'] = array(
|
292 |
'target' => '.wrap > h2:first-child',
|
315 |
);
|
316 |
return $p;
|
317 |
}
|
318 |
+
|
319 |
function qppr_register_pointer_use_jquery( $p ) {
|
320 |
$p['qppr-use-jquery'] = array(
|
321 |
'target' => '#ppr_use-jquery',
|
331 |
);
|
332 |
return $p;
|
333 |
}
|
334 |
+
|
335 |
function qppr_delete_quick_redirect_ajax(){
|
336 |
+
if ( !current_user_can( 'manage_options' ) ) exit('error');
|
337 |
+
|
338 |
check_ajax_referer( 'qppr_ajax_verify', 'security', true );
|
339 |
$request = isset($_POST['request']) && esc_url($_POST['request']) != '' ? esc_url($_POST['request']) : '';
|
340 |
$curRedirects = get_option( 'quickppr_redirects', array() );
|
346 |
$this->qppr_try_to_clear_cache_plugins();
|
347 |
echo 'redirect deleted';
|
348 |
}else{
|
349 |
+
echo 'error';
|
350 |
}
|
351 |
exit;
|
352 |
}
|
353 |
+
|
354 |
function qppr_save_quick_redirect_ajax(){
|
355 |
+
if ( !current_user_can( 'manage_options' ) ) exit('error');
|
356 |
+
|
357 |
check_ajax_referer( 'qppr_ajax_verify', 'security', true );
|
358 |
+
|
359 |
$protocols = apply_filters('qppr_allowed_protocols',array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn', 'tel', 'fax', 'xmpp'));
|
360 |
$request = isset($_POST['request']) && trim($_POST['request']) != '' ? esc_url(str_replace(' ','%20',trim($_POST['request'])), null, 'appip') : '';
|
361 |
$requestOrig = isset($_POST['original']) && trim($_POST['original']) != '' ? esc_url(str_replace(' ','%20',trim($_POST['original'])), null, 'appip') : '';
|
369 |
$mkeys = array_keys($curMeta);
|
370 |
if( $updateRow == -1 || $requestOrig == '' || $request == '' || $destination == '' || empty( $curRedirects ) || empty( $curMeta) ){
|
371 |
echo 'error';
|
372 |
+
exit;
|
373 |
}
|
374 |
$toDelete = array();
|
375 |
$newRedirects = array();
|
376 |
$newMeta = array();
|
377 |
$orkey = array_search($requestOrig, $rkeys);
|
378 |
$omkey = array_search($requestOrig, $mkeys);
|
379 |
+
|
380 |
if( is_array( $rkeys ) && ! empty( $rkeys ) ){
|
381 |
foreach( $rkeys as $key => $val ){
|
382 |
$newRedirects[] = array( 'request' => $val, 'destination' => $curRedirects[$val] );
|
407 |
}
|
408 |
}
|
409 |
if( $originalRowMetaKey == $request ){
|
410 |
+
//if row to udpate has same request value then just update data
|
411 |
$newMeta[$omkey]['key'] = $request;
|
412 |
$newMeta[$omkey]['newwindow'] = $newWin;
|
413 |
+
$newMeta[$omkey]['nofollow'] = $noFollow;
|
414 |
}else{
|
415 |
if( isset( $curMeta[$request] ) ){
|
416 |
echo 'duplicate';
|
435 |
echo 'saved';
|
436 |
exit;
|
437 |
}
|
438 |
+
|
439 |
function save_quick_redirects_fields(){
|
440 |
if( isset( $_POST['submit_301'] ) ) {
|
441 |
if( check_admin_referer( 'add_qppr_redirects' )){
|
454 |
$currMeta = get_option( 'quickppr_redirects_meta', array() );
|
455 |
//TODO: Add Back up Redirects
|
456 |
//TODO: Add New Redirects to TOP not Bottom.
|
457 |
+
|
458 |
$protocols = apply_filters( 'qppr_allowed_protocols', array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn', 'tel', 'fax', 'xmpp'));
|
459 |
+
|
460 |
for($i = 0; $i < sizeof($data['request']); ++$i) {
|
461 |
$request = esc_url(str_replace(' ','%20',trim($data['request'][$i])), null, 'appip');
|
462 |
$destination = esc_url(str_replace(' ','%20',trim($data['destination'][$i])), null, 'appip');
|
468 |
if((strpos($request,'.') === false && strpos($request,'?') === false) && strpos($request,'/',strlen($request)-1) === false){
|
469 |
$request = $request.'/';
|
470 |
} // adds end folder marker if not a file end
|
471 |
+
if (($request == '' || $request == '/') && $destination == '') {
|
472 |
continue; //if nothing there do nothing
|
473 |
} elseif ($request != '' && $request != '/' && $destination == '' ){
|
474 |
$currRedirects[$request] = '/';
|
475 |
+
} else {
|
476 |
$currRedirects[$request] = $destination;
|
477 |
}
|
478 |
$currMeta[$request]['newwindow'] = $newwin;
|
479 |
$currMeta[$request]['nofollow'] = $nofoll;
|
480 |
}
|
481 |
+
|
482 |
update_option( 'quickppr_redirects', sanitize_option( 'quickppr_redirects', $currRedirects ) );
|
483 |
update_option( 'quickppr_redirects_meta', sanitize_option( 'quickppr_redirects_meta', $currMeta ) );
|
484 |
$this->quickppr_redirectsmeta = get_option( 'quickppr_redirects_meta', array() );
|
485 |
$this->quickppr_redirects = get_option( 'quickppr_redirects', array() );
|
486 |
return $currRedirects;
|
487 |
}
|
488 |
+
|
489 |
function qppr_strposa($haystack, $needle, $offset = 0) {
|
490 |
+
if( !is_array( $needle ) )
|
491 |
$needle = array( $needle );
|
492 |
foreach( $needle as $key => $query ) {
|
493 |
if(strpos($haystack, $query, $offset) !== false) return true; // stop on first true result
|
541 |
add_filter( "manage_page_posts_columns", array( $this, 'set_custom_edit_qppr_columns' ) );
|
542 |
add_action( "manage_page_posts_custom_column" , array( $this, 'custom_qppr_column' ), 10, 2 );
|
543 |
}
|
544 |
+
|
545 |
}
|
546 |
+
|
547 |
function set_custom_edit_qppr_columns($columns) {
|
548 |
$columns['qppr_redirect'] = __( 'Redirect', 'quick-pagepost-redirect-plugin' );
|
549 |
return $columns;
|
552 |
function custom_qppr_column( $column, $post_id ) {
|
553 |
switch ( $column ) {
|
554 |
case 'qppr_redirect' :
|
555 |
+
$qppr_url = get_post_meta( $post_id , '_pprredirect_url', true ) != '' ? get_post_meta( $post_id , '_pprredirect_url', true ) : '';
|
556 |
if( $qppr_url != '' ){
|
557 |
+
$qppr_type = get_post_meta( $post_id , '_pprredirect_type', true );
|
558 |
+
$qppr_active = get_post_meta( $post_id , '_pprredirect_active', true );
|
559 |
+
$qppr_rewrite = get_post_meta( $post_id , '_pprredirect_rewritelink', true );
|
560 |
+
$qppr_newwin = get_post_meta( $post_id , '_pprredirect_newwindow', true );
|
561 |
+
$qppr_nofoll = get_post_meta( $post_id , '_pprredirect_relnofollow', true );
|
562 |
$rediricon = $qppr_newwin != '' ? '<span class="dashicons dashicons-external" title="New Window"></span>' : '<span class="dashicons dashicons-arrow-right-alt" title="Redirects to"></span>';
|
563 |
if($qppr_active == '1'){
|
564 |
echo '<div class="qpprfont-on" title="on">('.$qppr_type.') ' . $rediricon . ' <code>'.$qppr_url.'</code></div>';
|
569 |
break;
|
570 |
}
|
571 |
}
|
572 |
+
|
573 |
function ppr_add_menu_and_metaboxes(){
|
574 |
/* add menus */
|
575 |
$qppr_add_page = add_menu_page( 'Quick Redirects', 'Quick Redirects', 'manage_options', 'redirect-updates', array( $this, 'ppr_options_page' ), 'dashicons-external' );
|
606 |
'post' => 'post'
|
607 |
);
|
608 |
}
|
609 |
+
|
610 |
$ptypesNOTok = is_array( $this->pprptypes_ok ) ? $this->pprptypes_ok : array();
|
611 |
+
|
612 |
foreach( $post_types_temp as $type ){
|
613 |
if( !in_array( $type, $ptypesNOTok ) ){
|
614 |
$context = apply_filters('appip_metabox_context_filter','normal');
|
615 |
$priority = apply_filters('appip_metabox_priority_filter','high');
|
616 |
+
add_meta_box( 'edit-box-ppr', __( 'Quick Page/Post Redirect', 'quick-pagepost-redirect-plugin' ) , array( $this, 'edit_box_ppr_1' ), $type, $context, $priority );
|
617 |
}
|
618 |
}
|
619 |
}
|
620 |
+
|
621 |
function qppr_admin_scripts($hook){
|
622 |
+
// include admin js and css only for users who has access to Options (Quick Redirects admin pages)
|
623 |
+
if ( current_user_can( 'manage_options' ) &&
|
624 |
+
in_array( $hook, array(
|
625 |
+
'post-new.php',
|
626 |
+
'edit.php',
|
627 |
+
'post.php',
|
628 |
+
'toplevel_page_redirect-updates',
|
629 |
+
'quick-redirects_page_redirect-options',
|
630 |
+
'quick-redirects_page_redirect-summary',
|
631 |
+
'quick-redirects_page_redirect-faqs',
|
632 |
+
'quick-redirects_page_redirect-import-export',
|
633 |
+
'quick-redirects_page_meta_addon'
|
634 |
+
) )
|
635 |
+
) {
|
636 |
+
|
637 |
$ajax_add_nonce = wp_create_nonce( 'qppr_ajax_verify' );
|
638 |
$secDeleteNonce = wp_create_nonce( 'qppr_ajax_delete_ALL_verify' );
|
639 |
$protocols = apply_filters( 'qppr_allowed_protocols', array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn', 'tel', 'fax', 'xmpp'));
|
640 |
+
|
641 |
wp_enqueue_style( 'qppr_admin_meta_style', plugins_url( '/css/qppr_admin_style.css', __FILE__ ) , null , $this->ppr_curr_version );
|
642 |
+
|
643 |
+
// wp_enqueue_script( 'qppr_admin_meta_script', plugins_url( '/js/qppr_admin_script.js', __FILE__ ) , array('jquery'), $this->ppr_curr_version );
|
644 |
wp_enqueue_script( 'qppr_admin_meta_script', plugins_url( '/js/qppr_admin_script.min.js', __FILE__ ) , array('jquery'), $this->ppr_curr_version );
|
645 |
+
wp_localize_script( 'qppr_admin_meta_script', 'qpprData', array(
|
646 |
+
'security' => $ajax_add_nonce,
|
647 |
+
'securityDelete' => $secDeleteNonce,
|
648 |
+
'protocols' => $protocols,
|
649 |
+
'msgAllDeleteConfirm' => __( 'Are you sure you want to PERMANENTLY Delete ALL Redirects and Settings (this cannot be undone)?', 'quick-pagepost-redirect-plugin' ),
|
650 |
+
'msgQuickDeleteConfirm' => __( 'Are you sure you want to PERMANENTLY Delete ALL Quick Redirects?', 'quick-pagepost-redirect-plugin' ),
|
651 |
+
'msgIndividualDeleteConfirm' => __( 'Are you sure you want to PERMANENTLY Delets ALL Individual Redirects?', 'quick-pagepost-redirect-plugin' ),
|
652 |
+
'msgDuplicate' => __( 'Redirect could not be saved as a redirect already exists with the same Request URL.', 'quick-pagepost-redirect-plugin' ) ,
|
653 |
+
'msgDeleteConfirm' => __( 'Are you sure you want to delete this redirect?', 'quick-pagepost-redirect-plugin' ) ,
|
654 |
+
'msgErrorSave' => __( 'Error Saving Redirect\nTry refreshing the page and trying again.', 'quick-pagepost-redirect-plugin' ) ,
|
655 |
+
'msgSelect' => 'select a file',
|
656 |
+
'msgFileType' => __( 'File type not allowed,\nAllowed file type: *.txt', 'quick-pagepost-redirect-plugin' ) ,
|
657 |
+
'adminURL' => admin_url('admin.php'),
|
658 |
+
'ajaxurl'=> admin_url('admin-ajax.php'),
|
659 |
+
'error' => __('Please add at least one redirect before submitting form', 'quick-pagepost-redirect-plugin')
|
660 |
+
));
|
661 |
}
|
662 |
return;
|
663 |
+
}
|
664 |
+
|
665 |
function qppr_frontend_scripts(){
|
666 |
global $qppr_setting_links;
|
667 |
$qppr_setting_links = true;
|
712 |
$linkData[$redURL] = array( $newWin, $noFoll, $rewriteval );
|
713 |
}
|
714 |
}
|
715 |
+
|
716 |
$qppr_setting_links = false;
|
717 |
//wp_enqueue_script( 'qppr_frontend_scripts', plugins_url( '/js/qppr_frontend_script.js', __FILE__ ) , array('jquery'), $this->ppr_curr_version, true );
|
718 |
wp_enqueue_script( 'qppr_frontend_scripts', plugins_url( '/js/qppr_frontend_script.min.js', __FILE__ ) , array('jquery'), $this->ppr_curr_version, true );
|
719 |
wp_localize_script( 'qppr_frontend_scripts', 'qpprFrontData', array( 'linkData' => $linkData, 'siteURL' => site_url(), 'siteURLq' => $this->getQAddress() ) );
|
720 |
}
|
721 |
+
|
722 |
function register_pprsettings() {
|
723 |
register_setting( 'ppr-settings-group', 'ppr_use-custom-post-types' );
|
724 |
register_setting( 'ppr-settings-group', 'ppr_override-nofollow' );
|
747 |
$cache = '1';
|
748 |
return $cache;
|
749 |
}
|
750 |
+
|
751 |
function ppr_faq_page(){
|
752 |
include_once(ABSPATH . WPINC . '/feed.php');
|
753 |
echo '
|
759 |
$rss = fetch_feed( 'http://www.anadnet.com/?feed=qppr_faqs&ver=' . $this->ppr_curr_version . '&loc=' . urlencode( $this->homelink ) );
|
760 |
$linkfaq = array();
|
761 |
$linkcontent = array();
|
762 |
+
if (!is_wp_error( $rss ) ) :
|
763 |
+
$maxitems = $rss->get_item_quantity( 100 );
|
764 |
+
$rss_items = $rss->get_items( 0, $maxitems );
|
765 |
endif;
|
766 |
$aqr = 0;
|
767 |
if ($maxitems != 0){
|
768 |
foreach ( $rss_items as $item ) :
|
769 |
+
$aqr++;
|
770 |
$linkfaq[] = '<li class="faq-top-item"><a href="#faq-'.$aqr.'">'.esc_html( $item->get_title() ).'</a></li>';
|
771 |
$linkcontent[] = '<li class="faq-item"><a name="faq-'.$aqr.'"></a><h3 class="qa"><span class="qa">Q. </span>'.esc_html( $item->get_title() ).'</h3><div class="qa-content"><span class="qa answer">A. </span>'.$item->get_content().'</div><div class="toplink"><a href="#faq-top">top ↑</a></li>';
|
772 |
endforeach;
|
783 |
</div>
|
784 |
</div>';
|
785 |
}
|
786 |
+
|
787 |
function ppr_summary_page() {
|
788 |
?>
|
789 |
<div class="wrap">
|
798 |
<?php $this->updatemsg ='';?>
|
799 |
<h2 style="font-size:20px;"><?php echo __( 'Summary', 'quick-pagepost-redirect-plugin' );?></h2>
|
800 |
<div align="left">
|
801 |
+
<?php
|
802 |
if($this->pproverride_active =='1'){echo '<div class="ppr-acor" style="margin:1px 0;width: 250px;font-weight: bold;padding: 2px;">' . __( 'Acitve Override is on - All Redirects are OFF!', 'quick-pagepost-redirect-plugin' ) . '</div>';}
|
803 |
if($this->pproverride_nofollow =='1'){echo '<div class="ppr-nfor" style="margin:1px 0;width: 200px;font-weight: bold;padding: 2px;">' . __( 'No Follow Override is on!', 'quick-pagepost-redirect-plugin' ) . '</div>';}
|
804 |
if($this->pproverride_newwin =='1'){echo '<div class="ppr-nwor" style="margin:1px 0;width: 200px;font-weight: bold;padding: 2px;">' . __( 'New Window Override is on!', 'quick-pagepost-redirect-plugin' ) . '</div>';}
|
841 |
</tr>
|
842 |
</thead>
|
843 |
<tbody>
|
844 |
+
<?php
|
845 |
$tempReportArray = array();
|
846 |
$tempa = array();
|
847 |
$tempQTReportArray = array();
|
911 |
if($tredURL == 'http://www.example.com' || $tredURL == '<span class="ppr-rrlor">http://www.example.com</span>'){$tredURL='<strong>N/A - redirection will not occur</strong>';}
|
912 |
?>
|
913 |
<tr class="<?php echo $pclass;?>">
|
914 |
+
<?php if( $tpostid != 'N/A'){ ?>
|
915 |
<td align="left"><?php echo $labelsTD[0];?><a href="<?php echo admin_url('post.php?post='.$tpostid.'&action=edit');?>" title="edit"><?php echo $tpostid;?></a></td>
|
916 |
<?php }else{ ?>
|
917 |
<td align="left"><?php echo $labelsTD[0];?><?php echo $tpostid;?></td>
|
932 |
</table>
|
933 |
</div>
|
934 |
</div>
|
935 |
+
<?php
|
936 |
+
}
|
937 |
+
|
938 |
function ppr_import_export_page(){
|
939 |
if(isset($_GET['update'])){
|
940 |
if($_GET['update']=='4'){$this->updatemsg ='' . __( 'Quick Redirects Imported & Replaced.', 'quick-pagepost-redirect-plugin' ) . '';}
|
1174 |
<div class="clear-both"></div>
|
1175 |
</div>
|
1176 |
</div>
|
1177 |
+
<?php }
|
1178 |
|
1179 |
function qppr_options_help_tab(){
|
1180 |
//generate the options page in the wordpress admin
|
1182 |
$screen_id = $screen->id;
|
1183 |
if($screen_id == 'toplevel_page_redirect-updates' ){
|
1184 |
$content = '
|
1185 |
+
<div style="padding:10px 0;">
|
1186 |
<table border="0" cellspacing="0" cellpadding="0">
|
1187 |
<tr>
|
1188 |
<th align="left">Example Requests</th>
|
1208 |
|
1209 |
</div>
|
1210 |
';
|
1211 |
+
$screen->add_help_tab( array(
|
1212 |
'id' => 'qppr_sample_redirects',
|
1213 |
+
'title' => __( 'Examples', 'quick-pagepost-redirect-plugin' ),
|
1214 |
'content' => $content ,
|
1215 |
) );
|
1216 |
+
$screen->add_help_tab( array(
|
1217 |
'id' => 'qppr_add_redirects',
|
1218 |
+
'title' => __( 'Troubleshooting', 'quick-pagepost-redirect-plugin' ),
|
1219 |
'content' => '
|
1220 |
+
<div style="padding:10px 0;">
|
1221 |
<b style="color:red;">' . __( 'IMPORTANT TROUBLESHOOTING NOTES:', 'quick-pagepost-redirect-plugin' ) . '</b>
|
1222 |
<ol style="margin-top:5px;">
|
1223 |
<li style="color:#214070;margin-left:15px;list-style-type:disc;">' . __( 'At this time the New Window (NW) and No Follow (NF) features will not work for Quick Redirects unless "Use jQuery" is enabled in the options.', 'quick-pagepost-redirect-plugin' ) . '</li>
|
1236 |
</div>' ,
|
1237 |
) );
|
1238 |
}elseif( $screen_id == 'quick-redirects_page_redirect-import-export' ){
|
1239 |
+
$screen->add_help_tab( array(
|
1240 |
'id' => 'qppr_export_redirects',
|
1241 |
+
'title' => __( 'Export Redirects', 'quick-pagepost-redirect-plugin' ),
|
1242 |
'content' => '<div style="padding:10px 0;"><p>' . __( 'You can export redirects in two formats - Encoded or Delimited.', 'quick-pagepost-redirect-plugin' ) . '</p></div>' ,
|
1243 |
) );
|
1244 |
+
$screen->add_help_tab( array(
|
1245 |
'id' => 'qppr_import_redirects',
|
1246 |
+
'title' => __( 'Import Redirects', 'quick-pagepost-redirect-plugin' ),
|
1247 |
'content' => '<div style="padding:10px 0;"><p>Help content coming soon.</p></div>' ,
|
1248 |
) );
|
1249 |
}elseif( $screen_id == 'quick-redirects_page_meta_addon' ){
|
1250 |
+
$screen->add_help_tab( array(
|
1251 |
'id' => 'qppr-load-page-content',
|
1252 |
+
'title' => __( 'Load Content?', 'quick-pagepost-redirect-plugin' ),
|
1253 |
'content' => '<div style="padding:10px 0;"><p>' . __( 'Use the <strong>Load Content?</strong> option to allow the page content to load as normal or to only load a blank page or the content provided in the <strong>Page Content</strong> section. ', 'quick-pagepost-redirect-plugin' ) . '</p>
|
1254 |
<p>' . __( 'If checked, all of the original content will load, so keep this in mind when setting the <strong>Redirect Seconds</strong> - if set too low, the page will not compeletely load. ', 'quick-pagepost-redirect-plugin' ) . '</p></div>' ,
|
1255 |
) );
|
1256 |
+
$screen->add_help_tab( array(
|
1257 |
'id' => 'qppr-redirect-seconds',
|
1258 |
+
'title' => __( 'Redirect Seconds', 'quick-pagepost-redirect-plugin' ),
|
1259 |
'content' => '<div style="padding:10px 0;"><p>' . __( 'Enter the nuber of seconds to wait before the redirect happens. Enter 0 to have an instant redirect*.', 'quick-pagepost-redirect-plugin' ) . '</p>
|
1260 |
<p>' . __( '*Keep in mind that the redirect seconds will start counting only AFTER the <strong>Redirect Trigger</strong> element is loaded - so 0 may be slightly longer than instant, depending on how much content needs to load before the trigger happens.', 'quick-pagepost-redirect-plugin' ) . '</p></div>' ,
|
1261 |
) );
|
1262 |
+
$screen->add_help_tab( array(
|
1263 |
'id' => 'qppr-redirect-trigger',
|
1264 |
+
'title' => __( 'Redirect Trigger', 'quick-pagepost-redirect-plugin' ),
|
1265 |
'content' => '<div style="padding:10px 0;"><p>' . __( 'The class or id or tag name of the element to load before the redirect starts counting down. If nothing is used, it will default to the body tag as a trigger.', 'quick-pagepost-redirect-plugin' ) . '</p>
|
1266 |
<p>' . __( 'If you use a class, the class name should have the "." in the name, i.e., <strong>.my-class-name</strong>', 'quick-pagepost-redirect-plugin' ) . '</p>
|
1267 |
<p>' . __( 'If you use an id, the id should have the "#" in the name, i.e., <strong>#my-id-name</strong>.', 'quick-pagepost-redirect-plugin' ) . '</p>
|
1268 |
<p>' . __( 'If you use a tag name, the name should NOT have the "<" or ">" characters in the name, i.e., <body> would just be <strong>body</strong>.', 'quick-pagepost-redirect-plugin' ) . '</p>
|
1269 |
<p>' . __( 'Do not use a tag name that is common, like "a" or "div" as it will trigger on all events.', 'quick-pagepost-redirect-plugin' ) . '</p></div>' ,
|
1270 |
) );
|
1271 |
+
$screen->add_help_tab( array(
|
1272 |
'id' => 'qppr-redirect-append',
|
1273 |
+
'title' => __( 'Append Content To', 'quick-pagepost-redirect-plugin' ),
|
1274 |
'content' => '<div style="padding:10px 0;"><p>' . __( 'The class, id or tag name that you want the content in the <strong>Page Content</strong> to be loading into.', 'quick-pagepost-redirect-plugin' ) . '</p>
|
1275 |
<p>' . __( 'If you are loading the content of the page, use an existing class or id for an existing element (i.e., .page-content) so your additional page content (if any) is loaded into that element.', 'quick-pagepost-redirect-plugin' ) . '</p>
|
1276 |
<p>' . __( 'When no class, id or tag name is used, the <strong>body</strong> tag will be used.', 'quick-pagepost-redirect-plugin' ) . '</p></div>' ,
|
1277 |
) );
|
1278 |
+
$screen->add_help_tab( array(
|
1279 |
'id' => 'qppr-redirect-content',
|
1280 |
+
'title' => __( 'Page Content', 'quick-pagepost-redirect-plugin' ),
|
1281 |
'content' => '<div style="padding:10px 0;"><p>' . __( 'This is your page content you want to add. If you have a "tracking pixel" script or image tag you want to use, add it here.', 'quick-pagepost-redirect-plugin' ) . '</p>
|
1282 |
<p>' . __( 'A good example of use, is adding a tracking script (or Facebook Conversion Pixel) to the <strong>Page Content box</strong> and unchecking the <strong>Load Content?</strong> box. Then set the <strong>Redirect Seconds</strong> to 1 or 2 so the script has a chance to load and set <strong>Append Content</strong> To to "body" and <strong>Redirect Trigger</strong> to "body".', 'quick-pagepost-redirect-plugin' ) . '</p>
|
1283 |
<p>' . __( 'Additionally, you can add the redirect counter to the page by adding the code sample under the <strong>Page Content</strong> box.', 'quick-pagepost-redirect-plugin' ) . '</p></div>' ,
|
1293 |
<div class="updated settings-error" id="setting-error-settings_updated"><p><strong><?php echo $this->updatemsg;?></strong></p></div>
|
1294 |
<?php } ?>
|
1295 |
<?php $this->updatemsg ='';//reset message;?>
|
1296 |
+
<?php
|
1297 |
$isJQueryOn = get_option('ppr_use-jquery');
|
1298 |
$isJQueryMsgHidden = get_option('qppr_jQuery_hide_message');
|
1299 |
$isJQueryMsgHidden2 = get_option('qppr_jQuery_hide_message2');?>
|
1395 |
<table id="qppr-temp-table-holder"><tr><td></td></tr></table>
|
1396 |
</div>
|
1397 |
<?php
|
1398 |
+
}
|
1399 |
|
1400 |
function expand_redirects(){
|
1401 |
//utility function to return the current list of redirects as form fields
|
1414 |
$newCheckedAjax = 'X';
|
1415 |
}
|
1416 |
if($noFollow == 1){
|
1417 |
+
$noChecked = ' checked="checked"';
|
1418 |
$noCheckedAjax = 'X';
|
1419 |
}
|
1420 |
$output .= '
|
1440 |
}
|
1441 |
return $output;
|
1442 |
}
|
1443 |
+
|
1444 |
function ppr_filter_links ($link = '', $post = array()) {
|
1445 |
global $qppr_setting_links;
|
1446 |
if( $qppr_setting_links)
|
1447 |
return $link;
|
1448 |
+
if(isset($post->ID)){
|
1449 |
$id = $post->ID;
|
1450 |
}else{
|
1451 |
$id = $post;
|
1468 |
}
|
1469 |
return $link;
|
1470 |
}
|
1471 |
+
|
1472 |
function ppr_filter_page_links ($link, $post) {
|
1473 |
global $qppr_setting_links;
|
1474 |
if( $qppr_setting_links)
|
1495 |
}
|
1496 |
return $link;
|
1497 |
}
|
1498 |
+
|
1499 |
function get_main_array(){
|
1500 |
global $wpdb;
|
1501 |
+
$this->pprptypes_ok = get_option( 'ppr_qpprptypeok', array() );
|
1502 |
if( is_array( $this->ppr_all_redir_array ) && ! empty( $this->ppr_all_redir_array ) )
|
1503 |
return $this->ppr_all_redir_array;
|
1504 |
$theArray = array();
|
1531 |
$this->ppr_nofollow = $theArrayNF;
|
1532 |
return $theArray;
|
1533 |
}
|
1534 |
+
|
1535 |
function get_value($theval='none'){
|
1536 |
return isset($this->$theval) ? $this->$theval : 0;
|
1537 |
}
|
1538 |
+
|
1539 |
function ppr_queryhook($vars) {
|
1540 |
$vars[] = 'qppr-file-type';
|
1541 |
return $vars;
|
1542 |
}
|
1543 |
+
|
1544 |
+
function ppr_parse_request_new($wp) {
|
1545 |
global $wp, $wpdb;
|
1546 |
$this->ppr_all_redir_array = $this->get_main_array();
|
1547 |
$this->pprptypes_ok = get_option( 'ppr_qpprptypeok', array() );
|
1550 |
$newQPPR_Array = array();
|
1551 |
check_admin_referer( 'export-redirects-qppr' );
|
1552 |
$type = isset( $_GET['qppr-file-type'] ) && sanitize_text_field( $_GET['qppr-file-type'] ) == 'encoded' ? 'encoded' : 'pipe' ; // can be 'encoded' or 'pipe';
|
1553 |
+
header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' );
|
1554 |
+
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
|
1555 |
+
header( 'Cache-Control: no-store, no-cache, must-revalidate' );
|
1556 |
+
header( 'Cache-Control: post-check=0, pre-check=0', false );
|
1557 |
+
header( 'Pragma: no-cache' );
|
1558 |
header( "Content-Type: application/force-download" );
|
1559 |
header( "Content-Type: application/octet-stream" );
|
1560 |
header( "Content-Type: application/download" );
|
1579 |
}else{
|
1580 |
$newfile = $newtext;
|
1581 |
}
|
1582 |
+
die( $newfile );
|
1583 |
}
|
1584 |
exit;
|
1585 |
} elseif( isset( $_POST['import-quick-redrects-file'] ) && isset( $_FILES['qppr_file'] ) ) {
|
1600 |
$delim = false;
|
1601 |
}
|
1602 |
if($delim != false){
|
1603 |
+
$config_file = str_replace("\r\n", "\n", $config_file);
|
1604 |
$config_file = str_replace("\r", "\n", $config_file);
|
1605 |
$text = explode( "\n", $config_file );
|
1606 |
$newfile1 = array();
|
1670 |
} else {
|
1671 |
$tempArr = array();
|
1672 |
$tempMArr = array();
|
1673 |
+
$config_file = str_replace("\r\n", "\n", $config_file);
|
1674 |
$config_file = str_replace("\r", "\n", $config_file);
|
1675 |
$QR_Array = explode( "\n", $config_file );
|
1676 |
$newfile1 = array();
|
1677 |
if( !empty( $QR_Array ) && is_array( $QR_Array )):
|
1678 |
foreach( $QR_Array as $qrtoadd ):
|
1679 |
if( $qrtoadd != '' && $delim != false && strpos( $qrtoadd, $delim ) !== false ){
|
1680 |
+
$elem = explode( $delim, str_replace( array( "\r", "\n" ), array( '', '' ), $qrtoadd ) );
|
1681 |
if( isset( $elem[0] ) && isset( $elem[1] ) ){
|
1682 |
$newfile1['quickppr_redirects'][esc_url($elem[0])] = esc_url($elem[1]);
|
1683 |
$nw = isset($elem[2]) && $elem[2] == '1' ? '1' : '0';
|
1686 |
$newfile1['quickppr_redirects_meta'][$elem[0]]['nofollow'] = $nf;
|
1687 |
}
|
1688 |
}
|
1689 |
+
endforeach;
|
1690 |
if(is_array($newfile1) && !empty( $newfile1 )){
|
1691 |
if( isset( $newfile1['quickppr_redirects'] ) ){
|
1692 |
$currQRs = get_option( 'quickppr_redirects', array() );
|
1711 |
} return;
|
1712 |
} return;
|
1713 |
}
|
1714 |
+
|
1715 |
function qppr_pprhidemessage_ajax(){
|
1716 |
check_ajax_referer( 'qppr_ajax_verify', 'scid', true );
|
1717 |
$msg = isset($_POST['pprhidemessage']) ? (int)$_POST['pprhidemessage'] : 0;
|
1722 |
update_option('qppr_jQuery_hide_message2','1');
|
1723 |
echo '1';
|
1724 |
}else{
|
1725 |
+
echo '0';
|
1726 |
}
|
1727 |
exit;
|
1728 |
}
|
1730 |
function ppr_init_check_version() {
|
1731 |
// checks version of plugin in DB and updates if needed.
|
1732 |
global $wpdb;
|
1733 |
+
//$this->pprptypes_ok = get_option( 'ppr_qpprptypeok', array() );
|
1734 |
if( is_array( $this->ppr_all_redir_array ) && ! empty( $this->ppr_all_redir_array ) )
|
1735 |
$this->ppr_all_redir_array = $this->get_main_array();
|
1736 |
|
1739 |
$metaMsgNew = get_option( 'qppr_meta_addon_content', 'not-set' );
|
1740 |
if( $metaMsgNew == 'not-set' && $metaMsg != 'not-set' ){
|
1741 |
update_option( 'qppr_meta_addon_content', $metaMsg );
|
1742 |
+
$this->pprmeta_message = $metaMsg;
|
1743 |
}
|
1744 |
$metaSec = get_option( 'ppr_meta-seconds', 'not-set' );
|
1745 |
$metaSecNew = get_option( 'qppr_meta_addon_sec', 'not-set');
|
1760 |
}elseif( version_compare( $this->thepprversion, $this->ppr_curr_version, '<' ) ){
|
1761 |
update_option( 'ppr_version', $this->ppr_curr_version );
|
1762 |
}
|
1763 |
+
|
1764 |
if( $this->thepprmeta != '1' && version_compare( $this->ppr_curr_version, '5.0.7', '<' )){
|
1765 |
update_option( 'ppr_meta_clean', '1' );
|
1766 |
$wpdb->query("UPDATE $wpdb->postmeta SET `meta_key` = CONCAT('_',`meta_key`) WHERE `meta_key` = 'pprredirect_active' OR `meta_key` = 'pprredirect_rewritelink' OR `meta_key` = 'pprredirect_newwindow' OR `meta_key` = 'pprredirect_relnofollow' OR `meta_key` = 'pprredirect_type' OR `meta_key` = 'pprredirect_url';");
|
1771 |
$links[] = '<a href="'.$this->adminlink.'admin.php?page=redirect-options"><span class="dashicons dashicons-admin-settings"></span> ' . __( 'Settings', 'quick-pagepost-redirect-plugin' ) . '</a>';
|
1772 |
return $links;
|
1773 |
}
|
1774 |
+
|
1775 |
function ppr_filter_plugin_links($links, $file){
|
1776 |
if ( $file == plugin_basename(__FILE__) ){
|
1777 |
$links[] = '<a href="'.$this->adminlink.'admin.php?page=redirect-updates"><span class="dashicons dashicons-external"></span> ' . __( 'Quick Redirects', 'quick-pagepost-redirect-plugin' ) . '</a>';
|
1780 |
}
|
1781 |
return $links;
|
1782 |
}
|
1783 |
+
|
1784 |
function edit_box_ppr_1() {
|
1785 |
+
// Prints the inner fields for the custom post/page section
|
1786 |
global $post;
|
1787 |
$ppr_option1='';
|
1788 |
$ppr_option2='';
|
1802 |
echo '<label for="pprredirect_url"><b>' . __( 'Redirect / Destination URL:', 'quick-pagepost-redirect-plugin' ) . '</b></label><br />';
|
1803 |
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 dashicons dashicons-editor-help"></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.)', 'quick-pagepost-redirect-plugin' ) . '</span></span><br /><br />';
|
1804 |
echo '<label for="pprredirect_type"><b>' . __( 'Type of Redirect:', 'quick-pagepost-redirect-plugin' ) . '</b></label><br />';
|
1805 |
+
|
1806 |
switch($pprredirecttype):
|
1807 |
case "":
|
1808 |
$ppr_option1=" selected"; //default is 301 (as of 5.1.1)
|
1820 |
$ppr_option5=" selected";
|
1821 |
break;
|
1822 |
endswitch;
|
1823 |
+
|
1824 |
echo '
|
1825 |
<select style="margin-top:2px;margin-bottom:2px;width:40%;" name="pprredirect_type" id="pprredirect_type">
|
1826 |
<option value="301" '.$ppr_option1.'>301 ' . __( 'Permanent', 'quick-pagepost-redirect-plugin' ) . '</option>
|
1832 |
$metasel = ' meta-not-selected';
|
1833 |
if( $ppr_option5 == ' selected' )
|
1834 |
$metasel = ' meta-selected';
|
1835 |
+
|
1836 |
echo '<div class="qppr-meta-section-wrapper'.$metasel.'">';
|
1837 |
echo ' <label for="pprredirect_meta_secs" style="padding:2px 0;"><strong>' . __( 'Redirect Seconds (ONLY for meta redirects).', 'quick-pagepost-redirect-plugin' ) . '</strong></label><br /><input type="text" name="pprredirect_meta_secs" id="pprredirect_meta_secs" value="'. (get_post_meta($post->ID,'_pprredirect_meta_secs',true) != '' ? get_post_meta($post->ID,'_pprredirect_meta_secs',true ): '' ).'" size="3"><span class="qppr_meta_help_wrap"><span class="qppr_meta_help_icon dashicons dashicons-editor-help"></span><span class="qppr_meta_help">' . __( 'Leave blank to use options setting. 0 = instant.', 'quick-pagepost-redirect-plugin' ) . ' </span></span><br /><br />';
|
1838 |
echo '</div>';
|
1839 |
echo __( '<strong>NOTE:</strong> 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', 'quick-pagepost-redirect-plugin' ) . ' <a href="./admin.php?page=redirect-updates">' . __( 'Quick Redirects', 'quick-pagepost-redirect-plugin' ) . '</a> ' . __( 'method.', 'quick-pagepost-redirect-plugin' );
|
1840 |
}
|
1841 |
+
|
1842 |
function isOne_none($val=''){ //true (1) or false =''
|
1843 |
if($val == '_blank'){
|
1844 |
return $val;
|
1847 |
}
|
1848 |
return '';
|
1849 |
}
|
1850 |
+
|
1851 |
function ppr_save_metadata($post_id, $post) {
|
1852 |
if($post->post_type == 'revision' || ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) )
|
1853 |
return;
|
1859 |
// check allowed to editing
|
1860 |
if ( !current_user_can('edit_posts', $post_id))
|
1861 |
return $post_id;
|
1862 |
+
|
1863 |
if(!empty($my_meta_data))
|
1864 |
unset($my_meta_data);
|
1865 |
+
|
1866 |
$my_meta_data = array();
|
1867 |
if( isset( $_POST['pprredirect_active'] ) || isset( $_POST['pprredirect_url'] ) || isset( $_POST['pprredirect_type'] ) || isset( $_POST['pprredirect_newwindow'] ) || isset($_POST['pprredirect_relnofollow']) || isset($_POST['pprredirect_meta_secs'])):
|
1868 |
$protocols = apply_filters( 'qppr_allowed_protocols', array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn', 'tel', 'fax', 'xmpp'));
|
1872 |
$my_meta_data['_pprredirect_relnofollow'] = isset($_REQUEST['pprredirect_relnofollow']) ? sanitize_meta( '_pprredirect_relnofollow', $this->isOne_none(intval( $_REQUEST['pprredirect_relnofollow'])), 'post' ) : '';
|
1873 |
$my_meta_data['_pprredirect_type'] = isset($_REQUEST['pprredirect_type']) ? sanitize_meta( '_pprredirect_type', sanitize_text_field( $_REQUEST['pprredirect_type'] ), 'post' ) : '';
|
1874 |
$my_meta_data['_pprredirect_rewritelink'] = isset($_REQUEST['pprredirect_rewritelink']) ? sanitize_meta( '_pprredirect_rewritelink', $this->isOne_none(intval( $_REQUEST['pprredirect_rewritelink'])), 'post' ) : '';
|
1875 |
+
$my_meta_data['_pprredirect_url'] = isset($_REQUEST['pprredirect_url']) ? esc_url_raw( $_REQUEST['pprredirect_url'], $protocols ) : '';
|
1876 |
+
$my_meta_data['_pprredirect_meta_secs'] = isset($_REQUEST['pprredirect_meta_secs']) && $_REQUEST['pprredirect_meta_secs'] != '' ? (int) $_REQUEST['pprredirect_meta_secs'] : '';
|
1877 |
|
1878 |
$info = $this->appip_parseURI($my_meta_data['_pprredirect_url']);
|
1879 |
//$my_meta_data['_pprredirect_url'] = esc_url_raw($info['url']);
|
1887 |
$my_meta_data['_pprredirect_newwindow'] = NULL; //turn it off if no URL is set
|
1888 |
$my_meta_data['_pprredirect_relnofollow'] = NULL; //turn it off if no URL is set
|
1889 |
}
|
1890 |
+
|
1891 |
// Add values of $my_meta_data as custom fields
|
1892 |
if(count($my_meta_data)>0){
|
1893 |
+
foreach ($my_meta_data as $key => $value) {
|
1894 |
$value = implode(',', (array)$value);
|
1895 |
+
if($value == '' || $value == NULL || $value == ','){
|
1896 |
+
delete_post_meta($post->ID, $key);
|
1897 |
}else{
|
1898 |
if(get_post_meta($post->ID, $key, true) != '') {
|
1899 |
update_post_meta($post->ID, $key, $value);
|
1900 |
+
} else {
|
1901 |
add_post_meta($post->ID, $key, $value);
|
1902 |
}
|
1903 |
}
|
1906 |
$this->qppr_try_to_clear_cache_plugins();
|
1907 |
endif;
|
1908 |
}
|
1909 |
+
|
1910 |
function appip_parseURI($url){
|
1911 |
/*
|
1912 |
[scheme]
|
1919 |
*/
|
1920 |
$strip_protocol = 0;
|
1921 |
$tostrip = '';
|
1922 |
+
if(substr($url,0,2) == 'p=' || substr($url,0,8) == 'page_id='){
|
1923 |
// page or post id
|
1924 |
$url = network_site_url().'/?'.$url;
|
1925 |
+
}elseif(is_numeric($url)){
|
1926 |
// page or post id
|
1927 |
$url = network_site_url().'/?'.$url;
|
1928 |
+
}elseif($url == "/" ){
|
1929 |
// root
|
1930 |
$url = network_site_url().'/';
|
1931 |
+
}elseif(substr($url,0,1) == '/' ){
|
1932 |
// relative to root
|
1933 |
$url = network_site_url().$url;
|
1934 |
$strip_protocol = 1;
|
1935 |
+
$tostrip = network_site_url();
|
1936 |
+
}elseif(substr($url,0,7) != 'http://' && substr($url,0,8) != 'https://' ){
|
1937 |
//no protocol so add it
|
1938 |
//NOTE: desided not to add it automatically - too iffy.
|
1939 |
}
|
1945 |
}
|
1946 |
return $info;
|
1947 |
}
|
1948 |
+
|
1949 |
function ppr_fix_targetsandrels($pages) {
|
1950 |
$ppr_url = array();
|
1951 |
$ppr_newindow = array();
|
1952 |
$ppr_nofollow = array();
|
1953 |
+
|
1954 |
if (empty($ppr_url) && empty($ppr_newindow) && empty($ppr_nofollow)){
|
1955 |
$thefirstppr = array();
|
1956 |
if(!empty($this->ppr_all_redir_array)){
|
1964 |
}
|
1965 |
if(!empty($thefirstppr)){
|
1966 |
foreach($thefirstppr as $ppitems){
|
1967 |
+
if($ppitems['_pprredirect_active'] == 1 && $this->pproverride_newwin =='1'){
|
1968 |
// check override of NEW WINDOW
|
1969 |
$ppr_newindow[] = $ppitems['post_id'];
|
1970 |
}else{
|
1972 |
$ppr_newindow[] = $ppitems['post_id'];
|
1973 |
}
|
1974 |
}
|
1975 |
+
|
1976 |
+
if($ppitems['_pprredirect_active']==1 && $this->pproverride_nofollow =='1'){
|
1977 |
//check override of NO FOLLOW
|
1978 |
$ppr_nofollow[] = $ppitems['post_id'];
|
1979 |
}else{
|
1981 |
$ppr_nofollow[] = $ppitems['post_id'];
|
1982 |
}
|
1983 |
}
|
1984 |
+
|
1985 |
+
if($ppitems['_pprredirect_active']==1 && $this->pproverride_rewrite =='1'){
|
1986 |
//check override of REWRITE
|
1987 |
if($this->pproverride_URL!=''){
|
1988 |
$ppr_url_rewrite[] = $ppitems['post_id'];
|
2003 |
return $pages;
|
2004 |
}
|
2005 |
}
|
2006 |
+
|
2007 |
//$this_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
2008 |
if(count($ppr_nofollow)>=1) {
|
2009 |
foreach($ppr_nofollow as $relid){
|
2016 |
}
|
2017 |
}
|
2018 |
}
|
2019 |
+
|
2020 |
if(count($ppr_newindow)>=1) {
|
2021 |
foreach($ppr_newindow as $p){
|
2022 |
$validexp="@\<li(?:.*?)".$p."(?:.*?)\>\<a(?:.*?)target\=(?:.*?)\>@i";
|
2030 |
}
|
2031 |
return $pages;
|
2032 |
}
|
2033 |
+
|
2034 |
function redirect_post_type(){
|
2035 |
return;
|
2036 |
//not needed at this time
|
2037 |
}
|
2038 |
+
|
2039 |
function getAddress($home = ''){
|
2040 |
// utility function to get the full address of the current request - credit: http://www.phpro.org/examples/Get-Full-URL.html
|
2041 |
if( !isset( $_SERVER['HTTPS'] ) ){
|
2044 |
$protocol = $_SERVER['HTTPS'] !== '' && strpos( $home, 'http:' ) === false ? 'https' : 'http'; //check for https
|
2045 |
return $protocol.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; //return the full address
|
2046 |
}
|
2047 |
+
|
2048 |
function getQAddress($home = ''){
|
2049 |
// utility function to get the protocol and host of the current request
|
2050 |
if( !isset( $_SERVER['HTTPS'] ) )
|
2051 |
$_SERVER['HTTPS'] = '';
|
2052 |
$protocol = $_SERVER['HTTPS'] !== '' && strpos( $home, 'http:' ) === false ? 'https' : 'http'; //check for https
|
2053 |
+
return $protocol.'://'.$_SERVER['HTTP_HOST'];
|
2054 |
}
|
2055 |
+
|
2056 |
function ppr_new_nav_menu_fix($ppr){
|
2057 |
$newmenu = array();
|
2058 |
if(!empty($ppr)){
|
2082 |
}
|
2083 |
return $newmenu;
|
2084 |
}
|
2085 |
+
|
2086 |
function redirect(){
|
2087 |
//bypass for testing.
|
2088 |
if(isset($_GET['action']) && $_GET['action'] == 'no-redirect' )
|
2093 |
$homeURL = get_option( 'home' );
|
2094 |
$getAddress = $this->getAddress( $homeURL ); // gets just the protocol and full URL of request. for cases when the setting for Site URL has a subfolder but a request may not.
|
2095 |
$getQAddress = $this->getQAddress( $homeURL ); // gets just the protocol and domain (host) of the request.
|
2096 |
+
|
2097 |
//get the query string if there is one so that it can be preserved
|
2098 |
// patch submitted for version 5.0.7 by Romulo De Lazzari <romulodelazzari@gmail.com> - THANKS!
|
2099 |
$finalQS = (filter_input(INPUT_SERVER, 'QUERY_STRING'));
|
2104 |
}
|
2105 |
$userrequest = str_replace( $homeURL, '', $getAddress );
|
2106 |
$userrequest = preg_replace('/\?.*/', '', $userrequest);
|
2107 |
+
// end patch
|
2108 |
//end QS preservation
|
2109 |
|
2110 |
$needle = $this->pproverride_casesensitive ? $userrequest : strtolower($userrequest);
|
2115 |
$finalQS = $this->pproverride_casesensitive ? $finalQS : strtolower( $finalQS ); //added 5.1.4 to fix URL needle being converted to lower, but not Query (as it never matches unless user enters lower)
|
2116 |
$finalQS = apply_filters( 'appip_filter_testing_finalQS', $finalQS, $needle, $haystack); // added 5.1.4 to allow filtering of QS data prior to matching.
|
2117 |
$index = false;
|
2118 |
+
|
2119 |
/* These are the URL matching checks to see if the request should be redirected.
|
2120 |
+
* They trickle down to the less likely scenarios last - tries to recover a redirect if the
|
2121 |
* user just forgot things like ending slash or used wrong protocol, etc.
|
2122 |
*/
|
2123 |
|
2124 |
+
if( array_key_exists( ($needle . $finalQS), $haystack ) ){
|
2125 |
//check if QS data might be part of the redirect URL and not supposed to be added back.
|
2126 |
$index = $needle . $finalQS;
|
2127 |
$finalQS = ''; //remove it
|
2128 |
+
}elseif( array_key_exists( urldecode($needle . $finalQS), $haystack ) ){
|
2129 |
//check if QS data might be part of the encoded redirect URL and not supposed to be added back.
|
2130 |
$index = $needle . $finalQS;
|
2131 |
$finalQS = ''; //remove it
|
2162 |
$index = $needle . '/';
|
2163 |
}
|
2164 |
$index = apply_filters('qppr_filter_quickredirect_index', $index, $finalQS);
|
2165 |
+
|
2166 |
if($index != false && $index != ''){
|
2167 |
// Finally, if we have a matched request URL, get ready to redirect.
|
2168 |
+
$val = isset($haystack[$index]) ? $haystack[$index] : false;
|
2169 |
if($val) {
|
2170 |
// if global setting to make all redirects go to a specific URL is set, that takes priority.
|
2171 |
$useURL = $this->pproverride_URL != '' ? $this->pproverride_URL : $val;
|
2172 |
$useURL .= apply_filters( 'qppr_filter_quickredirect_append_QS_data', $finalQS ); //add QS back or use filter to set to blank.
|
2173 |
$useURL = apply_filters( 'qppr_filter_quickredirect_url', $useURL, $index ); // final URL filter
|
2174 |
+
|
2175 |
$qpprRedType = apply_filters( 'qppr_filter_quickredirect_type', 301 ) ; // filter for redirect type (301 is default here).
|
2176 |
$qpprMetaSec = apply_filters( 'qppr_filter_quickredirect_secs', $this->pprmeta_seconds ) ; // filter for redirect seconds if type is changed to meta).
|
2177 |
if( strpos( $useURL, '/' ) !== false && strpos( $useURL, '/' ) === 0 ){
|
2178 |
+
// $addback refers to adding back the site home link back to the front of the request URL that is relative to the root.
|
2179 |
// by default it will, but this can be filtered to never add it back (or based on URL).
|
2180 |
$addback = (bool) apply_filters( 'qppr_filter_quickredirect_add_home_link_to_destination_url', true, $useURL);
|
2181 |
$useURL = $addback ? $homeURL . $useURL : $useURL;
|
2182 |
}
|
2183 |
// action to allow take over.
|
2184 |
do_action( 'qppr_redirect', $useURL, $qpprRedType );
|
2185 |
+
|
2186 |
if( $useURL != '' ){
|
2187 |
// and now the redirect (meta or type set).
|
2188 |
if( $qpprRedType == 'meta' ){
|
2194 |
exit();
|
2195 |
}
|
2196 |
}
|
2197 |
+
}
|
2198 |
}
|
2199 |
}
|
2200 |
}
|
2201 |
+
|
2202 |
function ppr_do_redirect( $var1='var1', $var2 = 'var2'){
|
2203 |
//bypass for testing.
|
2204 |
if(isset($_GET['action']) && $_GET['action'] == 'no-redirect' )
|
2205 |
return;
|
2206 |
// Individual Redirects Redirect.
|
2207 |
// Read the list of redirects and if the current page is found in the list, send the visitor on her way
|
2208 |
+
|
2209 |
global $post;
|
2210 |
if ( count( $this->ppr_all_redir_array ) > 0 && ( is_single() || is_singular() || is_page() ) ) {
|
2211 |
if( isset( $this->ppr_all_redir_array[$post->ID] ) ){
|
2222 |
$urlsite = 'http://'.$redrurl;
|
2223 |
}elseif(is_numeric($redrurl)){ // page/post number
|
2224 |
$urlsite = $this->homelink.'/?p='.$redrurl;
|
2225 |
+
}elseif(strpos($redrurl,'/') === 0){ // relative to root
|
2226 |
$urlsite = $this->homelink.$redrurl;
|
2227 |
}else{ // we assume they are using the permalink / page name??
|
2228 |
$urlsite=$this->homelink.'/'.$redrurl;
|
2229 |
}
|
2230 |
// check if override is set for all redirects to go to one URL
|
2231 |
+
if($this->pproverride_URL !=''){$urlsite=$this->pproverride_URL;}
|
2232 |
if($this->pproverride_type!='0' && $this->pproverride_type!=''){$redrtype = $this->pproverride_type;} //override check
|
2233 |
if($redrtype == 'meta'){
|
2234 |
$this->ppr_metaurl = $redrurl;
|
2289 |
$pcontent = '';
|
2290 |
$appMsgTo = 'body';
|
2291 |
if( is_object( $post ) && !empty( $post )){
|
2292 |
+
$psecs = get_post_meta($post->ID, '_pprredirect_meta_secs', true);
|
2293 |
$ptrigger = get_post_meta($post->ID, 'qppr_meta_trigger', true) != '' ? get_post_meta($post->ID, 'qppr_meta_trigger', true) : '';
|
2294 |
$pload = (bool) get_post_meta($post->ID, 'qppr_meta_load', true) === true ? '1' : '';
|
2295 |
$pcontent = get_post_meta($post->ID, 'qppr_meta_content', true) != '' ? get_post_meta($post->ID, 'qppr_meta_content', true) : '';
|
2373 |
</table>
|
2374 |
<p class="submit"><input type="submit" class="button-primary" value="<?php echo __( 'Save Changes', 'quick-pagepost-redirect-plugin' );?>" /></p>
|
2375 |
</form>
|
2376 |
+
</div>
|
2377 |
<?php
|
2378 |
}
|
2379 |
+
|
2380 |
function qppr_meta_plugin_has_addon() {
|
2381 |
if ( ( defined('DOING_AJAX') && DOING_AJAX ) || ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) )
|
2382 |
return;
|
2383 |
if ( is_admin() && is_plugin_active( 'qppr-meta-redirect-add-on/qppr-meta-redirect-add-on.php' ) ) {
|
2384 |
add_action( 'admin_notices', array( $this, 'qppr_meta_addon_admin_notice' ) );
|
2385 |
+
deactivate_plugins( 'qppr-meta-redirect-add-on/qppr-meta-redirect-add-on.php' );
|
2386 |
}
|
2387 |
}
|
2388 |
|
2412 |
* newwindow int 1 or 0
|
2413 |
* nofollow int 1 or 0
|
2414 |
* rewrite int 1 or 0
|
2415 |
+
* @return bool true on success
|
2416 |
* @example:
|
2417 |
* *****************
|
2418 |
$atts = array(
|
2419 |
'post_id' => $post->ID,
|
2420 |
'url' => 'http://example.com/',
|
2421 |
+
'active' => 0,
|
2422 |
'type' => '301',
|
2423 |
'newwindow' => 1,
|
2424 |
'nofollow' => 0,
|
2430 |
function qppr_create_individual_redirect( $atts = array() ){
|
2431 |
if( !is_array( $atts ) )
|
2432 |
return false;
|
2433 |
+
$defaults = array(
|
2434 |
+
'post_id' => '0',
|
2435 |
+
'active' => 1,
|
2436 |
'url' => '',
|
2437 |
'type' => '301',
|
2438 |
'newwindow' => 0,
|
2448 |
$newwindow = (int) $newwindow == 1 ? 1 : 0;
|
2449 |
$nofollow = (int) $nofollow == 1 ? 1 : 0;
|
2450 |
$rewrite = (int) $rewrite == 1 ? 1 : 0;
|
2451 |
+
// set required meta
|
2452 |
add_post_meta( $post_id, '_pprredirect_url', $url );
|
2453 |
add_post_meta( $post_id, '_pprredirect_type', $type );
|
2454 |
add_post_meta( $post_id, '_pprredirect_active', $active );
|
2458 |
if( $newwindow == 1 )
|
2459 |
add_post_meta( $post_id, '_pprredirect_newwindow', '_blank' );
|
2460 |
if( $nofollow == 1 )
|
2461 |
+
add_post_meta( $post_id, '_pprredirect_relnofollow', 1 );
|
2462 |
return true;
|
2463 |
}
|
2464 |
/**
|
2465 |
* qppr_delete_individual_redirect - helper function to delete Individual Redirect programatically.
|
2466 |
* @param post_id int|string the post id
|
2467 |
+
* @return bool true on success
|
2468 |
* @example:
|
2469 |
* *****************
|
2470 |
qppr_delete_individual_redirect( $post_id );
|
2479 |
$ok = current_user_can( 'edit_pages' );
|
2480 |
else
|
2481 |
$ok = current_user_can( 'edit_posts' );
|
2482 |
+
|
2483 |
+
if( $ok ){
|
2484 |
// delete meta fields
|
2485 |
delete_post_meta( $post_id, '_pprredirect_url' );
|
2486 |
delete_post_meta( $post_id, '_pprredirect_type');
|
2487 |
delete_post_meta( $post_id, '_pprredirect_active' );
|
2488 |
delete_post_meta( $post_id, '_pprredirect_rewritelink' );
|
2489 |
delete_post_meta( $post_id, '_pprredirect_newwindow' );
|
2490 |
+
delete_post_meta( $post_id, '_pprredirect_relnofollow' );
|
2491 |
return true;
|
2492 |
}else{
|
2493 |
return false;
|
2501 |
* destination_url string redirect URL
|
2502 |
* newwindow int 1 or 0
|
2503 |
* nofollow int 1 or 0
|
2504 |
+
* @return bool true on success
|
2505 |
* @example:
|
2506 |
* *****************
|
2507 |
$atts = array(
|
2516 |
function qppr_create_quick_redirect( $atts = array() ){
|
2517 |
if( !is_array( $atts ) )
|
2518 |
return false;
|
2519 |
+
$defaults = array(
|
2520 |
'request_url' => '',
|
2521 |
'destination_url' => '',
|
2522 |
'newwindow' => 0,
|
2525 |
extract( shortcode_atts($defaults, $atts) );
|
2526 |
if( $request_url == '' || $destination_url == '' )
|
2527 |
return false;
|
2528 |
+
|
2529 |
global $newqppr, $redirect_plugin;
|
2530 |
$currRedirects = get_option( 'quickppr_redirects', array() );
|
2531 |
$currMeta = get_option( 'quickppr_redirects_meta', array() );
|
2556 |
/**
|
2557 |
* qppr_delete_quick_redirect - helper function to delete Quick Redirect programatically.
|
2558 |
* @param request_url string redirect URL
|
2559 |
+
* @return bool true on success
|
2560 |
* @example:
|
2561 |
* *****************
|
2562 |
qppr_delete_quick_redirect( '/some-url/' );
|
2572 |
$request_url = esc_url( str_replace( ' ', '%20', trim( $request_url ) ), null, 'appip' );
|
2573 |
if( !isset( $currRedirects[$request_url] ) )
|
2574 |
return false;
|
2575 |
+
if( !isset( $currMeta[$request_url] ) )
|
2576 |
return false;
|
2577 |
unset( $currRedirects[$request_url], $currMeta[$request_url] );
|
2578 |
update_option( 'quickppr_redirects', sanitize_option( 'quickppr_redirects', $currRedirects ) );
|
2622 |
}else if( $is_lynx ){
|
2623 |
$name = 'Lynx';
|
2624 |
}else{
|
2625 |
+
$name = 'Unknown';
|
2626 |
}
|
2627 |
if($type == 'name')
|
2628 |
return $name;
|
2629 |
return sanitize_title_with_dashes( 'browser-'.$name );
|
2630 |
+
}
|
readme.txt
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
=== Quick Page/Post Redirect Plugin ===
|
2 |
Contributors: anadnet
|
3 |
Tags: redirect, 301, 302, meta, plugin, forward, nofollow, posts, pages, 404, custom post types, nav menu
|
4 |
-
Donate Link:
|
5 |
Requires at least: 4.0
|
6 |
License: GPLv2 or later
|
7 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
8 |
-
Tested up to: 5.
|
9 |
-
Stable tag: 5.
|
10 |
|
11 |
Easily redirect pages/posts or custom post types to another page/post or external URL by specifying the redirect URL and type (301, 302, 307, meta).
|
12 |
|
13 |
== Description ==
|
14 |
-
**Current Version 5.
|
15 |
|
16 |
This plugin has two redirect functionalities - **"Quick Redirects"** and **"Individual Redirects"**:
|
17 |
|
@@ -19,18 +19,18 @@ This plugin has two redirect functionalities - **"Quick Redirects"** and **"Indi
|
|
19 |
Quick Redirects are designed to be quick and simple to add. You do not need to have an existing page or post set up to add one. You just put the Request URL and the Destination URL and the plugin will redirect it. This type of redirect is great for fixing typos when a page was created, redirecting old URLs to a new URL so there is no 404, and to redirect links from an old site that has been converted to WordPress.
|
20 |
|
21 |
= INDIVIDUAL REDIRECTS (for existing pages/posts) =
|
22 |
-
For pages/posts that already exist, the plugin adds an option meta box to the edit screen where you can specify the redirect location and type (301, 302 or meta). This type of redirect is useful for many things, including menu items, duplicate posts, or just redirecting a page to a different URL or location on your existing site.
|
23 |
|
24 |
For best results use some form of WordPress Permalink structure. If you have other Redirect plugins installed, it is recommended that you use only one redirect plugin or they may conflict with each other or one may take over before the other can do its job.
|
25 |
|
26 |
-
= What You CAN Do (aka, Features): =
|
27 |
* Works with WordPress Nav Menus
|
28 |
* Works with WordPress Custom Post Types (select setting on options page)
|
29 |
* You can set a redirected page or menu item to open in a new window (Quick Redirects require **Use jQuery?** option to be set)
|
30 |
* You can add a *rel="nofollow"* attribute to the page or menu item link for the redirect (Quick Redirects require **Use jQuery?** option to be set)
|
31 |
* You can completely re-write the URL for the redirect so it takes the place of the original URL (rewrite the href link)
|
32 |
* You can redirect without needing to create a Page or Post using Quick Redirects. This is useful for sites that were converted to WordPress and have old links that create 404 errors (see FAQs for more information).
|
33 |
-
* Destination URL can be to another WordPress page/post or any other website with an external URL.
|
34 |
* Request URL can be a full URL path, the post or page ID, permalink or page slug.
|
35 |
* Option Screen to set global overrides like turning off all redirects at once, setting a global destination link, make all redirects open in a new window, etc.
|
36 |
* View a summary of all redirected pages/posts, custom post types and Quick Redirects that are currently set up.
|
@@ -59,7 +59,7 @@ This plugin is not compatible with WordPress versions less than 4.0. Requires PH
|
|
59 |
* If your site uses mixes SSL, use relative links whenever possible (i.e., '/my-page/'). The plugin is designed to detect the incoming protocol and try to apply the appropriate protocol to the destination URL.
|
60 |
* Links in page/post content and links that are created using get_permalink() or the_permalink() will not open in a new window or add the rel=nofollow UNLESS you have the **Use jQuery?** option set.
|
61 |
* 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. Many times a plugin or bad code is the culprit.
|
62 |
-
* We try to test the plugin in many popular themes and alongside popular plugins. In our experience, (with exception to a few bugs from time to time) many times another plugin is the cause of the issues - or a customized theme. If you do notice a problem, please let us know at info@anadnet.com - along with the WP version, theme you are using and plugins you have installed - and we will try to troubleshoot the problem.
|
63 |
* Check the FAQs/Help located in the Plugin menu for more up to date issues and fixes.
|
64 |
|
65 |
== Installation ==
|
@@ -77,20 +77,20 @@ This plugin is not compatible with WordPress versions less than 4.0. Requires PH
|
|
77 |
1. You can create a redirect with the 'Quick Redirects' option located in the Quick Redirects admin menu.
|
78 |
|
79 |
== Frequently Asked Questions ==
|
80 |
-
** SEE A LIST OF MORE UP TO DATE FAQS IN THE PLUGIN MENU ITSELF **
|
81 |
|
82 |
= Why is my Page/Post not redirecting? =
|
83 |
FIRST - make sure it is active if using Individual Redirects (set up on the edit page for a post or page). Then, check to make sure the global option to turn off all redirects is not checked (in the plugin options).
|
84 |
|
85 |
-
SECOND - if you are using Quick Redirects, try using links relative to the root (so 'http://mysite.com/contact/' would be '/contact/' if using the root path). If your site is in a sub-folder (set in Settings/General), do not use the sub-folder in the root path as it is already taken into consideration by WordPress.
|
86 |
|
87 |
NEXT - clear your site's cache files if you are using a caching plugin/theme. You may also need to clear your browser cache and internet files if you use caching - the browser WILL hold cached versions of a page and not redirect if there was no redirect in the cached version.
|
88 |
|
89 |
FINALLY - if you are not using a permalink structure of some sort, it is recommended that you set up at least a basic one. Redirects without a permalink structure can be inconsistant.
|
90 |
|
91 |
-
If your page or post is still not redirecting, then it 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. many time a plugin or bad code is the culprit - or the redirect is just simply turned off.
|
92 |
|
93 |
-
We have tested the plugin in dozens of themes and a whole lot more plugins. In our experience, (with exception to a few bugs) many times another plugin or the theme scripting is the problem. If you do notice a problem, please let us know at info@anadnet.com - along with the WP version, theme you are using and plugins you have installed - and we will try to troubleshoot the problem.
|
94 |
|
95 |
= Should I use a full URL with http:// or https:// ? =
|
96 |
Yes, you can, but you do not always need to. If you are redirecting to an external URL, then yes. If you are just redirecting to another page or post on your site, then no, it is not needed. When in doubt, use the entire URL. For Quick Redirects, it is recommended that you use relative URLs whenever possible.
|
@@ -100,7 +100,7 @@ Yes. You can perform a 301 Permanent Redirect. Additionally, you can select a 30
|
|
100 |
|
101 |
= Is the plugin SEO friendly? =
|
102 |
Yes it is.
|
103 |
-
The plugin uses standard redirect status methods to redirect the URLs. SEO crawlers use the status code to determine if a page request is available, moved or if there is some other error.
|
104 |
|
105 |
If you do not want a search engine to follow a Redirect URL, use the No Follow option to add 'rel="nofollow"' to the link.
|
106 |
|
@@ -117,13 +117,13 @@ If you use a redirect of 301 and the content is different, then it will be index
|
|
117 |
If you use a 302 redirect, the search engines will not change anything, but also index the destination page as it would any other page.
|
118 |
|
119 |
= Do I need to have a Page or Post Created to redirect? =
|
120 |
-
No. There is a Quick Redirects feature that allows you to create a redirect for any URL on your site. This is VERY helpful when you move an old site to WordPress and have old links that need to go some place new. For example,
|
121 |
If you had a link on a site that went to http://yoursite.com/aboutme.html you can now redirect that to http://yoursite.com/about/ without needing to edit the htaccess file. You simply add the old URL (/aboutme.html) and tell it you want to go to the new one (/about/). Simple as that.
|
122 |
|
123 |
The functionality is located in the QUICK REDIRECTS menu. The old URL goes in the Request field and the to new URL goes in the Destination field. Simple and Quick!
|
124 |
|
125 |
= Does the Page/Post need to be Published to redirect? =
|
126 |
-
YES... and NO... The redirect will always work on a Published Post/Page. For it to work correctly on a Post/Page in DRAFT status, you need to fist publish the page, then re-save it as a draft. If you don't follow that step, you will get a 404 error.
|
127 |
|
128 |
= Can I add 'rel="nofollow" attribute to the redirect link? =
|
129 |
YES, you can 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 only available for the Quick Redirects method when the 'Use jQuery?' functionality is enabled in the settings and you select the 'NF' box for the corresponding redirect.
|
@@ -134,20 +134,20 @@ YES, you can make the redirect link open in a new window. Simply check the "Open
|
|
134 |
= I still can't get the OPEN IN NEW WINDOW option to work... why? =
|
135 |
First, make sure you have the 'Use jQuery?' option set in the options page. This funcitonality drastically increases the plugin's ability to add the correct properties and attributes to the links to make them work as desired.
|
136 |
|
137 |
-
If you cannot us this option (because of a conflict with another script), then you may only have limited success with this feature.
|
138 |
The reason - some themes put custom links in the menu, like RSS and other similar items. Many times (an this is usually the main reason why), they do not use the WP hook to add the menu item to the list - they literally just put it there. Unless the theme uses the internal WordPress hooks to call the menu, redirects, open in a new window and rel=nofollow features just will not work.
|
139 |
ADDITIONALLY - Links in page/post content and Permalinks will not open in a new window or add the rel=nofollow. That is because the theme template actually sets up the links by calling "the_permalink()" function so add these elements is not consistently possible so it has been excluded from the functionality. The links will still redirect just fine but without that feature.
|
140 |
|
141 |
= 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? =
|
142 |
-
YES, you can 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.
|
143 |
|
144 |
-
Note - This option is available for the Quick Redirects only with the 'Use jQuery?' option enabled.
|
145 |
|
146 |
= I have Business Cards/Postcards/Ads that say my website is http://something.com/my-name/ or http://something.com/my-product/, but it should be a different page, can I set that up with this? =
|
147 |
YES! Just set up a Quick Redirect (see above) and set the Request URL to `/my-name/` or `/my-product/` and the Destination URL 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!
|
148 |
|
149 |
= What the heck is a 301 or 302 redirect anyway? =
|
150 |
-
Good question! The number corresponds with the header code that is returned to the browser when the page is first accessed. A good page, meaning something was found, returns a 200 status code and that tells the browser to go ahead and keep loading the content for the page. If nothing is found a 404 error is returned (and we have ALL seen these - usually it is a bad link or a page was moved). There are many other types of codes, but those are the most common.
|
151 |
|
152 |
The 300+ range of codes in the header tells the browser (and search engine spider) that the original page has moved to a new location - this can be just a new file name a new folder or a completely different site.
|
153 |
|
@@ -156,7 +156,7 @@ A 301 code means that you want to tell the browser (or Google, bing, etc.) that
|
|
156 |
A 302 or 307 code tell the browser that the file was there but TEMPORARILY it can be found at a new location. This will tell the search engines to KEEP the old link in place because SOME day it will be back at the same old link. There is only a slight difference between a 302 and a 307 status. Truth is, 302 is more widely used, so unless you know why you need a 307, stick with a 302.
|
157 |
|
158 |
= So, which one do I use? =
|
159 |
-
Easiest way to decide is this: If you want the page to permanently change to a new spot, use 301. If you are editing the page or post and only want it to be down for a few hours, minutes, days or weeks and plan on putting it back with the same link as before, then us 302. If you are having trouble with the redirects, use a `meta` redirect. The meta redirect actually starts to load the page as a 200 good status, then redirects using a meta redirect tag.
|
160 |
|
161 |
Still not sure? Try 302 for now - at least until you have a little time to read up on the subject.
|
162 |
|
@@ -182,6 +182,9 @@ NO it isn't! Check the plugin FAQs/Help page for a more up to date list of Frequ
|
|
182 |
* THIS SECTION IS JUST TO KEEP TRACK OF TODO ITEMS FOR FUTURE UPDATES.
|
183 |
* Add New Window and No Follow to links where the URL has been rewritten. Currently if you rewrite the URL neither will work as they are referenced with the original URL, not the rewrite.
|
184 |
|
|
|
|
|
|
|
185 |
= 5.1.9 =
|
186 |
* **New Compatibility Tested** from WordPress versions 4.3.19 up to 5.22
|
187 |
|
@@ -231,7 +234,7 @@ NO it isn't! Check the plugin FAQs/Help page for a more up to date list of Frequ
|
|
231 |
* Added Meta Redirect Options Page - this splits out Meta Options from the main options page.
|
232 |
* Added more enhanced meta redirect scripting to allow for tracking or other page content (including countdown if desired).
|
233 |
* Fixed Layout issues on Quick Redirect Page making it impossible to edit redirects in some cases.
|
234 |
-
* Fixed a few spelling errors.
|
235 |
* Added Help Content to Meta Options page.
|
236 |
* Added metabox setting for meta redirect seconds for individual redirects so you can set different time for each meta redirect.
|
237 |
* Update POT and English Translation file - added limited Spanish translations.
|
@@ -284,7 +287,7 @@ NO it isn't! Check the plugin FAQs/Help page for a more up to date list of Frequ
|
|
284 |
* Added jQuery version check to ensure no problems with themes forcing older versions of jQuery
|
285 |
* Added a few warning /info messages to Quick Redirects page.
|
286 |
* Redirect summary was updated to display Quick Redirects as well as individual redirects. Now it is easier to see at a glance what redirects you have set up.
|
287 |
-
* Rewrite of Quick Redirects functions to allow selecting Open in New Window (NW) and rel=nofollow (NF) as long as **use jQuery?** is selected.
|
288 |
* Added "use jQuery" option on settings page - on by default after upgrade
|
289 |
* Added jQuery redirect replace, target="_blank", and rel="nofollow" to increase success for additional options (mainly Quick redirects).
|
290 |
* Changed out WP_PLUGIN_URL for plugins_url() to help resolve errors in redirects for SSL/https
|
@@ -334,10 +337,10 @@ NO it isn't! Check the plugin FAQs/Help page for a more up to date list of Frequ
|
|
334 |
= 3.2.1 =
|
335 |
* limited test release - testing for some of 3.2.2 release fixes. (12/14/10)
|
336 |
= 3.2 =
|
337 |
-
* remove functions ppr_linktotarget, ppr_linktonorel, ppr_redirectto and ppr_linktometa.(12/10/2010)
|
338 |
-
* re-write functions to consolidate queries. (12/10/2010)
|
339 |
-
* added new filters for New menu structure to filter wp_nav_menu menus as well as old wp_page_menus functions. (12/10/2010)
|
340 |
-
* cleaned up new window and nofollow code to work more consistently. (12/10/2010)
|
341 |
= 3.1 =
|
342 |
* Re-issue of 2.1 for immediate fix of issue with the 3.0 version.(6/21/2010)
|
343 |
= 3.0 =
|
@@ -346,7 +349,7 @@ NO it isn't! Check the plugin FAQs/Help page for a more up to date list of Frequ
|
|
346 |
* Fix Bug - Open in New Window would not work unless Show Link URL was also selected. (3/12/2010)
|
347 |
* Fix Bug - Add rel=nofollow would not work if Open in a New Window was not selected. (3/13/2010)
|
348 |
* Fix Bug - Show Link, Add nofollow and Open in New Window would still work when redirect not active. (3/13/2010)
|
349 |
-
* Added new preg_match_all and preg_replace calls to add target and nofollow links - more efficient and accurate - noticed some cases where old function would add the items if a redirect link had the same URL. (3/13/2010)
|
350 |
= 2.0 =
|
351 |
* Cosmetic code cleanup. (2/28/2010)
|
352 |
* Remove warning and error messages created in 1.9 (2/28/2010)
|
@@ -360,24 +363,24 @@ NO it isn't! Check the plugin FAQs/Help page for a more up to date list of Frequ
|
|
360 |
= 1.7 =
|
361 |
* fix to correct meta redirect - moved "exit" command to "addtoheader_theme" function. Also fixed the problem with some pages not redirecting. Made the plugin WordPress MU compatible. (9/8/2009)
|
362 |
= 1.6.1 =
|
363 |
-
* Small fix to correct the same problem as 1.6 for Category and Archive pages (9/1/2009)
|
364 |
= 1.6 =
|
365 |
* Fixed wrongful redirect when the first blog post on home page (main blog page) has a redirect set up - this was redirecting the entire page incorrectly. This was only an issue with the first post on a page. (9/1/2009)
|
366 |
= 1.5 =
|
367 |
-
* Major re-Write of the plugin core function to hook WP at a later time to take advantage of the POST function - no sense re-creating the wheel.
|
368 |
* Removed the 'no code' redirect, as it turns out, many browsers will not redirect properly without a code - sorry guys.
|
369 |
* Can have page/post as draft and still redirect - but ONLY after the post/page has first been published and then re-saved as draft (this will hopefully be a fix for a later version). (8/31/2009)
|
370 |
= 1.4 =
|
371 |
* Add exit script command after header redirect function - needed on some servers and browsers. (8/19/2009)
|
372 |
-
= 1.3 =
|
373 |
* Add Meta Re-fresh option (7/26/2009)
|
374 |
-
= 1.2 =
|
375 |
* Add easy Post/Page Edit Box (7/25/2009)
|
376 |
-
= 1.1 =
|
377 |
* Fix redirect for off site links (7/7/2009)
|
378 |
-
= 1.0 =
|
379 |
* Initial Plugin creation (7/1/2009)
|
380 |
|
381 |
== Upgrade Notice ==
|
382 |
= 5.1.5 =
|
383 |
-
* Bug Fixes.
|
1 |
=== Quick Page/Post Redirect Plugin ===
|
2 |
Contributors: anadnet
|
3 |
Tags: redirect, 301, 302, meta, plugin, forward, nofollow, posts, pages, 404, custom post types, nav menu
|
4 |
+
Donate Link:
|
5 |
Requires at least: 4.0
|
6 |
License: GPLv2 or later
|
7 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
8 |
+
Tested up to: 5.5.1
|
9 |
+
Stable tag: 5.2.0
|
10 |
|
11 |
Easily redirect pages/posts or custom post types to another page/post or external URL by specifying the redirect URL and type (301, 302, 307, meta).
|
12 |
|
13 |
== Description ==
|
14 |
+
**Current Version 5.2.0**
|
15 |
|
16 |
This plugin has two redirect functionalities - **"Quick Redirects"** and **"Individual Redirects"**:
|
17 |
|
19 |
Quick Redirects are designed to be quick and simple to add. You do not need to have an existing page or post set up to add one. You just put the Request URL and the Destination URL and the plugin will redirect it. This type of redirect is great for fixing typos when a page was created, redirecting old URLs to a new URL so there is no 404, and to redirect links from an old site that has been converted to WordPress.
|
20 |
|
21 |
= INDIVIDUAL REDIRECTS (for existing pages/posts) =
|
22 |
+
For pages/posts that already exist, the plugin adds an option meta box to the edit screen where you can specify the redirect location and type (301, 302 or meta). This type of redirect is useful for many things, including menu items, duplicate posts, or just redirecting a page to a different URL or location on your existing site.
|
23 |
|
24 |
For best results use some form of WordPress Permalink structure. If you have other Redirect plugins installed, it is recommended that you use only one redirect plugin or they may conflict with each other or one may take over before the other can do its job.
|
25 |
|
26 |
+
= What You CAN Do (aka, Features): =
|
27 |
* Works with WordPress Nav Menus
|
28 |
* Works with WordPress Custom Post Types (select setting on options page)
|
29 |
* You can set a redirected page or menu item to open in a new window (Quick Redirects require **Use jQuery?** option to be set)
|
30 |
* You can add a *rel="nofollow"* attribute to the page or menu item link for the redirect (Quick Redirects require **Use jQuery?** option to be set)
|
31 |
* You can completely re-write the URL for the redirect so it takes the place of the original URL (rewrite the href link)
|
32 |
* You can redirect without needing to create a Page or Post using Quick Redirects. This is useful for sites that were converted to WordPress and have old links that create 404 errors (see FAQs for more information).
|
33 |
+
* Destination URL can be to another WordPress page/post or any other website with an external URL.
|
34 |
* Request URL can be a full URL path, the post or page ID, permalink or page slug.
|
35 |
* Option Screen to set global overrides like turning off all redirects at once, setting a global destination link, make all redirects open in a new window, etc.
|
36 |
* View a summary of all redirected pages/posts, custom post types and Quick Redirects that are currently set up.
|
59 |
* If your site uses mixes SSL, use relative links whenever possible (i.e., '/my-page/'). The plugin is designed to detect the incoming protocol and try to apply the appropriate protocol to the destination URL.
|
60 |
* Links in page/post content and links that are created using get_permalink() or the_permalink() will not open in a new window or add the rel=nofollow UNLESS you have the **Use jQuery?** option set.
|
61 |
* 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. Many times a plugin or bad code is the culprit.
|
62 |
+
* We try to test the plugin in many popular themes and alongside popular plugins. In our experience, (with exception to a few bugs from time to time) many times another plugin is the cause of the issues - or a customized theme. If you do notice a problem, please let us know at info@anadnet.com - along with the WP version, theme you are using and plugins you have installed - and we will try to troubleshoot the problem.
|
63 |
* Check the FAQs/Help located in the Plugin menu for more up to date issues and fixes.
|
64 |
|
65 |
== Installation ==
|
77 |
1. You can create a redirect with the 'Quick Redirects' option located in the Quick Redirects admin menu.
|
78 |
|
79 |
== Frequently Asked Questions ==
|
80 |
+
** SEE A LIST OF MORE UP TO DATE FAQS IN THE PLUGIN MENU ITSELF **
|
81 |
|
82 |
= Why is my Page/Post not redirecting? =
|
83 |
FIRST - make sure it is active if using Individual Redirects (set up on the edit page for a post or page). Then, check to make sure the global option to turn off all redirects is not checked (in the plugin options).
|
84 |
|
85 |
+
SECOND - if you are using Quick Redirects, try using links relative to the root (so 'http://mysite.com/contact/' would be '/contact/' if using the root path). If your site is in a sub-folder (set in Settings/General), do not use the sub-folder in the root path as it is already taken into consideration by WordPress.
|
86 |
|
87 |
NEXT - clear your site's cache files if you are using a caching plugin/theme. You may also need to clear your browser cache and internet files if you use caching - the browser WILL hold cached versions of a page and not redirect if there was no redirect in the cached version.
|
88 |
|
89 |
FINALLY - if you are not using a permalink structure of some sort, it is recommended that you set up at least a basic one. Redirects without a permalink structure can be inconsistant.
|
90 |
|
91 |
+
If your page or post is still not redirecting, then it 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. many time a plugin or bad code is the culprit - or the redirect is just simply turned off.
|
92 |
|
93 |
+
We have tested the plugin in dozens of themes and a whole lot more plugins. In our experience, (with exception to a few bugs) many times another plugin or the theme scripting is the problem. If you do notice a problem, please let us know at info@anadnet.com - along with the WP version, theme you are using and plugins you have installed - and we will try to troubleshoot the problem.
|
94 |
|
95 |
= Should I use a full URL with http:// or https:// ? =
|
96 |
Yes, you can, but you do not always need to. If you are redirecting to an external URL, then yes. If you are just redirecting to another page or post on your site, then no, it is not needed. When in doubt, use the entire URL. For Quick Redirects, it is recommended that you use relative URLs whenever possible.
|
100 |
|
101 |
= Is the plugin SEO friendly? =
|
102 |
Yes it is.
|
103 |
+
The plugin uses standard redirect status methods to redirect the URLs. SEO crawlers use the status code to determine if a page request is available, moved or if there is some other error.
|
104 |
|
105 |
If you do not want a search engine to follow a Redirect URL, use the No Follow option to add 'rel="nofollow"' to the link.
|
106 |
|
117 |
If you use a 302 redirect, the search engines will not change anything, but also index the destination page as it would any other page.
|
118 |
|
119 |
= Do I need to have a Page or Post Created to redirect? =
|
120 |
+
No. There is a Quick Redirects feature that allows you to create a redirect for any URL on your site. This is VERY helpful when you move an old site to WordPress and have old links that need to go some place new. For example,
|
121 |
If you had a link on a site that went to http://yoursite.com/aboutme.html you can now redirect that to http://yoursite.com/about/ without needing to edit the htaccess file. You simply add the old URL (/aboutme.html) and tell it you want to go to the new one (/about/). Simple as that.
|
122 |
|
123 |
The functionality is located in the QUICK REDIRECTS menu. The old URL goes in the Request field and the to new URL goes in the Destination field. Simple and Quick!
|
124 |
|
125 |
= Does the Page/Post need to be Published to redirect? =
|
126 |
+
YES... and NO... The redirect will always work on a Published Post/Page. For it to work correctly on a Post/Page in DRAFT status, you need to fist publish the page, then re-save it as a draft. If you don't follow that step, you will get a 404 error.
|
127 |
|
128 |
= Can I add 'rel="nofollow" attribute to the redirect link? =
|
129 |
YES, you can 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 only available for the Quick Redirects method when the 'Use jQuery?' functionality is enabled in the settings and you select the 'NF' box for the corresponding redirect.
|
134 |
= I still can't get the OPEN IN NEW WINDOW option to work... why? =
|
135 |
First, make sure you have the 'Use jQuery?' option set in the options page. This funcitonality drastically increases the plugin's ability to add the correct properties and attributes to the links to make them work as desired.
|
136 |
|
137 |
+
If you cannot us this option (because of a conflict with another script), then you may only have limited success with this feature.
|
138 |
The reason - some themes put custom links in the menu, like RSS and other similar items. Many times (an this is usually the main reason why), they do not use the WP hook to add the menu item to the list - they literally just put it there. Unless the theme uses the internal WordPress hooks to call the menu, redirects, open in a new window and rel=nofollow features just will not work.
|
139 |
ADDITIONALLY - Links in page/post content and Permalinks will not open in a new window or add the rel=nofollow. That is because the theme template actually sets up the links by calling "the_permalink()" function so add these elements is not consistently possible so it has been excluded from the functionality. The links will still redirect just fine but without that feature.
|
140 |
|
141 |
= 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? =
|
142 |
+
YES, you can 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.
|
143 |
|
144 |
+
Note - This option is available for the Quick Redirects only with the 'Use jQuery?' option enabled.
|
145 |
|
146 |
= I have Business Cards/Postcards/Ads that say my website is http://something.com/my-name/ or http://something.com/my-product/, but it should be a different page, can I set that up with this? =
|
147 |
YES! Just set up a Quick Redirect (see above) and set the Request URL to `/my-name/` or `/my-product/` and the Destination URL 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!
|
148 |
|
149 |
= What the heck is a 301 or 302 redirect anyway? =
|
150 |
+
Good question! The number corresponds with the header code that is returned to the browser when the page is first accessed. A good page, meaning something was found, returns a 200 status code and that tells the browser to go ahead and keep loading the content for the page. If nothing is found a 404 error is returned (and we have ALL seen these - usually it is a bad link or a page was moved). There are many other types of codes, but those are the most common.
|
151 |
|
152 |
The 300+ range of codes in the header tells the browser (and search engine spider) that the original page has moved to a new location - this can be just a new file name a new folder or a completely different site.
|
153 |
|
156 |
A 302 or 307 code tell the browser that the file was there but TEMPORARILY it can be found at a new location. This will tell the search engines to KEEP the old link in place because SOME day it will be back at the same old link. There is only a slight difference between a 302 and a 307 status. Truth is, 302 is more widely used, so unless you know why you need a 307, stick with a 302.
|
157 |
|
158 |
= So, which one do I use? =
|
159 |
+
Easiest way to decide is this: If you want the page to permanently change to a new spot, use 301. If you are editing the page or post and only want it to be down for a few hours, minutes, days or weeks and plan on putting it back with the same link as before, then us 302. If you are having trouble with the redirects, use a `meta` redirect. The meta redirect actually starts to load the page as a 200 good status, then redirects using a meta redirect tag.
|
160 |
|
161 |
Still not sure? Try 302 for now - at least until you have a little time to read up on the subject.
|
162 |
|
182 |
* THIS SECTION IS JUST TO KEEP TRACK OF TODO ITEMS FOR FUTURE UPDATES.
|
183 |
* Add New Window and No Follow to links where the URL has been rewritten. Currently if you rewrite the URL neither will work as they are referenced with the original URL, not the rewrite.
|
184 |
|
185 |
+
= 5.2.0 =
|
186 |
+
* **Resolved potential nonce vulnerability issue
|
187 |
+
|
188 |
= 5.1.9 =
|
189 |
* **New Compatibility Tested** from WordPress versions 4.3.19 up to 5.22
|
190 |
|
234 |
* Added Meta Redirect Options Page - this splits out Meta Options from the main options page.
|
235 |
* Added more enhanced meta redirect scripting to allow for tracking or other page content (including countdown if desired).
|
236 |
* Fixed Layout issues on Quick Redirect Page making it impossible to edit redirects in some cases.
|
237 |
+
* Fixed a few spelling errors.
|
238 |
* Added Help Content to Meta Options page.
|
239 |
* Added metabox setting for meta redirect seconds for individual redirects so you can set different time for each meta redirect.
|
240 |
* Update POT and English Translation file - added limited Spanish translations.
|
287 |
* Added jQuery version check to ensure no problems with themes forcing older versions of jQuery
|
288 |
* Added a few warning /info messages to Quick Redirects page.
|
289 |
* Redirect summary was updated to display Quick Redirects as well as individual redirects. Now it is easier to see at a glance what redirects you have set up.
|
290 |
+
* Rewrite of Quick Redirects functions to allow selecting Open in New Window (NW) and rel=nofollow (NF) as long as **use jQuery?** is selected.
|
291 |
* Added "use jQuery" option on settings page - on by default after upgrade
|
292 |
* Added jQuery redirect replace, target="_blank", and rel="nofollow" to increase success for additional options (mainly Quick redirects).
|
293 |
* Changed out WP_PLUGIN_URL for plugins_url() to help resolve errors in redirects for SSL/https
|
337 |
= 3.2.1 =
|
338 |
* limited test release - testing for some of 3.2.2 release fixes. (12/14/10)
|
339 |
= 3.2 =
|
340 |
+
* remove functions ppr_linktotarget, ppr_linktonorel, ppr_redirectto and ppr_linktometa.(12/10/2010)
|
341 |
+
* re-write functions to consolidate queries. (12/10/2010)
|
342 |
+
* added new filters for New menu structure to filter wp_nav_menu menus as well as old wp_page_menus functions. (12/10/2010)
|
343 |
+
* cleaned up new window and nofollow code to work more consistently. (12/10/2010)
|
344 |
= 3.1 =
|
345 |
* Re-issue of 2.1 for immediate fix of issue with the 3.0 version.(6/21/2010)
|
346 |
= 3.0 =
|
349 |
* Fix Bug - Open in New Window would not work unless Show Link URL was also selected. (3/12/2010)
|
350 |
* Fix Bug - Add rel=nofollow would not work if Open in a New Window was not selected. (3/13/2010)
|
351 |
* Fix Bug - Show Link, Add nofollow and Open in New Window would still work when redirect not active. (3/13/2010)
|
352 |
+
* Added new preg_match_all and preg_replace calls to add target and nofollow links - more efficient and accurate - noticed some cases where old function would add the items if a redirect link had the same URL. (3/13/2010)
|
353 |
= 2.0 =
|
354 |
* Cosmetic code cleanup. (2/28/2010)
|
355 |
* Remove warning and error messages created in 1.9 (2/28/2010)
|
363 |
= 1.7 =
|
364 |
* fix to correct meta redirect - moved "exit" command to "addtoheader_theme" function. Also fixed the problem with some pages not redirecting. Made the plugin WordPress MU compatible. (9/8/2009)
|
365 |
= 1.6.1 =
|
366 |
+
* Small fix to correct the same problem as 1.6 for Category and Archive pages (9/1/2009)
|
367 |
= 1.6 =
|
368 |
* Fixed wrongful redirect when the first blog post on home page (main blog page) has a redirect set up - this was redirecting the entire page incorrectly. This was only an issue with the first post on a page. (9/1/2009)
|
369 |
= 1.5 =
|
370 |
+
* Major re-Write of the plugin core function to hook WP at a later time to take advantage of the POST function - no sense re-creating the wheel.
|
371 |
* Removed the 'no code' redirect, as it turns out, many browsers will not redirect properly without a code - sorry guys.
|
372 |
* Can have page/post as draft and still redirect - but ONLY after the post/page has first been published and then re-saved as draft (this will hopefully be a fix for a later version). (8/31/2009)
|
373 |
= 1.4 =
|
374 |
* Add exit script command after header redirect function - needed on some servers and browsers. (8/19/2009)
|
375 |
+
= 1.3 =
|
376 |
* Add Meta Re-fresh option (7/26/2009)
|
377 |
+
= 1.2 =
|
378 |
* Add easy Post/Page Edit Box (7/25/2009)
|
379 |
+
= 1.1 =
|
380 |
* Fix redirect for off site links (7/7/2009)
|
381 |
+
= 1.0 =
|
382 |
* Initial Plugin creation (7/1/2009)
|
383 |
|
384 |
== Upgrade Notice ==
|
385 |
= 5.1.5 =
|
386 |
+
* Bug Fixes.
|