Version Description
- Rewrite of all functions for better optimization.(05/01/2011)
- Added consolidated DB call at class setup to reduce DB calls to one call per page load.(05/01/2011)
- Moved entire plugin into a class for easier updates.(05/01/2011)
- Added new Options page with Global Overrides.(05/02/2011)
- Integrated Custom Post Types functionality.(05/02/2011)
- Created a Summary Page for a quick glace of set up redirects.(05/04/2011)
- Moved Quick Redirects menu from settings to a new Redirects Menu.(05/03/2011)
- Added additional checks and validations when adding Quick Redirects.(05/03/2011)
- Added a way to delete Quick Redirects easier.(03/01/2011)
Download this release
Release Info
Developer | prophecy2040 |
Plugin | Quick Page/Post Redirect Plugin |
Version | 4.0 |
Comparing to | |
See all releases |
Code changes from version 3.2.3 to 4.0
- page_post_redirect_plugin.php +727 -445
- readme.txt +65 -47
- screenshot-1.jpg +0 -0
- screenshot-2.jpg +0 -0
- screenshot-3.jpg +0 -0
- screenshot-4.jpg +0 -0
- settings-16-icon.png +0 -0
- settings-icon.png +0 -0
page_post_redirect_plugin.php
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
-
<?php
|
2 |
/*
|
3 |
Plugin Name: Quick Page/Post Redirect
|
4 |
-
Plugin URI: http://fischercreativemedia.com/wordpress-plugins/quick-pagepost-
|
5 |
-
Description: Redirect Pages
|
6 |
Author: Don Fischer
|
7 |
Author URI: http://www.fischercreativemedia.com/
|
8 |
Donate link: http://www.fischercreativemedia.com/wordpress-plugins/donate/
|
9 |
-
Version:
|
10 |
|
11 |
Version info:
|
12 |
See change log in readme.txt file.
|
13 |
|
14 |
-
Copyright (C) 2009
|
15 |
|
16 |
This program is free software: you can redistribute it and/or modify
|
17 |
it under the terms of the GNU General Public License as published by
|
@@ -26,206 +26,521 @@ See change log in readme.txt file.
|
|
26 |
You should have received a copy of the GNU General Public License
|
27 |
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
28 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
//=======================================
|
31 |
-
// Redirect Class
|
32 |
-
// Original Simple 301 Redirects Class created by Scott Nelle (http://www.scottnelle.com/)
|
33 |
//=======================================
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
}
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
</tr>
|
94 |
-
|
95 |
-
|
96 |
-
<p class="submit">
|
97 |
-
<input type="submit" name="submit_301" class="button-primary" value="<?php _e('Save Changes') ?>" />
|
98 |
-
</p>
|
99 |
-
</form>
|
100 |
-
</div>
|
101 |
-
|
102 |
-
<?php
|
103 |
-
} // end of function options_page
|
104 |
-
|
105 |
-
//utility function to return the current list of redirects as form fields
|
106 |
-
function expand_redirects(){
|
107 |
-
$redirects = get_option('quickppr_redirects');
|
108 |
-
$output = '';
|
109 |
-
if (!empty($redirects)) {
|
110 |
-
$ww=1;
|
111 |
-
foreach ($redirects as $request => $destination) {
|
112 |
-
$output .= '
|
113 |
-
<tr id="rowpprdel-'.$ww.'">
|
114 |
-
<td><input type="text" name="quickppr_redirects[request][]" value="'.$request.'" style="width:35em" /> » </td>
|
115 |
-
<td><input type="text" name="quickppr_redirects[destination][]" value="'.$destination.'" style="width:35em;" /></td>
|
116 |
-
<td> <a href="javascript:void();" id="pprdel-'.$ww.'" class="delete-qppr">x</a> </td>
|
117 |
-
</tr>
|
118 |
-
';
|
119 |
-
$ww++;
|
120 |
-
}
|
121 |
-
} // end if
|
122 |
-
return $output;
|
123 |
}
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
$redirects = array();
|
128 |
-
|
129 |
-
for($i = 0; $i < sizeof($data['request']); ++$i) {
|
130 |
-
$request = trim($data['request'][$i]);
|
131 |
-
$destination = trim($data['destination'][$i]);
|
132 |
-
|
133 |
-
if ($request == '' && $destination == '') { continue; }
|
134 |
-
else { $redirects[$request] = $destination; }
|
135 |
-
}
|
136 |
|
137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
}
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
}
|
158 |
-
} // end funcion redirect
|
159 |
-
|
160 |
-
//utility function to get the full address of the current request - credit: http://www.phpro.org/examples/Get-Full-URL.html
|
161 |
-
function getAddress(){
|
162 |
-
if(!isset($_SERVER['HTTPS'])){$_SERVER['HTTPS']='';}
|
163 |
-
$protocol = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http'; //check for https
|
164 |
-
return $protocol.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; //return the full address
|
165 |
}
|
166 |
-
|
167 |
-
} // end class quick_page_post_redirects
|
168 |
-
} // end check for existance of class
|
169 |
|
170 |
-
|
171 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
global $wp_query;
|
177 |
-
global $ppr_nofollow;
|
178 |
-
global $ppr_newindow;
|
179 |
-
global $ppr_url;
|
180 |
-
global $ppr_url_rewrite;
|
181 |
-
global $ppr_type;
|
182 |
-
global $ppr_curr_version;
|
183 |
-
global $ppr_metaurl;
|
184 |
-
$ppr_curr_version = '3.2.1';
|
185 |
-
$ppr_nofollow = array();
|
186 |
-
$ppr_newindow = array();
|
187 |
-
$ppr_url = array();
|
188 |
-
$ppr_url_rewrite = array();
|
189 |
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
}
|
206 |
|
207 |
-
|
208 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
function ppr_queryhook($vars) {
|
210 |
$vars[] = 'pprd';
|
211 |
$vars[] = 'scid';
|
212 |
return $vars;
|
213 |
}
|
214 |
-
|
215 |
-
//Hook into the Query Parse and get our vars to see if the page is the one we want.
|
216 |
function ppr_parse_request($wp) {
|
217 |
global $wp;
|
218 |
-
$quickppr_redirects = array();
|
219 |
if(array_key_exists('pprd', $wp->query_vars) && array_key_exists('scid', $wp->query_vars)){
|
220 |
$tohash = get_bloginfo('url').'/';
|
221 |
-
if( $wp->query_vars['pprd'] !='' && $wp->query_vars['scid'] == md5(
|
222 |
$theDel = str_replace('pprdel-','',$wp->query_vars['pprd']);
|
223 |
$redirects = get_option('quickppr_redirects');
|
224 |
if (!empty($redirects)) {
|
225 |
$ww=1;
|
226 |
foreach ($redirects as $request => $destination) {
|
227 |
if($ww != (int)$theDel){
|
228 |
-
$quickppr_redirects[$request]
|
229 |
}
|
230 |
$ww++;
|
231 |
}
|
@@ -240,226 +555,37 @@ See change log in readme.txt file.
|
|
240 |
}else{
|
241 |
return;
|
242 |
}
|
243 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
}
|
245 |
|
246 |
function ppr_filter_plugin_actions($links){
|
247 |
$new_links = array();
|
248 |
-
$
|
249 |
-
$new_links[] = '<a href="'.$fcmlink.'/donate/">Donate</a>';
|
250 |
return array_merge($links,$new_links );
|
251 |
}
|
|
|
252 |
function ppr_filter_plugin_links($links, $file){
|
253 |
if ( $file == plugin_basename(__FILE__) ){
|
254 |
-
$
|
255 |
-
$
|
256 |
-
$links[] = '<a href="'.$
|
257 |
-
$links[] = '<a target="_blank" href="'.$fcmlink.'/quick-pagepost-redirect-plugin/">FAQ</a>';
|
258 |
-
$links[] = '<a target="_blank" href="'.$fcmlink.'/donate/">Donate</a>';
|
259 |
}
|
260 |
return $links;
|
261 |
}
|
262 |
|
263 |
-
function ppr_new_nav_menu($items){
|
264 |
-
global $ppr_nofollow;
|
265 |
-
global $ppr_newindow;
|
266 |
-
global $ppr_url;
|
267 |
-
global $ppr_url_rewrite;
|
268 |
-
global $ppr_type;
|
269 |
-
add_filter( 'wp_get_nav_menu_items','ppr_new_nav_menu_fix',1,1);
|
270 |
-
add_filter( 'wp_list_pages','ppr_fix_targetsandrels');
|
271 |
-
add_filter( 'page_link','ppr_filter_pages',20, 2 );
|
272 |
-
add_filter( 'post_link','ppr_filter_pages',20, 2 );
|
273 |
-
return $items;
|
274 |
-
}
|
275 |
-
|
276 |
-
function ppr_new_nav_menu_fix($ppr){
|
277 |
-
global $ppr_nofollow;
|
278 |
-
global $ppr_newindow;
|
279 |
-
global $ppr_url;
|
280 |
-
global $ppr_url_rewrite;
|
281 |
-
global $ppr_type;
|
282 |
-
global $wpdb;
|
283 |
-
$thefirstppr = array();
|
284 |
-
|
285 |
-
$select_tiems = $wpdb->get_results("SELECT post_id,meta_key,meta_value FROM $wpdb->postmeta WHERE (meta_key='_pprredirect_type' OR meta_key='_pprredirect_url' OR meta_key='_pprredirect_rewritelink' OR meta_key = '_pprredirect_active' OR meta_key='_pprredirect_newwindow' OR meta_key='_pprredirect_relnofollow') AND meta_value!='' ORDER BY post_id ASC;");
|
286 |
-
if(!empty($select_tiems)){
|
287 |
-
foreach($select_tiems as $pprs){
|
288 |
-
$thefirstppr[$pprs->post_id][$pprs->meta_key] = $pprs->meta_value;
|
289 |
-
$thefirstppr[$pprs->post_id]['post_id'] = $pprs->post_id;
|
290 |
-
}
|
291 |
-
}
|
292 |
-
if(!empty($thefirstppr)){
|
293 |
-
foreach($thefirstppr as $ppitems){
|
294 |
-
if(isset($ppitems['_pprredirect_active']) && isset($ppitems['_pprredirect_newwindow'])){
|
295 |
-
$ppr_newindow[] = $ppitems['post_id'];
|
296 |
-
}
|
297 |
-
if(isset($ppitems['_pprredirect_active']) && isset($ppitems['_pprredirect_relnofollow'])){
|
298 |
-
$ppr_nofollow[] = $ppitems['post_id'];
|
299 |
-
}
|
300 |
-
if(isset($ppitems['_pprredirect_active']) && isset($ppitems['_pprredirect_rewritelink']) && isset($ppitems['_pprredirect_url'])){
|
301 |
-
$ppr_url_rewrite[] = $ppitems['post_id'];
|
302 |
-
$ppr_url[$ppitems['post_id']]['URL'] = $ppitems['_pprredirect_url'];
|
303 |
-
}
|
304 |
-
if(isset($ppitems['_pprredirect_active']) && isset($ppitems['_pprredirect_type'])){
|
305 |
-
$ppr_type[$ppitems['post_id']]['type'] = $ppitems['_pprredirect_type'];
|
306 |
-
}
|
307 |
-
}
|
308 |
-
}
|
309 |
-
$newmenu = array();
|
310 |
-
if(!empty($ppr)){
|
311 |
-
foreach($ppr as $ppd){
|
312 |
-
if(in_array($ppd->object_id,$ppr_newindow)){
|
313 |
-
$ppd->target = '_blank';
|
314 |
-
$ppd->classes[] = 'ppr-new-window';
|
315 |
-
}
|
316 |
-
if(in_array($ppd->object_id,$ppr_nofollow)){
|
317 |
-
$ppd->xfn = 'nofollow';
|
318 |
-
$ppd->classes[] = 'ppr-nofollow';
|
319 |
-
}
|
320 |
-
if(in_array($ppd->object_id,$ppr_url_rewrite)){
|
321 |
-
$ppd->url = $ppr_url[$ppd->object_id]['URL'];
|
322 |
-
$ppd->classes[] = 'ppr-rewrite';
|
323 |
-
|
324 |
-
}
|
325 |
-
$newmenu[] = $ppd;
|
326 |
-
}
|
327 |
-
}
|
328 |
-
return $newmenu;
|
329 |
-
}
|
330 |
-
|
331 |
-
function ppr_init_metaclean() {
|
332 |
-
global $ppr_curr_version;
|
333 |
-
$thepprversion = get_option('ppr_version');
|
334 |
-
if($thepprversion != $ppr_curr_version){
|
335 |
-
update_option( 'ppr_version', $ppr_curr_version );
|
336 |
-
}
|
337 |
-
}
|
338 |
-
|
339 |
-
// For WordPress < 2.8 function compatibility
|
340 |
-
if (!function_exists('esc_attr')) {
|
341 |
-
function esc_attr($attr){return attribute_escape( $attr );}
|
342 |
-
function esc_url($url){return clean_url( $url );}
|
343 |
-
}
|
344 |
-
|
345 |
-
function ppr_filter_pages ($link, $post) {
|
346 |
-
global $ppr_nofollow;
|
347 |
-
global $ppr_newindow;
|
348 |
-
global $ppr_url;
|
349 |
-
global $ppr_url_rewrite;
|
350 |
-
global $ppr_type;
|
351 |
-
global $wpdb;
|
352 |
-
|
353 |
-
if(isset($post->ID)){
|
354 |
-
$id = $post->ID;
|
355 |
-
}else{
|
356 |
-
$id = $post;
|
357 |
-
}
|
358 |
-
if(is_array($ppr_url_rewrite)){
|
359 |
-
if(in_array($id, $ppr_url_rewrite)){
|
360 |
-
$newURL = $ppr_url[$id]['URL'];
|
361 |
-
if(strpos($newURL,get_bloginfo('url'))>=0 || strpos($newURL,'www.')>=0 || strpos($newURL,'http://')>=0 || strpos($newURL,'https://')>=0){
|
362 |
-
$link = esc_url( $newURL );
|
363 |
-
}else{
|
364 |
-
$link = esc_url( get_bloginfo('url').'/'. $newURL );
|
365 |
-
}
|
366 |
-
}
|
367 |
-
}
|
368 |
-
|
369 |
-
return $link;
|
370 |
-
}
|
371 |
-
|
372 |
-
function addmetatohead_theme(){
|
373 |
-
global $ppr_metaurl;
|
374 |
-
$meta_code = '<meta http-equiv="refresh" content="0; URL='.$ppr_metaurl.'" />';
|
375 |
-
echo $meta_code;
|
376 |
-
exit;//stop loading page so meta can do it's job without rest of page loading.
|
377 |
-
}
|
378 |
-
|
379 |
-
function ppr_do_redirect(){
|
380 |
-
global $post,$wp_query,$ppr_active,$wpdb;
|
381 |
-
$select_tiems = $wpdb->get_results("SELECT post_id,meta_key,meta_value FROM $wpdb->postmeta WHERE (meta_key='_pprredirect_type' OR meta_key='_pprredirect_url' OR meta_key = '_pprredirect_active') AND meta_value!='' ORDER BY post_id ASC;");
|
382 |
-
if(!empty($select_tiems)){
|
383 |
-
foreach($select_tiems as $pprs){
|
384 |
-
$thefirstppr[$pprs->post_id][$pprs->meta_key] = $pprs->meta_value;
|
385 |
-
$thefirstppr[$pprs->post_id]['post_id'] = $pprs->post_id;
|
386 |
-
}
|
387 |
-
}
|
388 |
-
if(!empty($thefirstppr)){
|
389 |
-
foreach($thefirstppr as $ppitems){
|
390 |
-
if(isset($ppitems['_pprredirect_active']) && isset($ppitems['_pprredirect_url'])){
|
391 |
-
$ppr_url_rewrite[] = $ppitems['post_id'];
|
392 |
-
$ppr_url[$ppitems['post_id']]['URL'] = $ppitems['_pprredirect_url'];
|
393 |
-
}
|
394 |
-
if(isset($ppitems['_pprredirect_active']) && isset($ppitems['_pprredirect_type'])){
|
395 |
-
$ppr_type[$ppitems['post_id']]['type'] = $ppitems['_pprredirect_type'];
|
396 |
-
}
|
397 |
-
|
398 |
-
}
|
399 |
-
}
|
400 |
-
if($wp_query->is_single || $wp_query->is_page ):
|
401 |
-
$thisidis_current = $post->ID;
|
402 |
-
global $ppr_metaurl;
|
403 |
-
if(isset($ppr_type[$thisidis_current]['type'])){$ppr_types = $ppr_type[$thisidis_current]['type'];}else{$ppr_types = '';}
|
404 |
-
if(isset($ppr_url[$thisidis_current]['URL'])){$ppr_urls = $ppr_url[$thisidis_current]['URL'];}else{$ppr_urls='';}
|
405 |
-
|
406 |
-
if( $ppr_urls!=''):
|
407 |
-
if($ppr_types===0){$ppr_types='200';}
|
408 |
-
if($ppr_types===''){$ppr_types='302';}
|
409 |
-
if($ppr_types=='meta'):
|
410 |
-
//metaredirect
|
411 |
-
$ppr_metaurl = $ppr_urls;
|
412 |
-
add_action('wp_head', "addmetatohead_theme",1);
|
413 |
-
else:
|
414 |
-
//check for http:// - as full url - then we can just redirect if it is //
|
415 |
-
if( strpos($ppr_urls, 'http://')=== 0 || strpos($ppr_urls, 'https://')=== 0){
|
416 |
-
$offsite=$ppr_urls;
|
417 |
-
header('Status: '.$ppr_types);
|
418 |
-
header('Location: '.$offsite, true, $ppr_types);
|
419 |
-
exit; //stop loading page
|
420 |
-
}elseif(strpos($ppr_urls, 'www')=== 0){ //check if they have full url but did not put http://
|
421 |
-
$offsite='http://'.$ppr_urls;
|
422 |
-
header("Status: $ppr_types");
|
423 |
-
header("Location: $offsite", true, $ppr_types);
|
424 |
-
exit; //stop loading page
|
425 |
-
}elseif(is_numeric($ppr_urls)){ // page/post number
|
426 |
-
if($ppr_postpage=='page'){ //page
|
427 |
-
$onsite=get_bloginfo('url').'/?page_id='.$ppr_url;
|
428 |
-
header("Status: $ppr_types");
|
429 |
-
header("Location: $onsite", true, $ppr_types);
|
430 |
-
exit; //stop loading page
|
431 |
-
}else{ //post
|
432 |
-
$onsite=get_bloginfo('url').'/?p='.$ppr_urls;
|
433 |
-
header("Status: $ppr_types");
|
434 |
-
header("Location: $onsite", true, $ppr_types);
|
435 |
-
exit; //stop loading page
|
436 |
-
}
|
437 |
-
//check permalink or local page redirect
|
438 |
-
}else{ // we assume they are using the permalink / page name??
|
439 |
-
$onsite=get_bloginfo('url'). $ppr_urls;
|
440 |
-
header("Location: $onsite", true, $ppr_types);
|
441 |
-
exit; //stop loading page
|
442 |
-
}
|
443 |
-
|
444 |
-
endif;
|
445 |
-
endif;
|
446 |
-
endif;
|
447 |
-
}
|
448 |
-
|
449 |
-
|
450 |
-
//=======================================
|
451 |
-
// Add options to post/page edit pages
|
452 |
-
//=======================================
|
453 |
-
// Adds a custom section to the Post and Page edit screens
|
454 |
-
function add_edit_box_ppr() {
|
455 |
-
if( function_exists( 'add_meta_box' )) {
|
456 |
-
add_meta_box( 'edit-box-ppr', __( 'Quick Page/Post Redirect', 'ppr_plugin' ), 'edit_box_ppr_1', 'page', 'normal', 'high' ); //for page
|
457 |
-
add_meta_box( 'edit-box-ppr', __( 'Quick Page/Post Redirect', 'ppr_plugin' ), 'edit_box_ppr_1', 'post', 'normal', 'high' ); //for post
|
458 |
-
}
|
459 |
-
}
|
460 |
-
|
461 |
-
// Prints the inner fields for the custom post/page section
|
462 |
function edit_box_ppr_1() {
|
|
|
463 |
global $post;
|
464 |
$ppr_option1='';
|
465 |
$ppr_option2='';
|
@@ -470,15 +596,15 @@ See change log in readme.txt file.
|
|
470 |
wp_nonce_field( 'pprredirect_noncename', 'pprredirect_noncename', false, true );
|
471 |
|
472 |
// The actual fields for data entry
|
473 |
-
echo '<label for="pprredirect_active" style="padding:2px 0;"><input type="checkbox" name="pprredirect_active" value="1" '. checked('1',get_post_meta($post->ID,'_pprredirect_active',true),0).' />
|
474 |
-
echo '<label for="pprredirect_newwindow" style="padding:2px 0;"><input type="checkbox" name="pprredirect_newwindow" id="pprredirect_newwindow" value="_blank" '. checked('_blank',get_post_meta($post->ID,'_pprredirect_newwindow',true),0).'>
|
475 |
-
echo '<label for="pprredirect_relnofollow" style="padding:2px 0;"><input type="checkbox" name="pprredirect_relnofollow" id="pprredirect_relnofollow" value="1" '. checked('1',get_post_meta($post->ID,'_pprredirect_relnofollow',true),0).'>
|
476 |
-
echo '<label for="pprredirect_rewritelink" style="padding:2px 0;"><input type="checkbox" name="pprredirect_rewritelink" id="pprredirect_rewritelink" value="1" '. checked('1',get_post_meta($post->ID,'_pprredirect_rewritelink',true),0).'
|
477 |
-
echo '<label for="pprredirect_url"
|
478 |
if(get_post_meta($post->ID, '_pprredirect_url', true)!=''){$pprredirecturl=get_post_meta($post->ID, '_pprredirect_url', true);}else{$pprredirecturl="";}
|
479 |
echo '<input type="text" style="width:75%;margin-top:2px;margin-bottom:2px;" name="pprredirect_url" value="'.$pprredirecturl.'" /><br />(i.e., <code>http://example.com</code> or <code>/somepage/</code> or <code>p=15</code> or <code>155</code>. Use <b>FULL URL</b> <i>including</i> <code>http://</code> for all external <i>and</i> meta redirects. )<br /><br />';
|
480 |
|
481 |
-
echo '<label for="pprredirect_type">
|
482 |
if(get_post_meta($post->ID, '_pprredirect_type', true)!=''){$pprredirecttype=get_post_meta($post->ID, '_pprredirect_type', true);}else{$pprredirecttype="";}
|
483 |
switch($pprredirecttype):
|
484 |
case "":
|
@@ -499,104 +625,117 @@ See change log in readme.txt file.
|
|
499 |
endswitch;
|
500 |
|
501 |
echo '<select style="margin-top:2px;margin-bottom:2px;width:40%;" name="pprredirect_type"><option value="301" '.$ppr_option1.'>301 Permanent</option><option value="302" '.$ppr_option2.'>302 Temporary</option><option value="307" '.$ppr_option3.'>307 Temporary</option><option value="meta" '.$ppr_option5.'>Meta Redirect</option></select> (Default is 302)<br /><br />';
|
502 |
-
echo '<b>NOTE:</b> For This Option to work, the page or post needs to be published for the redirect to happen <i><b>UNLESS</b></i> you publish it first, then save it as a Draft. If you want to add a redirect without adding a page/post or having it published, use the <a href="./options-general.php?page=
|
503 |
}
|
504 |
|
505 |
-
|
506 |
-
|
507 |
-
function ppr_save_postdata($post_id, $post) {
|
508 |
if(isset($_REQUEST['pprredirect_noncename']) && (isset($_POST['pprredirect_active']) || isset($_POST['pprredirect_url']) || isset($_POST['pprredirect_type']) || isset($_POST['pprredirect_newwindow']) || isset($_POST['pprredirect_relnofollow']))):
|
|
|
|
|
509 |
// verify authorization
|
510 |
if(isset($_POST['pprredirect_noncename'])){
|
511 |
if ( !wp_verify_nonce( $_REQUEST['pprredirect_noncename'], 'pprredirect_noncename' )) {
|
512 |
-
return $
|
513 |
}
|
514 |
}
|
515 |
-
|
516 |
// check allowed to editing
|
517 |
-
if ( '
|
518 |
-
|
519 |
-
return $post->ID;
|
520 |
-
} else {
|
521 |
-
if ( !current_user_can( 'edit_post', $post->ID ))
|
522 |
-
return $post->ID;
|
523 |
}
|
524 |
-
|
525 |
// find & save the form data & put it into an array
|
526 |
-
$
|
527 |
-
$
|
528 |
-
$
|
529 |
-
$
|
530 |
-
$
|
531 |
-
$
|
532 |
|
533 |
-
if ( 0 === strpos($
|
534 |
-
$
|
535 |
|
536 |
-
if($
|
537 |
-
$
|
538 |
-
$
|
539 |
}
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
|
|
544 |
$value = implode(',', (array)$value); //if $value is an array, make it a CSV (unlikely)
|
545 |
|
546 |
-
if(
|
547 |
-
|
548 |
-
}
|
549 |
-
|
|
|
|
|
|
|
|
|
550 |
}
|
551 |
-
|
552 |
-
if(!$value) delete_post_meta($post->ID, $key); //delete if blank
|
553 |
}
|
554 |
}
|
555 |
endif;
|
556 |
}
|
557 |
|
558 |
function ppr_fix_targetsandrels($pages) {
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
global $wpdb;
|
565 |
-
|
566 |
-
if (!$ppr_url && !$ppr_newindow && !$ppr_nofollow){
|
567 |
$thefirstppr = array();
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
|
|
573 |
}
|
574 |
}
|
575 |
if(!empty($thefirstppr)){
|
576 |
foreach($thefirstppr as $ppitems){
|
577 |
-
if(
|
578 |
-
|
|
|
|
|
|
|
|
|
579 |
}
|
580 |
-
|
|
|
581 |
$ppr_nofollow[] = $ppitems['post_id'];
|
|
|
|
|
|
|
|
|
582 |
}
|
583 |
-
|
584 |
-
|
585 |
-
$
|
586 |
-
|
587 |
-
|
588 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
589 |
}
|
590 |
}
|
591 |
}
|
592 |
|
593 |
-
if (
|
594 |
return $pages;
|
595 |
}
|
596 |
}
|
597 |
|
598 |
$this_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
599 |
-
|
600 |
if(count($ppr_nofollow)>=1) {
|
601 |
foreach($ppr_nofollow as $relid){
|
602 |
$validexp="@\<li(?:.*?)".$relid."(?:.*?)\>\<a(?:.*?)rel\=\"nofollow\"(?:.*?)\>@i";
|
@@ -620,7 +759,150 @@ See change log in readme.txt file.
|
|
620 |
}
|
621 |
}
|
622 |
}
|
623 |
-
|
624 |
return $pages;
|
625 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
626 |
?>
|
1 |
+
<?php
|
2 |
/*
|
3 |
Plugin Name: Quick Page/Post Redirect
|
4 |
+
Plugin URI: http://www.fischercreativemedia.com/wordpress-plugins/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: Don Fischer
|
7 |
Author URI: http://www.fischercreativemedia.com/
|
8 |
Donate link: http://www.fischercreativemedia.com/wordpress-plugins/donate/
|
9 |
+
Version: 4.0.1
|
10 |
|
11 |
Version info:
|
12 |
See change log in readme.txt file.
|
13 |
|
14 |
+
Copyright (C) 2009-2011 Donald J. Fischer
|
15 |
|
16 |
This program is free software: you can redistribute it and/or modify
|
17 |
it under the terms of the GNU General Public License as published by
|
26 |
You should have received a copy of the GNU General Public License
|
27 |
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
28 |
*/
|
29 |
+
|
30 |
+
if (!function_exists('esc_attr')) {
|
31 |
+
// For WordPress < 2.8 function compatibility
|
32 |
+
function esc_attr($attr){return attribute_escape( $attr );}
|
33 |
+
function esc_url($url){return clean_url( $url );}
|
34 |
+
}
|
35 |
|
36 |
//=======================================
|
37 |
+
// Main Redirect Class.
|
|
|
38 |
//=======================================
|
39 |
+
class quick_page_post_reds {
|
40 |
+
public $ppr_nofollow;
|
41 |
+
public $ppr_newindow;
|
42 |
+
public $ppr_url;
|
43 |
+
public $ppr_url_rewrite;
|
44 |
+
public $ppr_type;
|
45 |
+
public $ppr_curr_version;
|
46 |
+
public $ppr_metaurlnew;
|
47 |
+
public $thepprversion;
|
48 |
+
public $thepprmeta;
|
49 |
+
public $quickppr_redirects;
|
50 |
+
public $tohash;
|
51 |
+
public $fcmlink;
|
52 |
+
public $adminlink;
|
53 |
+
public $ppr_all_redir_array;
|
54 |
+
public $homelink;
|
55 |
+
public $updatemsg;
|
56 |
+
public $pproverride_nofollow;
|
57 |
+
public $pproverride_newwin;
|
58 |
+
public $pproverride_type;
|
59 |
+
public $pproverride_active;
|
60 |
+
public $pproverride_URL;
|
61 |
+
public $pproverride_rewrite;
|
62 |
+
public $pprmeta_seconds;
|
63 |
+
public $pprmeta_message;
|
64 |
+
|
65 |
+
function __construct() {
|
66 |
+
$this->ppr_curr_version = '4.0';
|
67 |
+
$this->ppr_nofollow = array();
|
68 |
+
$this->ppr_newindow = array();
|
69 |
+
$this->ppr_url = array();
|
70 |
+
$this->ppr_url_rewrite = array();
|
71 |
+
$this->thepprversion = get_option('ppr_version');
|
72 |
+
$this->thepprmeta = get_option('ppr_meta_clean');
|
73 |
+
$this->quickppr_redirects = get_option('quickppr_redirects');
|
74 |
+
$this->homelink = get_option('home');
|
75 |
+
$this->pproverride_nofollow = get_option( 'ppr_override-nofollow' );
|
76 |
+
$this->pproverride_newwin = get_option( 'ppr_override-newwindow' );
|
77 |
+
$this->pproverride_type = get_option( 'ppr_override-redirect-type' );
|
78 |
+
$this->pproverride_active = get_option( 'ppr_override-active' );
|
79 |
+
$this->pproverride_URL = get_option( 'ppr_override-URL' );
|
80 |
+
$this->pproverride_rewrite = get_option( 'ppr_override-rewrite' );
|
81 |
+
$this->pprmeta_message = get_option( 'ppr_meta-message' );
|
82 |
+
$this->pprmeta_seconds = get_option( 'ppr_meta-seconds' );
|
83 |
+
$this->adminlink = get_bloginfo('url').'/wp-admin/';
|
84 |
+
$this->fcmlink = 'http://www.fischercreativemedia.com/wordpress-plugins';
|
85 |
+
$this->ppr_metaurl = '';
|
86 |
+
$this->ppr_all_redir_array = $this->get_main_array();
|
87 |
+
$this->updatemsg = '';
|
88 |
+
if($this->pprmeta_seconds==''){$this->pprmeta_seconds='0';}
|
89 |
|
90 |
+
//these are for all the time - even if there are overrides
|
91 |
+
add_action( 'init', array($this,'ppr_init_check_version'), 1 ); // checks version of plugin in DB and updates if needed.
|
92 |
+
add_action( 'save_post', array($this,'ppr_save_metadata'),20,2 ); // save the custom fields
|
93 |
+
add_action( 'wp',array($this,'ppr_parse_request') ); // parse query vars
|
94 |
+
add_action( 'admin_menu', array($this,'ppr_add_menu') ); // add the menu items needed
|
95 |
+
add_action( 'admin_menu', array($this,'ppr_add_metabox') ); // add the metaboxes where needed
|
96 |
+
add_action( 'plugin_action_links_' . plugin_basename(__FILE__), array($this,'ppr_filter_plugin_actions') );
|
97 |
+
add_filter( 'query_vars',array($this,'ppr_queryhook') );
|
98 |
+
add_filter( 'plugin_row_meta', array($this,'ppr_filter_plugin_links'), 10, 2 );
|
99 |
+
|
100 |
+
if($this->pproverride_active!='1' && !is_admin()){ // don't run these if override active is set
|
101 |
+
add_action( 'init', array($this,'redirect'), 1 ); // add the 301 redirect action, high priority
|
102 |
+
add_action( 'init', array($this,'redirect_post_type'), 1 ); // add the normal redirect action, high priority
|
103 |
+
add_action( 'template_redirect',array($this,'ppr_do_redirect'), 1, 2); // do the redirects
|
104 |
+
add_filter( 'wp_get_nav_menu_items',array($this,'ppr_new_nav_menu_fix'),1,1 );
|
105 |
+
add_filter( 'wp_list_pages',array($this,'ppr_fix_targetsandrels') );
|
106 |
+
add_filter( 'page_link',array($this,'ppr_filter_page_links'),20, 2 );
|
107 |
+
add_filter( 'post_link',array($this,'ppr_filter_page_links'),20, 2 );
|
108 |
+
add_filter( 'post_type_link', array($this, 'ppr_filter_page_links'), 20, 2 );
|
109 |
+
add_filter( 'get_permalink', array($this, 'ppr_filter_links'), 20, 2 );
|
110 |
+
}
|
111 |
|
112 |
+
if (isset( $_POST['submit_301']) ) {$this->quickppr_redirects = $this->save_redirects($_POST['quickppr_redirects']);$this->updatemsg ='Quick Redirects Updated.';} //if submitted, process the data
|
113 |
+
if (isset( $_REQUEST['settings-updated'] ) && $_REQUEST['settings-updated']=='true'){$this->updatemsg ='Settings Updated.';}
|
114 |
+
}
|
115 |
+
|
116 |
+
function ppr_add_menu(){
|
117 |
+
add_menu_page('Redirect Menu', 'Redirect Menu', 'administrator', 'redirect-options', array($this,'ppr_settings_page'),WP_PLUGIN_URL.'/quick-pagepost-redirect-plugin/settings-16-icon.png');
|
118 |
+
add_submenu_page( 'redirect-options', 'Quick Redirects', 'Quick Redirects', 'manage_options', 'redirect-updates', array($this,'ppr_options_page') );
|
119 |
+
add_submenu_page( 'redirect-options', 'Redirect Summary', 'Redirect Summary', 'manage_options', 'redirect-summary', array($this,'ppr_summary_page') );
|
120 |
+
add_action( 'admin_init', array($this,'register_pprsettings') );
|
121 |
+
}
|
122 |
+
|
123 |
+
function register_pprsettings() {
|
124 |
+
register_setting( 'ppr-settings-group', 'ppr_use-custom-post-types' );
|
125 |
+
register_setting( 'ppr-settings-group', 'ppr_override-nofollow' );
|
126 |
+
register_setting( 'ppr-settings-group', 'ppr_override-newwindow' );
|
127 |
+
register_setting( 'ppr-settings-group', 'ppr_override-redirect-type' );
|
128 |
+
register_setting( 'ppr-settings-group', 'ppr_override-active' );
|
129 |
+
register_setting( 'ppr-settings-group', 'ppr_override-URL' );
|
130 |
+
register_setting( 'ppr-settings-group', 'ppr_override-rewrite' );
|
131 |
+
register_setting( 'ppr-settings-group', 'ppr_meta-seconds' );
|
132 |
+
register_setting( 'ppr-settings-group', 'ppr_meta-message' );
|
133 |
+
}
|
134 |
+
|
135 |
+
function ppr_summary_page() {?>
|
136 |
+
<div class="wrap">
|
137 |
+
<style type="text/css">.pprdonate{padding:5px;border:1px solid #dadada;font-family:tahoma, arial, helvetica, sans-serif;font-size:12px;float:right;position:absolute;top:25px;right:5px;width:250px;text-align:center;}.qform-table td{padding:2px !important;border:1px solid #cccccc;}.qform-table .headrow td{font-weight:bold;}.qform-table .onrow td{background-color:#eaeaea;}.qform-table .offrow td{background-color:#ffffff;}</style>
|
138 |
+
<div class="icon32" style="<?php echo 'background: url('.WP_PLUGIN_URL.'/quick-pagepost-redirect-plugin/settings-icon.png) no-repeat transparent;';?>"><br></div>
|
139 |
+
<h2>Quick Page Post Redirect Summary</h2>
|
140 |
+
<p>This is a summary of Individual redirects only. Quick 301 Redirects can be found <a href="admin.php?page=redirect-updates">here</a>.</p><br/>
|
141 |
+
<?php if($this->updatemsg!=''){?><div class="updated settings-error" id="setting-error-settings_updated"><p><strong><?php echo $this->updatemsg;?></strong></p></div><?php } ?>
|
142 |
+
<?php $this->updatemsg ='';?>
|
143 |
+
<h2 style="font-size:20px;">Summary</h2>
|
144 |
+
<div align="left">
|
145 |
+
<table class="form-table qform-table" width="100%">
|
146 |
+
<tr valign="top" class="headrow">
|
147 |
+
<td width="50" align="left">ID</td>
|
148 |
+
<td width="75" align="left">post type</td>
|
149 |
+
<td width="65" align="center">active</td>
|
150 |
+
<td width="65" align="center">no follow</td>
|
151 |
+
<td width="65" align="center">new win</td>
|
152 |
+
<td width="60" align="center">type</td>
|
153 |
+
<td width="50" align="center">rewrite</td>
|
154 |
+
<td align="left">original URL</td>
|
155 |
+
<td align="left">redirect to URL</td>
|
156 |
+
|
157 |
+
</tr>
|
158 |
+
<?php
|
159 |
+
$tempReportArray = array();
|
160 |
+
$tempa = array();
|
161 |
+
$tempQTReportArray = array();
|
162 |
+
if(count($this->quickppr_redirects)>0){
|
163 |
+
foreach($this->quickppr_redirects as $key=>$redir){
|
164 |
+
$tempQTReportArray = array('url'=>$key,'destinaition'=>$redir);
|
165 |
+
}
|
166 |
+
}
|
167 |
+
if(count($this->ppr_all_redir_array)>0){
|
168 |
+
foreach($this->ppr_all_redir_array as $key=>$result){
|
169 |
+
$tempa['id']= $key;
|
170 |
+
$tempa['post_type'] = get_post_type( $key );
|
171 |
+
foreach($result as $metakey => $metaval){
|
172 |
+
$tempa[$metakey] = $metaval;
|
173 |
}
|
174 |
+
$tempReportArray[] = $tempa;
|
175 |
+
unset($tempa);
|
176 |
+
}
|
177 |
+
}
|
178 |
+
if(count($tempReportArray)>0){
|
179 |
+
$pclass = 'onrow';
|
180 |
+
foreach($tempReportArray as $reportItem){
|
181 |
+
$tactive = $reportItem['_pprredirect_active'];
|
182 |
+
$trewrit = $reportItem['_pprredirect_rewritelink'];
|
183 |
+
$tnofoll = $reportItem['_pprredirect_relnofollow'];
|
184 |
+
$tnewwin = $reportItem['_pprredirect_newwindow'];
|
185 |
+
$tretype = $reportItem['_pprredirect_type'];
|
186 |
+
$tredURL = $reportItem['_pprredirect_url'];
|
187 |
+
$tpotype = $reportItem['post_type'];
|
188 |
+
$tpostid = $reportItem['id'];
|
189 |
+
$toriurl = get_permalink($tpostid);
|
190 |
+
if($pclass == 'offrow'){$pclass = 'onrow';}else{$pclass = 'offrow';}
|
191 |
+
if($tnewwin == '0'){$tnewwin = '0';}else{$tnewwin = '1';}
|
192 |
+
if($tredURL == 'http://www.example.com'){$tredURL='<strong>N/A - redirection will not occur</strong>';}
|
193 |
+
?>
|
194 |
+
<tr valign="top" class="<?php echo $pclass;?>">
|
195 |
+
<td width="50" align="left"><?php echo $tpostid;?></td>
|
196 |
+
<td width="75" align="left"><?php echo $tpotype;?></td>
|
197 |
+
<td width="65" align="center"><?php echo $tactive;?></td>
|
198 |
+
<td width="65" align="center"><?php echo $tnofoll;?></td>
|
199 |
+
<td width="65" align="center"><?php echo $tnewwin;?></td>
|
200 |
+
<td width="60" align="center"><?php echo $tretype;?></td>
|
201 |
+
<td width="50" align="center"><?php echo $trewrit;?></td>
|
202 |
+
<td align="left"><?php echo $toriurl;?></td>
|
203 |
+
<td align="left"><?php echo $tredURL;?></td>
|
204 |
+
</tr>
|
205 |
+
<?php }
|
206 |
+
}
|
207 |
+
?>
|
208 |
+
</table>
|
209 |
+
</div>
|
210 |
+
</div>
|
211 |
+
<?php
|
212 |
+
}
|
213 |
+
|
214 |
+
function ppr_settings_page() {
|
215 |
+
?>
|
216 |
+
<div class="wrap" style="position:relative;">
|
217 |
+
<style type="text/css">.pprdonate{padding:5px;border:1px solid #dadada;font-family:tahoma, arial, helvetica, sans-serif;font-size:12px;float:right;position:absolute;top:25px;right:5px;width:250px;text-align:center;}.qpprform label {float:left;display:block;width:290px;margin-left:30px;}.qpprform .submit{clear:both;}.qpprform span{font-size:9px;}</style>
|
218 |
+
<div class="icon32" style="<?php echo 'background: url('.WP_PLUGIN_URL.'/quick-pagepost-redirect-plugin/settings-icon.png) no-repeat transparent;';?>"><br></div>
|
219 |
+
<div class="pprdonate">
|
220 |
+
<p>If you enjoy or find any of our plugins useful, please donate a few dollars to help with future development and updates.</p>
|
221 |
+
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
222 |
+
<input name="cmd" value="_s-xclick" type="hidden">
|
223 |
+
<input name="hosted_button_id" value="8274582" type="hidden">
|
224 |
+
<input alt="PayPal - The safer, easier way to pay online!" name="submit" src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" type="image"> <img src="https://www.paypal.com/en_US/i/scr/pixel.gif" alt="" border="0" height="1" width="1"><br>
|
225 |
+
</form>
|
226 |
+
<p>We thank you in advance.</p>
|
227 |
+
</div>
|
228 |
+
<h2>Quick Page Post Redirect Options & Settings</h2>
|
229 |
+
<?php if($this->updatemsg!=''){?><div class="updated settings-error" id="setting-error-settings_updated"><p><strong><?php echo $this->updatemsg;?></strong></p></div><?php } ?>
|
230 |
+
<?php $this->updatemsg ='';//reset message;?>
|
231 |
+
|
232 |
+
<form method="post" action="options.php" class="qpprform">
|
233 |
+
<?php settings_fields( 'ppr-settings-group' ); ?>
|
234 |
+
<table class="form-table">
|
235 |
+
<tr valign="top">
|
236 |
+
<td><h2 style="font-size:20px;">Basic Settings</h2></td>
|
237 |
+
</tr>
|
238 |
+
<tr valign="top">
|
239 |
+
<td><label>Use with Custom Post Types?</label> <input type="checkbox" name="ppr_use-custom-post-types" value="1"<?php if(get_option('ppr_use-custom-post-types')=='1'){echo ' checked="checked" ';} ?>/></td>
|
240 |
+
</tr>
|
241 |
+
<tr valign="top">
|
242 |
+
<td><label>Meta Refresh Time (in seconds):</label> <input type="text" size="5" name="ppr_meta-seconds" value="<?php echo get_option('ppr_meta-seconds');?>" /> <span>only needed for meta refresh. 0=default (instant)</span></td>
|
243 |
+
</tr>
|
244 |
+
<tr valign="top">
|
245 |
+
<td><label>Meta Refresh Message:</label> <input type="text" size="25" name="ppr_meta-message" value="<?php echo get_option('ppr_meta-message');?>" /> <span>default is none. message to display while waiting for refresh</span></td>
|
246 |
+
</tr>
|
247 |
+
<tr valign="top">
|
248 |
+
<td><h2 style="font-size:20px;">Master Override Options</h2><b>NOTE: </b>These will override all individual settings.</td>
|
249 |
+
</tr>
|
250 |
+
<tr valign="top">
|
251 |
+
<td><label>Turn OFF all Redirects? </label><input type="checkbox" name="ppr_override-active" value="1"<?php if(get_option('ppr_override-active')=='1'){echo ' checked="checked" ';} ?>/></td>
|
252 |
+
</tr>
|
253 |
+
<tr valign="top">
|
254 |
+
<td><label>Make ALL Rediects have <code>rel="nofollow"</code>? </label><input type="checkbox" name="ppr_override-nofollow" value="1"<?php if(get_option('ppr_override-nofollow')=='1'){echo ' checked="checked" ';} ?>/></td>
|
255 |
+
</tr>
|
256 |
+
<tr valign="top">
|
257 |
+
<td><label>Make ALL Rediects open in a New Window? </label><input type="checkbox" name="ppr_override-newwindow" value="1"<?php if(get_option('ppr_override-newwindow')=='1'){echo ' checked="checked" ';} ?>/> <span>(Quick Redirect will not open in a new Window).</span></td>
|
258 |
+
</tr>
|
259 |
+
<tr valign="top">
|
260 |
+
<td><label>Make ALL Rediects this type: </label>
|
261 |
+
<select name="ppr_override-redirect-type">
|
262 |
+
<option value="0">Use Individual Settings</option>
|
263 |
+
<option value="301" <?php if( get_option('ppr_override-redirect-type')=='301') {echo ' selected="selected" ';} ?>/>301 Permanant Redirect</option>
|
264 |
+
<option value="302" <?php if( get_option('ppr_override-redirect-type')=='302') {echo ' selected="selected" ';} ?>/>302 Temporary Redirect</option>
|
265 |
+
<option value="307" <?php if( get_option('ppr_override-redirect-type')=='307') {echo ' selected="selected" ';} ?>/>307 Temporary Redirect</option>
|
266 |
+
<option value="meta" <?php if(get_option('ppr_override-redirect-type')=='meta'){echo ' selected="selected" ';} ?>/>Meta Refresh Redirect</option>
|
267 |
+
</select>
|
268 |
+
</td>
|
269 |
+
</tr>
|
270 |
+
<tr valign="top">
|
271 |
+
<td><label>Make ALL Rediects go to this URL: </label><input type="text" size="50" name="ppr_override-URL" value="<?php echo get_option('ppr_override-URL'); ?>"/> <span>(use full URL including <code>http://</code>).</span></td>
|
272 |
+
</tr>
|
273 |
+
<tr valign="top">
|
274 |
+
<td><label>Rewrite ALL Rediects URLs to Show in LINK? </label><input type="checkbox" name="ppr_override-rewrite" value="1"<?php if(get_option('ppr_override-rewrite')=='1'){echo ' checked="checked" ';} ?>/> <span>(makes link show redirect URL instead of the original URL).</span></td>
|
275 |
+
</tr>
|
276 |
+
</table>
|
277 |
+
<p class="submit">
|
278 |
+
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
|
279 |
+
</p>
|
280 |
+
</form>
|
281 |
+
</div>
|
282 |
+
<?php }
|
283 |
+
|
284 |
+
function ppr_options_page(){
|
285 |
+
//generate the options page in the wordpress admin
|
286 |
+
$tohash = $this->homelink.'/';
|
287 |
+
?>
|
288 |
+
<div class="wrap">
|
289 |
+
<div class="icon32" style="<?php echo 'background: url('.WP_PLUGIN_URL.'/quick-pagepost-redirect-plugin/settings-icon.png) no-repeat transparent;';?>"><br></div>
|
290 |
+
<script type="text/javascript">jQuery(document).ready(function() {jQuery(".delete-qppr").click(function(){var mainurl = '<?php echo get_bloginfo('url');?>/'; var thepprdel = jQuery(this).attr('id');if(confirm('Are you sure you want to delete this redirect?')){jQuery.ajax({url: mainurl+"/",data : "pprd="+thepprdel+"&scid=<?php echo md5($tohash);?>",success: function(data){jQuery('#row'+thepprdel).remove();},complete: function(){}});return false;}else{return false;}});});</script>
|
291 |
+
<h2>Quick 301 Redirects</h2>
|
292 |
+
<?php if($this->updatemsg!=''){?><div class="updated settings-error" id="setting-error-settings_updated"><p><strong><?php echo $this->updatemsg;?></strong></p></div><?php } ?>
|
293 |
+
<?php $this->updatemsg ='';//reset message;?>
|
294 |
+
<br/>This section is useful if you have links from an old site and need to have them redirect to a new location on the current site, or if you have an existing URL that you need to send some place else and you don't want to have a Page or Post created to use the other Page/Post Redirect option.
|
295 |
+
<br/>
|
296 |
+
<br/>To add additional 301 redirects, put the URL you want to redirect in the Request field and the Place you want it to redirect to, in the Destination field.
|
297 |
+
<br/>To delete a redirect, click the 'x' next to the Destination Field.
|
298 |
+
<br/>
|
299 |
+
<br/><b style="color:red;">PLEASE NOTE:</b>
|
300 |
+
<ul>
|
301 |
+
<li style="color:#214070;margin-left:25px;list-style-type:disc;">The <b>Request</b> field MUST be relative to the ROOT directory and contain the <code>/</code> at the beginning.</li>
|
302 |
+
<li style="color:#214070;margin-left:25px;list-style-type:disc;">The <b>Destination</b> field can be any valid URL or relative path (from root).</li>
|
303 |
+
<li style="color:#214070;margin-left:25px;list-style-type:disc;">Quick Redirects <b>WILL NOT open in a new window</b>. They are meant to be 'Quick' and since the user will not aculally be clicking anything, a new window cannot be opened.</li>
|
304 |
+
</ul>
|
305 |
+
<br/>
|
306 |
+
<form method="post" action="admin.php?page=redirect-updates">
|
307 |
+
<table>
|
308 |
+
<tr>
|
309 |
+
<th align="left">Request</th>
|
310 |
+
<th align="left">Destination</th>
|
311 |
+
<th align="left"> </th>
|
312 |
+
</tr>
|
313 |
+
<tr>
|
314 |
+
<td><small>example: <code>/about.htm</code> or <code>/test-directory/landing-zone/</code></small></td>
|
315 |
+
<td><small>example: <code><?php echo $this->homelink; ?>/about/</code> or <code><?php echo $this->homelink; ?>/landing/</code></small></td>
|
316 |
+
<td> </td>
|
317 |
+
</tr>
|
318 |
+
<?php echo $this->expand_redirects(); ?>
|
319 |
+
<tr>
|
320 |
+
<td><input type="text" name="quickppr_redirects[request][]" value="" style="width:35em" /> » </td>
|
321 |
+
<td><input type="text" name="quickppr_redirects[destination][]" value="" style="width:35em;" /></td>
|
322 |
+
<td></td>
|
323 |
+
</tr>
|
324 |
+
</table>
|
325 |
+
|
326 |
+
<p class="submit">
|
327 |
+
<input type="submit" name="submit_301" class="button-primary" value="<?php _e('Save Changes') ?>" />
|
328 |
+
</p>
|
329 |
+
</form>
|
330 |
+
</div>
|
331 |
+
|
332 |
+
<?php
|
333 |
+
}
|
334 |
+
|
335 |
+
function save_redirects($data){
|
336 |
+
// Save the redirects from the options page to the database
|
337 |
+
$redirects = array();
|
338 |
+
for($i = 0; $i < sizeof($data['request']); ++$i) {
|
339 |
+
$request = trim($data['request'][$i]);
|
340 |
+
if(strpos($request,'/',0) !== 0 && strpos($request,'http',0) !== 0){$request = '/'.$request;} // adds root marker to front if not there
|
341 |
+
if((strpos($request,'.') === false && strpos($request,'?') === false) && strpos($request,'/',strlen($request)-1) === false){$request = $request.'/';} // adds end folder marker if not a file end
|
342 |
+
$destination = trim($data['destination'][$i]);
|
343 |
+
if (($request == '' || $request == '/') && $destination == '') { continue; } elseif($request != '' && $request != '/' && $destination == '' ){ $redirects[$request] = $this->homelink.'/';}else { $redirects[$request] = $destination; }
|
344 |
+
}
|
345 |
+
update_option('quickppr_redirects', $redirects);
|
346 |
+
return $redirects;
|
347 |
+
}
|
348 |
+
|
349 |
+
function expand_redirects(){
|
350 |
+
//utility function to return the current list of redirects as form fields
|
351 |
+
$output = '';
|
352 |
+
if (!empty($this->quickppr_redirects)) {
|
353 |
+
$ww=1;
|
354 |
+
foreach ($this->quickppr_redirects as $request => $destination) {
|
355 |
+
$output .= '
|
356 |
+
<tr id="rowpprdel-'.$ww.'">
|
357 |
+
<td><input type="text" name="quickppr_redirects[request][]" value="'.$request.'" style="width:35em" /> » </td>
|
358 |
+
<td><input type="text" name="quickppr_redirects[destination][]" value="'.$destination.'" style="width:35em;" /></td>
|
359 |
+
<td> <a href="javascript:void();" id="pprdel-'.$ww.'" class="delete-qppr">x</a> </td>
|
360 |
</tr>
|
361 |
+
';
|
362 |
+
$ww++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
363 |
}
|
364 |
+
}
|
365 |
+
return $output;
|
366 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
367 |
|
368 |
+
|
369 |
+
function ppr_filter_links ($link = '', $post = array()) {
|
370 |
+
if(isset($post->ID)){
|
371 |
+
$id = $post->ID;
|
372 |
+
}else{
|
373 |
+
$id = $post;
|
374 |
+
}
|
375 |
+
if(array_key_exists($id, $this->ppr_all_redir_array)){
|
376 |
+
$matchedID = $this->ppr_all_redir_array[$id];
|
377 |
+
if($matchedID['_pprredirect_rewritelink'] == '1' || $this->pproverride_rewrite =='1'){ // if rewrite link is checked or override is set
|
378 |
+
if($this->pproverride_URL ==''){$newURL = $matchedID['_pprredirect_url'];}else{$newURL = $this->pproverride_URL;} // check override
|
379 |
+
if(strpos($newURL,$this->homelink)>=0 || strpos($newURL,'www.')>=0 || strpos($newURL,'http://')>=0 || strpos($newURL,'https://')>=0){
|
380 |
+
$link = esc_url( $newURL );
|
381 |
+
}else{
|
382 |
+
$link = esc_url( $this->homelink.'/'. $newURL );
|
383 |
+
}
|
384 |
}
|
385 |
+
}
|
386 |
+
|
387 |
+
return $link;
|
388 |
+
}
|
389 |
+
function ppr_filter_page_links ($link, $post) {
|
390 |
+
if(isset($post->ID)){
|
391 |
+
$id = $post->ID;
|
392 |
+
}else{
|
393 |
+
$id = $post;
|
394 |
+
}
|
395 |
+
if(array_key_exists($id, $this->ppr_all_redir_array)){
|
396 |
+
$matchedID = $this->ppr_all_redir_array[$id];
|
397 |
+
if($matchedID['_pprredirect_rewritelink'] == '1' || $this->pproverride_rewrite =='1'){ // if rewrite link is checked
|
398 |
+
if($this->pproverride_URL ==''){$newURL = $matchedID['_pprredirect_url'];}else{$newURL = $this->pproverride_URL;} // check override
|
399 |
+
if(strpos($newURL,$this->homelink)>=0 || strpos($newURL,'www.')>=0 || strpos($newURL,'http://')>=0 || strpos($newURL,'https://')>=0){
|
400 |
+
$link = esc_url( $newURL );
|
401 |
+
}else{
|
402 |
+
$link = esc_url( $this->homelink.'/'. $newURL );
|
403 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
404 |
}
|
405 |
+
}
|
|
|
|
|
406 |
|
407 |
+
return $link;
|
408 |
+
}
|
409 |
+
|
410 |
+
|
411 |
+
function ppr_add_metabox(){
|
412 |
+
if( function_exists( 'add_meta_box' ) ) {
|
413 |
+
$usetypes = get_option('ppr_use-custom-post-types')!= '' ? get_option('ppr_use-custom-post-types') : '0';
|
414 |
+
if($usetypes == '1'){
|
415 |
+
$post_types_temp = get_post_types();
|
416 |
+
if(count($post_types_temp)==0){
|
417 |
+
$post_types_temp = array('page' => 'page','post' => 'post','attachment' => 'attachment','nav_menu_item' => 'nav_menu_item');
|
418 |
+
}
|
419 |
+
}else{
|
420 |
+
$post_types_temp = array('page' => 'page','post' => 'post','attachment' => 'attachment','nav_menu_item' => 'nav_menu_item');
|
421 |
+
}
|
422 |
+
unset($post_types_temp['revision']); //remove revions from array if present as they are not needed.
|
423 |
+
foreach($post_types_temp as $type){
|
424 |
+
add_meta_box( 'edit-box-ppr', 'Quick Page/Post Redirect', array($this,'edit_box_ppr_1'), $type, 'normal', 'high' );
|
425 |
+
}
|
426 |
+
}
|
427 |
+
}
|
428 |
+
|
429 |
+
function get_main_array(){
|
430 |
+
global $wpdb;
|
431 |
+
$theArray = array();
|
432 |
+
$thetemp = $wpdb->get_results("SELECT * FROM $wpdb->postmeta 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') ORDER BY `post_id` ASC;");
|
433 |
+
if(count($thetemp)>0){
|
434 |
+
foreach($thetemp as $key){
|
435 |
+
$theArray[$key->post_id][$key->meta_key] = $key->meta_value;
|
436 |
+
}
|
437 |
+
foreach($thetemp as $key){
|
438 |
+
// defaults
|
439 |
+
if(!isset($theArray[$key->post_id]['_pprredirect_rewritelink'])){$theArray[$key->post_id]['_pprredirect_rewritelink'] = 0;}
|
440 |
+
if(!isset($theArray[$key->post_id]['_pprredirect_url'])){$theArray[$key->post_id]['_pprredirect_url'] = 'http://www.example.com';}
|
441 |
+
if(!isset($theArray[$key->post_id]['_pprredirect_type'] )){$theArray[$key->post_id]['_pprredirect_type'] = 302;}
|
442 |
+
if(!isset($theArray[$key->post_id]['_pprredirect_relnofollow'])){$theArray[$key->post_id]['_pprredirect_relnofollow'] = 0;}
|
443 |
+
if(!isset($theArray[$key->post_id]['_pprredirect_newwindow'] )) {$theArray[$key->post_id]['_pprredirect_newwindow'] = 0;}
|
444 |
+
if(!isset($theArray[$key->post_id]['_pprredirect_active'] )){$theArray[$key->post_id]['_pprredirect_active'] = 0;}
|
445 |
+
}
|
446 |
|
447 |
+
}
|
448 |
+
return $theArray;
|
449 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
450 |
|
451 |
+
function get_value($theval='none'){
|
452 |
+
if($theval==''){return;}
|
453 |
+
switch($theval){
|
454 |
+
case 'ppr_all_redir_array':
|
455 |
+
return $this->ppr_all_redir_array;
|
456 |
+
break;
|
457 |
+
case 'ppr_nofollow':
|
458 |
+
return $this->ppr_all_redir_array;
|
459 |
+
break;
|
460 |
+
case 'ppr_newindow':
|
461 |
+
return $this->ppr_newindow;
|
462 |
+
break;
|
463 |
+
case 'ppr_url':
|
464 |
+
return $this->ppr_url;
|
465 |
+
break;
|
466 |
+
case 'ppr_url_rewrite':
|
467 |
+
return $this->ppr_url_rewrite;
|
468 |
+
break;
|
469 |
+
case 'ppr_type':
|
470 |
+
return $this->ppr_type;
|
471 |
+
break;
|
472 |
+
case 'ppr_curr_version':
|
473 |
+
return $this->ppr_curr_version;
|
474 |
+
break;
|
475 |
+
case 'ppr_metaurlnew':
|
476 |
+
return $this->ppr_metaurlnew;
|
477 |
+
break;
|
478 |
+
case 'hepprversion':
|
479 |
+
return $this->hepprversion;
|
480 |
+
break;
|
481 |
+
case 'thepprmeta':
|
482 |
+
return $this->thepprmeta;
|
483 |
+
break;
|
484 |
+
case 'quickppr_redirects':
|
485 |
+
return $this->quickppr_redirects;
|
486 |
+
break;
|
487 |
+
case 'tohash':
|
488 |
+
return $this->tohash;
|
489 |
+
break;
|
490 |
+
case 'fcmlink':
|
491 |
+
return $this->fcmlink;
|
492 |
+
break;
|
493 |
+
case 'adminlink':
|
494 |
+
return $this->adminlink;
|
495 |
+
break;
|
496 |
+
case 'homelink':
|
497 |
+
return $this->homelink;
|
498 |
+
break;
|
499 |
+
case 'updatemsg':
|
500 |
+
return $this->updatemsg;
|
501 |
+
break;
|
502 |
+
case 'pprmeta_seconds':
|
503 |
+
return $this->pprmeta_seconds;
|
504 |
+
break;
|
505 |
+
case 'pprmeta_message':
|
506 |
+
return $this->pprmeta_message;
|
507 |
+
break;
|
508 |
+
case 'none':
|
509 |
+
return 0;
|
510 |
+
break;
|
511 |
+
}
|
512 |
+
|
513 |
+
return '';
|
514 |
}
|
515 |
|
516 |
+
function ppr_addmetatohead_theme(){
|
517 |
+
// check URL override
|
518 |
+
if($this->pproverride_URL !=''){$urlsite = $this->pproverride_URL;} else {$urlsite = $this->ppr_metaurl;}
|
519 |
+
$this->pproverride_URL = ''; //reset
|
520 |
+
if($this->pprmeta_seconds==''){$this->pprmeta_seconds='0';}
|
521 |
+
echo '<meta http-equiv="refresh" content="'.$this->pprmeta_seconds.'; URL='.$urlsite.'" />';
|
522 |
+
if($this->pprmeta_message!='' && $this->pprmeta_seconds!='0'){echo '<div style="margin-top:20px;text-align:center;">'.$this->pprmeta_message.'</div>';}
|
523 |
+
exit; //stop loading page so meta can do it's job without rest of page loading.
|
524 |
+
}
|
525 |
+
|
526 |
function ppr_queryhook($vars) {
|
527 |
$vars[] = 'pprd';
|
528 |
$vars[] = 'scid';
|
529 |
return $vars;
|
530 |
}
|
531 |
+
|
|
|
532 |
function ppr_parse_request($wp) {
|
533 |
global $wp;
|
|
|
534 |
if(array_key_exists('pprd', $wp->query_vars) && array_key_exists('scid', $wp->query_vars)){
|
535 |
$tohash = get_bloginfo('url').'/';
|
536 |
+
if( $wp->query_vars['pprd'] !='' && $wp->query_vars['scid'] == md5($tohash)){
|
537 |
$theDel = str_replace('pprdel-','',$wp->query_vars['pprd']);
|
538 |
$redirects = get_option('quickppr_redirects');
|
539 |
if (!empty($redirects)) {
|
540 |
$ww=1;
|
541 |
foreach ($redirects as $request => $destination) {
|
542 |
if($ww != (int)$theDel){
|
543 |
+
$quickppr_redirects[$request] = $destination;
|
544 |
}
|
545 |
$ww++;
|
546 |
}
|
555 |
}else{
|
556 |
return;
|
557 |
}
|
558 |
+
}
|
559 |
+
|
560 |
+
function ppr_init_check_version() {
|
561 |
+
// checks version of plugin in DB and updates if needed.
|
562 |
+
global $wpdb;
|
563 |
+
if($this->thepprversion != $this->ppr_curr_version){
|
564 |
+
update_option( 'ppr_version', $this->ppr_curr_version );
|
565 |
+
}
|
566 |
+
if($this->thepprmeta != '1'){
|
567 |
+
update_option( 'ppr_meta_clean', '1' );
|
568 |
+
$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';");
|
569 |
+
}
|
570 |
}
|
571 |
|
572 |
function ppr_filter_plugin_actions($links){
|
573 |
$new_links = array();
|
574 |
+
$new_links[] = '<a href="'.$this->fcmlink.'/donate/">Donate</a>';
|
|
|
575 |
return array_merge($links,$new_links );
|
576 |
}
|
577 |
+
|
578 |
function ppr_filter_plugin_links($links, $file){
|
579 |
if ( $file == plugin_basename(__FILE__) ){
|
580 |
+
$links[] = '<a href="'.$this->adminlink.'options-general.php?page=redirect-updates">Quick Redirects</a>';
|
581 |
+
$links[] = '<a target="_blank" href="'.$this->fcmlink.'/quick-pagepost-redirect-plugin/">FAQ</a>';
|
582 |
+
$links[] = '<a target="_blank" href="'.$this->fcmlink.'/donate/">Donate</a>';
|
|
|
|
|
583 |
}
|
584 |
return $links;
|
585 |
}
|
586 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
587 |
function edit_box_ppr_1() {
|
588 |
+
// Prints the inner fields for the custom post/page section
|
589 |
global $post;
|
590 |
$ppr_option1='';
|
591 |
$ppr_option2='';
|
596 |
wp_nonce_field( 'pprredirect_noncename', 'pprredirect_noncename', false, true );
|
597 |
|
598 |
// The actual fields for data entry
|
599 |
+
echo '<label for="pprredirect_active" style="padding:2px 0;"><input type="checkbox" name="pprredirect_active" value="1" '. checked('1',get_post_meta($post->ID,'_pprredirect_active',true),0).' />Make Redirect <b>Active</b>. (check to turn on)</label><br />';
|
600 |
+
echo '<label for="pprredirect_newwindow" style="padding:2px 0;"><input type="checkbox" name="pprredirect_newwindow" id="pprredirect_newwindow" value="_blank" '. checked('_blank',get_post_meta($post->ID,'_pprredirect_newwindow',true),0).'>Open redirect link in a <b>new window.</b></label><br />';
|
601 |
+
echo '<label for="pprredirect_relnofollow" style="padding:2px 0;"><input type="checkbox" name="pprredirect_relnofollow" id="pprredirect_relnofollow" value="1" '. checked('1',get_post_meta($post->ID,'_pprredirect_relnofollow',true),0).'>Add <b>rel=\"nofollow\"</b> to redirect link.</label><br />';
|
602 |
+
echo '<label for="pprredirect_rewritelink" style="padding:2px 0;"><input type="checkbox" name="pprredirect_rewritelink" id="pprredirect_rewritelink" value="1" '. checked('1',get_post_meta($post->ID,'_pprredirect_rewritelink',true),0).'><b>Show</b> the Redirect URL below in the link instead of this page URL. <b>NOTE: You may have to use the <u>FULL</u> URL below!</b></label><br /><br />';
|
603 |
+
echo '<label for="pprredirect_url"><b>Redirect URL:</b></label><br />';
|
604 |
if(get_post_meta($post->ID, '_pprredirect_url', true)!=''){$pprredirecturl=get_post_meta($post->ID, '_pprredirect_url', true);}else{$pprredirecturl="";}
|
605 |
echo '<input type="text" style="width:75%;margin-top:2px;margin-bottom:2px;" name="pprredirect_url" value="'.$pprredirecturl.'" /><br />(i.e., <code>http://example.com</code> or <code>/somepage/</code> or <code>p=15</code> or <code>155</code>. Use <b>FULL URL</b> <i>including</i> <code>http://</code> for all external <i>and</i> meta redirects. )<br /><br />';
|
606 |
|
607 |
+
echo '<label for="pprredirect_type">Type of Redirect:</label> ';
|
608 |
if(get_post_meta($post->ID, '_pprredirect_type', true)!=''){$pprredirecttype=get_post_meta($post->ID, '_pprredirect_type', true);}else{$pprredirecttype="";}
|
609 |
switch($pprredirecttype):
|
610 |
case "":
|
625 |
endswitch;
|
626 |
|
627 |
echo '<select style="margin-top:2px;margin-bottom:2px;width:40%;" name="pprredirect_type"><option value="301" '.$ppr_option1.'>301 Permanent</option><option value="302" '.$ppr_option2.'>302 Temporary</option><option value="307" '.$ppr_option3.'>307 Temporary</option><option value="meta" '.$ppr_option5.'>Meta Redirect</option></select> (Default is 302)<br /><br />';
|
628 |
+
echo '<b>NOTE:</b> For This Option to work, the page or post needs to be published for the redirect to happen <i><b>UNLESS</b></i> you publish it first, then save it as a Draft. If you want to add a redirect without adding a page/post or having it published, use the <a href="./options-general.php?page=redirect-updates">Quick Redirects</a> method.';
|
629 |
}
|
630 |
|
631 |
+
function ppr_save_metadata($post_id, $post) {
|
632 |
+
if($post->post_type == 'revision'){return;}
|
|
|
633 |
if(isset($_REQUEST['pprredirect_noncename']) && (isset($_POST['pprredirect_active']) || isset($_POST['pprredirect_url']) || isset($_POST['pprredirect_type']) || isset($_POST['pprredirect_newwindow']) || isset($_POST['pprredirect_relnofollow']))):
|
634 |
+
unset($my_meta_data);
|
635 |
+
$my_meta_data = array();
|
636 |
// verify authorization
|
637 |
if(isset($_POST['pprredirect_noncename'])){
|
638 |
if ( !wp_verify_nonce( $_REQUEST['pprredirect_noncename'], 'pprredirect_noncename' )) {
|
639 |
+
return $post_id;
|
640 |
}
|
641 |
}
|
|
|
642 |
// check allowed to editing
|
643 |
+
if ( !(current_user_can('edit_page', $post_id ) || current_user_can( 'edit_post', $post_id ))){
|
644 |
+
return $post_id;
|
|
|
|
|
|
|
|
|
645 |
}
|
646 |
+
|
647 |
// find & save the form data & put it into an array
|
648 |
+
$my_meta_data['_pprredirect_active'] = $_REQUEST['pprredirect_active'];
|
649 |
+
$my_meta_data['_pprredirect_newwindow'] = $_REQUEST['pprredirect_newwindow'];
|
650 |
+
$my_meta_data['_pprredirect_relnofollow'] = $_REQUEST['pprredirect_relnofollow'];
|
651 |
+
$my_meta_data['_pprredirect_type'] = $_REQUEST['pprredirect_type'];
|
652 |
+
$my_meta_data['_pprredirect_rewritelink'] = $_REQUEST['pprredirect_rewritelink'];
|
653 |
+
$my_meta_data['_pprredirect_url'] = $_REQUEST['pprredirect_url']; //stripslashes( $_POST['pprredirect_url']);
|
654 |
|
655 |
+
if ( 0 === strpos($my_meta_data['_pprredirect_url'], 'www.'))
|
656 |
+
$my_meta_data['_pprredirect_url'] = 'http://' . $my_meta_data['_pprredirect_url'] ; // Starts with www., so add http://
|
657 |
|
658 |
+
if($my_meta_data['_pprredirect_url'] == ''){
|
659 |
+
$my_meta_data['_pprredirect_type'] = NULL; //clear Type if no URL is set.
|
660 |
+
$my_meta_data['_pprredirect_active'] = NULL; //turn it off if no URL is set
|
661 |
}
|
662 |
+
|
663 |
+
// Add values of $my_meta_data as custom fields
|
664 |
+
if(count($my_meta_data)>0){
|
665 |
+
foreach ($my_meta_data as $key => $value) { //Let's cycle through the $my_meta_data array!
|
666 |
+
if( $post->post_type == 'revision' ){ return; } //don't store custom data twice
|
667 |
$value = implode(',', (array)$value); //if $value is an array, make it a CSV (unlikely)
|
668 |
|
669 |
+
if($value=='' || $value == NULL){
|
670 |
+
delete_post_meta($post->ID, $key);
|
671 |
+
}else{
|
672 |
+
if(get_post_meta($post->ID, $key, true) != '') {
|
673 |
+
update_post_meta($post->ID, $key, $value);
|
674 |
+
} else {
|
675 |
+
add_post_meta($post->ID, $key, $value);
|
676 |
+
}
|
677 |
}
|
|
|
|
|
678 |
}
|
679 |
}
|
680 |
endif;
|
681 |
}
|
682 |
|
683 |
function ppr_fix_targetsandrels($pages) {
|
684 |
+
$ppr_url = array();
|
685 |
+
$ppr_newindow = array();
|
686 |
+
$ppr_nofollow = array();
|
687 |
+
|
688 |
+
if (empty($ppr_url) && empty($ppr_newindow) && empty($ppr_nofollow)){
|
|
|
|
|
|
|
689 |
$thefirstppr = array();
|
690 |
+
if(!empty($this->ppr_all_redir_array)){
|
691 |
+
foreach($this->ppr_all_redir_array as $key => $pprd){
|
692 |
+
foreach($pprd as $ppkey => $pprs){
|
693 |
+
$thefirstppr[$key][$ppkey] = $pprs;
|
694 |
+
$thefirstppr[$key]['post_id'] = $key;
|
695 |
+
}
|
696 |
}
|
697 |
}
|
698 |
if(!empty($thefirstppr)){
|
699 |
foreach($thefirstppr as $ppitems){
|
700 |
+
if($ppitems['_pprredirect_active'] == 1 && $this->pproverride_newwin =='1'){ // check override of NEW WINDOW
|
701 |
+
$ppr_newindow[] = $ppitems['post_id'];
|
702 |
+
}else{
|
703 |
+
if($ppitems['_pprredirect_active'] == 1 && $ppitems['_pprredirect_newwindow'] == '_blank'){
|
704 |
+
$ppr_newindow[] = $ppitems['post_id'];
|
705 |
+
}
|
706 |
}
|
707 |
+
|
708 |
+
if($ppitems['_pprredirect_active']==1 && $this->pproverride_nofollow =='1'){ //check override of NO FOLLOW
|
709 |
$ppr_nofollow[] = $ppitems['post_id'];
|
710 |
+
}else{
|
711 |
+
if($ppitems['_pprredirect_active']==1 && $ppitems['_pprredirect_relnofollow'] == 1){
|
712 |
+
$ppr_nofollow[] = $ppitems['post_id'];
|
713 |
+
}
|
714 |
}
|
715 |
+
|
716 |
+
if($ppitems['_pprredirect_active']==1 && $this->pproverride_rewrite =='1'){ //check override of REWRITE
|
717 |
+
if($this->pproverride_URL!=''){
|
718 |
+
$ppr_url_rewrite[] = $ppitems['post_id'];
|
719 |
+
$ppr_url[$ppitems['post_id']]['URL'] = $this->pproverride_URL; //check override of URL
|
720 |
+
}elseif($ppitems['_pprredirect_url']!=''){
|
721 |
+
$ppr_url_rewrite[] = $ppitems['post_id'];
|
722 |
+
$ppr_url[$ppitems['post_id']]['URL'] = $ppitems['_pprredirect_url'];
|
723 |
+
}
|
724 |
+
}else{
|
725 |
+
if($ppitems['_pprredirect_active']==1 && $ppitems['_pprredirect_rewritelink'] == '1' && $ppitems['_pprredirect_url']!=''){
|
726 |
+
$ppr_url_rewrite[] = $ppitems['post_id'];
|
727 |
+
$ppr_url[$ppitems['post_id']]['URL'] = $ppitems['_pprredirect_url'];
|
728 |
+
}
|
729 |
}
|
730 |
}
|
731 |
}
|
732 |
|
733 |
+
if (count($ppr_newindow)<0 && count($ppr_nofollow)<0){
|
734 |
return $pages;
|
735 |
}
|
736 |
}
|
737 |
|
738 |
$this_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
|
|
739 |
if(count($ppr_nofollow)>=1) {
|
740 |
foreach($ppr_nofollow as $relid){
|
741 |
$validexp="@\<li(?:.*?)".$relid."(?:.*?)\>\<a(?:.*?)rel\=\"nofollow\"(?:.*?)\>@i";
|
759 |
}
|
760 |
}
|
761 |
}
|
|
|
762 |
return $pages;
|
763 |
}
|
764 |
+
|
765 |
+
function redirect_post_type(){
|
766 |
+
return;
|
767 |
+
//not needed at this time
|
768 |
+
}
|
769 |
+
|
770 |
+
function getAddress(){
|
771 |
+
// utility function to get the full address of the current request - credit: http://www.phpro.org/examples/Get-Full-URL.html
|
772 |
+
if(!isset($_SERVER['HTTPS'])){$_SERVER['HTTPS']='';}
|
773 |
+
$protocol = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http'; //check for https
|
774 |
+
return $protocol.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; //return the full address
|
775 |
+
}
|
776 |
+
|
777 |
+
function redirect(){
|
778 |
+
// Read the list of redirects and if the current page is found in the list, send the visitor on her way
|
779 |
+
if (!empty($this->quickppr_redirects) && !is_admin()) {
|
780 |
+
$userrequest = str_replace(get_option('home'),'',$this->getAddress());
|
781 |
+
if (array_key_exists($userrequest,$this->quickppr_redirects)) {
|
782 |
+
if($this->quickppr_redirects[$userrequest]!='') {
|
783 |
+
if($this->pproverride_URL!=''){$useURL = $this->pproverride_URL;}else{$useURL = $this->quickppr_redirects[$userrequest];}
|
784 |
+
switch($this->pproverride_type){
|
785 |
+
case '':
|
786 |
+
case '0':
|
787 |
+
case '301':
|
788 |
+
header ('Status: 301');
|
789 |
+
header ('HTTP/1.1 301 Moved Permanently');
|
790 |
+
break;
|
791 |
+
case '302':
|
792 |
+
header ('Status: 302');
|
793 |
+
header ('HTTP/1.1 302 Moved Temporarily');
|
794 |
+
break;
|
795 |
+
case '307':
|
796 |
+
header ('Status: 307');
|
797 |
+
header ('HTTP/1.1 307 Moved Temporarily');
|
798 |
+
break;
|
799 |
+
case 'meta':
|
800 |
+
$this->ppr_metaurl = $useURL;
|
801 |
+
add_action('wp_head', array($this,'ppr_addmetatohead_theme'),1);
|
802 |
+
break;
|
803 |
+
}
|
804 |
+
//check URL Override
|
805 |
+
header ('Location: ' . $useURL);
|
806 |
+
exit();
|
807 |
+
}
|
808 |
+
}
|
809 |
+
}
|
810 |
+
}
|
811 |
+
|
812 |
+
function ppr_do_redirect(){
|
813 |
+
// Read the list of redirects and if the current page is found in the list, send the visitor on her way
|
814 |
+
global $post; //temp
|
815 |
+
if (count($this->ppr_all_redir_array)>0) {
|
816 |
+
if(isset($this->ppr_all_redir_array[$post->ID])){
|
817 |
+
$isactive = $this->ppr_all_redir_array[$post->ID]['_pprredirect_active'];
|
818 |
+
$redrtype = $this->ppr_all_redir_array[$post->ID]['_pprredirect_type'];
|
819 |
+
$redrurl = $this->ppr_all_redir_array[$post->ID]['_pprredirect_url'];
|
820 |
+
if($isactive == 1 && $redrurl != '' && $redrurl != 'http://www.example.com'){
|
821 |
+
if($redrtype === 0){$redrtype = '200';}
|
822 |
+
if($redrtype === ''){$redrtype = '302';}
|
823 |
+
|
824 |
+
if( strpos($redrurl, 'http://')=== 0 || strpos($redrurl, 'https://')=== 0){
|
825 |
+
$urlsite=$redrurl;
|
826 |
+
}elseif(strpos($redrurl, 'www')=== 0){ //check if they have full url but did not put http://
|
827 |
+
$urlsite='http://'.$redrurl;
|
828 |
+
}elseif(is_numeric($redrurl)){ // page/post number
|
829 |
+
$urlsite=$this->homelink.'/?p='.$redrurl;
|
830 |
+
}elseif(strpos($redrurl,'/') === 0){ // relative to root
|
831 |
+
$urlsite = $this->homelink.$redrurl;
|
832 |
+
}else{ // we assume they are using the permalink / page name??
|
833 |
+
$urlsite=$this->homelink.'/'.$redrurl;
|
834 |
+
}
|
835 |
+
|
836 |
+
// check if override is set for all redirects to go to one URL
|
837 |
+
if($this->pproverride_URL !=''){$urlsite=$this->pproverride_URL;}
|
838 |
+
if($this->pproverride_type!='0' && $this->pproverride_type!=''){$redrtype = $this->pproverride_type;} //override check
|
839 |
+
|
840 |
+
header("Status: $redrtype");
|
841 |
+
switch($redrtype){
|
842 |
+
case '301':
|
843 |
+
case '0':
|
844 |
+
case '':
|
845 |
+
header ('HTTP/1.1 301 Moved Permanently');
|
846 |
+
header("Location: $urlsite", true, $redrtype);
|
847 |
+
exit(); //stop loading page
|
848 |
+
break;
|
849 |
+
case '302':
|
850 |
+
header ('HTTP/1.1 302 Moved Temporarily');
|
851 |
+
header("Location: $urlsite", true, $redrtype);
|
852 |
+
exit(); //stop loading page
|
853 |
+
break;
|
854 |
+
case '307':
|
855 |
+
header ('HTTP/1.1 307 Moved Temporarily');
|
856 |
+
header("Location: $urlsite", true, $redrtype);
|
857 |
+
exit(); //stop loading page
|
858 |
+
break;
|
859 |
+
case 'meta':
|
860 |
+
$this->ppr_metaurl = $redrurl;
|
861 |
+
add_action('wp_head', array($this,'ppr_addmetatohead_theme'),1);
|
862 |
+
break;
|
863 |
+
}
|
864 |
+
}
|
865 |
+
}
|
866 |
+
}
|
867 |
+
}
|
868 |
+
|
869 |
+
function ppr_new_nav_menu_fix($ppr){
|
870 |
+
$newmenu = array();
|
871 |
+
if(!empty($ppr)){
|
872 |
+
foreach($ppr as $ppd){
|
873 |
+
if(isset($this->ppr_all_redir_array[$ppd->object_id])){
|
874 |
+
$theIsActives = $this->ppr_all_redir_array[$ppd->object_id]['_pprredirect_active'];
|
875 |
+
$theNewWindow = $this->ppr_all_redir_array[$ppd->object_id]['_pprredirect_newwindow'];
|
876 |
+
$theNoFollow = $this->ppr_all_redir_array[$ppd->object_id]['_pprredirect_relnofollow'];
|
877 |
+
$theRewrite = $this->ppr_all_redir_array[$ppd->object_id]['_pprredirect_rewritelink'];
|
878 |
+
$theRedURL = $this->ppr_all_redir_array[$ppd->object_id]['_pprredirect_url'];
|
879 |
+
|
880 |
+
if($this->pproverride_URL !=''){$theRedURL = $this->pproverride_URL;} // check override
|
881 |
+
|
882 |
+
if($theIsActives == '1' && $theNewWindow == '_blank'){
|
883 |
+
$ppd->target = '_blank';
|
884 |
+
$ppd->classes[] = 'ppr-new-window';
|
885 |
+
}
|
886 |
+
if($theIsActives == '1' && $theNoFollow == '1'){
|
887 |
+
$ppd->xfn = 'nofollow';
|
888 |
+
$ppd->classes[] = 'ppr-nofollow';
|
889 |
+
}
|
890 |
+
if($theIsActives == '1' && $theRewrite == '1' && $theRedURL != ''){
|
891 |
+
$ppd->url = $theRedURL;
|
892 |
+
$ppd->classes[] = 'ppr-rewrite';
|
893 |
+
|
894 |
+
}
|
895 |
+
}
|
896 |
+
$newmenu[] = $ppd;
|
897 |
+
}
|
898 |
+
}
|
899 |
+
return $newmenu;
|
900 |
+
}
|
901 |
+
|
902 |
+
}
|
903 |
+
//=======================================
|
904 |
+
// END Main Redirect Class.
|
905 |
+
//=======================================
|
906 |
+
|
907 |
+
$redirect_plugin = new quick_page_post_reds(); // call our class
|
908 |
?>
|
readme.txt
CHANGED
@@ -1,86 +1,87 @@
|
|
1 |
=== Quick Page/Post Redirect ===
|
2 |
Contributors: Don Fischer
|
3 |
Donate link: http://www.fischercreativemedia.com/wordpress-plugins/donate/
|
4 |
-
Tags: redirect, 301, 302, meta, post, plugin, page, forward, re-direct, nofollow,
|
5 |
Requires at least: 2.5
|
6 |
-
Tested up to: 3.
|
7 |
-
Stable tag:
|
8 |
|
9 |
-
Redirect Pages/Posts to another page/post or external URL.
|
10 |
-
|
11 |
-
== Upgrade Notice ==
|
12 |
-
= Version 3.2.3 fixes New Window and No Follow attributes in wp_list_pages menu calls & fixed problem where Quick Redirects would not delete =
|
13 |
-
= Version 3.2.2 fixes some minor code errors and the meta redirect function =
|
14 |
|
15 |
== Description ==
|
16 |
-
= Version 3.2.3 fixes New Window and No Follow attributes in wp_list_pages menu calls =
|
17 |
-
= Version 3.2.2 fixes some minor code errors and the meta redirect function =
|
18 |
|
19 |
-
Quick Page/Post Redirect Plugin redirects WordPress Pages or Posts to another location quickly.
|
20 |
It adds an option box to the edit section where you can specify the redirect location and type of redirect that you want, temporary, permanent, or meta. See below for additional features added.
|
21 |
|
22 |
= Features: =
|
23 |
-
* Works with new WordPress menus
|
24 |
-
*
|
25 |
-
*
|
26 |
-
* You can
|
|
|
27 |
* You can redirect without needing to create a Page or Post. This is very useful for sites that were converted to WordPress and have old links that create 404 errors (see FAQs for more information). This option does not allow for open in a new window or nofollow functions.
|
28 |
-
*
|
29 |
* Redirect can use a full URL path, the post or page ID, permalink or page-name (not available for Quick Redirects method).
|
|
|
|
|
|
|
|
|
30 |
|
31 |
-
This plugin is also not compatible with WordPress versions less than 2.5.
|
32 |
=PLEASE NOTE:= A new page or post needs to be Published in order for the redirect to happen. It WILL work on a DRAFT Status Post/Page ONLY, and I mean ONLY, if the Post/Page has FIRST been Published and the re-saved as a Draft.
|
33 |
|
34 |
= TROUBLESHOOTING: =
|
35 |
-
*
|
36 |
-
* If
|
37 |
-
* If
|
|
|
|
|
38 |
* If your page or post is not redirecting, this is most likely because something else like the theme functions file or another plugin is outputting the header BEFORE the plugin can perform the redirect. This can be tested by turning off all plugins except the Quick Page/Post Redirect Plugin and testing if the redirect works. 9 out of 10 times, a plugin or bad code is the culprit.
|
39 |
* We have tested the plugin in dozens of themes and alongside a whole lot more plugins. In our experience, (with exception to a few bugs) most of the time another plugin is the problem. If you do notice a problem, please let us know at plugins@fischercreativemedia.com - along with the WP version, theme you are using and plugins you have installed - and we will try to troubleshoot the problem.
|
40 |
|
41 |
== Installation ==
|
42 |
|
43 |
= If you downloaded this plugin: =
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
|
49 |
= If you install this plugin through WordPress 2.8+ plugin search interface: =
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
|
55 |
== Frequently Asked Questions ==
|
56 |
= With 3.0s new menu structure, isn't your plugin now obsolete? =
|
57 |
Yes, and No. Mostly No.
|
58 |
-
Here is why - with WordPress 3.0, comes the new menu
|
59 |
-
Additionally, the Quick Redirects option still allows you to create redirects for any url on your site, so that is very much not obsolete (until WP makes
|
60 |
|
61 |
= I still can't get the OPEN IN NEW WINDOW option to work... why? =
|
62 |
-
Some
|
|
|
63 |
|
64 |
= Do I need to have a Page or Post Created to redirect? =
|
65 |
-
|
66 |
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.
|
67 |
|
68 |
-
The
|
69 |
|
70 |
= Can I add 'rel="nofollow" attribute to the redirect link? =
|
71 |
-
YES
|
72 |
|
73 |
= Can I make the redirect open in a new window? =
|
74 |
-
YES
|
75 |
|
76 |
= 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? =
|
77 |
-
YES
|
78 |
|
79 |
= I have Business Cards/Postcards/Ads that say my website is http://something.com/my-name/ or http://something.com/my-product/, can I set that up with this? =
|
80 |
YES! Just set up a redirect (see above) and set the Request field to /my-name/ or /my-product/ and the Destination field to the place you want it to go. The destination doesn't even need to be on the same site - it can go anywhere you want it to go!
|
81 |
|
82 |
= Why is my Page/Post not redirecting? =
|
83 |
-
|
|
|
84 |
|
85 |
We have tested the plugin in dozens of themes and a whole lot more plugins. In our experience, (with exception to a few bugs) most of the time another plugin is the problem. If you do notice a problem, please let us know at plugins@fischercreativemedia.com - along with the WP version, theme you are using and plugins you have installed - and we will try to troubleshoot the problem.
|
86 |
|
@@ -90,17 +91,17 @@ YES... and NO... The redirect will always work on a Published Post/Page. For it
|
|
90 |
= Can I do a permanent 301 Redirect? =
|
91 |
Yes. You can perform a 301 Permanent Redirect. Additionally, you can select a 302 Temporary or a 307 Temporary redirect or a Meta redirect.
|
92 |
|
93 |
-
= What the heck is a 301 or 302 redirect anyway?
|
94 |
-
Good question!
|
95 |
|
96 |
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.
|
97 |
|
98 |
A 301 code means that you want to tell the browser (or Google, bing, etc.) that your new page has permanently moved to a new location. This is great for search engines because it lets them know that there was a page there once, but now go to the new place to get it - and they update there old link to is so future visitors will not have to go through the same process.
|
99 |
|
100 |
-
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
|
101 |
|
102 |
= So, which one do I use? =
|
103 |
-
Easiest way to decide is this: If you want the page to
|
104 |
|
105 |
Still not sure? Try 302 for now - at least until you have a little time to read up on the subject.
|
106 |
|
@@ -110,11 +111,23 @@ Yes, you can, but you do not always need to. If you are redirecting to an extern
|
|
110 |
|
111 |
== Screenshots ==
|
112 |
|
113 |
-
1.
|
114 |
2. Quick 301 Redirects Page (Added in version 1.8).
|
115 |
-
3.
|
|
|
116 |
|
117 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
= 3.2.3 =
|
119 |
* Fix New Window and No Follow attributes in themes with older menu calls. (12/29/10)
|
120 |
= 3.2.2 =
|
@@ -125,7 +138,7 @@ Yes, you can, but you do not always need to. If you are redirecting to an extern
|
|
125 |
= 3.2 =
|
126 |
* remove functions ppr_linktotarget, ppr_linktonorel, ppr_redirectto and ppr_linktometa.(12/10/2010)
|
127 |
* re-write functions to consolidate queries. (12/10/2010)
|
128 |
-
* added new filters for New menu structure to filter wp_nav_menu menus as well as old wp_page_menus functions. (12/10/2010)
|
129 |
* cleaned up new window and nofollow code to work more consistently. (12/10/2010)
|
130 |
= 3.1 =
|
131 |
* Re-issue of 2.1 for immediate fix of issue with the 3.0 version.(6/21/2010)
|
@@ -147,11 +160,11 @@ Yes, you can, but you do not always need to. If you are redirecting to an extern
|
|
147 |
= 1.8 =
|
148 |
* Added a new Quick 301 Redirects Page to allow adding of additional redirects that do not have Pages or Posts created for them. Based on Scott Nelle's Simple 301 Redirects plugin.(12/28/2009)
|
149 |
= 1.7 =
|
150 |
-
* fix to correct meta redirect - moved "exit"
|
151 |
= 1.6.1 =
|
152 |
* Small fix to correct the same problem as 1.6 for Category and Archive pages (9/1/2009)
|
153 |
= 1.6 =
|
154 |
-
* Fixed
|
155 |
= 1.5 =
|
156 |
* 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.
|
157 |
* Removed the 'no code' redirect, as it turns out, many browsers will not redirect properly without a code - sorry guys.
|
@@ -165,4 +178,9 @@ Yes, you can, but you do not always need to. If you are redirecting to an extern
|
|
165 |
= 1.1 =
|
166 |
* Fix redirect for off site links (7/7/2009)
|
167 |
= 1.0 =
|
168 |
-
* Initial Plugin creation (7/1/2009)
|
|
|
|
|
|
|
|
|
|
1 |
=== Quick Page/Post Redirect ===
|
2 |
Contributors: Don Fischer
|
3 |
Donate link: http://www.fischercreativemedia.com/wordpress-plugins/donate/
|
4 |
+
Tags: redirect, 301, 302, meta, post, plugin, page, forward, re-direct, nofollow, menu links, posts, pages, admin, 404, custom post types, nav menu
|
5 |
Requires at least: 2.5
|
6 |
+
Tested up to: 3.2
|
7 |
+
Stable tag: 4.0.1
|
8 |
|
9 |
+
Redirect Pages/Posts to another page/post or external URL. Has edit box as well as global options. Specify the redirect Location and type.
|
|
|
|
|
|
|
|
|
10 |
|
11 |
== Description ==
|
|
|
|
|
12 |
|
|
|
13 |
It adds an option box to the edit section where you can specify the redirect location and type of redirect that you want, temporary, permanent, or meta. See below for additional features added.
|
14 |
|
15 |
= Features: =
|
16 |
+
* Works with new WordPress menus
|
17 |
+
* Works with new WordPress Custom Post Types (set option on settings page)
|
18 |
+
* you set a redirect page or menu link to open in a new window (will not work on permalinks)
|
19 |
+
* You can add a *rel="nofollow"* attribute to the page or menu link of the redirect (will not work on permalinks)
|
20 |
+
* You can completely re-write the URL for the redirect so it takes the place of the default page URL (rewrite the href link)
|
21 |
* You can redirect without needing to create a Page or Post. This is very useful for sites that were converted to WordPress and have old links that create 404 errors (see FAQs for more information). This option does not allow for open in a new window or nofollow functions.
|
22 |
+
* Redirect Location can be to another WordPress page/post or any other website with an external URL.
|
23 |
* Redirect can use a full URL path, the post or page ID, permalink or page-name (not available for Quick Redirects method).
|
24 |
+
* Option Screen to set global overrides like turning off all redirects at once, setting a global destination link, make all redirect open in a new window, etc.
|
25 |
+
* View a summary of all individual redirected pages/posts or custom post types that are currently set up.
|
26 |
+
|
27 |
+
This plugin is not compatible with WordPress versions less than 2.5.
|
28 |
|
|
|
29 |
=PLEASE NOTE:= A new page or post needs to be Published in order for the redirect to happen. It WILL work on a DRAFT Status Post/Page ONLY, and I mean ONLY, if the Post/Page has FIRST been Published and the re-saved as a Draft.
|
30 |
|
31 |
= TROUBLESHOOTING: =
|
32 |
+
* To include custom post types, check the setting on the main plugin option page.
|
33 |
+
* If you check the box for "Show Redirect URL below" on the edit page, please note that you MUST use the full URL in the Redirect URL box. If you do not, you may experience some odd links and 404 pages, as this option changes the Permalink for the page/post to the EXACT URL you enter in that field. (i.e., if you enter '2' in the field, it will redirect to 'http://2' which is not the same as 'http://yoursite.com/?p=2').
|
34 |
+
* If your browser tells you that your are in an infinite loop, check to make sure you do not have pages redirecting to another page that redirects back to the initial page. That WILL cause an infinite loop.
|
35 |
+
* If you are using the Quick 301 Redirects method to do your redirects, be sure that your Request URL starts with a / and is relative to the root (i.e., http://mysite.com/test/ would have /test/ in the request field).
|
36 |
+
* 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.
|
37 |
* If your page or post is not redirecting, this is most likely because something else like the theme functions file or another plugin is outputting the header BEFORE the plugin can perform the redirect. This can be tested by turning off all plugins except the Quick Page/Post Redirect Plugin and testing if the redirect works. 9 out of 10 times, a plugin or bad code is the culprit.
|
38 |
* We have tested the plugin in dozens of themes and alongside a whole lot more plugins. In our experience, (with exception to a few bugs) most of the time another plugin is the problem. If you do notice a problem, please let us know at plugins@fischercreativemedia.com - along with the WP version, theme you are using and plugins you have installed - and we will try to troubleshoot the problem.
|
39 |
|
40 |
== Installation ==
|
41 |
|
42 |
= If you downloaded this plugin: =
|
43 |
+
1. Upload `quick_page_post_redirect` folder to the `/wp-content/plugins/` directory
|
44 |
+
1. Activate the plugin through the 'Plugins' menu in WordPress
|
45 |
+
1. Once Activated, you can add a redirect by entering the correct information in the `Quick Page/Post Redirect` box in the edit section of a page or post
|
46 |
+
1. You can create a redirect with the 'Quick Redirects' option located in the Admin Settings menu.
|
47 |
|
48 |
= If you install this plugin through WordPress 2.8+ plugin search interface: =
|
49 |
+
1. Click Install `Quick Page/Post Redirect Plugin`
|
50 |
+
1. Activate the plugin through the 'Plugins' menu in WordPress
|
51 |
+
1. Once Activated, you can add a redirect by entering the correct information in the `Quick Page/Post Redirect` box in the edit section of a page or post
|
52 |
+
1. You can create a redirect with the 'Quick Redirects' option located in the Admin Settings menu.
|
53 |
|
54 |
== Frequently Asked Questions ==
|
55 |
= With 3.0s new menu structure, isn't your plugin now obsolete? =
|
56 |
Yes, and No. Mostly No.
|
57 |
+
Here is why - with WordPress 3.0, comes the new menu structure, but only a handful of themes actually have the menu structure already integrated into theme. This means that there are tons of themes out there that still need to use the the old way until they can update their theme template pages and functions to turn on the menu capability.
|
58 |
+
Additionally, the Quick Redirects option still allows you to create redirects for any url on your site, so that is very much not obsolete (until WP makes something to do that as well). And as a final note, the plugin is still compatible with WP's new menu functionality using the standard page/post creations - only custom menu items will be out of the plugin's realm of redirects - and you could set the URL in the new WP menu anyway, so that would be covered.
|
59 |
|
60 |
= I still can't get the OPEN IN NEW WINDOW option to work... why? =
|
61 |
+
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.
|
62 |
+
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.
|
63 |
|
64 |
= Do I need to have a Page or Post Created to redirect? =
|
65 |
+
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,
|
66 |
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.
|
67 |
|
68 |
+
The functionality is located in the REDIRECT MENU under Quick Redirects. The old URL goes in the Request field and the to new URL goes in the Destination field. Simple and Quick!
|
69 |
|
70 |
= Can I add 'rel="nofollow" attribute to the redirect link? =
|
71 |
+
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 not available for the Quick Redirects method or for permalinks and link within post content.
|
72 |
|
73 |
= Can I make the redirect open in a new window? =
|
74 |
+
YES, you can make the redirect link open in a new window. Simply check the "Open in a new window" box when setting up the redirect on the page/post edit page. Note - this option is not available for the Quick Redirects method or for permalinks and link within post content.
|
75 |
|
76 |
= 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? =
|
77 |
+
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. Note - this option is not available for the Quick Redirects method.
|
78 |
|
79 |
= I have Business Cards/Postcards/Ads that say my website is http://something.com/my-name/ or http://something.com/my-product/, can I set that up with this? =
|
80 |
YES! Just set up a redirect (see above) and set the Request field to /my-name/ or /my-product/ and the Destination field to the place you want it to go. The destination doesn't even need to be on the same site - it can go anywhere you want it to go!
|
81 |
|
82 |
= Why is my Page/Post not redirecting? =
|
83 |
+
FIRST - make sure it is active. Then, check to make sure the global option to turn off all redirects is not checked.
|
84 |
+
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. 9 out of 10 times, a plugin or bad code is the culprit - or the redirect is just simply turned off.
|
85 |
|
86 |
We have tested the plugin in dozens of themes and a whole lot more plugins. In our experience, (with exception to a few bugs) most of the time another plugin is the problem. If you do notice a problem, please let us know at plugins@fischercreativemedia.com - along with the WP version, theme you are using and plugins you have installed - and we will try to troubleshoot the problem.
|
87 |
|
91 |
= Can I do a permanent 301 Redirect? =
|
92 |
Yes. You can perform a 301 Permanent Redirect. Additionally, you can select a 302 Temporary or a 307 Temporary redirect or a Meta redirect.
|
93 |
|
94 |
+
= What the heck is a 301 or 302 redirect anyway? =
|
95 |
+
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 ore the most common.
|
96 |
|
97 |
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.
|
98 |
|
99 |
A 301 code means that you want to tell the browser (or Google, bing, etc.) that your new page has permanently moved to a new location. This is great for search engines because it lets them know that there was a page there once, but now go to the new place to get it - and they update there old link to is so future visitors will not have to go through the same process.
|
100 |
|
101 |
+
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.
|
102 |
|
103 |
= So, which one do I use? =
|
104 |
+
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 want to hide the responses code from the spiders, use the `no code` option, and 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.
|
105 |
|
106 |
Still not sure? Try 302 for now - at least until you have a little time to read up on the subject.
|
107 |
|
111 |
|
112 |
== Screenshots ==
|
113 |
|
114 |
+
1. The Redirect Menu and available option pages (updated for version 4.0).
|
115 |
2. Quick 301 Redirects Page (Added in version 1.8).
|
116 |
+
3. Main settings and Options page (new in version 4.0)
|
117 |
+
4. Summary of redirects page (new in version 4.0)
|
118 |
|
119 |
== Changelog ==
|
120 |
+
= 4.0 =
|
121 |
+
* Rewrite of all functions for better optimization.(05/01/2011)
|
122 |
+
* Added consolidated DB call at class setup to reduce DB calls to one call per page load.(05/01/2011)
|
123 |
+
* Moved entire plugin into a class for easier updates.(05/01/2011)
|
124 |
+
* Added new Options page with Global Overrides.(05/02/2011)
|
125 |
+
* Integrated Custom Post Types functionality.(05/02/2011)
|
126 |
+
* Created a Summary Page for a quick glace of set up redirects.(05/04/2011)
|
127 |
+
* Moved Quick Redirects menu from settings to a new Redirects Menu.(05/03/2011)
|
128 |
+
* Added additional checks and validations when adding Quick Redirects.(05/03/2011)
|
129 |
+
* Added a way to delete Quick Redirects easier.(03/01/2011)
|
130 |
+
|
131 |
= 3.2.3 =
|
132 |
* Fix New Window and No Follow attributes in themes with older menu calls. (12/29/10)
|
133 |
= 3.2.2 =
|
138 |
= 3.2 =
|
139 |
* remove functions ppr_linktotarget, ppr_linktonorel, ppr_redirectto and ppr_linktometa.(12/10/2010)
|
140 |
* re-write functions to consolidate queries. (12/10/2010)
|
141 |
+
* added new filters for New menu structure to filter wp_nav_menu menus as well as old wp_page_menus functions. (12/10/2010)
|
142 |
* cleaned up new window and nofollow code to work more consistently. (12/10/2010)
|
143 |
= 3.1 =
|
144 |
* Re-issue of 2.1 for immediate fix of issue with the 3.0 version.(6/21/2010)
|
160 |
= 1.8 =
|
161 |
* Added a new Quick 301 Redirects Page to allow adding of additional redirects that do not have Pages or Posts created for them. Based on Scott Nelle's Simple 301 Redirects plugin.(12/28/2009)
|
162 |
= 1.7 =
|
163 |
+
* 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)
|
164 |
= 1.6.1 =
|
165 |
* Small fix to correct the same problem as 1.6 for Category and Archive pages (9/1/2009)
|
166 |
= 1.6 =
|
167 |
+
* 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)
|
168 |
= 1.5 =
|
169 |
* 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.
|
170 |
* Removed the 'no code' redirect, as it turns out, many browsers will not redirect properly without a code - sorry guys.
|
178 |
= 1.1 =
|
179 |
* Fix redirect for off site links (7/7/2009)
|
180 |
= 1.0 =
|
181 |
+
* Initial Plugin creation (7/1/2009)
|
182 |
+
|
183 |
+
== Upgrade Notice ==
|
184 |
+
|
185 |
+
= 4.0 =
|
186 |
+
This upgrade contains new features and drastically reduces the plugin overhead on your site. It is strongly recommended that you updgrade.
|
screenshot-1.jpg
CHANGED
Binary file
|
screenshot-2.jpg
CHANGED
Binary file
|
screenshot-3.jpg
CHANGED
Binary file
|
screenshot-4.jpg
ADDED
Binary file
|
settings-16-icon.png
ADDED
Binary file
|
settings-icon.png
ADDED
Binary file
|