Version Description
- Fix CSV export merging everything into one line
- Fix bug with HTTP codes not being imported from CSV
- Add filters for source and target URLs
- Add filters for log and 404s
- Add filters for request data
- Add filter for monitoring post permalinks
- Fix export of 404 and logs
Download this release
Release Info
Developer | johnny5 |
Plugin | Redirection |
Version | 2.6.1 |
Comparing to | |
See all releases |
Code changes from version 2.6 to 2.6.1
- README.md +42 -6
- actions/random.php +1 -1
- actions/url.php +1 -1
- fileio/csv.php +40 -15
- locale/redirection.pot +94 -64
- models/database.php +2 -2
- models/log.php +2 -0
- models/monitor.php +67 -23
- models/redirect.php +13 -48
- models/request.php +45 -0
- modules/wordpress.php +3 -29
- readme.txt +11 -2
- redirection-admin.php +14 -12
- redirection-front.php +20 -0
- redirection.php +2 -1
README.md
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
-
Redirection
|
2 |
-
===========
|
3 |
|
4 |
[![Build Status](https://travis-ci.org/johngodley/redirection.svg?branch=master)](https://travis-ci.org/johngodley/redirection)
|
5 |
|
@@ -7,14 +6,51 @@ Redirection is a WordPress plugin to manage 301 redirections, keep track of 404
|
|
7 |
|
8 |
Note: this is the current 'trunk' version of Redirection. It may be newer than what is in the WordPress.org plugin repository, and should be considered experimental.
|
9 |
|
10 |
-
Installation
|
11 |
-
============
|
12 |
Redirection can be installed by visiting the WordPress.org plugin page:
|
13 |
|
14 |
https://wordpress.org/plugins/redirection/
|
15 |
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
Please raise any bug reports or enhancement requests here. Pull requests are always welcome.
|
19 |
|
20 |
You can find a more detailed description of the plugin on the [Redirection home page](http://urbangiraffe.com/plugins/redirection/)
|
1 |
+
# Redirection
|
|
|
2 |
|
3 |
[![Build Status](https://travis-ci.org/johngodley/redirection.svg?branch=master)](https://travis-ci.org/johngodley/redirection)
|
4 |
|
6 |
|
7 |
Note: this is the current 'trunk' version of Redirection. It may be newer than what is in the WordPress.org plugin repository, and should be considered experimental.
|
8 |
|
9 |
+
## Installation
|
|
|
10 |
Redirection can be installed by visiting the WordPress.org plugin page:
|
11 |
|
12 |
https://wordpress.org/plugins/redirection/
|
13 |
|
14 |
+
## Customisation
|
15 |
+
|
16 |
+
### Request Information
|
17 |
+
|
18 |
+
The following WordPress filters are available for customisation of a server requests:
|
19 |
+
|
20 |
+
- `redirection_request_url` - The request URL
|
21 |
+
- `redirection_request_agent` - The request user agent
|
22 |
+
- `redirection_request_referrer` - The request referrer
|
23 |
+
- `redirection_request_ip` - The request IP address
|
24 |
+
|
25 |
+
### Logging
|
26 |
+
|
27 |
+
The following WordPress filters are available for customisation of logged data:
|
28 |
+
|
29 |
+
- `redirection_404_data` - Data to be inserted into the 404 table
|
30 |
+
- `redirection_log_data` - Data to be inserted into the redirect log table
|
31 |
+
|
32 |
+
### Redirect source and target
|
33 |
+
|
34 |
+
- `redirection_url_source` - The original URL used before matching a request. Return false to stop any redirection
|
35 |
+
- `redirection_url_target` - The target URL after a request has been matched (and after any regular expression captures have been replaced). Return false to stop any redirection
|
36 |
+
|
37 |
+
### Dynamic URL data
|
38 |
+
|
39 |
+
The following special words can be inserted into a target URL:
|
40 |
+
|
41 |
+
- `%userid%` - Insert user's ID
|
42 |
+
- `%userlogin%` - Insert user's login name
|
43 |
+
- `%userurl%` - Insert user's custom URL
|
44 |
+
|
45 |
+
### Management
|
46 |
+
|
47 |
+
- `redirection_permalink_changed` - return boolean if a post's permalink has changed
|
48 |
+
- `redirection_remove_existing` - fired when a post changes permalink and we need to clear existing redirects that might affect it
|
49 |
+
|
50 |
+
Additionally, if the target URL is a number without any slashes then Redirection will treat it as a post ID and redirect to the full URL for that post.
|
51 |
+
|
52 |
+
## Support
|
53 |
+
|
54 |
Please raise any bug reports or enhancement requests here. Pull requests are always welcome.
|
55 |
|
56 |
You can find a more detailed description of the plugin on the [Redirection home page](http://urbangiraffe.com/plugins/redirection/)
|
actions/random.php
CHANGED
@@ -14,7 +14,7 @@ class Random_Action extends Red_Action {
|
|
14 |
301 => get_status_header_desc( 301 ),
|
15 |
302 => get_status_header_desc( 302 ),
|
16 |
307 => get_status_header_desc( 307 ),
|
17 |
-
|
18 |
);
|
19 |
}
|
20 |
|
14 |
301 => get_status_header_desc( 301 ),
|
15 |
302 => get_status_header_desc( 302 ),
|
16 |
307 => get_status_header_desc( 307 ),
|
17 |
+
308 => get_status_header_desc( 308 ),
|
18 |
);
|
19 |
}
|
20 |
|
actions/url.php
CHANGED
@@ -10,7 +10,7 @@ class Url_Action extends Red_Action {
|
|
10 |
301 => get_status_header_desc( 301 ),
|
11 |
302 => get_status_header_desc( 302 ),
|
12 |
307 => get_status_header_desc( 307 ),
|
13 |
-
|
14 |
);
|
15 |
}
|
16 |
|
10 |
301 => get_status_header_desc( 301 ),
|
11 |
302 => get_status_header_desc( 302 ),
|
12 |
307 => get_status_header_desc( 307 ),
|
13 |
+
308 => get_status_header_desc( 308 ),
|
14 |
);
|
15 |
}
|
16 |
|
fileio/csv.php
CHANGED
@@ -1,6 +1,12 @@
|
|
1 |
<?php
|
2 |
|
3 |
class Red_Csv_File extends Red_FileIO {
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
public function export( array $items ) {
|
5 |
$filename = 'redirection-'.date_i18n( get_option( 'date_format' ) ).'.csv';
|
6 |
|
@@ -11,10 +17,14 @@ class Red_Csv_File extends Red_FileIO {
|
|
11 |
|
12 |
$stdout = fopen( 'php://output', 'w' );
|
13 |
|
14 |
-
|
|
|
|
|
|
|
|
|
15 |
|
16 |
foreach ( $items as $line ) {
|
17 |
-
fwrite( $
|
18 |
}
|
19 |
}
|
20 |
|
@@ -39,33 +49,48 @@ class Red_Csv_File extends Red_FileIO {
|
|
39 |
}
|
40 |
|
41 |
public function load( $group, $filename, $data ) {
|
42 |
-
$
|
43 |
-
$file = fopen( $filename, 'r' );
|
44 |
|
45 |
if ( $file ) {
|
46 |
-
|
47 |
-
|
|
|
|
|
|
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
53 |
}
|
54 |
}
|
55 |
|
56 |
return $count;
|
57 |
}
|
58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
public function csv_as_item( $csv, $group ) {
|
60 |
-
if ( $csv[
|
61 |
return array(
|
62 |
-
'source' => trim( $csv[
|
63 |
-
'target' => trim( $csv[
|
64 |
-
'regex' => isset( $csv[
|
65 |
'group_id' => $group,
|
66 |
'match' => 'url',
|
67 |
'red_action' => 'url',
|
68 |
-
'action_code' => isset( $csv[
|
69 |
);
|
70 |
}
|
71 |
|
1 |
<?php
|
2 |
|
3 |
class Red_Csv_File extends Red_FileIO {
|
4 |
+
const CSV_SOURCE = 0;
|
5 |
+
const CSV_TARGET = 1;
|
6 |
+
const CSV_REGEX = 2;
|
7 |
+
const CSV_TYPE = 3;
|
8 |
+
const CSV_CODE = 4;
|
9 |
+
|
10 |
public function export( array $items ) {
|
11 |
$filename = 'redirection-'.date_i18n( get_option( 'date_format' ) ).'.csv';
|
12 |
|
17 |
|
18 |
$stdout = fopen( 'php://output', 'w' );
|
19 |
|
20 |
+
$this->output_to_file( $stdout, $items );
|
21 |
+
}
|
22 |
+
|
23 |
+
public function output_to_file( $handle, array $items ) {
|
24 |
+
fputcsv( $handle, array( 'source', 'target', 'regex', 'type', 'code', 'match', 'hits', 'title' ) );
|
25 |
|
26 |
foreach ( $items as $line ) {
|
27 |
+
fwrite( $handle, $this->item_as_csv( $line ).PHP_EOL );
|
28 |
}
|
29 |
}
|
30 |
|
49 |
}
|
50 |
|
51 |
public function load( $group, $filename, $data ) {
|
52 |
+
$file = fopen( $filename, 'r' );
|
|
|
53 |
|
54 |
if ( $file ) {
|
55 |
+
return $this->load_from_file( $group, $file );
|
56 |
+
}
|
57 |
+
|
58 |
+
return 0;
|
59 |
+
}
|
60 |
|
61 |
+
public function load_from_file( $group_id, $file ) {
|
62 |
+
$count = 0;
|
63 |
+
|
64 |
+
while ( ( $csv = fgetcsv( $file, 1000, ',' ) ) ) {
|
65 |
+
$item = $this->csv_as_item( $csv, $group_id );
|
66 |
+
|
67 |
+
if ( $item ) {
|
68 |
+
Red_Item::create( $item );
|
69 |
+
$count++;
|
70 |
}
|
71 |
}
|
72 |
|
73 |
return $count;
|
74 |
}
|
75 |
|
76 |
+
private function get_valid_code( $code ) {
|
77 |
+
if ( get_status_header_desc( $code ) !== '' ) {
|
78 |
+
return intval( $code, 10 );
|
79 |
+
}
|
80 |
+
|
81 |
+
return 301;
|
82 |
+
}
|
83 |
+
|
84 |
public function csv_as_item( $csv, $group ) {
|
85 |
+
if ( $csv[ self::CSV_SOURCE ] !== 'source' && $csv[ self::CSV_TARGET ] !== 'target' && count( $csv ) > 1 ) {
|
86 |
return array(
|
87 |
+
'source' => trim( $csv[ self::CSV_SOURCE ] ),
|
88 |
+
'target' => trim( $csv[ self::CSV_TARGET ] ),
|
89 |
+
'regex' => isset( $csv[ self::CSV_REGEX ] ) ? $this->parse_regex( $csv[ self::CSV_REGEX ] ) : $this->is_regex( $csv[ self::CSV_SOURCE ] ),
|
90 |
'group_id' => $group,
|
91 |
'match' => 'url',
|
92 |
'red_action' => 'url',
|
93 |
+
'action_code' => isset( $csv[ self::CSV_CODE ] ) ? $this->get_valid_code( $csv[ self::CSV_CODE ] ) : 301,
|
94 |
);
|
95 |
}
|
96 |
|
locale/redirection.pot
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
# Copyright (C)
|
2 |
# This file is distributed under the same license as the Redirection package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
@@ -7,13 +7,13 @@ msgstr ""
|
|
7 |
"MIME-Version: 1.0\n"
|
8 |
"Content-Type: text/plain; charset=UTF-8\n"
|
9 |
"Content-Transfer-Encoding: 8bit\n"
|
10 |
-
"PO-Revision-Date:
|
11 |
"X-Poedit-Basepath: ..\n"
|
12 |
"X-Poedit-SourceCharset: UTF-8\n"
|
13 |
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
|
14 |
"X-Poedit-SearchPath-0: .\n"
|
15 |
"X-Poedit-SearchPathExcluded-0: *.js\n"
|
16 |
-
"Plural-Forms: nplurals=2; plural=(n != 1);\n
|
17 |
|
18 |
#: matches/login.php:7
|
19 |
msgid "URL and login status"
|
@@ -47,6 +47,10 @@ msgstr ""
|
|
47 |
msgid "HTTP Code"
|
48 |
msgstr ""
|
49 |
|
|
|
|
|
|
|
|
|
50 |
#: matches/referrer.php:46, matches/referrer.php:48, matches/user-agent.php:58, matches/user-agent.php:60
|
51 |
msgid "Matched"
|
52 |
msgstr ""
|
@@ -107,6 +111,20 @@ msgstr ""
|
|
107 |
msgid "User Agent"
|
108 |
msgstr ""
|
109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
#: models/pager.php:28
|
111 |
msgid "Type"
|
112 |
msgstr ""
|
@@ -127,7 +145,7 @@ msgstr ""
|
|
127 |
msgid "Edit"
|
128 |
msgstr ""
|
129 |
|
130 |
-
#: models/pager.php:54, models/pager.php:101, models/pager.php:254, models/pager.php:300, models/pager.php:498, models/pager.php:628, view/options.php:
|
131 |
msgid "Delete"
|
132 |
msgstr ""
|
133 |
|
@@ -147,7 +165,7 @@ msgstr ""
|
|
147 |
msgid "No group filter"
|
148 |
msgstr ""
|
149 |
|
150 |
-
#: models/pager.php:243, view/group-edit.php:4, view/group-list.php:
|
151 |
msgid "Name"
|
152 |
msgstr ""
|
153 |
|
@@ -211,23 +229,23 @@ msgstr ""
|
|
211 |
msgid "Invalid source URL when creating redirect for given match type"
|
212 |
msgstr ""
|
213 |
|
214 |
-
#: models/redirect.php:
|
215 |
msgid "Redirect to URL"
|
216 |
msgstr ""
|
217 |
|
218 |
-
#: models/redirect.php:
|
219 |
msgid "Redirect to random post"
|
220 |
msgstr ""
|
221 |
|
222 |
-
#: models/redirect.php:
|
223 |
msgid "Pass-through"
|
224 |
msgstr ""
|
225 |
|
226 |
-
#: models/redirect.php:
|
227 |
msgid "Error (404)"
|
228 |
msgstr ""
|
229 |
|
230 |
-
#: models/redirect.php:
|
231 |
msgid "Do nothing"
|
232 |
msgstr ""
|
233 |
|
@@ -295,61 +313,57 @@ msgstr ""
|
|
295 |
msgid "WordPress-powered redirects. This requires no further configuration, and you can track hits."
|
296 |
msgstr ""
|
297 |
|
298 |
-
#: redirection-admin.php:
|
299 |
msgid "Settings"
|
300 |
msgstr ""
|
301 |
|
302 |
-
#: redirection-admin.php:
|
303 |
msgid "Log entries"
|
304 |
msgstr ""
|
305 |
|
306 |
-
#: redirection-admin.php:
|
307 |
-
msgid "Redirection"
|
308 |
-
msgstr ""
|
309 |
-
|
310 |
-
#: redirection-admin.php:229, redirection-admin.php:245
|
311 |
msgid "Your options were updated"
|
312 |
msgstr ""
|
313 |
|
314 |
-
#: redirection-admin.php:
|
315 |
msgid "Redirection data has been deleted and the plugin disabled"
|
316 |
msgstr ""
|
317 |
|
318 |
-
#: redirection-admin.php:
|
319 |
msgid "%d redirection was successfully imported"
|
320 |
msgid_plural "%d redirections were successfully imported"
|
321 |
msgstr[0] ""
|
322 |
msgstr[1] ""
|
323 |
|
324 |
-
#: redirection-admin.php:
|
325 |
msgid "No items were imported"
|
326 |
msgstr ""
|
327 |
|
328 |
-
#: redirection-admin.php:
|
329 |
msgid "Your logs have been deleted"
|
330 |
msgstr ""
|
331 |
|
332 |
-
#: redirection-admin.php:
|
333 |
msgid "Your group was added successfully"
|
334 |
msgstr ""
|
335 |
|
336 |
-
#: redirection-admin.php:
|
337 |
msgid "Please specify a group name"
|
338 |
msgstr ""
|
339 |
|
340 |
-
#: redirection-admin.php:
|
341 |
msgid "Sorry, but your redirection was not created"
|
342 |
msgstr ""
|
343 |
|
344 |
-
#: redirection-admin.php:
|
345 |
msgid "Invalid module"
|
346 |
msgstr ""
|
347 |
|
348 |
-
#: redirection-admin.php:
|
349 |
msgid "Download"
|
350 |
msgstr ""
|
351 |
|
352 |
-
#: redirection-admin.php:
|
353 |
msgid "Cancel"
|
354 |
msgstr ""
|
355 |
|
@@ -385,19 +399,19 @@ msgstr ""
|
|
385 |
msgid "Save"
|
386 |
msgstr ""
|
387 |
|
388 |
-
#: view/group-list.php:
|
389 |
msgid "Groups"
|
390 |
msgstr ""
|
391 |
|
392 |
-
#: view/group-list.php:
|
393 |
msgid "Add Group"
|
394 |
msgstr ""
|
395 |
|
396 |
-
#: view/group-list.php:
|
397 |
msgid "Use groups to organise your redirects. Groups are assigned to a module, which affects how the redirects in that group work. If you are unsure then stick to the WordPress module."
|
398 |
msgstr ""
|
399 |
|
400 |
-
#: view/group-list.php:
|
401 |
msgid "Add"
|
402 |
msgstr ""
|
403 |
|
@@ -409,23 +423,19 @@ msgstr ""
|
|
409 |
msgid "optional"
|
410 |
msgstr ""
|
411 |
|
412 |
-
#: view/
|
413 |
-
msgid "Redirections"
|
414 |
-
msgstr ""
|
415 |
-
|
416 |
-
#: view/log.php:5
|
417 |
msgid "Redirection Log"
|
418 |
msgstr ""
|
419 |
|
420 |
-
#: view/log.php:
|
421 |
msgid "Log Management"
|
422 |
msgstr ""
|
423 |
|
424 |
-
#: view/log.php:
|
425 |
msgid "These apply to the current search term, if any, otherwise all logs."
|
426 |
msgstr ""
|
427 |
|
428 |
-
#: view/module-list.php:
|
429 |
msgid "Modules"
|
430 |
msgstr ""
|
431 |
|
@@ -453,71 +463,79 @@ msgstr ""
|
|
453 |
msgid "Keep forever"
|
454 |
msgstr ""
|
455 |
|
456 |
-
#: view/options.php:
|
457 |
msgid "Options"
|
458 |
msgstr ""
|
459 |
|
460 |
-
#: view/options.php:
|
461 |
msgid "Plugin Support"
|
462 |
msgstr ""
|
463 |
|
464 |
-
#: view/options.php:
|
|
|
|
|
|
|
|
|
465 |
msgid "Redirect Logs"
|
466 |
msgstr ""
|
467 |
|
468 |
-
#: view/options.php:
|
469 |
msgid "(time to keep logs for)"
|
470 |
msgstr ""
|
471 |
|
472 |
-
#: view/options.php:
|
473 |
msgid "404 Logs"
|
474 |
msgstr ""
|
475 |
|
476 |
-
#: view/options.php:
|
477 |
msgid "Monitor changes to posts"
|
478 |
msgstr ""
|
479 |
|
480 |
-
#: view/options.php:
|
|
|
|
|
|
|
|
|
481 |
msgid "RSS Token"
|
482 |
msgstr ""
|
483 |
|
484 |
-
#: view/options.php:
|
485 |
msgid "A unique token allowing feed readers access to Redirection log RSS (leave blank to auto-generate)"
|
486 |
msgstr ""
|
487 |
|
488 |
-
#: view/options.php:
|
489 |
msgid "Auto-generate URL"
|
490 |
msgstr ""
|
491 |
|
492 |
-
#: view/options.php:
|
493 |
msgid "This will be used to auto-generate a URL if no URL is given. You can use the special tags <code>$dec$</code> or <code>$hex$</code> to have a unique ID inserted (either decimal or hex)"
|
494 |
msgstr ""
|
495 |
|
496 |
-
#: view/options.php:
|
497 |
msgid "Update"
|
498 |
msgstr ""
|
499 |
|
500 |
-
#: view/options.php:
|
501 |
msgid "Import"
|
502 |
msgstr ""
|
503 |
|
504 |
-
#: view/options.php:
|
505 |
msgid "Here you can import redirections from an existing <code>.htaccess</code> file, or a CSV file."
|
506 |
msgstr ""
|
507 |
|
508 |
-
#: view/options.php:
|
509 |
msgid "Import into"
|
510 |
msgstr ""
|
511 |
|
512 |
-
#: view/options.php:
|
513 |
msgid "Upload"
|
514 |
msgstr ""
|
515 |
|
516 |
-
#: view/options.php:
|
517 |
msgid "Delete Redirection"
|
518 |
msgstr ""
|
519 |
|
520 |
-
#: view/options.php:
|
521 |
msgid "Selecting this option will delete all redirections, all logs, and any options associated with the Redirection plugin. Make sure this is what you want to do."
|
522 |
msgstr ""
|
523 |
|
@@ -537,30 +555,42 @@ msgstr ""
|
|
537 |
msgid "Support"
|
538 |
msgstr ""
|
539 |
|
540 |
-
#: view/support.php:
|
541 |
msgid "Redirection Support"
|
542 |
msgstr ""
|
543 |
|
544 |
-
#: view/support.php:
|
545 |
msgid "Redirection is free to use - life is wonderful and lovely! However, it has required a great deal of time and effort to develop and if it has been useful you can help support this development by <strong>making a small donation</strong>."
|
546 |
msgstr ""
|
547 |
|
548 |
-
#: view/support.php:
|
549 |
msgid "This will act as an incentive for me to carry on developing. You get some useful software and I get to carry on making it. Everybody wins."
|
550 |
msgstr ""
|
551 |
|
552 |
-
#: view/support.php:
|
|
|
|
|
|
|
|
|
553 |
msgid "Individual<br/>Donation"
|
554 |
msgstr ""
|
555 |
|
556 |
-
#: view/support.php:
|
557 |
msgid "Commercial<br/>Donation"
|
558 |
msgstr ""
|
559 |
|
560 |
-
#: view/support.php:
|
|
|
|
|
|
|
|
|
561 |
msgid "Translations"
|
562 |
msgstr ""
|
563 |
|
564 |
-
#: view/support.php:
|
565 |
-
msgid "
|
|
|
|
|
|
|
|
|
566 |
msgstr ""
|
1 |
+
# Copyright (C) 2017 Redirection
|
2 |
# This file is distributed under the same license as the Redirection package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
7 |
"MIME-Version: 1.0\n"
|
8 |
"Content-Type: text/plain; charset=UTF-8\n"
|
9 |
"Content-Transfer-Encoding: 8bit\n"
|
10 |
+
"PO-Revision-Date: 2017-MO-DA HO:MI+ZONE\n"
|
11 |
"X-Poedit-Basepath: ..\n"
|
12 |
"X-Poedit-SourceCharset: UTF-8\n"
|
13 |
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
|
14 |
"X-Poedit-SearchPath-0: .\n"
|
15 |
"X-Poedit-SearchPathExcluded-0: *.js\n"
|
16 |
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
17 |
|
18 |
#: matches/login.php:7
|
19 |
msgid "URL and login status"
|
47 |
msgid "HTTP Code"
|
48 |
msgstr ""
|
49 |
|
50 |
+
#: matches/referrer.php:40
|
51 |
+
msgid "The visitor will be redirected from the source URL if the referrer matches. You can specify a <em>matched</em> target URL as the address to send visitors if they do match, and <em>not matched</em> if they don't match. Leaving a URL blank means that the visitor is not redirected."
|
52 |
+
msgstr ""
|
53 |
+
|
54 |
#: matches/referrer.php:46, matches/referrer.php:48, matches/user-agent.php:58, matches/user-agent.php:60
|
55 |
msgid "Matched"
|
56 |
msgstr ""
|
111 |
msgid "User Agent"
|
112 |
msgstr ""
|
113 |
|
114 |
+
#: matches/user-agent.php:51
|
115 |
+
msgid ""
|
116 |
+
"The visitor will be redirected from the source URL if the user agent matches. You can specify a <em>matched</em> target URL as the address to send visitors if they do match, and <em>not matched</em> if they don't match. Leaving a URL blank means that the visitor is not redirected. <strong>All matches are performed as regular expressions</strong>.\n"
|
117 |
+
""
|
118 |
+
msgstr ""
|
119 |
+
|
120 |
+
#: models/database.php:120, view/item-list.php:3
|
121 |
+
msgid "Redirections"
|
122 |
+
msgstr ""
|
123 |
+
|
124 |
+
#: models/database.php:121
|
125 |
+
msgid "Modified Posts"
|
126 |
+
msgstr ""
|
127 |
+
|
128 |
#: models/pager.php:28
|
129 |
msgid "Type"
|
130 |
msgstr ""
|
145 |
msgid "Edit"
|
146 |
msgstr ""
|
147 |
|
148 |
+
#: models/pager.php:54, models/pager.php:101, models/pager.php:254, models/pager.php:300, models/pager.php:498, models/pager.php:628, view/options.php:111
|
149 |
msgid "Delete"
|
150 |
msgstr ""
|
151 |
|
165 |
msgid "No group filter"
|
166 |
msgstr ""
|
167 |
|
168 |
+
#: models/pager.php:243, view/group-edit.php:4, view/group-list.php:28
|
169 |
msgid "Name"
|
170 |
msgstr ""
|
171 |
|
229 |
msgid "Invalid source URL when creating redirect for given match type"
|
230 |
msgstr ""
|
231 |
|
232 |
+
#: models/redirect.php:380
|
233 |
msgid "Redirect to URL"
|
234 |
msgstr ""
|
235 |
|
236 |
+
#: models/redirect.php:381
|
237 |
msgid "Redirect to random post"
|
238 |
msgstr ""
|
239 |
|
240 |
+
#: models/redirect.php:382
|
241 |
msgid "Pass-through"
|
242 |
msgstr ""
|
243 |
|
244 |
+
#: models/redirect.php:383
|
245 |
msgid "Error (404)"
|
246 |
msgstr ""
|
247 |
|
248 |
+
#: models/redirect.php:384
|
249 |
msgid "Do nothing"
|
250 |
msgstr ""
|
251 |
|
313 |
msgid "WordPress-powered redirects. This requires no further configuration, and you can track hits."
|
314 |
msgstr ""
|
315 |
|
316 |
+
#: redirection-admin.php:146
|
317 |
msgid "Settings"
|
318 |
msgstr ""
|
319 |
|
320 |
+
#: redirection-admin.php:158
|
321 |
msgid "Log entries"
|
322 |
msgstr ""
|
323 |
|
324 |
+
#: redirection-admin.php:249, redirection-admin.php:265
|
|
|
|
|
|
|
|
|
325 |
msgid "Your options were updated"
|
326 |
msgstr ""
|
327 |
|
328 |
+
#: redirection-admin.php:274
|
329 |
msgid "Redirection data has been deleted and the plugin disabled"
|
330 |
msgstr ""
|
331 |
|
332 |
+
#: redirection-admin.php:281
|
333 |
msgid "%d redirection was successfully imported"
|
334 |
msgid_plural "%d redirections were successfully imported"
|
335 |
msgstr[0] ""
|
336 |
msgstr[1] ""
|
337 |
|
338 |
+
#: redirection-admin.php:283
|
339 |
msgid "No items were imported"
|
340 |
msgstr ""
|
341 |
|
342 |
+
#: redirection-admin.php:295, redirection-admin.php:315
|
343 |
msgid "Your logs have been deleted"
|
344 |
msgstr ""
|
345 |
|
346 |
+
#: redirection-admin.php:329
|
347 |
msgid "Your group was added successfully"
|
348 |
msgstr ""
|
349 |
|
350 |
+
#: redirection-admin.php:332
|
351 |
msgid "Please specify a group name"
|
352 |
msgstr ""
|
353 |
|
354 |
+
#: redirection-admin.php:508
|
355 |
msgid "Sorry, but your redirection was not created"
|
356 |
msgstr ""
|
357 |
|
358 |
+
#: redirection-admin.php:514
|
359 |
msgid "Invalid module"
|
360 |
msgstr ""
|
361 |
|
362 |
+
#: redirection-admin.php:530
|
363 |
msgid "Download"
|
364 |
msgstr ""
|
365 |
|
366 |
+
#: redirection-admin.php:531, view/group-edit.php:22, view/item-edit.php:33, view/module-edit.php:13
|
367 |
msgid "Cancel"
|
368 |
msgstr ""
|
369 |
|
399 |
msgid "Save"
|
400 |
msgstr ""
|
401 |
|
402 |
+
#: view/group-list.php:3, view/submenu.php:11
|
403 |
msgid "Groups"
|
404 |
msgstr ""
|
405 |
|
406 |
+
#: view/group-list.php:20
|
407 |
msgid "Add Group"
|
408 |
msgstr ""
|
409 |
|
410 |
+
#: view/group-list.php:22
|
411 |
msgid "Use groups to organise your redirects. Groups are assigned to a module, which affects how the redirects in that group work. If you are unsure then stick to the WordPress module."
|
412 |
msgstr ""
|
413 |
|
414 |
+
#: view/group-list.php:42
|
415 |
msgid "Add"
|
416 |
msgstr ""
|
417 |
|
423 |
msgid "optional"
|
424 |
msgstr ""
|
425 |
|
426 |
+
#: view/log.php:3
|
|
|
|
|
|
|
|
|
427 |
msgid "Redirection Log"
|
428 |
msgstr ""
|
429 |
|
430 |
+
#: view/log.php:17
|
431 |
msgid "Log Management"
|
432 |
msgstr ""
|
433 |
|
434 |
+
#: view/log.php:21
|
435 |
msgid "These apply to the current search term, if any, otherwise all logs."
|
436 |
msgstr ""
|
437 |
|
438 |
+
#: view/module-list.php:3, view/submenu.php:16
|
439 |
msgid "Modules"
|
440 |
msgstr ""
|
441 |
|
463 |
msgid "Keep forever"
|
464 |
msgstr ""
|
465 |
|
466 |
+
#: view/options.php:17, view/submenu.php:42
|
467 |
msgid "Options"
|
468 |
msgstr ""
|
469 |
|
470 |
+
#: view/options.php:25
|
471 |
msgid "Plugin Support"
|
472 |
msgstr ""
|
473 |
|
474 |
+
#: view/options.php:28
|
475 |
+
msgid "I'm a nice person and I have helped support the author of this plugin"
|
476 |
+
msgstr ""
|
477 |
+
|
478 |
+
#: view/options.php:32
|
479 |
msgid "Redirect Logs"
|
480 |
msgstr ""
|
481 |
|
482 |
+
#: view/options.php:38, view/options.php:48
|
483 |
msgid "(time to keep logs for)"
|
484 |
msgstr ""
|
485 |
|
486 |
+
#: view/options.php:42
|
487 |
msgid "404 Logs"
|
488 |
msgstr ""
|
489 |
|
490 |
+
#: view/options.php:52
|
491 |
msgid "Monitor changes to posts"
|
492 |
msgstr ""
|
493 |
|
494 |
+
#: view/options.php:55
|
495 |
+
msgid "Don't monitor"
|
496 |
+
msgstr ""
|
497 |
+
|
498 |
+
#: view/options.php:61
|
499 |
msgid "RSS Token"
|
500 |
msgstr ""
|
501 |
|
502 |
+
#: view/options.php:64
|
503 |
msgid "A unique token allowing feed readers access to Redirection log RSS (leave blank to auto-generate)"
|
504 |
msgstr ""
|
505 |
|
506 |
+
#: view/options.php:68
|
507 |
msgid "Auto-generate URL"
|
508 |
msgstr ""
|
509 |
|
510 |
+
#: view/options.php:72
|
511 |
msgid "This will be used to auto-generate a URL if no URL is given. You can use the special tags <code>$dec$</code> or <code>$hex$</code> to have a unique ID inserted (either decimal or hex)"
|
512 |
msgstr ""
|
513 |
|
514 |
+
#: view/options.php:77
|
515 |
msgid "Update"
|
516 |
msgstr ""
|
517 |
|
518 |
+
#: view/options.php:83
|
519 |
msgid "Import"
|
520 |
msgstr ""
|
521 |
|
522 |
+
#: view/options.php:85
|
523 |
msgid "Here you can import redirections from an existing <code>.htaccess</code> file, or a CSV file."
|
524 |
msgstr ""
|
525 |
|
526 |
+
#: view/options.php:92
|
527 |
msgid "Import into"
|
528 |
msgstr ""
|
529 |
|
530 |
+
#: view/options.php:95
|
531 |
msgid "Upload"
|
532 |
msgstr ""
|
533 |
|
534 |
+
#: view/options.php:105
|
535 |
msgid "Delete Redirection"
|
536 |
msgstr ""
|
537 |
|
538 |
+
#: view/options.php:106
|
539 |
msgid "Selecting this option will delete all redirections, all logs, and any options associated with the Redirection plugin. Make sure this is what you want to do."
|
540 |
msgstr ""
|
541 |
|
555 |
msgid "Support"
|
556 |
msgstr ""
|
557 |
|
558 |
+
#: view/support.php:3
|
559 |
msgid "Redirection Support"
|
560 |
msgstr ""
|
561 |
|
562 |
+
#: view/support.php:7
|
563 |
msgid "Redirection is free to use - life is wonderful and lovely! However, it has required a great deal of time and effort to develop and if it has been useful you can help support this development by <strong>making a small donation</strong>."
|
564 |
msgstr ""
|
565 |
|
566 |
+
#: view/support.php:8
|
567 |
msgid "This will act as an incentive for me to carry on developing. You get some useful software and I get to carry on making it. Everybody wins."
|
568 |
msgstr ""
|
569 |
|
570 |
+
#: view/support.php:13
|
571 |
+
msgid "If you are using this plugin in a commercial setup, or feel that it's been particularly useful, then you may want to consider a <strong>commercial donation</strong>."
|
572 |
+
msgstr ""
|
573 |
+
|
574 |
+
#: view/support.php:36
|
575 |
msgid "Individual<br/>Donation"
|
576 |
msgstr ""
|
577 |
|
578 |
+
#: view/support.php:56
|
579 |
msgid "Commercial<br/>Donation"
|
580 |
msgstr ""
|
581 |
|
582 |
+
#: view/support.php:60
|
583 |
+
msgid "Help! Frequently Asked Questions"
|
584 |
+
msgstr ""
|
585 |
+
|
586 |
+
#: view/support.php:77
|
587 |
msgid "Translations"
|
588 |
msgstr ""
|
589 |
|
590 |
+
#: view/support.php:79
|
591 |
+
msgid "Many thanks to the following for their translations:"
|
592 |
+
msgstr ""
|
593 |
+
|
594 |
+
#: view/support.php:87
|
595 |
+
msgid "Full details of producing a translation can be found in this <a href=\"http://urbangiraffe.com/articles/translating-wordpress-themes-and-plugins/\">guide to translating WordPress plugins</a>."
|
596 |
msgstr ""
|
models/database.php
CHANGED
@@ -117,8 +117,8 @@ class RE_Database {
|
|
117 |
|
118 |
// Default groups
|
119 |
if ( intval( $existing_groups, 10 ) === 0 ) {
|
120 |
-
$wpdb->insert( $wpdb->prefix.'redirection_groups', array( 'name' => __( 'Redirections' ), 'module_id' => 1, 'position' => 0 ) );
|
121 |
-
$wpdb->insert( $wpdb->prefix.'redirection_groups', array( 'name' => __( 'Modified Posts' ), 'module_id' => 1, 'position' => 1 ) );
|
122 |
}
|
123 |
}
|
124 |
|
117 |
|
118 |
// Default groups
|
119 |
if ( intval( $existing_groups, 10 ) === 0 ) {
|
120 |
+
$wpdb->insert( $wpdb->prefix.'redirection_groups', array( 'name' => __( 'Redirections', 'redirection' ), 'module_id' => 1, 'position' => 0 ) );
|
121 |
+
$wpdb->insert( $wpdb->prefix.'redirection_groups', array( 'name' => __( 'Modified Posts', 'redirection' ), 'module_id' => 1, 'position' => 1 ) );
|
122 |
}
|
123 |
}
|
124 |
|
models/log.php
CHANGED
@@ -176,6 +176,8 @@ class RE_404 {
|
|
176 |
|
177 |
if ( ! empty( $referrer ) )
|
178 |
$insert['referrer'] = $referrer;
|
|
|
|
|
179 |
|
180 |
$wpdb->insert( $wpdb->prefix.'redirection_404', $insert );
|
181 |
}
|
176 |
|
177 |
if ( ! empty( $referrer ) )
|
178 |
$insert['referrer'] = $referrer;
|
179 |
+
|
180 |
+
$insert = apply_filters( 'redirection_404_data', $insert );
|
181 |
|
182 |
$wpdb->insert( $wpdb->prefix.'redirection_404', $insert );
|
183 |
}
|
models/monitor.php
CHANGED
@@ -5,22 +5,25 @@ class Red_Monitor {
|
|
5 |
|
6 |
function __construct( $options ) {
|
7 |
if ( isset( $options['monitor_post'] ) && $options['monitor_post'] > 0 ) {
|
8 |
-
$this->monitor_group_id = intval( $options['monitor_post'] );
|
9 |
|
10 |
// Only monitor if permalinks enabled
|
11 |
if ( get_option( 'permalink_structure' ) ) {
|
12 |
-
add_action( 'post_updated', array(
|
13 |
-
add_action( 'edit_form_advanced', array(
|
14 |
-
add_action( 'edit_page_form', array(
|
|
|
|
|
15 |
}
|
16 |
}
|
17 |
}
|
18 |
|
19 |
-
public function
|
20 |
-
|
|
|
21 |
|
22 |
-
|
23 |
-
$url =
|
24 |
|
25 |
?>
|
26 |
<input type="hidden" name="redirection_slug" value="<?php echo esc_attr( $url ) ?>"/>
|
@@ -28,14 +31,22 @@ class Red_Monitor {
|
|
28 |
}
|
29 |
|
30 |
public function can_monitor_post( $post, $post_before, $form_data ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
if ( $post->post_status !== 'publish' || $post_before->post_status !== 'publish' ) {
|
32 |
return false;
|
33 |
}
|
34 |
|
35 |
-
|
|
|
36 |
return false;
|
37 |
}
|
38 |
|
|
|
39 |
if ( ! isset( $form_data['redirection_slug'] ) ) {
|
40 |
return false;
|
41 |
}
|
@@ -43,22 +54,55 @@ class Red_Monitor {
|
|
43 |
return true;
|
44 |
}
|
45 |
|
|
|
|
|
|
|
46 |
public function post_updated( $post_id, $post, $post_before ) {
|
47 |
if ( $this->can_monitor_post( $post, $post_before, $_POST ) ) {
|
48 |
-
$
|
49 |
-
$after = $after['path'];
|
50 |
-
$before = esc_url( $_POST['redirection_slug'] );
|
51 |
-
$site = parse_url( get_site_url() );
|
52 |
-
|
53 |
-
if ( $before !== $after && $before !== '/' && ( ! isset( $site['path'] ) || ( isset( $site['path'] ) && $before !== $site['path'].'/' ) ) ) {
|
54 |
-
Red_Item::create( array(
|
55 |
-
'source' => $before,
|
56 |
-
'target' => $after,
|
57 |
-
'match' => 'url',
|
58 |
-
'red_action' => 'url',
|
59 |
-
'group_id' => $this->monitor_group_id,
|
60 |
-
) );
|
61 |
-
}
|
62 |
}
|
63 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
}
|
5 |
|
6 |
function __construct( $options ) {
|
7 |
if ( isset( $options['monitor_post'] ) && $options['monitor_post'] > 0 ) {
|
8 |
+
$this->monitor_group_id = intval( $options['monitor_post'], 10 );
|
9 |
|
10 |
// Only monitor if permalinks enabled
|
11 |
if ( get_option( 'permalink_structure' ) ) {
|
12 |
+
add_action( 'post_updated', array( $this, 'post_updated' ), 11, 3 );
|
13 |
+
add_action( 'edit_form_advanced', array( $this, 'insert_old_post' ) );
|
14 |
+
add_action( 'edit_page_form', array( $this, 'insert_old_post' ) );
|
15 |
+
add_filter( 'redirection_remove_existing', array( $this, 'remove_existing_redirect' ) );
|
16 |
+
add_filter( 'redirection_permalink_changed', array( $this, 'has_permalink_changed' ), 10, 3 );
|
17 |
}
|
18 |
}
|
19 |
}
|
20 |
|
21 |
+
public function remove_existing_redirect( $url ) {
|
22 |
+
Red_Item::disable_where_matches( $url );
|
23 |
+
}
|
24 |
|
25 |
+
public function insert_old_post() {
|
26 |
+
$url = parse_url( get_permalink(), PHP_URL_PATH );
|
27 |
|
28 |
?>
|
29 |
<input type="hidden" name="redirection_slug" value="<?php echo esc_attr( $url ) ?>"/>
|
31 |
}
|
32 |
|
33 |
public function can_monitor_post( $post, $post_before, $form_data ) {
|
34 |
+
// Check this is the for the expected post
|
35 |
+
if ( ! isset( $form_data['ID'] ) || ! isset( $post->ID ) || $form_data['ID'] !== $post->ID ) {
|
36 |
+
return false;
|
37 |
+
}
|
38 |
+
|
39 |
+
// Don't do anything if we're not published
|
40 |
if ( $post->post_status !== 'publish' || $post_before->post_status !== 'publish' ) {
|
41 |
return false;
|
42 |
}
|
43 |
|
44 |
+
// Hierarchical post? Do nothing
|
45 |
+
if ( is_post_type_hierarchical( $post->post_type ) ) {
|
46 |
return false;
|
47 |
}
|
48 |
|
49 |
+
// Old Redirection slug not defined? Do nothing
|
50 |
if ( ! isset( $form_data['redirection_slug'] ) ) {
|
51 |
return false;
|
52 |
}
|
54 |
return true;
|
55 |
}
|
56 |
|
57 |
+
/**
|
58 |
+
* Called when a post has been updated - check if the slug has changed
|
59 |
+
*/
|
60 |
public function post_updated( $post_id, $post, $post_before ) {
|
61 |
if ( $this->can_monitor_post( $post, $post_before, $_POST ) ) {
|
62 |
+
$this->check_for_modified_slug( $post_id, $_POST['redirection_slug'] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
}
|
64 |
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Changed if permalinks are different and the before wasn't the site url (we don't want to redirect the site URL)
|
68 |
+
*/
|
69 |
+
public function has_permalink_changed( $result, $before, $after ) {
|
70 |
+
if ( $before !== $after && $this->get_site_path() !== $before ) {
|
71 |
+
return true;
|
72 |
+
}
|
73 |
+
|
74 |
+
return false;
|
75 |
+
}
|
76 |
+
|
77 |
+
private function get_site_path() {
|
78 |
+
$path = parse_url( get_site_url(), PHP_URL_PATH );
|
79 |
+
|
80 |
+
if ( $path ) {
|
81 |
+
return rtrim( $path, '/' ).'/';
|
82 |
+
}
|
83 |
+
|
84 |
+
return '/';
|
85 |
+
}
|
86 |
+
|
87 |
+
public function check_for_modified_slug( $post_id, $before ) {
|
88 |
+
$after = parse_url( get_permalink( $post_id ), PHP_URL_PATH );
|
89 |
+
$before = esc_url( $before );
|
90 |
+
|
91 |
+
if ( apply_filters( 'redirection_permalink_changed', false, $before, $after ) ) {
|
92 |
+
do_action( 'redirection_remove_existing', $after, $post_id );
|
93 |
+
|
94 |
+
// Create a new redirect for this post
|
95 |
+
Red_Item::create( array(
|
96 |
+
'source' => $before,
|
97 |
+
'target' => $after,
|
98 |
+
'match' => 'url',
|
99 |
+
'red_action' => 'url',
|
100 |
+
'group_id' => $this->monitor_group_id,
|
101 |
+
) );
|
102 |
+
|
103 |
+
return true;
|
104 |
+
}
|
105 |
+
|
106 |
+
return false;
|
107 |
+
}
|
108 |
}
|
models/redirect.php
CHANGED
@@ -163,7 +163,7 @@ class Red_Item {
|
|
163 |
$parsed_domain = parse_url( site_url() );
|
164 |
|
165 |
if ( isset( $parsed_url['scheme'] ) && ( $parsed_url['scheme'] === 'http' || $parsed_url['scheme'] === 'https' ) && $parsed_url['host'] !== $parsed_domain['host'] ) {
|
166 |
-
return new WP_Error( 'redirect-add', sprintf( __( 'You can only redirect from a relative URL (<code>%s</code>) on this domain (<code>%s</code>).', 'redirection' ), $parsed_url['path'], $parsed_domain['host'] ) );
|
167 |
}
|
168 |
|
169 |
$matcher = Red_Match::create( $details['match'] );
|
@@ -186,8 +186,9 @@ class Red_Item {
|
|
186 |
elseif ( $action === 'error' )
|
187 |
$action_code = 404;
|
188 |
|
189 |
-
if ( isset( $details['action_code'] ) )
|
190 |
$action_code = intval( $details['action_code'] );
|
|
|
191 |
|
192 |
$data = array(
|
193 |
'url' => self::sanitize_url( $details['source'], $regex ),
|
@@ -213,6 +214,12 @@ class Red_Item {
|
|
213 |
return new WP_Error( 'redirect-add', __( 'Unable to add new redirect - delete Redirection from the options page and re-install' ) );
|
214 |
}
|
215 |
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
public function delete() {
|
217 |
global $wpdb;
|
218 |
|
@@ -303,35 +310,17 @@ class Red_Item {
|
|
303 |
if ( ( $this->regex === false && ( $this->url === $url || $this->url === rtrim( $url, '/' ) || $this->url === urldecode( $url ) ) ) || ( $this->regex === true && @preg_match( '@'.str_replace( '@', '\\@', $this->url ).'@', $url, $matches ) > 0) || ( $this->regex === true && @preg_match( '@'.str_replace( '@', '\\@', $this->url ).'@', urldecode( $url ), $matches ) > 0) ) {
|
304 |
// Check if our match wants this URL
|
305 |
$target = $this->match->get_target( $url, $this->url, $this->regex );
|
|
|
306 |
|
307 |
-
if ( $target ) {
|
308 |
-
$target = $this->replace_special_tags( $target );
|
309 |
-
|
310 |
$this->visit( $url, $target );
|
311 |
-
|
312 |
-
if ( $this->status === 'enabled' )
|
313 |
-
return $this->action->process_before( $this->action_code, $target );
|
314 |
}
|
315 |
}
|
316 |
|
317 |
return false;
|
318 |
}
|
319 |
|
320 |
-
function replace_special_tags( $target ) {
|
321 |
-
if ( is_numeric( $target ) )
|
322 |
-
$target = get_permalink( $target );
|
323 |
-
else {
|
324 |
-
$user = wp_get_current_user();
|
325 |
-
if ( ! empty( $user ) ) {
|
326 |
-
$target = str_replace( '%userid%', $user->ID, $target );
|
327 |
-
$target = str_replace( '%userlogin%', isset( $user->user_login ) ? $user->user_login : '', $target );
|
328 |
-
$target = str_replace( '%userurl%', isset( $user->user_url ) ? $user->user_url : '', $target );
|
329 |
-
}
|
330 |
-
}
|
331 |
-
|
332 |
-
return $target;
|
333 |
-
}
|
334 |
-
|
335 |
function visit( $url, $target ) {
|
336 |
if ( $this->tracking && $this->id ) {
|
337 |
global $wpdb;
|
@@ -342,35 +331,11 @@ class Red_Item {
|
|
342 |
|
343 |
$options = red_get_options();
|
344 |
if ( isset( $options['expire_redirect'] ) && $options['expire_redirect'] >= 0 ) {
|
345 |
-
$log = RE_Log::create( $url, $target,
|
346 |
}
|
347 |
}
|
348 |
}
|
349 |
|
350 |
-
private function get_ip() {
|
351 |
-
if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) )
|
352 |
-
return $_SERVER['HTTP_X_FORWARDED_FOR'];
|
353 |
-
elseif ( isset( $_SERVER['REMOTE_ADDR'] ) )
|
354 |
-
return $_SERVER['REMOTE_ADDR'];
|
355 |
-
return '';
|
356 |
-
}
|
357 |
-
|
358 |
-
private function get_referrer() {
|
359 |
-
if ( isset( $_SERVER['HTTP_REFERER'] ) ) {
|
360 |
-
return $_SERVER['HTTP_REFERER'];
|
361 |
-
}
|
362 |
-
|
363 |
-
return '';
|
364 |
-
}
|
365 |
-
|
366 |
-
private function get_user_agent() {
|
367 |
-
if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
368 |
-
return $_SERVER['HTTP_USER_AGENT'];
|
369 |
-
}
|
370 |
-
|
371 |
-
return '';
|
372 |
-
}
|
373 |
-
|
374 |
public function is_enabled() {
|
375 |
return $this->status === 'enabled';
|
376 |
}
|
163 |
$parsed_domain = parse_url( site_url() );
|
164 |
|
165 |
if ( isset( $parsed_url['scheme'] ) && ( $parsed_url['scheme'] === 'http' || $parsed_url['scheme'] === 'https' ) && $parsed_url['host'] !== $parsed_domain['host'] ) {
|
166 |
+
return new WP_Error( 'redirect-add', sprintf( __( 'You can only redirect from a relative URL (<code>%s</code>) on this domain (<code>%s</code>).', 'redirection' ), isset( $parsed_url['path'] ) ? $parsed_url['path'] : '', $parsed_domain['host'] ) );
|
167 |
}
|
168 |
|
169 |
$matcher = Red_Match::create( $details['match'] );
|
186 |
elseif ( $action === 'error' )
|
187 |
$action_code = 404;
|
188 |
|
189 |
+
if ( isset( $details['action_code'] ) && get_status_header_desc( $details['action_code'] ) !== '' ) {
|
190 |
$action_code = intval( $details['action_code'] );
|
191 |
+
}
|
192 |
|
193 |
$data = array(
|
194 |
'url' => self::sanitize_url( $details['source'], $regex ),
|
214 |
return new WP_Error( 'redirect-add', __( 'Unable to add new redirect - delete Redirection from the options page and re-install' ) );
|
215 |
}
|
216 |
|
217 |
+
public static function disable_where_matches( $url ) {
|
218 |
+
global $wpdb;
|
219 |
+
|
220 |
+
$wpdb->update( $wpdb->prefix.'redirection_items', array( 'status' => 'disabled' ), array( 'url' => $url ) );
|
221 |
+
}
|
222 |
+
|
223 |
public function delete() {
|
224 |
global $wpdb;
|
225 |
|
310 |
if ( ( $this->regex === false && ( $this->url === $url || $this->url === rtrim( $url, '/' ) || $this->url === urldecode( $url ) ) ) || ( $this->regex === true && @preg_match( '@'.str_replace( '@', '\\@', $this->url ).'@', $url, $matches ) > 0) || ( $this->regex === true && @preg_match( '@'.str_replace( '@', '\\@', $this->url ).'@', urldecode( $url ), $matches ) > 0) ) {
|
311 |
// Check if our match wants this URL
|
312 |
$target = $this->match->get_target( $url, $this->url, $this->regex );
|
313 |
+
$target = apply_filters( 'redirection_url_target', $target, $this->url );
|
314 |
|
315 |
+
if ( $target && $this->is_enabled() ) {
|
|
|
|
|
316 |
$this->visit( $url, $target );
|
317 |
+
return $this->action->process_before( $this->action_code, $target );
|
|
|
|
|
318 |
}
|
319 |
}
|
320 |
|
321 |
return false;
|
322 |
}
|
323 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
324 |
function visit( $url, $target ) {
|
325 |
if ( $this->tracking && $this->id ) {
|
326 |
global $wpdb;
|
331 |
|
332 |
$options = red_get_options();
|
333 |
if ( isset( $options['expire_redirect'] ) && $options['expire_redirect'] >= 0 ) {
|
334 |
+
$log = RE_Log::create( $url, $target, Redirection_Request::get_user_agent(), Redirection_Request::get_ip(), Redirection_Request::get_referrer(), array( 'redirect_id' => $this->id, 'group_id' => $this->group_id ) );
|
335 |
}
|
336 |
}
|
337 |
}
|
338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
339 |
public function is_enabled() {
|
340 |
return $this->status === 'enabled';
|
341 |
}
|
models/request.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Redirection_Request {
|
4 |
+
public static function get_request_url() {
|
5 |
+
$url = '';
|
6 |
+
|
7 |
+
if ( isset( $_SERVER['REQUEST_URI'] ) ) {
|
8 |
+
$url = $_SERVER['REQUEST_URI'];
|
9 |
+
}
|
10 |
+
|
11 |
+
return apply_filters( 'redirection_request_url', $url );
|
12 |
+
}
|
13 |
+
|
14 |
+
public static function get_user_agent() {
|
15 |
+
$agent = '';
|
16 |
+
|
17 |
+
if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
18 |
+
$agent = $_SERVER['HTTP_USER_AGENT'];
|
19 |
+
}
|
20 |
+
|
21 |
+
return apply_filters( 'redirection_request_agent', $agent );
|
22 |
+
}
|
23 |
+
|
24 |
+
public static function get_referrer() {
|
25 |
+
$referrer = '';
|
26 |
+
|
27 |
+
if ( isset( $_SERVER['HTTP_REFERER'] ) ) {
|
28 |
+
$referrer = $_SERVER['HTTP_REFERER'];
|
29 |
+
}
|
30 |
+
|
31 |
+
return apply_filters( 'redirection_request_referrer', $referrer );
|
32 |
+
}
|
33 |
+
|
34 |
+
public static function get_ip() {
|
35 |
+
$ip = '';
|
36 |
+
|
37 |
+
if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
|
38 |
+
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
39 |
+
} elseif ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
|
40 |
+
$ip = $_SERVER['REMOTE_ADDR'];
|
41 |
+
}
|
42 |
+
|
43 |
+
return apply_filters( 'redirection_request_ip', $ip );
|
44 |
+
}
|
45 |
+
}
|
modules/wordpress.php
CHANGED
@@ -34,10 +34,10 @@ class WordPress_Module extends Red_Module {
|
|
34 |
}
|
35 |
|
36 |
public function init() {
|
37 |
-
$url =
|
38 |
|
39 |
// Make sure we don't try and redirect something essential
|
40 |
-
if ( ! $this->protected_url( $url ) && $this->matched === false ) {
|
41 |
do_action( 'redirection_first', $url, $this );
|
42 |
|
43 |
$redirects = Red_Item::get_for_url( $url, 'wp' );
|
@@ -62,7 +62,7 @@ class WordPress_Module extends Red_Module {
|
|
62 |
$options = red_get_options();
|
63 |
|
64 |
if ( isset( $options['expire_404'] ) && $options['expire_404'] >= 0 ) {
|
65 |
-
RE_404::create(
|
66 |
}
|
67 |
}
|
68 |
}
|
@@ -136,30 +136,4 @@ class WordPress_Module extends Red_Module {
|
|
136 |
public function get_description() {
|
137 |
return __( 'WordPress-powered redirects. This requires no further configuration, and you can track hits.', 'redirection' );
|
138 |
}
|
139 |
-
|
140 |
-
private function get_url() {
|
141 |
-
if ( isset( $_SERVER['REQUEST_URI'] ) )
|
142 |
-
return $_SERVER['REQUEST_URI'];
|
143 |
-
return '';
|
144 |
-
}
|
145 |
-
|
146 |
-
private function get_user_agent() {
|
147 |
-
if ( isset( $_SERVER['HTTP_USER_AGENT'] ) )
|
148 |
-
return $_SERVER['HTTP_USER_AGENT'];
|
149 |
-
return false;
|
150 |
-
}
|
151 |
-
|
152 |
-
private function get_referrer() {
|
153 |
-
if ( isset( $_SERVER['HTTP_REFERER'] ) )
|
154 |
-
return $_SERVER['HTTP_REFERER'];
|
155 |
-
return false;
|
156 |
-
}
|
157 |
-
|
158 |
-
private function get_ip() {
|
159 |
-
if ( isset( $_SERVER['REMOTE_ADDR'] ) )
|
160 |
-
return $_SERVER['REMOTE_ADDR'];
|
161 |
-
elseif ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) )
|
162 |
-
return $_SERVER['HTTP_X_FORWARDED_FOR'];
|
163 |
-
return '';
|
164 |
-
}
|
165 |
}
|
34 |
}
|
35 |
|
36 |
public function init() {
|
37 |
+
$url = apply_filters( 'redirection_url_source', Redirection_Request::get_request_url() );
|
38 |
|
39 |
// Make sure we don't try and redirect something essential
|
40 |
+
if ( $url && ! $this->protected_url( $url ) && $this->matched === false ) {
|
41 |
do_action( 'redirection_first', $url, $this );
|
42 |
|
43 |
$redirects = Red_Item::get_for_url( $url, 'wp' );
|
62 |
$options = red_get_options();
|
63 |
|
64 |
if ( isset( $options['expire_404'] ) && $options['expire_404'] >= 0 ) {
|
65 |
+
RE_404::create( Redirection_Request::get_request_url(), Redirection_Request::get_user_agent(), Redirection_Request::get_ip(), Redirection_Request::get_referrer() );
|
66 |
}
|
67 |
}
|
68 |
}
|
136 |
public function get_description() {
|
137 |
return __( 'WordPress-powered redirects. This requires no further configuration, and you can track hits.', 'redirection' );
|
138 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
}
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: johnny5
|
|
3 |
Donate link: http://urbangiraffe.com/about/
|
4 |
Tags: post, admin, seo, pages, manage, 301, 404, redirect, permalink
|
5 |
Requires at least: 4.2
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 2.6
|
8 |
|
9 |
Redirection is a WordPress plugin to manage 301 redirections and keep track of 404 errors without requiring knowledge of Apache .htaccess files.
|
10 |
|
@@ -97,6 +97,15 @@ The plugin works in a similar manner to how WordPress handles permalinks and sho
|
|
97 |
|
98 |
== Changelog ==
|
99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
= 2.6 =
|
101 |
* Show example CSV
|
102 |
* Allow regex and redirect code to be set on import
|
3 |
Donate link: http://urbangiraffe.com/about/
|
4 |
Tags: post, admin, seo, pages, manage, 301, 404, redirect, permalink
|
5 |
Requires at least: 4.2
|
6 |
+
Tested up to: 4.8
|
7 |
+
Stable tag: 2.6.1
|
8 |
|
9 |
Redirection is a WordPress plugin to manage 301 redirections and keep track of 404 errors without requiring knowledge of Apache .htaccess files.
|
10 |
|
97 |
|
98 |
== Changelog ==
|
99 |
|
100 |
+
= 2.6.1 =
|
101 |
+
* Fix CSV export merging everything into one line
|
102 |
+
* Fix bug with HTTP codes not being imported from CSV
|
103 |
+
* Add filters for source and target URLs
|
104 |
+
* Add filters for log and 404s
|
105 |
+
* Add filters for request data
|
106 |
+
* Add filter for monitoring post permalinks
|
107 |
+
* Fix export of 404 and logs
|
108 |
+
|
109 |
= 2.6 =
|
110 |
* Show example CSV
|
111 |
* Allow regex and redirect code to be set on import
|
redirection-admin.php
CHANGED
@@ -221,22 +221,24 @@ class Redirection_Admin {
|
|
221 |
}
|
222 |
|
223 |
if ( isset( $_GET['page'] ) && isset( $_GET['sub'] ) && $_GET['page'] === 'redirection.php' ) {
|
224 |
-
|
|
|
|
|
|
|
|
|
225 |
|
226 |
-
if ( $exporter ) {
|
227 |
-
$items = Red_Item::get_all_for_module( intval( $_GET['module'] ) );
|
228 |
-
|
229 |
-
$exporter->export( $items );
|
230 |
die();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
}
|
232 |
}
|
233 |
-
elseif ( isset( $_POST['export-csv'] ) && check_admin_referer( 'redirection-log_management' ) ) {
|
234 |
-
if ( isset( $_GET['sub'] ) && $_GET['sub'] === 'log' )
|
235 |
-
RE_Log::export_to_csv();
|
236 |
-
else
|
237 |
-
RE_404::export_to_csv();
|
238 |
-
die();
|
239 |
-
}
|
240 |
}
|
241 |
|
242 |
function admin_screen_options() {
|
221 |
}
|
222 |
|
223 |
if ( isset( $_GET['page'] ) && isset( $_GET['sub'] ) && $_GET['page'] === 'redirection.php' ) {
|
224 |
+
if ( isset( $_POST['export-csv'] ) && check_admin_referer( 'redirection-log_management' ) ) {
|
225 |
+
if ( isset( $_GET['sub'] ) && $_GET['sub'] === 'log' )
|
226 |
+
RE_Log::export_to_csv();
|
227 |
+
else
|
228 |
+
RE_404::export_to_csv();
|
229 |
|
|
|
|
|
|
|
|
|
230 |
die();
|
231 |
+
} else {
|
232 |
+
$exporter = Red_FileIO::create( $_GET['sub'] );
|
233 |
+
|
234 |
+
if ( $exporter ) {
|
235 |
+
$items = Red_Item::get_all_for_module( intval( $_GET['module'] ) );
|
236 |
+
|
237 |
+
$exporter->export( $items );
|
238 |
+
die();
|
239 |
+
}
|
240 |
}
|
241 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
}
|
243 |
|
244 |
function admin_screen_options() {
|
redirection-front.php
CHANGED
@@ -19,12 +19,32 @@ class Redirection {
|
|
19 |
$this->module->start();
|
20 |
|
21 |
add_action( Red_Flusher::DELETE_HOOK, array( $this, 'clean_redirection_logs' ) );
|
|
|
22 |
}
|
23 |
|
24 |
public function clean_redirection_logs() {
|
25 |
$flusher = new Red_Flusher();
|
26 |
$flusher->flush();
|
27 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
}
|
29 |
|
30 |
add_action( 'plugins_loaded', array( 'Redirection', 'init' ) );
|
19 |
$this->module->start();
|
20 |
|
21 |
add_action( Red_Flusher::DELETE_HOOK, array( $this, 'clean_redirection_logs' ) );
|
22 |
+
add_action( 'redirection_url_target', array( $this, 'replace_special_tags' ) );
|
23 |
}
|
24 |
|
25 |
public function clean_redirection_logs() {
|
26 |
$flusher = new Red_Flusher();
|
27 |
$flusher->flush();
|
28 |
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* From the distant Redirection past. Undecided whether to keep
|
32 |
+
*/
|
33 |
+
public function replace_special_tags( $url ) {
|
34 |
+
if ( is_numeric( $url ) ) {
|
35 |
+
$url = get_permalink( $url );
|
36 |
+
} else {
|
37 |
+
$user = wp_get_current_user();
|
38 |
+
|
39 |
+
if ( ! empty( $user ) ) {
|
40 |
+
$url = str_replace( '%userid%', $user->ID, $url );
|
41 |
+
$url = str_replace( '%userlogin%', isset( $user->user_login ) ? $user->user_login : '', $url );
|
42 |
+
$url = str_replace( '%userurl%', isset( $user->user_url ) ? $user->user_url : '', $url );
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
return $url;
|
47 |
+
}
|
48 |
}
|
49 |
|
50 |
add_action( 'plugins_loaded', array( 'Redirection', 'init' ) );
|
redirection.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Redirection
|
4 |
Plugin URI: http://urbangiraffe.com/plugins/redirection/
|
5 |
Description: Manage all your 301 redirects and monitor 404 errors
|
6 |
-
Version: 2.6
|
7 |
Author: John Godley
|
8 |
Author URI: http://urbangiraffe.com
|
9 |
Text Domain: redirection
|
@@ -30,6 +30,7 @@ include dirname( __FILE__ ).'/models/log.php';
|
|
30 |
include dirname( __FILE__ ).'/models/flusher.php';
|
31 |
include dirname( __FILE__ ).'/models/match.php';
|
32 |
include dirname( __FILE__ ).'/models/action.php';
|
|
|
33 |
|
34 |
function red_get_options() {
|
35 |
$options = get_option( 'redirection_options' );
|
3 |
Plugin Name: Redirection
|
4 |
Plugin URI: http://urbangiraffe.com/plugins/redirection/
|
5 |
Description: Manage all your 301 redirects and monitor 404 errors
|
6 |
+
Version: 2.6.1
|
7 |
Author: John Godley
|
8 |
Author URI: http://urbangiraffe.com
|
9 |
Text Domain: redirection
|
30 |
include dirname( __FILE__ ).'/models/flusher.php';
|
31 |
include dirname( __FILE__ ).'/models/match.php';
|
32 |
include dirname( __FILE__ ).'/models/action.php';
|
33 |
+
include dirname( __FILE__ ).'/models/request.php';
|
34 |
|
35 |
function red_get_options() {
|
36 |
$options = get_option( 'redirection_options' );
|