Version Description
Changed
* Allow for escaped values on _redirect_rule_from
, useful when importing regex (props @raymondware)
* Check current_user_can
cap later to prevent the notice being thrown during Jetpack sitemap cron event runs (props @rebeccahum)
* Updated tests and documentation (props @adamsilverstein, @jeffpaul, @helen)
* Check correct meta field when updating notes (props @lucymtc, @adamsilverstein)
* Bump WordPress version "tested up to" 5.3 (props @jeffpaul)
Fixed
* Update the logic for wildcard matching to properly match URLs with query parameters (props @adamsilverstein, @mslinnea
Security
* Bump lodash from 4.17.11 to 4.17.15 (props @dependabot)
Download this release
Release Info
Developer | 10upbot |
Plugin | Safe Redirect Manager |
Version | 1.9.3 |
Comparing to | |
See all releases |
Code changes from version 1.9.2 to 1.9.3
- README.md +0 -95
- inc/classes/class-srm-post-type.php +3 -3
- inc/classes/class-srm-redirect.php +4 -1
- inc/functions.php +1 -1
- readme.txt +54 -5
- safe-redirect-manager.php +1 -1
README.md
DELETED
@@ -1,95 +0,0 @@
|
|
1 |
-
Safe Redirect Manager [![Build Status](https://travis-ci.org/10up/safe-redirect-manager.svg?branch=master)](https://travis-ci.org/10up/safe-redirect-manager)
|
2 |
-
==============
|
3 |
-
|
4 |
-
A WordPress plugin to safely and easily manage your website's HTTP redirects.
|
5 |
-
|
6 |
-
<p align="center">
|
7 |
-
<a href="http://10up.com/contact/"><img src="https://10updotcom-wpengine.s3.amazonaws.com/uploads/2016/10/10up-Github-Banner.png" width="850"></a>
|
8 |
-
</p>
|
9 |
-
|
10 |
-
## Purpose
|
11 |
-
|
12 |
-
Easily and safely manage your site's redirects the WordPress way. There are many redirect plugins available. Most of
|
13 |
-
them store redirects in the options table or in custom tables. Most of them provide tons of unnecessary options. Some
|
14 |
-
of them have serious performance implications (404 error logging). Safe Redirect Manager stores redirects as Custom
|
15 |
-
Post Types. This makes your data portable and your website scalable. Safe Redirect Manager is built to handle enterprise
|
16 |
-
level traffic and is used on major publishing websites. The plugin comes with only what you need following the
|
17 |
-
WordPress mantra, decisions not options. Actions in filters make the plugin very extensible.
|
18 |
-
|
19 |
-
## Installation
|
20 |
-
|
21 |
-
Install the plugin in WordPress. You can download a
|
22 |
-
[zip via Github](https://github.com/10up/safe-redirect-manager/archive/master.zip) and upload it using the WP
|
23 |
-
plugin uploader.
|
24 |
-
|
25 |
-
## Non-English Usage
|
26 |
-
Safe Redirect Manager is available in English, French, and Slovak. Instructions for translating the plugin into other
|
27 |
-
languages are below.
|
28 |
-
|
29 |
-
## Configuration
|
30 |
-
|
31 |
-
There are no overarching settings for this plugin. To manager redirects navigate to the administration panel. Within
|
32 |
-
the main menu, click "Tools" > "Safe Redirect Manager".
|
33 |
-
|
34 |
-
Each redirect contains a few fields that you can utilize:
|
35 |
-
|
36 |
-
#### "Redirect From"
|
37 |
-
This should be a path relative to the root of your WordPress installation. When someone visits your site with a path
|
38 |
-
that matches this one, a redirect will occur. If your site is located at ```http://example.com/wp/``` and you wanted to redirect `http://example.com/wp/about` to `http://example.com`, your "Redirect From" would be `/about`.
|
39 |
-
|
40 |
-
Clicking the "Enable Regex" checkbox allows you to use regular expressions in your path. There are many
|
41 |
-
[great tutorials](http://www.regular-expressions.info) on regular expressions.
|
42 |
-
|
43 |
-
You can also use wildcards in your "Redirect From" paths. By adding an `*` at the end of a URL, your redirect will
|
44 |
-
match any request that starts with your "Redirect From". Wildcards support replacements. This means if you have a
|
45 |
-
wildcard in your from path that matches a string, you can have that string replace a wildcard character in your
|
46 |
-
"Redirect To" path. For example, if your "Redirect From" is `/test/*`, your "Redirect To" is
|
47 |
-
`http://google.com/*`, and the requested path is `/test/string`, the user would be redirect to `http://google.com/string`.
|
48 |
-
|
49 |
-
#### "Redirect To"
|
50 |
-
This should be a path i.e. `/test` or a URL i.e. `http://example.com/wp/test`. If a requested path matches
|
51 |
-
"Redirect From", they will be redirected here. "Redirect To" supports wildcard and regular expression replacements.
|
52 |
-
|
53 |
-
#### "HTTP Status Code"
|
54 |
-
[HTTP status codes](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html) are numbers that contain information about
|
55 |
-
a request i.e. whether it was successful, unauthorized, not found, etc. You should almost always use either 302,
|
56 |
-
temporarily moved, or 301, permanently moved.
|
57 |
-
|
58 |
-
*Note:*
|
59 |
-
|
60 |
-
* Redirects are cached using the Transients API. Cache busts occur when redirects are added, updated, and deleted
|
61 |
-
so you shouldn't be serving stale redirects.
|
62 |
-
* By default the plugin only allows at most 250 redirects to prevent performance issues. There is a filter
|
63 |
-
`srm_max_redirects` that you can utilize to up this number.
|
64 |
-
* "Redirect From" and requested paths are case insensitive by default.
|
65 |
-
|
66 |
-
## Redirect loops
|
67 |
-
|
68 |
-
By default redirect loop detection is disabled. To prevent redirect loops you can filter `srm_check_for_possible_redirect_loops`.
|
69 |
-
|
70 |
-
```php
|
71 |
-
add_filter( 'my_srm_redirect_loop_filter', '__return_true' );
|
72 |
-
```
|
73 |
-
|
74 |
-
## Development
|
75 |
-
|
76 |
-
#### Setup
|
77 |
-
Follow the configuration instructions above to setup the plugin. I recommend developing the plugin locally in an
|
78 |
-
environment such as [WP Local Docker](https://github.com/10up/wp-local-docker).
|
79 |
-
|
80 |
-
#### Testing
|
81 |
-
Within the terminal change directories to the plugin folder. Initialize your unit testing environment by running the
|
82 |
-
following command:
|
83 |
-
|
84 |
-
```bash
|
85 |
-
bash bin/install-wp-tests.sh database username password host version
|
86 |
-
```
|
87 |
-
|
88 |
-
Run the plugin tests:
|
89 |
-
```bash
|
90 |
-
phpunit
|
91 |
-
```
|
92 |
-
|
93 |
-
#### Issues
|
94 |
-
If you identify any errors or have an idea for improving the plugin, please
|
95 |
-
[open an issue](https://github.com/10up/safe-redirect-manager/issues?state=open).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inc/classes/class-srm-post-type.php
CHANGED
@@ -403,12 +403,12 @@ class SRM_Post_Type {
|
|
403 |
* @return void
|
404 |
*/
|
405 |
public function action_save_post( $post_id ) {
|
406 |
-
if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) ||
|
407 |
return;
|
408 |
}
|
409 |
|
410 |
// Update post meta for redirect rules
|
411 |
-
if ( ! empty( $_POST['srm_redirect_nonce'] ) && wp_verify_nonce( $_POST['srm_redirect_nonce'], 'srm-save-redirect-meta' ) ) {
|
412 |
|
413 |
if ( ! empty( $_POST['srm_redirect_rule_from_regex'] ) ) {
|
414 |
$allow_regex = (bool) $_POST['srm_redirect_rule_from_regex'];
|
@@ -436,7 +436,7 @@ class SRM_Post_Type {
|
|
436 |
delete_post_meta( $post_id, '_redirect_rule_status_code' );
|
437 |
}
|
438 |
|
439 |
-
if ( ! empty( $_POST['
|
440 |
update_post_meta( $post_id, '_redirect_rule_notes', sanitize_text_field( $_POST['srm_redirect_rule_notes'] ) );
|
441 |
} else {
|
442 |
delete_post_meta( $post_id, '_redirect_rule_notes' );
|
403 |
* @return void
|
404 |
*/
|
405 |
public function action_save_post( $post_id ) {
|
406 |
+
if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || 'revision' === get_post_type( $post_id ) ) {
|
407 |
return;
|
408 |
}
|
409 |
|
410 |
// Update post meta for redirect rules
|
411 |
+
if ( ! empty( $_POST['srm_redirect_nonce'] ) && wp_verify_nonce( $_POST['srm_redirect_nonce'], 'srm-save-redirect-meta' ) && current_user_can( 'edit_post', $post_id ) ) {
|
412 |
|
413 |
if ( ! empty( $_POST['srm_redirect_rule_from_regex'] ) ) {
|
414 |
$allow_regex = (bool) $_POST['srm_redirect_rule_from_regex'];
|
436 |
delete_post_meta( $post_id, '_redirect_rule_status_code' );
|
437 |
}
|
438 |
|
439 |
+
if ( ! empty( $_POST['srm_redirect_rule_notes'] ) ) {
|
440 |
update_post_meta( $post_id, '_redirect_rule_notes', sanitize_text_field( $_POST['srm_redirect_rule_notes'] ) );
|
441 |
} else {
|
442 |
delete_post_meta( $post_id, '_redirect_rule_notes' );
|
inc/classes/class-srm-redirect.php
CHANGED
@@ -136,7 +136,10 @@ class SRM_Redirect {
|
|
136 |
if ( ! $matched_path && ( strrpos( $redirect_from, '*' ) === strlen( $redirect_from ) - 1 ) ) {
|
137 |
$wildcard_base = substr( $redirect_from, 0, strlen( $redirect_from ) - 1 );
|
138 |
|
139 |
-
//
|
|
|
|
|
|
|
140 |
$matched_path = ( substr( $normalized_requested_path, 0, strlen( $wildcard_base ) ) === $wildcard_base );
|
141 |
if ( ( strrpos( $redirect_to, '*' ) === strlen( $redirect_to ) - 1 ) ) {
|
142 |
$redirect_to = rtrim( $redirect_to, '*' ) . ltrim( substr( $requested_path, strlen( $wildcard_base ) ), '/' );
|
136 |
if ( ! $matched_path && ( strrpos( $redirect_from, '*' ) === strlen( $redirect_from ) - 1 ) ) {
|
137 |
$wildcard_base = substr( $redirect_from, 0, strlen( $redirect_from ) - 1 );
|
138 |
|
139 |
+
// Remove the trailing slash from the wildcard base, matching removal from request path.
|
140 |
+
$wildcard_base = untrailingslashit( $wildcard_base );
|
141 |
+
|
142 |
+
// Mark as path match if requested path matches the base of the redirect from.
|
143 |
$matched_path = ( substr( $normalized_requested_path, 0, strlen( $wildcard_base ) ) === $wildcard_base );
|
144 |
if ( ( strrpos( $redirect_to, '*' ) === strlen( $redirect_to ) - 1 ) ) {
|
145 |
$redirect_to = rtrim( $redirect_to, '*' ) . ltrim( substr( $requested_path, strlen( $wildcard_base ) ), '/' );
|
inc/functions.php
CHANGED
@@ -217,7 +217,7 @@ function srm_create_redirect( $redirect_from, $redirect_to, $status_code = 302,
|
|
217 |
}
|
218 |
|
219 |
// update the posts meta info
|
220 |
-
update_post_meta( $post_id, '_redirect_rule_from', $sanitized_redirect_from );
|
221 |
update_post_meta( $post_id, '_redirect_rule_to', $sanitized_redirect_to );
|
222 |
update_post_meta( $post_id, '_redirect_rule_status_code', $sanitized_status_code );
|
223 |
update_post_meta( $post_id, '_redirect_rule_from_regex', $sanitized_enable_regex );
|
217 |
}
|
218 |
|
219 |
// update the posts meta info
|
220 |
+
update_post_meta( $post_id, '_redirect_rule_from', wp_slash( $sanitized_redirect_from ) );
|
221 |
update_post_meta( $post_id, '_redirect_rule_to', $sanitized_redirect_to );
|
222 |
update_post_meta( $post_id, '_redirect_rule_status_code', $sanitized_status_code );
|
223 |
update_post_meta( $post_id, '_redirect_rule_from_regex', $sanitized_enable_regex );
|
readme.txt
CHANGED
@@ -2,23 +2,72 @@
|
|
2 |
Contributors: tlovett1, tollmanz, taylorde, 10up, jakemgold, danielbachhuber, VentureBeat
|
3 |
Tags: http redirects, redirect manager, url redirection, safe http redirection, multisite redirects, redirects
|
4 |
Requires at least: 3.1
|
5 |
-
Tested up to: 5.
|
6 |
-
Stable tag:
|
7 |
-
|
|
|
|
|
8 |
Safely and easily manage your website's HTTP redirects.
|
9 |
|
10 |
== Description ==
|
11 |
|
12 |
-
Safe Redirect Manager
|
13 |
|
14 |
[Fork the plugin on GitHub.](https://github.com/10up/safe-redirect-manager)
|
15 |
|
16 |
== Installation ==
|
17 |
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
== Changelog ==
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
= 1.9.2 =
|
23 |
* Fix CLI list function name for PHP 5
|
24 |
|
2 |
Contributors: tlovett1, tollmanz, taylorde, 10up, jakemgold, danielbachhuber, VentureBeat
|
3 |
Tags: http redirects, redirect manager, url redirection, safe http redirection, multisite redirects, redirects
|
4 |
Requires at least: 3.1
|
5 |
+
Tested up to: 5.3
|
6 |
+
Stable tag: 1.9.3
|
7 |
+
License: GPLv2 or later
|
8 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
+
|
10 |
Safely and easily manage your website's HTTP redirects.
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
+
Easily and safely manage your site's redirects the WordPress way. There are many redirect plugins available. Most of them store redirects in the options table or in custom tables. Most of them provide tons of unnecessary options. Some of them have serious performance implications (404 error logging). Safe Redirect Manager stores redirects as Custom Post Types. This makes your data portable and your website scalable. Safe Redirect Manager is built to handle enterprise level traffic and is used on major publishing websites. The plugin comes with only what you need following the WordPress mantra, decisions not options. Actions and filters make the plugin very extensible.
|
15 |
|
16 |
[Fork the plugin on GitHub.](https://github.com/10up/safe-redirect-manager)
|
17 |
|
18 |
== Installation ==
|
19 |
|
20 |
+
Install the plugin in WordPress. You can download a [zip via Github](https://github.com/10up/safe-redirect-manager/archive/master.zip) and upload it using the WordPress plugin uploader ("Plugins" > "Add New" > "Upload Plugin").
|
21 |
+
|
22 |
+
== Configuration ==
|
23 |
+
|
24 |
+
There are no overarching settings for this plugin. To manage redirects, navigate to the administration panel ("Tools" > "Safe Redirect Manager").
|
25 |
+
|
26 |
+
Each redirect contains a few fields that you can utilize:
|
27 |
+
|
28 |
+
=== "Redirect From" ===
|
29 |
+
This should be a path relative to the root of your WordPress installation. When someone visits your site with a path
|
30 |
+
that matches this one, a redirect will occur. If your site is located at `http://example.com/wp/`` and you wanted to redirect `http://example.com/wp/about` to `http://example.com`, your "Redirect From" would be `/about`.
|
31 |
+
|
32 |
+
Clicking the "Enable Regex" checkbox allows you to use regular expressions in your path. There are many
|
33 |
+
[great tutorials](http://www.regular-expressions.info) on regular expressions.
|
34 |
+
|
35 |
+
You can also use wildcards in your "Redirect From" paths. By adding an `*` at the end of a URL, your redirect will
|
36 |
+
match any request that starts with your "Redirect From". Wildcards support replacements. This means if you have a
|
37 |
+
wildcard in your from path that matches a string, you can have that string replace a wildcard character in your
|
38 |
+
"Redirect To" path. For example, if your "Redirect From" is `/test/*`, your "Redirect To" is
|
39 |
+
`http://google.com/*`, and the requested path is `/test/string`, the user would be redirect to `http://google.com/string`.
|
40 |
+
|
41 |
+
=== "Redirect To" ===
|
42 |
+
This should be a path (i.e. `/test`) or a URL (i.e. `http://example.com/wp/test`). If a requested path matches
|
43 |
+
"Redirect From", they will be redirected here. "Redirect To" supports wildcard and regular expression replacements.
|
44 |
+
|
45 |
+
=== "HTTP Status Code" ===
|
46 |
+
[HTTP status codes](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html) are numbers that contain information about
|
47 |
+
a request (i.e. whether it was successful, unauthorized, not found, etc). You should almost always use either 302 (temporarily moved) or 301 (permanently moved).
|
48 |
+
|
49 |
+
*Note:*
|
50 |
+
|
51 |
+
* Redirects are cached using the Transients API. Cache busts occur when redirects are added, updated, and deleted
|
52 |
+
so you shouldn't be serving stale redirects.
|
53 |
+
* By default the plugin only allows at most 250 redirects to prevent performance issues. There is a filter
|
54 |
+
`srm_max_redirects` that you can utilize to up this number.
|
55 |
+
* "Redirect From" and requested paths are case insensitive by default.
|
56 |
|
57 |
== Changelog ==
|
58 |
|
59 |
+
= 1.9.3 =
|
60 |
+
Changed
|
61 |
+
* Allow for escaped values on `_redirect_rule_from`, useful when importing regex (props [@raymondware](https://profiles.wordpress.org/raymondware))
|
62 |
+
* Check `current_user_can` cap later to prevent the notice being thrown during Jetpack sitemap cron event runs (props [@rebeccahum](https://profiles.wordpress.org/rebasaurus))
|
63 |
+
* Updated tests and documentation (props [@adamsilverstein](https://profiles.wordpress.org/adamsilverstein), [@jeffpaul](https://profiles.wordpress.org/jeffpaul), [@helen](https://profiles.wordpress.org/helen))
|
64 |
+
* Check correct meta field when updating notes (props [@lucymtc](https://profiles.wordpress.org/lucymtc), [@adamsilverstein](https://profiles.wordpress.org/adamsilverstein))
|
65 |
+
* Bump WordPress version "tested up to" 5.3 (props [@jeffpaul](https://profiles.wordpress.org/jeffpaul))
|
66 |
+
Fixed
|
67 |
+
* Update the logic for wildcard matching to properly match URLs with query parameters (props [@adamsilverstein](https://profiles.wordpress.org/adamsilverstein), [@mslinnea](https://profiles.wordpress.org/linsoftware)
|
68 |
+
Security
|
69 |
+
* Bump lodash from 4.17.11 to 4.17.15 (props [@dependabot](https://github.com/dependabot))
|
70 |
+
|
71 |
= 1.9.2 =
|
72 |
* Fix CLI list function name for PHP 5
|
73 |
|
safe-redirect-manager.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin URI: https://wordpress.org/plugins/safe-redirect-manager
|
5 |
* Description: Easily and safely manage HTTP redirects.
|
6 |
* Author: 10up
|
7 |
-
* Version: 1.9.
|
8 |
* Text Domain: safe-redirect-manager
|
9 |
* Domain Path: /lang/
|
10 |
* Author URI: https://10up.com
|
4 |
* Plugin URI: https://wordpress.org/plugins/safe-redirect-manager
|
5 |
* Description: Easily and safely manage HTTP redirects.
|
6 |
* Author: 10up
|
7 |
+
* Version: 1.9.3
|
8 |
* Text Domain: safe-redirect-manager
|
9 |
* Domain Path: /lang/
|
10 |
* Author URI: https://10up.com
|