Version Description
(Jun. 18, 2015) = * Make default redirect status filterable * Add composer.json * Fix delete capability on redirect post type
Download this release
Release Info
| Developer | tlovett1 |
| Plugin | |
| Version | 1.7.7 |
| Comparing to | |
| See all releases | |
Code changes from version 1.7.6 to 1.7.7
- Dockunit.json +20 -0
- README.md +18 -11
- bin/install-wp-tests.sh +4 -4
- composer.json +11 -0
- readme.txt +6 -1
- safe-redirect-manager.php +3 -2
Dockunit.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"containers": [
|
| 3 |
+
{
|
| 4 |
+
"prettyName": "PHP-FPM 5.2",
|
| 5 |
+
"image": "tlovett1/php-5.2-phpunit-3.5",
|
| 6 |
+
"beforeScripts": [
|
| 7 |
+
"bash bin/install-wp-tests.sh wordpress_test234234 external external 192.168.50.4 4.1"
|
| 8 |
+
],
|
| 9 |
+
"testCommand": "phpunit"
|
| 10 |
+
},
|
| 11 |
+
{
|
| 12 |
+
"prettyName": "PHP-FPM 5.5",
|
| 13 |
+
"image": "tlovett1/php-fpm-phpunit-wp",
|
| 14 |
+
"beforeScripts": [
|
| 15 |
+
"bash bin/install-wp-tests.sh wordpress_testhey external external 192.168.50.4 4.1"
|
| 16 |
+
],
|
| 17 |
+
"testCommand": "phpunit"
|
| 18 |
+
}
|
| 19 |
+
]
|
| 20 |
+
}
|
README.md
CHANGED
|
@@ -31,20 +31,19 @@ Each redirect contains a few fields that you can utilize:
|
|
| 31 |
|
| 32 |
#### "Redirect From"
|
| 33 |
This should be a path relative to the root of your WordPress installation. When someone visits your site with a path
|
| 34 |
-
that matches this one, a redirect will occur. If your site is located at ```http://example.com/wp/``` and you wanted to
|
| 35 |
-
redirect ```http://example.com/wp/about``` to ```http://example.com```, your "Redirect From" would be ```/about```.
|
| 36 |
|
| 37 |
Clicking the "Enable Regex" checkbox allows you to use regular expressions in your path. There are many
|
| 38 |
[great tutorials](http://www.regular-expressions.info) on regular expressions.
|
| 39 |
|
| 40 |
-
You can also use wildcards in your "Redirect From" paths. By adding an
|
| 41 |
match any request that starts with your "Redirect From". Wildcards support replacements. This means if you have a
|
| 42 |
wildcard in your from path that matches a string, you can have that string replace a wildcard character in your
|
| 43 |
-
"Redirect To" path. For example, if your "Redirect From" is
|
| 44 |
-
|
| 45 |
|
| 46 |
#### "Redirect To"
|
| 47 |
-
This should be a path i.e.
|
| 48 |
"Redirect From", they will be redirected here. "Redirect To" supports wildcard and regular expression replacements.
|
| 49 |
|
| 50 |
#### "HTTP Status Code"
|
|
@@ -57,9 +56,17 @@ temporarily moved, or 301, permanently moved.
|
|
| 57 |
* Redirects are cached using the Transients API. Cache busts occur when redirects are added, updated, and deleted
|
| 58 |
so you shouldn't be serving stale redirects.
|
| 59 |
* By default the plugin only allows at most 150 redirects to prevent performance issues. There is a filter
|
| 60 |
-
|
| 61 |
* "Redirect From" and requested paths are case insensitive by default.
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
## Development
|
| 64 |
|
| 65 |
#### Setup
|
|
@@ -76,12 +83,12 @@ Within the terminal change directories to the plugin folder. Initialize your uni
|
|
| 76 |
following command:
|
| 77 |
|
| 78 |
For VVV users:
|
| 79 |
-
```
|
| 80 |
bash bin/install-wp-tests.sh wordpress_test root root localhost latest
|
| 81 |
```
|
| 82 |
|
| 83 |
For VIP Quickstart users:
|
| 84 |
-
```
|
| 85 |
bash bin/install-wp-tests.sh wordpress_test root '' localhost latest
|
| 86 |
```
|
| 87 |
|
|
@@ -94,10 +101,10 @@ where:
|
|
| 94 |
* latest is the WordPress version; could also be 3.7, 3.6.2 etc.
|
| 95 |
|
| 96 |
Run the plugin tests:
|
| 97 |
-
```
|
| 98 |
phpunit
|
| 99 |
```
|
| 100 |
|
| 101 |
#### Issues
|
| 102 |
If you identify any errors or have an idea for improving the plugin, please
|
| 103 |
-
[open an issue](https://github.com/tlovett1/safe-redirect-manager/issues?state=open).
|
| 31 |
|
| 32 |
#### "Redirect From"
|
| 33 |
This should be a path relative to the root of your WordPress installation. When someone visits your site with a path
|
| 34 |
+
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`.
|
|
|
|
| 35 |
|
| 36 |
Clicking the "Enable Regex" checkbox allows you to use regular expressions in your path. There are many
|
| 37 |
[great tutorials](http://www.regular-expressions.info) on regular expressions.
|
| 38 |
|
| 39 |
+
You can also use wildcards in your "Redirect From" paths. By adding an `*` at the end of a URL, your redirect will
|
| 40 |
match any request that starts with your "Redirect From". Wildcards support replacements. This means if you have a
|
| 41 |
wildcard in your from path that matches a string, you can have that string replace a wildcard character in your
|
| 42 |
+
"Redirect To" path. For example, if your "Redirect From" is `/test/*`, your "Redirect To" is
|
| 43 |
+
`http://google.com/*`, and the requested path is `/test/string`, the user would be redirect to `http://google.com/string`.
|
| 44 |
|
| 45 |
#### "Redirect To"
|
| 46 |
+
This should be a path i.e. `/test` or a URL i.e. `http://example.com/wp/test`. If a requested path matches
|
| 47 |
"Redirect From", they will be redirected here. "Redirect To" supports wildcard and regular expression replacements.
|
| 48 |
|
| 49 |
#### "HTTP Status Code"
|
| 56 |
* Redirects are cached using the Transients API. Cache busts occur when redirects are added, updated, and deleted
|
| 57 |
so you shouldn't be serving stale redirects.
|
| 58 |
* By default the plugin only allows at most 150 redirects to prevent performance issues. There is a filter
|
| 59 |
+
`srm_max_redirects` that you can utilize to up this number.
|
| 60 |
* "Redirect From" and requested paths are case insensitive by default.
|
| 61 |
|
| 62 |
+
## Redirect loops
|
| 63 |
+
|
| 64 |
+
By default redirect loop detection is disabled. To prevent redirect loops you can filter `srm_check_for_possible_redirect_loops`.
|
| 65 |
+
|
| 66 |
+
```php
|
| 67 |
+
add_filter( 'my_srm_redirect_loop_filter', '__return_true' );
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
## Development
|
| 71 |
|
| 72 |
#### Setup
|
| 83 |
following command:
|
| 84 |
|
| 85 |
For VVV users:
|
| 86 |
+
```bash
|
| 87 |
bash bin/install-wp-tests.sh wordpress_test root root localhost latest
|
| 88 |
```
|
| 89 |
|
| 90 |
For VIP Quickstart users:
|
| 91 |
+
```bash
|
| 92 |
bash bin/install-wp-tests.sh wordpress_test root '' localhost latest
|
| 93 |
```
|
| 94 |
|
| 101 |
* latest is the WordPress version; could also be 3.7, 3.6.2 etc.
|
| 102 |
|
| 103 |
Run the plugin tests:
|
| 104 |
+
```bash
|
| 105 |
phpunit
|
| 106 |
```
|
| 107 |
|
| 108 |
#### Issues
|
| 109 |
If you identify any errors or have an idea for improving the plugin, please
|
| 110 |
+
[open an issue](https://github.com/tlovett1/safe-redirect-manager/issues?state=open).
|
bin/install-wp-tests.sh
CHANGED
|
@@ -19,16 +19,16 @@ set -ex
|
|
| 19 |
install_wp() {
|
| 20 |
mkdir -p $WP_CORE_DIR
|
| 21 |
|
| 22 |
-
if [ $WP_VERSION == 'latest' ]; then
|
| 23 |
local ARCHIVE_NAME='latest'
|
| 24 |
else
|
| 25 |
local ARCHIVE_NAME="wordpress-$WP_VERSION"
|
| 26 |
fi
|
| 27 |
|
| 28 |
-
wget -nv -O /tmp/wordpress.tar.gz http://wordpress.org/${ARCHIVE_NAME}.tar.gz
|
| 29 |
tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
|
| 30 |
|
| 31 |
-
wget -nv -O $WP_CORE_DIR/wp-content/db.php https://raw.github.com/markoheijnen/wp-mysqli/master/db.php
|
| 32 |
}
|
| 33 |
|
| 34 |
install_test_suite() {
|
|
@@ -44,7 +44,7 @@ install_test_suite() {
|
|
| 44 |
cd $WP_TESTS_DIR
|
| 45 |
svn co --quiet http://develop.svn.wordpress.org/trunk/tests/phpunit/includes/
|
| 46 |
|
| 47 |
-
wget -nv -O wp-tests-config.php http://develop.svn.wordpress.org/trunk/wp-tests-config-sample.php
|
| 48 |
sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR':" wp-tests-config.php
|
| 49 |
sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" wp-tests-config.php
|
| 50 |
sed $ioption "s/yourusernamehere/$DB_USER/" wp-tests-config.php
|
| 19 |
install_wp() {
|
| 20 |
mkdir -p $WP_CORE_DIR
|
| 21 |
|
| 22 |
+
if [ $WP_VERSION == 'latest' ]; then
|
| 23 |
local ARCHIVE_NAME='latest'
|
| 24 |
else
|
| 25 |
local ARCHIVE_NAME="wordpress-$WP_VERSION"
|
| 26 |
fi
|
| 27 |
|
| 28 |
+
wget -nv -O /tmp/wordpress.tar.gz http://wordpress.org/${ARCHIVE_NAME}.tar.gz --no-check-certificate
|
| 29 |
tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
|
| 30 |
|
| 31 |
+
wget -nv -O $WP_CORE_DIR/wp-content/db.php https://raw.github.com/markoheijnen/wp-mysqli/master/db.php --no-check-certificate
|
| 32 |
}
|
| 33 |
|
| 34 |
install_test_suite() {
|
| 44 |
cd $WP_TESTS_DIR
|
| 45 |
svn co --quiet http://develop.svn.wordpress.org/trunk/tests/phpunit/includes/
|
| 46 |
|
| 47 |
+
wget -nv -O wp-tests-config.php http://develop.svn.wordpress.org/trunk/wp-tests-config-sample.php --no-check-certificate
|
| 48 |
sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR':" wp-tests-config.php
|
| 49 |
sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" wp-tests-config.php
|
| 50 |
sed $ioption "s/yourusernamehere/$DB_USER/" wp-tests-config.php
|
composer.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "tlovett1/safe-redirect-manager",
|
| 3 |
+
"type": "wordpress-plugin",
|
| 4 |
+
"description": "Easily and safely manage HTTP redirects.",
|
| 5 |
+
"authors": [
|
| 6 |
+
{
|
| 7 |
+
"name": "Taylor Lovett",
|
| 8 |
+
"email": "taylorl@10up.com"
|
| 9 |
+
}
|
| 10 |
+
]
|
| 11 |
+
}
|
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, multisite redirects
|
| 4 |
Requires at least: 3.1
|
| 5 |
Tested up to: 4.2
|
| 6 |
-
Stable tag: 1.7.
|
| 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.7.6 (Feb. 13, 2015) =
|
| 28 |
* Use home_url() instead of site_url(). Props [swalkinshaw](https://github.com/swalkinshaw)
|
| 29 |
* Don't redirect if redirect to location is invalid. Props [vaurdan](https://github.com/vaurdan)
|
| 3 |
Tags: http redirects, redirect manager, url redirection, safe http redirection, multisite redirects
|
| 4 |
Requires at least: 3.1
|
| 5 |
Tested up to: 4.2
|
| 6 |
+
Stable tag: 1.7.7
|
| 7 |
|
| 8 |
Safely and easily manage your website's HTTP redirects.
|
| 9 |
|
| 24 |
|
| 25 |
== Changelog ==
|
| 26 |
|
| 27 |
+
= 1.7.7 (Jun. 18, 2015) =
|
| 28 |
+
* Make default redirect status filterable
|
| 29 |
+
* Add composer.json
|
| 30 |
+
* Fix delete capability on redirect post type
|
| 31 |
+
|
| 32 |
= 1.7.6 (Feb. 13, 2015) =
|
| 33 |
* Use home_url() instead of site_url(). Props [swalkinshaw](https://github.com/swalkinshaw)
|
| 34 |
* Don't redirect if redirect to location is invalid. Props [vaurdan](https://github.com/vaurdan)
|
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)
|
| 7 |
-
Version: 1.7.
|
| 8 |
Author URI: http://www.10up.com
|
| 9 |
|
| 10 |
GNU General Public License, Free Software Foundation <http://creativecommons.org/licenses/GPL/2.0/>
|
|
@@ -583,6 +583,7 @@ class SRM_Safe_Redirect_Manager {
|
|
| 583 |
'edit_post' => $redirect_capability,
|
| 584 |
'read_post' => $redirect_capability,
|
| 585 |
'delete_post' => $redirect_capability,
|
|
|
|
| 586 |
'edit_posts' => $redirect_capability,
|
| 587 |
'edit_others_posts' => $redirect_capability,
|
| 588 |
'publish_posts' => $redirect_capability,
|
|
@@ -635,7 +636,7 @@ class SRM_Safe_Redirect_Manager {
|
|
| 635 |
$status_code = get_post_meta( $post->ID, $this->meta_key_redirect_status_code, true );
|
| 636 |
$enable_regex = get_post_meta( $post->ID, $this->meta_key_enable_redirect_from_regex, true );
|
| 637 |
if ( empty( $status_code ) )
|
| 638 |
-
$status_code = 302;
|
| 639 |
?>
|
| 640 |
<p>
|
| 641 |
<label for="srm<?php echo $this->meta_key_redirect_from; ?>"><?php _e( 'Redirect From:', 'safe-redirect-manager' ); ?></label><br />
|
| 4 |
Plugin URI: http://www.10up.com
|
| 5 |
Description: Easily and safely manage HTTP redirects.
|
| 6 |
Author: Taylor Lovett (10up)
|
| 7 |
+
Version: 1.7.7
|
| 8 |
Author URI: http://www.10up.com
|
| 9 |
|
| 10 |
GNU General Public License, Free Software Foundation <http://creativecommons.org/licenses/GPL/2.0/>
|
| 583 |
'edit_post' => $redirect_capability,
|
| 584 |
'read_post' => $redirect_capability,
|
| 585 |
'delete_post' => $redirect_capability,
|
| 586 |
+
'delete_posts' => $redirect_capability,
|
| 587 |
'edit_posts' => $redirect_capability,
|
| 588 |
'edit_others_posts' => $redirect_capability,
|
| 589 |
'publish_posts' => $redirect_capability,
|
| 636 |
$status_code = get_post_meta( $post->ID, $this->meta_key_redirect_status_code, true );
|
| 637 |
$enable_regex = get_post_meta( $post->ID, $this->meta_key_enable_redirect_from_regex, true );
|
| 638 |
if ( empty( $status_code ) )
|
| 639 |
+
$status_code = apply_filters( 'srm_default_direct_status', 302 );
|
| 640 |
?>
|
| 641 |
<p>
|
| 642 |
<label for="srm<?php echo $this->meta_key_redirect_from; ?>"><?php _e( 'Redirect From:', 'safe-redirect-manager' ); ?></label><br />
|
