Version Description
(Dec. 12, 2013) = * Add 307 redirect status code. Thanks lgedeon * Plugin textdomain should be loaded on init * Add status code labels to creation dropdown. Thanks Chancey Mathews
Download this release
Release Info
Developer | tlovett1 |
Plugin | Safe Redirect Manager |
Version | 1.7.1 |
Comparing to | |
See all releases |
Code changes from version 1.6 to 1.7.1
- languages/safe-redirect-manager-sk_SK.mo +0 -0
- languages/safe-redirect-manager-sk_SK.po +142 -0
- readme.txt +15 -4
- safe-redirect-manager.php +110 -32
languages/safe-redirect-manager-sk_SK.mo
ADDED
Binary file
|
languages/safe-redirect-manager-sk_SK.po
ADDED
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: \n"
|
4 |
+
"POT-Creation-Date: \n"
|
5 |
+
"PO-Revision-Date: \n"
|
6 |
+
"Last-Translator: \n"
|
7 |
+
"Language-Team: \n"
|
8 |
+
"MIME-Version: 1.0\n"
|
9 |
+
"Content-Type: text/plain; charset=iso-8859-1\n"
|
10 |
+
"Content-Transfer-Encoding: 8bit\n"
|
11 |
+
"X-Generator: Poedit 1.5.4\n"
|
12 |
+
|
13 |
+
#: safe-redirect-manager.php:367 safe-redirect-manager.php:370
|
14 |
+
msgid "Redirect rule updated."
|
15 |
+
msgstr "Presmerovat pravidlo aktualizovany."
|
16 |
+
|
17 |
+
#: safe-redirect-manager.php:368
|
18 |
+
msgid "Custom field updated."
|
19 |
+
msgstr "Vlastne aktualizacie pola."
|
20 |
+
|
21 |
+
#: safe-redirect-manager.php:369
|
22 |
+
msgid "Custom field deleted."
|
23 |
+
msgstr "Vlastne vypustaju pola."
|
24 |
+
|
25 |
+
#. translators: %s: date and time of the revision
|
26 |
+
#: safe-redirect-manager.php:372
|
27 |
+
msgid "Redirect rule restored to revision from %s"
|
28 |
+
msgstr "Presmerovat pravidlo obnovena reviziu z %s"
|
29 |
+
|
30 |
+
#: safe-redirect-manager.php:373
|
31 |
+
msgid "Redirect rule published."
|
32 |
+
msgstr "Presmerovat pravidlo zverejneny."
|
33 |
+
|
34 |
+
#: safe-redirect-manager.php:374
|
35 |
+
msgid "Redirect rule saved."
|
36 |
+
msgstr "Presmerovat pravidlo ulozeny."
|
37 |
+
|
38 |
+
#: safe-redirect-manager.php:375
|
39 |
+
msgid "Redirect rule submitted."
|
40 |
+
msgstr "Presmerovat pravidlo predlozene."
|
41 |
+
|
42 |
+
#: safe-redirect-manager.php:376
|
43 |
+
msgid "Redirect rule scheduled for: <strong>%1$s</strong>."
|
44 |
+
msgstr "Presmerovat pravidlo naplanovany:. <strong>%1$s</strong>."
|
45 |
+
|
46 |
+
#. translators: Publish box date format, see http:php.net/date
|
47 |
+
#: safe-redirect-manager.php:378
|
48 |
+
msgid "M j, Y @ G:i"
|
49 |
+
msgstr "M j, Y @ G: i"
|
50 |
+
|
51 |
+
#: safe-redirect-manager.php:379
|
52 |
+
msgid "Redirect rule draft updated."
|
53 |
+
msgstr "Presmerovat pravidlo aktualizovany navrh."
|
54 |
+
|
55 |
+
#: safe-redirect-manager.php:431
|
56 |
+
msgid "Redirect To"
|
57 |
+
msgstr "Presmerovat na"
|
58 |
+
|
59 |
+
#: safe-redirect-manager.php:432
|
60 |
+
msgid "HTTP Status Code"
|
61 |
+
msgstr "HTTP Status Code"
|
62 |
+
|
63 |
+
#: safe-redirect-manager.php:435
|
64 |
+
msgid "Redirect From"
|
65 |
+
msgstr "Presmerovanie od"
|
66 |
+
|
67 |
+
#: safe-redirect-manager.php:439
|
68 |
+
msgid "Date"
|
69 |
+
msgstr "Datum"
|
70 |
+
|
71 |
+
#: safe-redirect-manager.php:491
|
72 |
+
msgctxt "post type general name"
|
73 |
+
msgid "Safe Redirect Manager"
|
74 |
+
msgstr "Safe Redirect Manager"
|
75 |
+
|
76 |
+
#: safe-redirect-manager.php:492
|
77 |
+
msgctxt "post type singular name"
|
78 |
+
msgid "Redirect"
|
79 |
+
msgstr "Presmerovanie"
|
80 |
+
|
81 |
+
#. #-#-#-#-# plugin.pot (Safe Redirect Manager 1.4-working) #-#-#-#-#
|
82 |
+
#. Plugin Name of the plugin/theme
|
83 |
+
#: safe-redirect-manager.php:494 safe-redirect-manager.php:497
|
84 |
+
#: safe-redirect-manager.php:503
|
85 |
+
msgid "Safe Redirect Manager"
|
86 |
+
msgstr "Safe Redirect Manager"
|
87 |
+
|
88 |
+
#: safe-redirect-manager.php:495
|
89 |
+
msgid "Edit Redirect Rule"
|
90 |
+
msgstr "Upravit presmerovanie pravidlo"
|
91 |
+
|
92 |
+
#: safe-redirect-manager.php:496
|
93 |
+
msgid "New Redirect Rule"
|
94 |
+
msgstr "Nova Presmerovanie pravidlo"
|
95 |
+
|
96 |
+
#: safe-redirect-manager.php:498
|
97 |
+
msgid "View Redirect Rule"
|
98 |
+
msgstr "Zobrazit Presmerovanie pravidlo"
|
99 |
+
|
100 |
+
#: safe-redirect-manager.php:499
|
101 |
+
msgid "Search Redirects"
|
102 |
+
msgstr "Hladat Presmerovanie"
|
103 |
+
|
104 |
+
#: safe-redirect-manager.php:500
|
105 |
+
msgid "No redirect rules found."
|
106 |
+
msgstr "Ziadne presmerovanie najdene pravidla."
|
107 |
+
|
108 |
+
#: safe-redirect-manager.php:501
|
109 |
+
msgid "No redirect rules found in trash."
|
110 |
+
msgstr "Ziadne presmerovanie pravidla najdene v smetiaku."
|
111 |
+
|
112 |
+
#: safe-redirect-manager.php:544
|
113 |
+
msgid "Redirect Settings"
|
114 |
+
msgstr "Presmerovanie Nastavenie"
|
115 |
+
|
116 |
+
#: safe-redirect-manager.php:565
|
117 |
+
msgid "Redirect From:"
|
118 |
+
msgstr "Presmerovat From:"
|
119 |
+
|
120 |
+
#: safe-redirect-manager.php:571
|
121 |
+
msgid "Redirect To:"
|
122 |
+
msgstr "Presmerovat na:"
|
123 |
+
|
124 |
+
#: safe-redirect-manager.php:577
|
125 |
+
msgid "HTTP Status Code:"
|
126 |
+
msgstr "HTTP Status Code:"
|
127 |
+
|
128 |
+
#. #-#-#-#-# plugin.pot (Safe Redirect Manager 1.4-working) #-#-#-#-#
|
129 |
+
#. Plugin URI of the plugin/theme
|
130 |
+
#. #-#-#-#-# plugin.pot (Safe Redirect Manager 1.4-working) #-#-#-#-#
|
131 |
+
#. Author URI of the plugin/theme
|
132 |
+
#: safe-redirect-manager.php:583
|
133 |
+
msgid "http://www.10up.com"
|
134 |
+
msgstr "http://www.10up.com"
|
135 |
+
|
136 |
+
#. Description of the plugin/theme
|
137 |
+
msgid "Easily and safely manage HTTP redirects."
|
138 |
+
msgstr "Lahko a bezpecne spravovat presmerovanie HTTP."
|
139 |
+
|
140 |
+
#. Author of the plugin/theme
|
141 |
+
msgid "Taylor Lovett (10up LLC), VentureBeat"
|
142 |
+
msgstr "Taylor Lovett (10up LLC), VentureBeat"
|
readme.txt
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
=== Safe Redirect Manager ===
|
2 |
Contributors: tlovett1, tollmanz, taylorde, 10up, jakemgold, danielbachhuber, VentureBeat
|
3 |
-
Tags: http redirects, redirect manager, url redirection, safe http redirection
|
4 |
Requires at least: 3.1
|
5 |
-
Tested up to: 3.
|
6 |
-
Stable tag: 1.
|
7 |
|
8 |
Safely and easily manage your website's HTTP redirects.
|
9 |
|
10 |
== Description ==
|
11 |
|
12 |
-
Safe Redirect Manager is a HTTP redirect manager for WordPress. An easy-to-use UI allows you to redirect locations to new URL's with the HTTP status codes of your
|
13 |
|
14 |
[Fork the plugin on GitHub.](https://github.com/tlovett1/Safe-Redirect-Manager)
|
15 |
|
@@ -24,6 +24,17 @@ Extract the zip file and just drop the contents in the wp-content/plugins/ direc
|
|
24 |
|
25 |
== Changelog ==
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
= 1.6 (Dec. 11, 2012) =
|
28 |
* Bulk delete redirects from the Manage Redirects screen
|
29 |
* wp-cli coverage including subcommands for creating, deleting, and listing redirects, and importing .htaccess files
|
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
|
4 |
Requires at least: 3.1
|
5 |
+
Tested up to: 3.8
|
6 |
+
Stable tag: 1.7.1
|
7 |
|
8 |
Safely and easily manage your website's HTTP redirects.
|
9 |
|
10 |
== Description ==
|
11 |
|
12 |
+
Safe Redirect Manager is a HTTP redirect manager for WordPress. An easy-to-use UI allows you to redirect locations to new URL's with the HTTP status codes of your choosing. The plugin uses the wp_safe_redirect function which only allows redirects to whitelisted hosts for security purposes. The plugin automatically handles whitelisting hosts for you. This plugin works great with Multisite.
|
13 |
|
14 |
[Fork the plugin on GitHub.](https://github.com/tlovett1/Safe-Redirect-Manager)
|
15 |
|
24 |
|
25 |
== Changelog ==
|
26 |
|
27 |
+
= 1.7.1 (Dec. 12, 2013) =
|
28 |
+
* Add 307 redirect status code. Thanks [lgedeon](https://github.com/lgedeon)
|
29 |
+
* Plugin textdomain should be loaded on init
|
30 |
+
* Add status code labels to creation dropdown. Thanks Chancey Mathews
|
31 |
+
|
32 |
+
= 1.7 (Apr. 6, 2013) =
|
33 |
+
* Return redirect_from on get_permalink. Thanks [simonwheatley](https://github.com/simonwheatley)
|
34 |
+
* Allow for regex replacement in from/to redirects
|
35 |
+
* Add Slovak translation. Thanks [Branco Radenovich](http://webhostinggeeks.com/blog)
|
36 |
+
* Notice fixed in filter_admin_title
|
37 |
+
|
38 |
= 1.6 (Dec. 11, 2012) =
|
39 |
* Bulk delete redirects from the Manage Redirects screen
|
40 |
* wp-cli coverage including subcommands for creating, deleting, and listing redirects, and importing .htaccess files
|
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.
|
8 |
Author URI: http://www.10up.com
|
9 |
|
10 |
GNU General Public License, Free Software Foundation <http://creativecommons.org/licenses/GPL/2.0/>
|
@@ -41,7 +41,16 @@ class SRM_Safe_Redirect_Manager {
|
|
41 |
|
42 |
public $cache_key_redirects = '_srm_redirects';
|
43 |
|
44 |
-
public $valid_status_codes = array( 301, 302, 303, 403, 404 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
private $whitelist_hosts = array();
|
47 |
|
@@ -55,10 +64,10 @@ class SRM_Safe_Redirect_Manager {
|
|
55 |
* @return object
|
56 |
*/
|
57 |
public function __construct() {
|
|
|
58 |
add_action( 'init', array( $this, 'action_init' ) );
|
59 |
add_action( 'init', array( $this, 'action_register_post_types' ) );
|
60 |
add_action( 'parse_request', array( $this, 'action_parse_request' ), 0 );
|
61 |
-
add_action( 'after_theme_setup', array( $this, 'action_load_texthost' ) );
|
62 |
add_action( 'save_post', array( $this, 'action_save_post' ) );
|
63 |
add_filter( 'manage_' . $this->redirect_post_type . '_posts_columns' , array( $this, 'filter_redirect_columns' ) );
|
64 |
add_action( 'manage_' . $this->redirect_post_type . '_posts_custom_column' , array( $this, 'action_custom_redirect_columns' ), 10, 2 );
|
@@ -70,6 +79,7 @@ class SRM_Safe_Redirect_Manager {
|
|
70 |
add_action( 'admin_print_styles-edit.php', array( $this, 'action_print_logo_css' ), 10, 1 );
|
71 |
add_action( 'admin_print_styles-post.php', array( $this, 'action_print_logo_css' ), 10, 1 );
|
72 |
add_action( 'admin_print_styles-post-new.php', array( $this, 'action_print_logo_css' ), 10, 1 );
|
|
|
73 |
|
74 |
// Search filters
|
75 |
add_filter( 'posts_join', array( $this, 'filter_search_join' ) );
|
@@ -77,6 +87,17 @@ class SRM_Safe_Redirect_Manager {
|
|
77 |
add_filter( 'posts_distinct', array( $this, 'filter_search_distinct' ) );
|
78 |
}
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
/**
|
81 |
* Join posts table with postmeta table on search
|
82 |
*
|
@@ -317,9 +338,7 @@ class SRM_Safe_Redirect_Manager {
|
|
317 |
$redirects = $this->update_redirect_cache();
|
318 |
}
|
319 |
|
320 |
-
|
321 |
-
|
322 |
-
return ( count( $redirects ) >= $max_redirects );
|
323 |
}
|
324 |
|
325 |
/**
|
@@ -376,9 +395,16 @@ class SRM_Safe_Redirect_Manager {
|
|
376 |
* @return string
|
377 |
*/
|
378 |
public function filter_admin_title( $title, $post_id = 0 ) {
|
379 |
-
if ( ! is_admin()
|
380 |
return $title;
|
381 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
382 |
$redirect_from = get_post_meta( $post_id, $this->meta_key_redirect_from, true );
|
383 |
if ( ! empty( $redirect_from ) )
|
384 |
return $redirect_from;
|
@@ -627,7 +653,7 @@ class SRM_Safe_Redirect_Manager {
|
|
627 |
<label for="srm<?php echo $this->meta_key_redirect_status_code; ?>"><?php _e( 'HTTP Status Code:', 'safe-redirect-manager' ); ?></label>
|
628 |
<select name="srm<?php echo $this->meta_key_redirect_status_code; ?>" id="srm<?php echo $this->meta_key_redirect_status_code; ?>">
|
629 |
<?php foreach ( $this->valid_status_codes as $code ) : ?>
|
630 |
-
<option <?php selected( $status_code, $code ); ?>><?php echo $code; ?></option>
|
631 |
<?php endforeach; ?>
|
632 |
</select>
|
633 |
<em><?php _e( "If you don't know what this is, leave it as is.", 'safe-redirect-manager' ); ?></em>
|
@@ -644,6 +670,8 @@ class SRM_Safe_Redirect_Manager {
|
|
644 |
*/
|
645 |
public function action_init() {
|
646 |
load_plugin_textdomain( 'safe-redirect-manager', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
|
|
|
|
647 |
}
|
648 |
|
649 |
/**
|
@@ -675,34 +703,52 @@ class SRM_Safe_Redirect_Manager {
|
|
675 |
*/
|
676 |
public function get_redirects( $args = array() ) {
|
677 |
|
678 |
-
$
|
679 |
-
|
680 |
-
|
681 |
-
|
|
|
|
|
682 |
|
683 |
-
$
|
|
|
684 |
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
|
|
689 |
|
690 |
-
|
691 |
|
692 |
-
|
693 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
694 |
|
695 |
-
$redirects = array();
|
696 |
-
foreach( $redirect_query->posts as $redirect ) {
|
697 |
-
$redirects[] = array(
|
698 |
-
'ID' => $redirect->ID,
|
699 |
-
'post_status' => $redirect->post_status,
|
700 |
-
'redirect_from' => get_post_meta( $redirect->ID, $this->meta_key_redirect_from, true ),
|
701 |
-
'redirect_to' => get_post_meta( $redirect->ID, $this->meta_key_redirect_to, true ),
|
702 |
-
'status_code' => (int)get_post_meta( $redirect->ID, $this->meta_key_redirect_status_code, true ),
|
703 |
-
'enable_regex' => (bool)get_post_meta( $redirect->ID, $this->meta_key_enable_redirect_from_regex, true ),
|
704 |
-
);
|
705 |
-
}
|
706 |
return $redirects;
|
707 |
}
|
708 |
|
@@ -741,7 +787,7 @@ class SRM_Safe_Redirect_Manager {
|
|
741 |
return;
|
742 |
|
743 |
// get requested path and add a / before it
|
744 |
-
$requested_path =
|
745 |
$requested_path = stripslashes( $requested_path );
|
746 |
|
747 |
/**
|
@@ -799,6 +845,11 @@ class SRM_Safe_Redirect_Manager {
|
|
799 |
|
800 |
header("X-Safe-Redirect-Manager: true");
|
801 |
|
|
|
|
|
|
|
|
|
|
|
802 |
// if we have a valid status code, then redirect with it
|
803 |
if ( in_array( $status_code, $this->valid_status_codes ) )
|
804 |
wp_safe_redirect( esc_url_raw( $redirect_to ), $status_code );
|
@@ -864,6 +915,33 @@ class SRM_Safe_Redirect_Manager {
|
|
864 |
|
865 |
return $path;
|
866 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
867 |
}
|
868 |
|
869 |
global $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.7.1
|
8 |
Author URI: http://www.10up.com
|
9 |
|
10 |
GNU General Public License, Free Software Foundation <http://creativecommons.org/licenses/GPL/2.0/>
|
41 |
|
42 |
public $cache_key_redirects = '_srm_redirects';
|
43 |
|
44 |
+
public $valid_status_codes = array( 301, 302, 303, 307, 403, 404 );
|
45 |
+
|
46 |
+
public $status_code_labels = array(
|
47 |
+
301 => 'Moved Permanently',
|
48 |
+
302 => 'Found',
|
49 |
+
303 => 'See Other',
|
50 |
+
307 => 'Temporary Redirect',
|
51 |
+
403 => 'Forbidden',
|
52 |
+
404 => 'Not Found',
|
53 |
+
);
|
54 |
|
55 |
private $whitelist_hosts = array();
|
56 |
|
64 |
* @return object
|
65 |
*/
|
66 |
public function __construct() {
|
67 |
+
add_action( 'init', array( $this, 'action_init_load_textdomain' ), 9 );
|
68 |
add_action( 'init', array( $this, 'action_init' ) );
|
69 |
add_action( 'init', array( $this, 'action_register_post_types' ) );
|
70 |
add_action( 'parse_request', array( $this, 'action_parse_request' ), 0 );
|
|
|
71 |
add_action( 'save_post', array( $this, 'action_save_post' ) );
|
72 |
add_filter( 'manage_' . $this->redirect_post_type . '_posts_columns' , array( $this, 'filter_redirect_columns' ) );
|
73 |
add_action( 'manage_' . $this->redirect_post_type . '_posts_custom_column' , array( $this, 'action_custom_redirect_columns' ), 10, 2 );
|
79 |
add_action( 'admin_print_styles-edit.php', array( $this, 'action_print_logo_css' ), 10, 1 );
|
80 |
add_action( 'admin_print_styles-post.php', array( $this, 'action_print_logo_css' ), 10, 1 );
|
81 |
add_action( 'admin_print_styles-post-new.php', array( $this, 'action_print_logo_css' ), 10, 1 );
|
82 |
+
add_filter( 'post_type_link', array( $this, 'filter_post_type_link' ), 10, 2 );
|
83 |
|
84 |
// Search filters
|
85 |
add_filter( 'posts_join', array( $this, 'filter_search_join' ) );
|
87 |
add_filter( 'posts_distinct', array( $this, 'filter_search_distinct' ) );
|
88 |
}
|
89 |
|
90 |
+
/**
|
91 |
+
* Localize plugin
|
92 |
+
*
|
93 |
+
* @since 1.7
|
94 |
+
* @uses load_plugin_textdomain
|
95 |
+
* @return void
|
96 |
+
*/
|
97 |
+
public function action_init_load_textdomain() {
|
98 |
+
load_plugin_textdomain( 'safe-redirect-manager', false, basename( dirname( __FILE__ ) ) . '/languages' );
|
99 |
+
}
|
100 |
+
|
101 |
/**
|
102 |
* Join posts table with postmeta table on search
|
103 |
*
|
338 |
$redirects = $this->update_redirect_cache();
|
339 |
}
|
340 |
|
341 |
+
return ( count( $redirects ) >= $this->default_max_redirects );
|
|
|
|
|
342 |
}
|
343 |
|
344 |
/**
|
395 |
* @return string
|
396 |
*/
|
397 |
public function filter_admin_title( $title, $post_id = 0 ) {
|
398 |
+
if ( ! is_admin() )
|
399 |
return $title;
|
400 |
|
401 |
+
$redirect = get_post( $post_id );
|
402 |
+
if ( empty( $redirect ) )
|
403 |
+
return $title;
|
404 |
+
|
405 |
+
if ( $redirect->post_type != $this->redirect_post_type )
|
406 |
+
return $title;
|
407 |
+
|
408 |
$redirect_from = get_post_meta( $post_id, $this->meta_key_redirect_from, true );
|
409 |
if ( ! empty( $redirect_from ) )
|
410 |
return $redirect_from;
|
653 |
<label for="srm<?php echo $this->meta_key_redirect_status_code; ?>"><?php _e( 'HTTP Status Code:', 'safe-redirect-manager' ); ?></label>
|
654 |
<select name="srm<?php echo $this->meta_key_redirect_status_code; ?>" id="srm<?php echo $this->meta_key_redirect_status_code; ?>">
|
655 |
<?php foreach ( $this->valid_status_codes as $code ) : ?>
|
656 |
+
<option value="<?php echo esc_attr( $code ); ?>" <?php selected( $status_code, $code ); ?>><?php echo esc_html( $code . ' ' . $this->status_code_labels[$code] ); ?></option>
|
657 |
<?php endforeach; ?>
|
658 |
</select>
|
659 |
<em><?php _e( "If you don't know what this is, leave it as is.", 'safe-redirect-manager' ); ?></em>
|
670 |
*/
|
671 |
public function action_init() {
|
672 |
load_plugin_textdomain( 'safe-redirect-manager', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
673 |
+
|
674 |
+
$this->default_max_redirects = apply_filters( 'srm_max_redirects', $this->default_max_redirects );
|
675 |
}
|
676 |
|
677 |
/**
|
703 |
*/
|
704 |
public function get_redirects( $args = array() ) {
|
705 |
|
706 |
+
$redirects = array();
|
707 |
+
|
708 |
+
if ( $this->default_max_redirects > 50 )
|
709 |
+
$posts_per_page = 50;
|
710 |
+
else
|
711 |
+
$posts_per_page = $this->default_max_redirects;
|
712 |
|
713 |
+
$i = 1;
|
714 |
+
do {
|
715 |
|
716 |
+
$defaults = array(
|
717 |
+
'posts_per_page' => $posts_per_page,
|
718 |
+
'post_status' => 'publish',
|
719 |
+
'paged' => $i,
|
720 |
+
);
|
721 |
|
722 |
+
$query_args = array_merge( $defaults, $args );
|
723 |
|
724 |
+
// Some arguments that don't need to be configurable
|
725 |
+
$query_args['post_type'] = $this->redirect_post_type;
|
726 |
+
$query_args['no_found_rows'] = false;
|
727 |
+
$query_args['update_term_cache'] = false;
|
728 |
+
|
729 |
+
$redirect_query = new WP_Query( $query_args );
|
730 |
+
|
731 |
+
foreach( $redirect_query->posts as $redirect ) {
|
732 |
+
$redirects[] = array(
|
733 |
+
'ID' => $redirect->ID,
|
734 |
+
'post_status' => $redirect->post_status,
|
735 |
+
'redirect_from' => get_post_meta( $redirect->ID, $this->meta_key_redirect_from, true ),
|
736 |
+
'redirect_to' => get_post_meta( $redirect->ID, $this->meta_key_redirect_to, true ),
|
737 |
+
'status_code' => (int)get_post_meta( $redirect->ID, $this->meta_key_redirect_status_code, true ),
|
738 |
+
'enable_regex' => (bool)get_post_meta( $redirect->ID, $this->meta_key_enable_redirect_from_regex, true ),
|
739 |
+
);
|
740 |
+
}
|
741 |
+
|
742 |
+
if ( count( $redirects ) == $this->default_max_redirects
|
743 |
+
|| count( $redirect_query->posts ) < $posts_per_page )
|
744 |
+
$build = false;
|
745 |
+
else
|
746 |
+
$build = true;
|
747 |
+
|
748 |
+
$i++;
|
749 |
+
|
750 |
+
} while ( $build );
|
751 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
752 |
return $redirects;
|
753 |
}
|
754 |
|
787 |
return;
|
788 |
|
789 |
// get requested path and add a / before it
|
790 |
+
$requested_path = esc_url_raw( $_SERVER['REQUEST_URI'] );
|
791 |
$requested_path = stripslashes( $requested_path );
|
792 |
|
793 |
/**
|
845 |
|
846 |
header("X-Safe-Redirect-Manager: true");
|
847 |
|
848 |
+
// Allow for regex replacement in $redirect_to
|
849 |
+
if ( $enable_regex ) {
|
850 |
+
$redirect_to = preg_replace( '@' . $redirect_from . '@', $redirect_to, $requested_path );
|
851 |
+
}
|
852 |
+
|
853 |
// if we have a valid status code, then redirect with it
|
854 |
if ( in_array( $status_code, $this->valid_status_codes ) )
|
855 |
wp_safe_redirect( esc_url_raw( $redirect_to ), $status_code );
|
915 |
|
916 |
return $path;
|
917 |
}
|
918 |
+
|
919 |
+
/**
|
920 |
+
* Return a permalink for a redirect post, which is the "redirect from"
|
921 |
+
* URL for that redirect.
|
922 |
+
*
|
923 |
+
* @since 1.7
|
924 |
+
* @param string $permalink The permalink
|
925 |
+
* @param object $post A Post object
|
926 |
+
* @uses home_url, get_post_meta
|
927 |
+
* @return string The permalink
|
928 |
+
*/
|
929 |
+
public function filter_post_type_link( $permalink, $post ) {
|
930 |
+
if ( $this->redirect_post_type != $post->post_type )
|
931 |
+
return $permalink;
|
932 |
+
|
933 |
+
// We can't do anything to provide a permalink
|
934 |
+
// for regex enabled redirects.
|
935 |
+
if ( get_post_meta( $post->ID, $this->meta_key_enable_redirect_from_regex, true ) )
|
936 |
+
return $permalink;
|
937 |
+
|
938 |
+
// We can't do anything if there is a wildcard in the redirect from
|
939 |
+
$redirect_from = get_post_meta( $post->ID, $this->meta_key_redirect_from, true );
|
940 |
+
if ( false !== strpos( $redirect_from, '*' ) )
|
941 |
+
return $permalink;
|
942 |
+
|
943 |
+
return home_url( $redirect_from );
|
944 |
+
}
|
945 |
}
|
946 |
|
947 |
global $safe_redirect_manager;
|