Version Description
(Oct. 11, 2012) = * Refresh cache after create_redirect call - bug fix * Refresh cache after save_post is called - bug fix * Chop off "pre-WP" path from requested path. This allows the plugin to work on WP installations in sub-directories - bug fix
Download this release
Release Info
Developer | tlovett1 |
Plugin | Safe Redirect Manager |
Version | 1.4.1 |
Comparing to | |
See all releases |
Code changes from version 1.4 to 1.4.1
- readme.txt +6 -1
- safe-redirect-manager.php +27 -4
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: tlovett1, tollmanz, taylorde, 10up, jakemgold, danielbachhuber, Ve
|
|
3 |
Tags: http redirects, redirect manager, url redirection, safe http redirection
|
4 |
Requires at least: 3.1
|
5 |
Tested up to: 3.4.2
|
6 |
-
Stable tag: 1.4
|
7 |
|
8 |
Safely and easily manage your website's HTTP redirects.
|
9 |
|
@@ -24,6 +24,11 @@ Extract the zip file and just drop the contents in the wp-content/plugins/ direc
|
|
24 |
|
25 |
== Changelog ==
|
26 |
|
|
|
|
|
|
|
|
|
|
|
27 |
= 1.4 (Oct. 9, 2012) =
|
28 |
* Use the '*' wildcard at the end of your match value to configure a wildcard redirect. Use the same symbol at the end of your redirect to value in order to have the matched value be appended to the end of the redirect. Thanks [prettyboymp](https://github.com/prettyboymp) for the pull request
|
29 |
* Change default request-matching behavior to be case-insensitive. This can be modified using the 'srm_case_insensitive_redirects' filter.
|
3 |
Tags: http redirects, redirect manager, url redirection, safe http redirection
|
4 |
Requires at least: 3.1
|
5 |
Tested up to: 3.4.2
|
6 |
+
Stable tag: 1.4.1
|
7 |
|
8 |
Safely and easily manage your website's HTTP redirects.
|
9 |
|
24 |
|
25 |
== Changelog ==
|
26 |
|
27 |
+
= 1.4.1 (Oct. 11, 2012) =
|
28 |
+
* Refresh cache after create_redirect call - bug fix
|
29 |
+
* Refresh cache after save_post is called - bug fix
|
30 |
+
* Chop off "pre-WP" path from requested path. This allows the plugin to work on WP installations in sub-directories - bug fix
|
31 |
+
|
32 |
= 1.4 (Oct. 9, 2012) =
|
33 |
* Use the '*' wildcard at the end of your match value to configure a wildcard redirect. Use the same symbol at the end of your redirect to value in order to have the matched value be appended to the end of the redirect. Thanks [prettyboymp](https://github.com/prettyboymp) for the pull request
|
34 |
* Change default request-matching behavior to be case-insensitive. This can be modified using the 'srm_case_insensitive_redirects' filter.
|
safe-redirect-manager.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Safe Redirect Manager
|
|
4 |
Plugin URI: http://www.10up.com
|
5 |
Description: Easily and safely manage HTTP redirects.
|
6 |
Author: Taylor Lovett (10up LLC), VentureBeat
|
7 |
-
Version: 1.4
|
8 |
Author URI: http://www.10up.com
|
9 |
|
10 |
GNU General Public License, Free Software Foundation <http://creativecommons.org/licenses/GPL/2.0/>
|
@@ -229,6 +229,9 @@ class SRM_Safe_Redirect_Manager {
|
|
229 |
update_post_meta( $post_id, $this->meta_key_redirect_to, $sanitized_redirect_to );
|
230 |
update_post_meta( $post_id, $this->meta_key_redirect_status_code, $sanitized_status_code );
|
231 |
|
|
|
|
|
|
|
232 |
return $post_id;
|
233 |
}
|
234 |
|
@@ -476,6 +479,13 @@ class SRM_Safe_Redirect_Manager {
|
|
476 |
} else {
|
477 |
delete_post_meta( $post_id, $this->meta_key_redirect_status_code );
|
478 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
479 |
}
|
480 |
}
|
481 |
|
@@ -668,14 +678,27 @@ class SRM_Safe_Redirect_Manager {
|
|
668 |
*/
|
669 |
public function action_parse_request() {
|
670 |
|
671 |
-
// get requested path and add a / before it
|
672 |
-
$requested_path = sanitize_text_field( $_SERVER['REQUEST_URI'] );
|
673 |
-
|
674 |
// get redirects from cache or recreate it
|
675 |
if ( false === ( $redirects = get_transient( $this->cache_key_redirects ) ) ) {
|
676 |
$redirects = $this->update_redirect_cache();
|
677 |
}
|
678 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
679 |
foreach ( $redirects as $redirect ) {
|
680 |
|
681 |
$redirect_from = untrailingslashit( $redirect['redirect_from'] );
|
4 |
Plugin URI: http://www.10up.com
|
5 |
Description: Easily and safely manage HTTP redirects.
|
6 |
Author: Taylor Lovett (10up LLC), VentureBeat
|
7 |
+
Version: 1.4.1
|
8 |
Author URI: http://www.10up.com
|
9 |
|
10 |
GNU General Public License, Free Software Foundation <http://creativecommons.org/licenses/GPL/2.0/>
|
229 |
update_post_meta( $post_id, $this->meta_key_redirect_to, $sanitized_redirect_to );
|
230 |
update_post_meta( $post_id, $this->meta_key_redirect_status_code, $sanitized_status_code );
|
231 |
|
232 |
+
// We need to update the cache after creating this redirect
|
233 |
+
$this->update_redirect_cache();
|
234 |
+
|
235 |
return $post_id;
|
236 |
}
|
237 |
|
479 |
} else {
|
480 |
delete_post_meta( $post_id, $this->meta_key_redirect_status_code );
|
481 |
}
|
482 |
+
|
483 |
+
/**
|
484 |
+
* This fixes an important bug where the redirect cache was not up-to-date. Previously the cache was only being
|
485 |
+
* updated on transition_post_status which gets called BEFORE save post. But since save_post is where all the important
|
486 |
+
* redirect info is saved, updating the cache before it is not sufficient.
|
487 |
+
*/
|
488 |
+
$this->update_redirect_cache();
|
489 |
}
|
490 |
}
|
491 |
|
678 |
*/
|
679 |
public function action_parse_request() {
|
680 |
|
|
|
|
|
|
|
681 |
// get redirects from cache or recreate it
|
682 |
if ( false === ( $redirects = get_transient( $this->cache_key_redirects ) ) ) {
|
683 |
$redirects = $this->update_redirect_cache();
|
684 |
}
|
685 |
|
686 |
+
// If we have no redirects, there is no need to continue
|
687 |
+
if ( empty( $redirects ) )
|
688 |
+
return;
|
689 |
+
|
690 |
+
// get requested path and add a / before it
|
691 |
+
$requested_path = sanitize_text_field( $_SERVER['REQUEST_URI'] );
|
692 |
+
|
693 |
+
/**
|
694 |
+
* If WordPress resides in a directory that is not the public root, we have to chop
|
695 |
+
* the pre-WP path off the requested path.
|
696 |
+
*/
|
697 |
+
$parsed_site_url = parse_url( site_url() );
|
698 |
+
if ( '/' != $parsed_site_url['path'] ) {
|
699 |
+
$requested_path = preg_replace( '@' . $parsed_site_url['path'] . '@i', '', $requested_path, 1 );
|
700 |
+
}
|
701 |
+
|
702 |
foreach ( $redirects as $redirect ) {
|
703 |
|
704 |
$redirect_from = untrailingslashit( $redirect['redirect_from'] );
|