Version Description
-
Added: Formatting options to
wp safe-redirect-manager list
command (props @dinhtungdu, @TheLastCicada). - Changed: Increased redirect limits from 250 to 1,000 (props @sultann, @dinhtungdu, @jilltilt, @yeevy).
- Changed: Bump WordPress version "tested up to" 5.8 (props @jeffpaul, @ankitguptaindia, @phpbits).
- Fixed: Required parameter following optional deprecated message in PHP 8 (props @vinkla, @dinhtungdu).
-
Fixed: Edge case when redirecting a URL with parameters where
$parsed_requested_path['path']
does not always exist (props @dinhtungdu, @davidmondok). - Fixed: Formatting fix to prevent npm install error (props @phpbits).
-
Security: Bump
minimist
from 0.0.8 to 1.2.5 (props @dependabot). -
Security: Bump
lodash
from 4.17.19 to 4.17.21 (props @dependabot).
Download this release
Release Info
Developer | 10upbot |
Plugin | Safe Redirect Manager |
Version | 1.10.1 |
Comparing to | |
See all releases |
Code changes from version 1.10.0 to 1.10.1
- README.md +0 -179
- inc/classes/class-srm-post-type.php +3 -3
- inc/classes/class-srm-redirect.php +7 -3
- inc/classes/class-srm-wp-cli.php +44 -18
- inc/functions.php +17 -8
- readme.txt +17 -6
- safe-redirect-manager.php +1 -1
README.md
DELETED
@@ -1,179 +0,0 @@
|
|
1 |
-
# Safe Redirect Manager
|
2 |
-
|
3 |
-
> A WordPress plugin to safely and easily manage your website's HTTP redirects.
|
4 |
-
|
5 |
-
[![Support Level](https://img.shields.io/badge/support-active-green.svg)](#support-level) [![Build Status](https://travis-ci.org/10up/safe-redirect-manager.svg?branch=develop)](https://travis-ci.org/10up/safe-redirect-manager) [![Release Version](https://img.shields.io/github/release/10up/safe-redirect-manager.svg)](https://github.com/10up/safe-redirect-manager/releases/latest) ![WordPress tested up to version](https://img.shields.io/badge/WordPress-v5.5.3%20tested-success.svg) [![GPLv2 License](https://img.shields.io/github/license/10up/safe-redirect-manager.svg)](https://github.com/10up/safe-redirect-manager/blob/develop/LICENSE.md)
|
6 |
-
|
7 |
-
## Purpose
|
8 |
-
|
9 |
-
Easily and safely manage your site's redirects the WordPress way. There are many redirect plugins available. Most of
|
10 |
-
them store redirects in the options table or in custom tables. Most of them provide tons of unnecessary options. Some
|
11 |
-
of them have serious performance implications (404 error logging). Safe Redirect Manager stores redirects as Custom
|
12 |
-
Post Types. This makes your data portable and your website scalable. Safe Redirect Manager is built to handle enterprise
|
13 |
-
level traffic and is used on major publishing websites. The plugin comes with only what you need following the
|
14 |
-
WordPress mantra, decisions not options. Actions and filters make the plugin very extensible.
|
15 |
-
|
16 |
-
## Installation
|
17 |
-
|
18 |
-
Install the plugin in WordPress. You can download a
|
19 |
-
[zip via GitHub](https://github.com/10up/safe-redirect-manager/archive/master.zip) and upload it using the WordPress
|
20 |
-
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 |
-
* Developers can use `srm_additional_status_codes` filter to add status codes if needed.
|
57 |
-
|
58 |
-
## Filters
|
59 |
-
|
60 |
-
### Redirect loops detection
|
61 |
-
|
62 |
-
By default redirect loop detection is disabled. To prevent redirect loops you can filter `srm_check_for_possible_redirect_loops`.
|
63 |
-
|
64 |
-
```php
|
65 |
-
add_filter( 'srm_check_for_possible_redirect_loops', '__return_true' );
|
66 |
-
```
|
67 |
-
|
68 |
-
### Only redirect if 404 occurs
|
69 |
-
|
70 |
-
By default every matched URL is redirected. To only redirect matched but not found URLs (i.e., 404 pages), use `srm_redirect_only_on_404`.
|
71 |
-
|
72 |
-
```php
|
73 |
-
add_filter( 'srm_redirect_only_on_404', '__return_true' );
|
74 |
-
```
|
75 |
-
|
76 |
-
## CLI commands
|
77 |
-
|
78 |
-
The following WP-CLI commands are supported by Safe Redirect Manager:
|
79 |
-
|
80 |
-
* **`wp safe-redirect-manager list`**
|
81 |
-
|
82 |
-
List all of the currently configured redirects.
|
83 |
-
|
84 |
-
* **`wp safe-redirect-manager create <from> <to> [<status-code>] [<enable-regex>] [<post-status>]`**
|
85 |
-
|
86 |
-
Create a redirect. `<from>` and `<to>` are required parameters.
|
87 |
-
|
88 |
-
* `<from>`: Redirect from path. Required.
|
89 |
-
|
90 |
-
* `<to>`: Redirect to path. Required.
|
91 |
-
|
92 |
-
* `<status-code>`: HTTP Status Code. Optional. Default to `302`.
|
93 |
-
|
94 |
-
* `<enable-regex>`: Whether to enable Regular expression. Optional. Default to `false`.
|
95 |
-
|
96 |
-
* `<post-status>`: The status of the redirect. Optional. Default to `publish`.
|
97 |
-
|
98 |
-
**Example:** `wp safe-redirect-manager create /about-us /contact-us 301`
|
99 |
-
|
100 |
-
* **`wp safe-redirect-manager delete <id>`**
|
101 |
-
|
102 |
-
Delete a redirect by `<id>`.
|
103 |
-
|
104 |
-
* **`wp safe-redirect-manager update-cache`**
|
105 |
-
|
106 |
-
Update the redirect cache.
|
107 |
-
|
108 |
-
* **`wp safe-redirect-manager import <file> [--source=<source-column>] [--target=<target-column>] [--regex=<regex-column>] [--code=<code-column>] [--order=<order-column>]`**
|
109 |
-
|
110 |
-
Imports redirects from a CSV file.
|
111 |
-
|
112 |
-
* `<file>`: Path to one or more valid CSV file for import. This file should contain redirection from and to URLs, regex flag and HTTP redirection code. Here is the example table:
|
113 |
-
|
114 |
-
| source | target | regex | code | order |
|
115 |
-
|----------------------------|--------------------|-------|------|-------|
|
116 |
-
| /legacy-url | /new-url | 0 | 301 | 0 |
|
117 |
-
| /category-1 | /new-category-slug | 0 | 302 | 1 |
|
118 |
-
| /tes?t/[0-9]+/path/[^/]+/? | /go/here | 1 | 302 | 3 |
|
119 |
-
| ... | ... | ... | ... | ... |
|
120 |
-
|
121 |
-
_You can also use exported redirects from "Redirection" plugin, which you can download here: /wp-admin/tools.php?page=redirection.php&sub=modules_
|
122 |
-
|
123 |
-
* `--source`: Header title for source ("from" URL) column mapping.
|
124 |
-
|
125 |
-
* `--target`: Header title for target ("to" URL) column mapping.
|
126 |
-
|
127 |
-
* `--regex`: Header title for regex column mapping.
|
128 |
-
|
129 |
-
* `--code`: Header title for code column mapping.
|
130 |
-
|
131 |
-
* `--order`: Header title for order column mapping.
|
132 |
-
|
133 |
-
* **`wp safe-redirect-manager import-htaccess <file>`**
|
134 |
-
|
135 |
-
Import .htaccess file redirects.
|
136 |
-
|
137 |
-
## Development
|
138 |
-
|
139 |
-
#### Setup
|
140 |
-
Follow the configuration instructions above to setup the plugin. We recommend developing the plugin locally in an
|
141 |
-
environment such as [WP Local Docker](https://github.com/10up/wp-local-docker).
|
142 |
-
|
143 |
-
#### Testing
|
144 |
-
Within the terminal change directories to the plugin folder. Initialize your unit testing environment by running the
|
145 |
-
following command:
|
146 |
-
|
147 |
-
```bash
|
148 |
-
bash bin/install-wp-tests.sh database username password host version
|
149 |
-
```
|
150 |
-
|
151 |
-
Run the plugin tests:
|
152 |
-
```bash
|
153 |
-
phpunit
|
154 |
-
```
|
155 |
-
|
156 |
-
#### Issues
|
157 |
-
If you identify any errors or have an idea for improving the plugin, please
|
158 |
-
[open an issue](https://github.com/10up/safe-redirect-manager/issues?state=open).
|
159 |
-
|
160 |
-
## Translations
|
161 |
-
Safe Redirect Manager is available in English and other languages. A listing of those languages and instructions for translating the plugin into other languages is available on [Translating WordPress](https://translate.wordpress.org/projects/wp-plugins/safe-redirect-manager/). Many thanks to the [contributors on the translation teams](https://translate.wordpress.org/projects/wp-plugins/safe-redirect-manager/contributors/)!
|
162 |
-
|
163 |
-
## Support Level
|
164 |
-
|
165 |
-
**Active:** 10up is actively working on this, and we expect to continue work for the foreseeable future including keeping tested up to the most recent version of WordPress. Bug reports, feature requests, questions, and pull requests are welcome.
|
166 |
-
|
167 |
-
## Changelog
|
168 |
-
|
169 |
-
A complete listing of all notable changes to Safe Redirect Manager are documented in [CHANGELOG.md](https://github.com/10up/safe-redirect-manager/blob/develop/CHANGELOG.md).
|
170 |
-
|
171 |
-
## Contributing
|
172 |
-
|
173 |
-
Please read [CODE_OF_CONDUCT.md](https://github.com/10up/safe-redirect-manager/blob/develop/CODE_OF_CONDUCT.md) for details on our code of conduct, [CONTRIBUTING.md](https://github.com/10up/safe-redirect-manager/blob/develop/CONTRIBUTING.md) for details on the process for submitting pull requests to us, and [CREDITS.md](https://github.com/10up/safe-redirect-manager/blob/develop/CREDITS.md) for a listing of maintainers of, contributors to, and libraries used by Safe Redirect Manager.
|
174 |
-
|
175 |
-
## Like what you see?
|
176 |
-
|
177 |
-
<p align="center">
|
178 |
-
<a href="http://10up.com/contact/"><img src="https://10updotcom-wpengine.s3.amazonaws.com/uploads/2016/10/10up-Github-Banner.png" width="850"></a>
|
179 |
-
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inc/classes/class-srm-post-type.php
CHANGED
@@ -90,12 +90,12 @@ class SRM_Post_Type {
|
|
90 |
/**
|
91 |
* Remove quick edit
|
92 |
*
|
93 |
-
* @param array
|
94 |
-
* @param WP_Post $post Post object
|
95 |
* @since 1.8
|
96 |
* @return array
|
97 |
*/
|
98 |
-
public function filter_disable_quick_edit( $actions
|
99 |
if ( 'redirect_rule' === get_post_type( $post ) && isset( $actions['inline hide-if-no-js'] ) ) {
|
100 |
unset( $actions['inline hide-if-no-js'] );
|
101 |
unset( $actions['view'] );
|
90 |
/**
|
91 |
* Remove quick edit
|
92 |
*
|
93 |
+
* @param array $actions Array of actions
|
94 |
+
* @param int|WP_Post|null $post Post object
|
95 |
* @since 1.8
|
96 |
* @return array
|
97 |
*/
|
98 |
+
public function filter_disable_quick_edit( $actions, $post ) {
|
99 |
if ( 'redirect_rule' === get_post_type( $post ) && isset( $actions['inline hide-if-no-js'] ) ) {
|
100 |
unset( $actions['inline hide-if-no-js'] );
|
101 |
unset( $actions['view'] );
|
inc/classes/class-srm-redirect.php
CHANGED
@@ -113,13 +113,17 @@ class SRM_Redirect {
|
|
113 |
$parsed_requested_path = parse_url( $normalized_requested_path );
|
114 |
}
|
115 |
// Normalize the request path with and without query strings, for comparison later
|
116 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
if ( ! empty( $parsed_requested_path['query'] ) ) {
|
118 |
$requested_query_params = $parsed_requested_path['query'];
|
119 |
}
|
120 |
|
121 |
-
$normalized_requested_path_no_query = untrailingslashit( stripslashes( $parsed_requested_path['path'] ) );
|
122 |
-
|
123 |
foreach ( (array) $redirects as $redirect ) {
|
124 |
|
125 |
$redirect_from = untrailingslashit( $redirect['redirect_from'] );
|
113 |
$parsed_requested_path = parse_url( $normalized_requested_path );
|
114 |
}
|
115 |
// Normalize the request path with and without query strings, for comparison later
|
116 |
+
$normalized_requested_path_no_query = '';
|
117 |
+
$requested_query_params = '';
|
118 |
+
|
119 |
+
if ( ! empty( $parsed_requested_path['path'] ) ) {
|
120 |
+
$normalized_requested_path_no_query = untrailingslashit( stripslashes( $parsed_requested_path['path'] ) );
|
121 |
+
}
|
122 |
+
|
123 |
if ( ! empty( $parsed_requested_path['query'] ) ) {
|
124 |
$requested_query_params = $parsed_requested_path['query'];
|
125 |
}
|
126 |
|
|
|
|
|
127 |
foreach ( (array) $redirects as $redirect ) {
|
128 |
|
129 |
$redirect_from = untrailingslashit( $redirect['redirect_from'] );
|
inc/classes/class-srm-wp-cli.php
CHANGED
@@ -12,11 +12,39 @@ class SRM_WP_CLI extends WP_CLI_Command {
|
|
12 |
|
13 |
|
14 |
/**
|
15 |
-
* List all of the currently configured redirects
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
*
|
17 |
* @subcommand list
|
|
|
|
|
|
|
18 |
*/
|
19 |
-
public function cli_list() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
$fields = array(
|
21 |
'ID',
|
22 |
'redirect_from',
|
@@ -26,27 +54,25 @@ class SRM_WP_CLI extends WP_CLI_Command {
|
|
26 |
'post_status',
|
27 |
);
|
28 |
|
29 |
-
$table = new \cli\Table();
|
30 |
-
$table->setHeaders( $fields );
|
31 |
-
|
32 |
$redirects = srm_get_redirects( array( 'post_status' => 'any' ), true );
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
if ( 'enable_regex' === $field ) {
|
38 |
-
$line[] = ( $redirect[ $field ] ) ? 'true' : 'false';
|
39 |
} else {
|
40 |
-
$
|
41 |
}
|
42 |
-
|
43 |
-
|
44 |
-
$
|
45 |
-
|
46 |
|
47 |
-
$
|
|
|
48 |
|
49 |
-
|
|
|
|
|
50 |
}
|
51 |
|
52 |
/**
|
12 |
|
13 |
|
14 |
/**
|
15 |
+
* List all of the currently configured redirects.
|
16 |
+
* Available fields: 'ID', 'redirect_from', 'redirect_to', 'status_code', 'enable_regex', 'post_status'.
|
17 |
+
*
|
18 |
+
* [--field=<field>]
|
19 |
+
* : Single field to dipslay, should be one of available fields.
|
20 |
+
*
|
21 |
+
* [--fields=<field1,field2>]
|
22 |
+
* : Multiple fields to dipslay, should be a list of available fields.
|
23 |
+
*
|
24 |
+
* [--format=<format>]
|
25 |
+
* : The command output format. Can be table, json, csv, yaml. Default to table.
|
26 |
+
*
|
27 |
+
* [--show_total=<bool>]
|
28 |
+
* : Show total redirects. Default to true.
|
29 |
*
|
30 |
* @subcommand list
|
31 |
+
*
|
32 |
+
* @param array $args Array of arguments
|
33 |
+
* @param array $assoc_args Array of options.
|
34 |
*/
|
35 |
+
public function cli_list( $args, $assoc_args ) {
|
36 |
+
$assoc_args = wp_parse_args(
|
37 |
+
$assoc_args,
|
38 |
+
[
|
39 |
+
'show_total' => true,
|
40 |
+
'format' => 'table',
|
41 |
+
]
|
42 |
+
);
|
43 |
+
|
44 |
+
if ( 'false' === $assoc_args['show_total'] ) {
|
45 |
+
$assoc_args['show_total'] = false;
|
46 |
+
}
|
47 |
+
|
48 |
$fields = array(
|
49 |
'ID',
|
50 |
'redirect_from',
|
54 |
'post_status',
|
55 |
);
|
56 |
|
|
|
|
|
|
|
57 |
$redirects = srm_get_redirects( array( 'post_status' => 'any' ), true );
|
58 |
+
$redirects = array_map(
|
59 |
+
function( &$item ) use ( $assoc_args ) {
|
60 |
+
if ( 'table' === $assoc_args['format'] ) {
|
61 |
+
$item['enable_regex'] = $item['enable_regex'] ? 'true' : 'false';
|
|
|
|
|
62 |
} else {
|
63 |
+
$item['enable_regex'] = (bool) $item['enable_regex'];
|
64 |
}
|
65 |
+
return $item;
|
66 |
+
},
|
67 |
+
$redirects
|
68 |
+
);
|
69 |
|
70 |
+
$formatter = new \WP_CLI\Formatter( $assoc_args, $fields );
|
71 |
+
$formatter->display_items( $redirects );
|
72 |
|
73 |
+
if ( ! empty( $assoc_args['show_total'] ) ) {
|
74 |
+
WP_CLI::line( 'Total of ' . count( $redirects ) . ' redirects.' );
|
75 |
+
}
|
76 |
}
|
77 |
|
78 |
/**
|
inc/functions.php
CHANGED
@@ -14,8 +14,9 @@
|
|
14 |
* @return array $redirects An array of redirects
|
15 |
*/
|
16 |
function srm_get_redirects( $args = array(), $hard = false ) {
|
17 |
-
|
18 |
-
$
|
|
|
19 |
|
20 |
if ( $hard || false === $redirects ) {
|
21 |
|
@@ -25,8 +26,6 @@ function srm_get_redirects( $args = array(), $hard = false ) {
|
|
25 |
|
26 |
$i = 1;
|
27 |
|
28 |
-
$default_max_redirects = apply_filters( 'srm_max_redirects', 250 );
|
29 |
-
|
30 |
while ( true ) {
|
31 |
if ( count( $redirects ) >= $default_max_redirects ) {
|
32 |
break;
|
@@ -72,7 +71,8 @@ function srm_get_redirects( $args = array(), $hard = false ) {
|
|
72 |
|
73 |
}
|
74 |
|
75 |
-
|
|
|
76 |
}
|
77 |
|
78 |
return $redirects;
|
@@ -85,7 +85,7 @@ function srm_get_redirects( $args = array(), $hard = false ) {
|
|
85 |
* @return bool
|
86 |
*/
|
87 |
function srm_max_redirects_reached() {
|
88 |
-
$default_max_redirects =
|
89 |
|
90 |
$redirects = srm_get_redirects();
|
91 |
|
@@ -133,10 +133,9 @@ function srm_get_valid_status_codes_data() {
|
|
133 |
* @since 1.8
|
134 |
*/
|
135 |
function srm_flush_cache() {
|
136 |
-
delete_transient( '
|
137 |
}
|
138 |
|
139 |
-
|
140 |
/**
|
141 |
* Check for potential redirect loops or chains
|
142 |
*
|
@@ -408,3 +407,13 @@ function srm_import_file( $file, $args ) {
|
|
408 |
function srm_match_redirect( $path ) {
|
409 |
return SRM_Redirect::factory()->match_redirect( $path );
|
410 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
* @return array $redirects An array of redirects
|
15 |
*/
|
16 |
function srm_get_redirects( $args = array(), $hard = false ) {
|
17 |
+
$default_max_redirects = srm_get_max_redirects();
|
18 |
+
$transient_key = '_srm_redirects_' . $default_max_redirects;
|
19 |
+
$redirects = get_transient( $transient_key );
|
20 |
|
21 |
if ( $hard || false === $redirects ) {
|
22 |
|
26 |
|
27 |
$i = 1;
|
28 |
|
|
|
|
|
29 |
while ( true ) {
|
30 |
if ( count( $redirects ) >= $default_max_redirects ) {
|
31 |
break;
|
71 |
|
72 |
}
|
73 |
|
74 |
+
// Set transient to 30 days to remove old transients if the max redirects changes.
|
75 |
+
set_transient( $transient_key, $redirects, 30 * DAY_IN_SECONDS );
|
76 |
}
|
77 |
|
78 |
return $redirects;
|
85 |
* @return bool
|
86 |
*/
|
87 |
function srm_max_redirects_reached() {
|
88 |
+
$default_max_redirects = srm_get_max_redirects();
|
89 |
|
90 |
$redirects = srm_get_redirects();
|
91 |
|
133 |
* @since 1.8
|
134 |
*/
|
135 |
function srm_flush_cache() {
|
136 |
+
delete_transient( '_srm_redirects_' . srm_get_max_redirects() );
|
137 |
}
|
138 |
|
|
|
139 |
/**
|
140 |
* Check for potential redirect loops or chains
|
141 |
*
|
407 |
function srm_match_redirect( $path ) {
|
408 |
return SRM_Redirect::factory()->match_redirect( $path );
|
409 |
}
|
410 |
+
|
411 |
+
/**
|
412 |
+
* Get maximum supported redirects.
|
413 |
+
*
|
414 |
+
* @since 2.0.0
|
415 |
+
* @return int
|
416 |
+
*/
|
417 |
+
function srm_get_max_redirects() {
|
418 |
+
return apply_filters( 'srm_max_redirects', 1000 );
|
419 |
+
}
|
readme.txt
CHANGED
@@ -1,11 +1,12 @@
|
|
1 |
=== Safe Redirect Manager ===
|
2 |
-
Contributors:
|
3 |
-
Tags:
|
4 |
Requires at least: 4.6
|
5 |
-
Tested up to:
|
6 |
-
|
7 |
-
|
8 |
-
License
|
|
|
9 |
|
10 |
Safely and easily manage your website's HTTP redirects.
|
11 |
|
@@ -47,6 +48,16 @@ This should be a path (i.e. `/test`) or a URL (i.e. `http://example.com/wp/test`
|
|
47 |
|
48 |
== Changelog ==
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
= 1.10.0 =
|
51 |
* **Added:** `410 Gone` status code to the list of HTTP status codes and `srm_additional_status_codes` to add additional status codes ([@dinhtungdu](https://profiles.wordpress.org/dinhtungdu/), [@helen](https://profiles.wordpress.org/helen), [@PopVeKind](https://profiles.wordpress.org/popvekind/)).
|
52 |
* **Added:** Option to ignore query parameters, previous behaviour still available via the new `srm_match_query_params` filter (props [@bradleyt](https://profiles.wordpress.org/bradleyt/), [@dinhtungdu](https://profiles.wordpress.org/dinhtungdu/)).
|
1 |
=== Safe Redirect Manager ===
|
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: 4.6
|
5 |
+
Tested up to: 5.8
|
6 |
+
Requires PHP:
|
7 |
+
Stable tag: 1.10.1
|
8 |
+
License: GPLv2 or later
|
9 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
Safely and easily manage your website's HTTP redirects.
|
12 |
|
48 |
|
49 |
== Changelog ==
|
50 |
|
51 |
+
= 1.10.1 =
|
52 |
+
* **Added:** Formatting options to `wp safe-redirect-manager list` command (props [@dinhtungdu](https://profiles.wordpress.org/dinhtungdu/), [@TheLastCicada](https://profiles.wordpress.org/thelastcicada/)).
|
53 |
+
* **Changed:** Increased redirect limits from 250 to 1,000 (props [@sultann](https://profiles.wordpress.org/manikmist09/), [@dinhtungdu](https://profiles.wordpress.org/dinhtungdu/), [@jilltilt](https://github.com/jilltilt), [@yeevy](https://github.com/yeevy)).
|
54 |
+
* **Changed:** Bump WordPress version "tested up to" 5.8 (props [@jeffpaul](https://profiles.wordpress.org/jeffpaul/), [@ankitguptaindia](https://profiles.wordpress.org/ankit-k-gupta/), [@phpbits](https://profiles.wordpress.org/phpbits/)).
|
55 |
+
* **Fixed:** Required parameter following optional deprecated message in PHP 8 (props [@vinkla](https://profiles.wordpress.org/vinkla/), [@dinhtungdu](https://profiles.wordpress.org/dinhtungdu/)).
|
56 |
+
* **Fixed:** Edge case when redirecting a URL with parameters where `$parsed_requested_path['path']` does not always exist (props [@dinhtungdu](https://profiles.wordpress.org/dinhtungdu/), [@davidmondok](https://profiles.wordpress.org/davidmondok/)).
|
57 |
+
* **Fixed:** Formatting fix to prevent npm install error (props [@phpbits](https://profiles.wordpress.org/phpbits/)).
|
58 |
+
* **Security:** Bump `minimist` from 0.0.8 to 1.2.5 (props [@dependabot](https://github.com/dependabot)).
|
59 |
+
* **Security:** Bump `lodash` from 4.17.19 to 4.17.21 (props [@dependabot](https://github.com/dependabot)).
|
60 |
+
|
61 |
= 1.10.0 =
|
62 |
* **Added:** `410 Gone` status code to the list of HTTP status codes and `srm_additional_status_codes` to add additional status codes ([@dinhtungdu](https://profiles.wordpress.org/dinhtungdu/), [@helen](https://profiles.wordpress.org/helen), [@PopVeKind](https://profiles.wordpress.org/popvekind/)).
|
63 |
* **Added:** Option to ignore query parameters, previous behaviour still available via the new `srm_match_query_params` filter (props [@bradleyt](https://profiles.wordpress.org/bradleyt/), [@dinhtungdu](https://profiles.wordpress.org/dinhtungdu/)).
|
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.10.
|
8 |
* Text Domain: safe-redirect-manager
|
9 |
* Author URI: https://10up.com
|
10 |
* License: GPLv2 or later
|
4 |
* Plugin URI: https://wordpress.org/plugins/safe-redirect-manager
|
5 |
* Description: Easily and safely manage HTTP redirects.
|
6 |
* Author: 10up
|
7 |
+
* Version: 1.10.1
|
8 |
* Text Domain: safe-redirect-manager
|
9 |
* Author URI: https://10up.com
|
10 |
* License: GPLv2 or later
|