Redirection - Version 2.4.4

Version Description

  • Fix large advanced settings icon
  • Add text domain to plugin file, props Bernhard Kau
  • Better PHP7 compatibility, props to Ohad Raz
  • Better Polylang compatibility, props to imrehg
Download this release

Release Info

Developer johnny5
Plugin Icon 128x128 Redirection
Version 2.4.4
Comparing to
See all releases

Code changes from version 2.4.3 to 2.4.4

README.md CHANGED
@@ -1,6 +1,8 @@
1
  Redirection
2
  ===========
3
 
 
 
4
  Redirection is a WordPress plugin to manage 301 redirections, keep track of 404 errors, and generally tidy up any loose ends your site may have. This is particularly useful if you are migrating pages from an old website, or are changing the directory of your WordPress installation.
5
 
6
  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.
@@ -16,3 +18,7 @@ Support
16
  Please raise any bug reports or enhancement requests here. Pull requests are always welcome.
17
 
18
  You can find a more detailed description of the plugin on the [Redirection home page](http://urbangiraffe.com/plugins/redirection/)
 
 
 
 
1
  Redirection
2
  ===========
3
 
4
+ [![Build Status](https://travis-ci.org/johngodley/redirection.svg?branch=master)](https://travis-ci.org/johngodley/redirection)
5
+
6
  Redirection is a WordPress plugin to manage 301 redirections, keep track of 404 errors, and generally tidy up any loose ends your site may have. This is particularly useful if you are migrating pages from an old website, or are changing the directory of your WordPress installation.
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.
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/)
21
+
22
+ Translations can be added here:
23
+
24
+ https://translate.wordpress.org/projects/wp-plugins/redirection
admin.css CHANGED
@@ -47,11 +47,15 @@ table.items .red-disabled {
47
  }
48
 
49
  .advanced-toggle {
50
- font-size: 26px;
51
  margin-left: 15px;
52
  vertical-align: sub;
53
  }
54
 
 
 
 
 
 
55
  .advanced-toggled {
56
  color: #aaa !important;
57
  }
47
  }
48
 
49
  .advanced-toggle {
 
50
  margin-left: 15px;
51
  vertical-align: sub;
52
  }
53
 
54
+ .advanced-toggle img {
55
+ width: 15px;
56
+ height: 15px;
57
+ }
58
+
59
  .advanced-toggled {
60
  color: #aaa !important;
61
  }
images/modules/404.png DELETED
Binary file
images/modules/apache.png DELETED
Binary file
images/modules/wordpress.png DELETED
Binary file
locale/redirection.pot CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2015 Redirection
2
  # This file is distributed under the same license as the Redirection package.
3
  msgid ""
4
  msgstr ""
@@ -7,7 +7,7 @@ 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: 2015-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"
@@ -195,39 +195,39 @@ msgstr ""
195
  msgid "Configure"
196
  msgstr ""
197
 
198
- #: models/redirect.php:139
199
  msgid "Source and target URL must be different"
200
  msgstr ""
201
 
202
- #: models/redirect.php:145
203
  msgid "You can only redirect from a relative URL (<code>%s</code>) on this domain (<code>%s</code>)."
204
  msgstr ""
205
 
206
- #: models/redirect.php:153
207
  msgid "Invalid group when creating redirect"
208
  msgstr ""
209
 
210
- #: models/redirect.php:156
211
  msgid "Invalid source URL when creating redirect for given match type"
212
  msgstr ""
213
 
214
- #: models/redirect.php:362
215
  msgid "Redirect to URL"
216
  msgstr ""
217
 
218
- #: models/redirect.php:363
219
  msgid "Redirect to random post"
220
  msgstr ""
221
 
222
- #: models/redirect.php:364
223
  msgid "Pass-through"
224
  msgstr ""
225
 
226
- #: models/redirect.php:365
227
  msgid "Error (404)"
228
  msgstr ""
229
 
230
- #: models/redirect.php:366
231
  msgid "Do nothing"
232
  msgstr ""
233
 
@@ -349,7 +349,7 @@ msgstr ""
349
  msgid "Download"
350
  msgstr ""
351
 
352
- #: redirection-admin.php:505, view/group-edit.php:22, view/item-edit.php:35, view/module-edit.php:13
353
  msgid "Cancel"
354
  msgstr ""
355
 
@@ -373,7 +373,7 @@ msgstr ""
373
  msgid "Regular expression"
374
  msgstr ""
375
 
376
- #: view/add.php:36, view/item-edit.php:20
377
  msgid "Group"
378
  msgstr ""
379
 
@@ -381,7 +381,7 @@ msgstr ""
381
  msgid "Add Redirection"
382
  msgstr ""
383
 
384
- #: view/group-edit.php:21, view/item-edit.php:34, view/module-edit.php:12
385
  msgid "Save"
386
  msgstr ""
387
 
@@ -401,11 +401,11 @@ msgstr ""
401
  msgid "Add"
402
  msgstr ""
403
 
404
- #: view/item-edit.php:13
405
  msgid "Description"
406
  msgstr ""
407
 
408
- #: view/item-edit.php:16
409
  msgid "optional"
410
  msgstr ""
411
 
1
+ # Copyright (C) 2016 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: 2016-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"
195
  msgid "Configure"
196
  msgstr ""
197
 
198
+ #: models/redirect.php:161
199
  msgid "Source and target URL must be different"
200
  msgstr ""
201
 
202
+ #: models/redirect.php:167
203
  msgid "You can only redirect from a relative URL (<code>%s</code>) on this domain (<code>%s</code>)."
204
  msgstr ""
205
 
206
+ #: models/redirect.php:175
207
  msgid "Invalid group when creating redirect"
208
  msgstr ""
209
 
210
+ #: models/redirect.php:178
211
  msgid "Invalid source URL when creating redirect for given match type"
212
  msgstr ""
213
 
214
+ #: models/redirect.php:384
215
  msgid "Redirect to URL"
216
  msgstr ""
217
 
218
+ #: models/redirect.php:385
219
  msgid "Redirect to random post"
220
  msgstr ""
221
 
222
+ #: models/redirect.php:386
223
  msgid "Pass-through"
224
  msgstr ""
225
 
226
+ #: models/redirect.php:387
227
  msgid "Error (404)"
228
  msgstr ""
229
 
230
+ #: models/redirect.php:388
231
  msgid "Do nothing"
232
  msgstr ""
233
 
349
  msgid "Download"
350
  msgstr ""
351
 
352
+ #: redirection-admin.php:505, view/group-edit.php:22, view/item-edit.php:33, view/module-edit.php:13
353
  msgid "Cancel"
354
  msgstr ""
355
 
373
  msgid "Regular expression"
374
  msgstr ""
375
 
376
+ #: view/add.php:36, view/item-edit.php:18
377
  msgid "Group"
378
  msgstr ""
379
 
381
  msgid "Add Redirection"
382
  msgstr ""
383
 
384
+ #: view/group-edit.php:21, view/item-edit.php:32, view/module-edit.php:12
385
  msgid "Save"
386
  msgstr ""
387
 
401
  msgid "Add"
402
  msgstr ""
403
 
404
+ #: view/item-edit.php:11
405
  msgid "Description"
406
  msgstr ""
407
 
408
+ #: view/item-edit.php:14
409
  msgid "optional"
410
  msgstr ""
411
 
models/action.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  class Red_Action
4
  {
5
- function Red_Action ($values)
6
  {
7
  if (is_array ($values))
8
  {
2
 
3
  class Red_Action
4
  {
5
+ function __construct ($values)
6
  {
7
  if (is_array ($values))
8
  {
models/log.php CHANGED
@@ -9,7 +9,7 @@ class RE_Log {
9
  var $ip;
10
  var $redirection_id;
11
 
12
- function RE_Log( $values ) {
13
  foreach ( $values AS $key => $value ) {
14
  $this->$key = $value;
15
  }
@@ -145,7 +145,7 @@ class RE_404 {
145
  var $referrer;
146
  var $ip;
147
 
148
- function RE_404( $values ) {
149
  foreach ( $values AS $key => $value ) {
150
  $this->$key = $value;
151
  }
9
  var $ip;
10
  var $redirection_id;
11
 
12
+ function __construct( $values ) {
13
  foreach ( $values AS $key => $value ) {
14
  $this->$key = $value;
15
  }
145
  var $referrer;
146
  var $ip;
147
 
148
+ function __construct( $values ) {
149
  foreach ( $values AS $key => $value ) {
150
  $this->$key = $value;
151
  }
models/match.php CHANGED
@@ -3,7 +3,7 @@
3
  class Red_Match {
4
  var $url;
5
 
6
- function Red_Match( $values = '' ) {
7
  if ( $values ) {
8
  $this->url = $values;
9
 
3
  class Red_Match {
4
  var $url;
5
 
6
+ function __construct( $values = '' ) {
7
  if ( $values ) {
8
  $this->url = $values;
9
 
models/monitor.php CHANGED
@@ -4,7 +4,7 @@ class Red_Monitor {
4
  private $monitor_group_id;
5
 
6
  function __construct( $options ) {
7
- if ( $options['monitor_post'] > 0 ) {
8
  $this->monitor_group_id = intval( $options['monitor_post'] );
9
 
10
  // Only monitor if permalinks enabled
@@ -21,28 +21,42 @@ class Red_Monitor {
21
 
22
  $url = parse_url( get_permalink() );
23
  $url = $url['path'];
 
24
  ?>
25
  <input type="hidden" name="redirection_slug" value="<?php echo esc_attr( $url ) ?>"/>
26
  <?php
27
  }
28
 
29
- public function post_updated( $post_id, $post, $post_before ) {
30
- if ( $post->post_status !== 'publish' || is_post_type_hierarchical( $post->post_type ) )
31
- return;
 
 
 
 
 
32
 
33
- if ( isset( $_POST['redirection_slug'] ) ) {
 
 
 
 
 
 
 
 
34
  $after = parse_url( get_permalink( $post_id ) );
35
  $after = $after['path'];
36
  $before = esc_url( $_POST['redirection_slug'] );
37
  $site = parse_url( get_site_url() );
38
 
39
- if ( in_array( $post->post_status, array( 'publish', 'static' ) ) && $before !== $after && $before !== '/' && ( !isset( $site['path'] ) || ( isset( $site['path'] ) && $before !== $site['path'].'/' ) ) ) {
40
  Red_Item::create( array(
41
  'source' => $before,
42
  'target' => $after,
43
  'match' => 'url',
44
  'red_action' => 'url',
45
- 'group_id' => $this->monitor_group_id
46
  ) );
47
  }
48
  }
4
  private $monitor_group_id;
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
21
 
22
  $url = parse_url( get_permalink() );
23
  $url = $url['path'];
24
+
25
  ?>
26
  <input type="hidden" name="redirection_slug" value="<?php echo esc_attr( $url ) ?>"/>
27
  <?php
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
+ if ( is_post_type_hierarchical( $post->post_type ) ) {
36
+ return false;
37
+ }
38
 
39
+ if ( ! isset( $form_data['redirection_slug'] ) ) {
40
+ return false;
41
+ }
42
+
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
  $after = parse_url( get_permalink( $post_id ) );
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
  }
models/redirect.php CHANGED
@@ -18,18 +18,20 @@ class Red_Item {
18
  private $position;
19
  private $group_id;
20
 
21
- function Red_Item( $values, $type = '', $match = '' ) {
22
  if ( is_object( $values ) ) {
23
  foreach ( $values as $key => $value ) {
24
  $this->$key = $value;
25
  }
26
 
27
- if ( $this->match_type ) {
28
- $this->match = Red_Match::create( $this->match_type, $this->action_data );
29
- $this->match->id = $this->id;
30
- $this->match->action_code = $this->action_code;
31
  }
32
 
 
 
 
 
33
  $action = false;
34
 
35
  if ( $this->action_type ) {
18
  private $position;
19
  private $group_id;
20
 
21
+ function __construct( $values, $type = '', $match = '' ) {
22
  if ( is_object( $values ) ) {
23
  foreach ( $values as $key => $value ) {
24
  $this->$key = $value;
25
  }
26
 
27
+ if ( $this->match_type === '' ) {
28
+ $this->match_type = 'url';
 
 
29
  }
30
 
31
+ $this->match = Red_Match::create( $this->match_type, $this->action_data );
32
+ $this->match->id = $this->id;
33
+ $this->match->action_code = $this->action_code;
34
+
35
  $action = false;
36
 
37
  if ( $this->action_type ) {
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  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.0.0
6
  Tested up to: 4.4
7
- Stable tag: 2.4.2
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
 
@@ -90,13 +90,19 @@ The plugin works in a similar manner to how WordPress handles permalinks and sho
90
  == Upgrade Notice ==
91
 
92
  = 2.3.3 =
93
- * Full WordPress 3.5+ compatability! Note that this contains database changes so please backup your data.
94
 
95
  = 2.4 =
96
  * Another database change. Please backup your data
97
 
98
  == Changelog ==
99
 
 
 
 
 
 
 
100
  = 2.4.3 =
101
  * Bump minimum WP to 4.0.0
102
  * Updated German translation, props to Konrad Tadesse
2
  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.1
6
  Tested up to: 4.4
7
+ Stable tag: 2.4.4
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
 
90
  == Upgrade Notice ==
91
 
92
  = 2.3.3 =
93
+ * Full WordPress 3.5+ compatibility! Note that this contains database changes so please backup your data.
94
 
95
  = 2.4 =
96
  * Another database change. Please backup your data
97
 
98
  == Changelog ==
99
 
100
+ = 2.4.4 =
101
+ * Fix large advanced settings icon
102
+ * Add text domain to plugin file, props Bernhard Kau
103
+ * Better PHP7 compatibility, props to Ohad Raz
104
+ * Better Polylang compatibility, props to imrehg
105
+
106
  = 2.4.3 =
107
  * Bump minimum WP to 4.0.0
108
  * Updated German translation, props to Konrad Tadesse
redirection-admin.php CHANGED
@@ -60,7 +60,7 @@ class Redirection_Admin {
60
  }
61
 
62
  private function render( $template, $template_vars = array() ) {
63
- foreach ( $template_vars AS $key => $val ) {
64
  $$key = $val;
65
  }
66
 
@@ -97,7 +97,7 @@ class Redirection_Admin {
97
  private static function update() {
98
  $version = get_option( 'redirection_version' );
99
 
100
- if ( $version != REDIRECTION_VERSION ) {
101
  include_once dirname( REDIRECTION_FILE ).'/models/database.php';
102
 
103
  $database = new RE_Database();
@@ -108,23 +108,23 @@ class Redirection_Admin {
108
  }
109
 
110
  private function select( $items, $default = '' ) {
111
- foreach ( $items AS $key => $value ) {
112
  if ( is_array( $value ) ) {
113
  echo '<optgroup label="'.esc_attr( $key ).'">';
114
 
115
- foreach ( $value AS $sub => $subvalue ) {
116
- echo '<option value="'.esc_attr( $sub ).'"'.( $sub == $default ? ' selected="selected"' : '' ).'>'.esc_html( $subvalue ).'</option>';
117
  }
118
 
119
  echo '</optgroup>';
120
  }
121
  else
122
- echo '<option value="'.esc_attr( $key ).'"'.( $key == $default ? ' selected="selected"' : '' ).'>'.esc_html( $value ).'</option>';
123
  }
124
  }
125
 
126
  function set_per_page( $status, $option, $value ) {
127
- if ( $option == 'redirection_log_per_page' )
128
  return $value;
129
  return $status;
130
  }
@@ -141,7 +141,7 @@ class Redirection_Admin {
141
 
142
  $this->inject();
143
 
144
- if ( !isset( $_GET['sub'] ) || ( isset( $_GET['sub'] ) && ( in_array( $_GET['sub'], array( 'log', '404s', 'groups' ) ) ) ) )
145
  add_screen_option( 'per_page', array( 'label' => __( 'Log entries', 'redirection' ), 'default' => 25, 'option' => 'redirection_log_per_page' ) );
146
 
147
  wp_enqueue_script( 'redirection', plugin_dir_url( REDIRECTION_FILE ).'redirection.js', array( 'jquery-form', 'jquery-ui-sortable' ), $version );
@@ -153,27 +153,27 @@ class Redirection_Admin {
153
  }
154
 
155
  function admin_menu() {
156
- add_management_page( __( "Redirection", 'redirection' ), __( "Redirection", 'redirection' ), apply_filters( 'redirection_role', 'administrator' ), basename( REDIRECTION_FILE ), array( &$this, "admin_screen" ) );
157
  }
158
 
159
  function admin_screen() {
160
  Redirection_Admin::update();
161
 
162
  if ( isset( $_GET['sub'] ) ) {
163
- if ( $_GET['sub'] == 'log' )
164
  return $this->admin_screen_log();
165
- elseif ( $_GET['sub'] == '404s' )
166
  return $this->admin_screen_404();
167
- elseif ( $_GET['sub'] == 'options' )
168
  return $this->admin_screen_options();
169
- elseif ( $_GET['sub'] == 'process' )
170
  return $this->admin_screen_process();
171
- elseif ( $_GET['sub'] == 'groups' )
172
  return $this->admin_groups( isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0 );
173
- elseif ( $_GET['sub'] == 'modules' )
174
  return $this->admin_screen_modules();
175
- elseif ( $_GET['sub'] == 'support' )
176
- return $this->render('support', array( 'options' => red_get_options() ) );
177
  }
178
 
179
  return $this->admin_redirects( isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0 );
@@ -190,12 +190,12 @@ class Redirection_Admin {
190
  function inject() {
191
  $options = red_get_options();
192
 
193
- if ( isset( $_POST['id'] ) && !isset( $_POST['action'] ) ) {
194
  wp_safe_redirect( add_query_arg( 'id', intval( $_POST['id'] ), $_SERVER['REQUEST_URI'] ) );
195
  die();
196
  }
197
 
198
- if ( isset( $_GET['token'] ) && isset( $_GET['page'] ) && isset( $_GET['sub'] ) && $_GET['token'] == $options['token'] && $_GET['page'] == 'redirection.php' ) {
199
  $exporter = Red_FileIO::create( $_GET['sub'] );
200
  if ( $exporter ) {
201
  $items = Red_Item::get_all_for_module( intval( $_GET['module'] ) );
@@ -205,7 +205,7 @@ class Redirection_Admin {
205
  }
206
  }
207
  elseif ( isset( $_POST['export-csv'] ) && check_admin_referer( 'redirection-log_management' ) ) {
208
- if ( isset( $_GET['sub'] ) && $_GET['sub'] == 'log' )
209
  RE_Log::export_to_csv();
210
  else
211
  RE_404::export_to_csv();
@@ -230,7 +230,7 @@ class Redirection_Admin {
230
  $options['expire_redirect'] = min( intval( $_POST['expire_redirect'] ), 60 );
231
  $options['expire_404'] = min( intval( $_POST['expire_404'] ), 60 );
232
 
233
- if ( trim( $options['token'] ) == '' )
234
  $options['token'] = md5( uniqid() );
235
 
236
  update_option( 'redirection_options', $options );
@@ -273,9 +273,9 @@ class Redirection_Admin {
273
 
274
  if ( isset( $_GET['module'] ) )
275
  $table->prepare_items( 'module', intval( $_GET['module'] ) );
276
- else if (isset($_GET['group']))
277
  $table->prepare_items( 'group', intval( $_GET['group'] ) );
278
- else if (isset($_GET['redirect']))
279
  $table->prepare_items( 'redirect', intval( $_GET['redirect'] ) );
280
  else
281
  $table->prepare_items();
@@ -316,7 +316,7 @@ class Redirection_Admin {
316
  $table = new Redirection_Table( Red_Group::get_for_select(), $group_id );
317
  $table->prepare_items();
318
 
319
- $this->render( 'item-list', array( 'options' => red_get_options(), 'group' => $group_id, 'table' => $table, 'date_format' => get_option( 'date_format' ) ) );
320
  }
321
 
322
  function locales() {
@@ -338,10 +338,10 @@ class Redirection_Admin {
338
  return $locales;
339
  }
340
 
341
- public function ajax_log_delete() {
342
  if ( check_ajax_referer( 'redirection-items' ) ) {
343
- if ( preg_match_all( '/=(\d*)/', $_POST['checked'], $items ) > 0) {
344
- foreach ( $items[1] AS $item ) {
345
  RE_Log::delete( intval( $item ) );
346
  }
347
  }
@@ -464,7 +464,7 @@ class Redirection_Admin {
464
  $this->output_ajax_response( $json );
465
  }
466
 
467
- public function ajax_redirect_add() {
468
  global $hook_suffix;
469
 
470
  $hook_suffix = '';
@@ -518,7 +518,7 @@ class Redirection_Admin {
518
 
519
  private function output_ajax_response( array $data ) {
520
  header( 'Content-Type: application/json' );
521
- echo json_encode( $data );
522
  die();
523
  }
524
  }
60
  }
61
 
62
  private function render( $template, $template_vars = array() ) {
63
+ foreach ( $template_vars as $key => $val ) {
64
  $$key = $val;
65
  }
66
 
97
  private static function update() {
98
  $version = get_option( 'redirection_version' );
99
 
100
+ if ( $version !== REDIRECTION_VERSION ) {
101
  include_once dirname( REDIRECTION_FILE ).'/models/database.php';
102
 
103
  $database = new RE_Database();
108
  }
109
 
110
  private function select( $items, $default = '' ) {
111
+ foreach ( $items as $key => $value ) {
112
  if ( is_array( $value ) ) {
113
  echo '<optgroup label="'.esc_attr( $key ).'">';
114
 
115
+ foreach ( $value as $sub => $subvalue ) {
116
+ echo '<option value="'.esc_attr( $sub ).'"'.( $sub === $default ? ' selected="selected"' : '' ).'>'.esc_html( $subvalue ).'</option>';
117
  }
118
 
119
  echo '</optgroup>';
120
  }
121
  else
122
+ echo '<option value="'.esc_attr( $key ).'"'.( $key === $default ? ' selected="selected"' : '' ).'>'.esc_html( $value ).'</option>';
123
  }
124
  }
125
 
126
  function set_per_page( $status, $option, $value ) {
127
+ if ( $option === 'redirection_log_per_page' )
128
  return $value;
129
  return $status;
130
  }
141
 
142
  $this->inject();
143
 
144
+ if ( ! isset( $_GET['sub'] ) || ( isset( $_GET['sub'] ) && ( in_array( $_GET['sub'], array( 'log', '404s', 'groups' ) ) ) ) )
145
  add_screen_option( 'per_page', array( 'label' => __( 'Log entries', 'redirection' ), 'default' => 25, 'option' => 'redirection_log_per_page' ) );
146
 
147
  wp_enqueue_script( 'redirection', plugin_dir_url( REDIRECTION_FILE ).'redirection.js', array( 'jquery-form', 'jquery-ui-sortable' ), $version );
153
  }
154
 
155
  function admin_menu() {
156
+ add_management_page( __( 'Redirection', 'redirection' ), __( 'Redirection', 'redirection' ), apply_filters( 'redirection_role', 'administrator' ), basename( REDIRECTION_FILE ), array( &$this, 'admin_screen' ) );
157
  }
158
 
159
  function admin_screen() {
160
  Redirection_Admin::update();
161
 
162
  if ( isset( $_GET['sub'] ) ) {
163
+ if ( $_GET['sub'] === 'log' )
164
  return $this->admin_screen_log();
165
+ elseif ( $_GET['sub'] === '404s' )
166
  return $this->admin_screen_404();
167
+ elseif ( $_GET['sub'] === 'options' )
168
  return $this->admin_screen_options();
169
+ elseif ( $_GET['sub'] === 'process' )
170
  return $this->admin_screen_process();
171
+ elseif ( $_GET['sub'] === 'groups' )
172
  return $this->admin_groups( isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0 );
173
+ elseif ( $_GET['sub'] === 'modules' )
174
  return $this->admin_screen_modules();
175
+ elseif ( $_GET['sub'] === 'support' )
176
+ return $this->render( 'support', array( 'options' => red_get_options() ) );
177
  }
178
 
179
  return $this->admin_redirects( isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0 );
190
  function inject() {
191
  $options = red_get_options();
192
 
193
+ if ( isset( $_POST['id'] ) && ! isset( $_POST['action'] ) ) {
194
  wp_safe_redirect( add_query_arg( 'id', intval( $_POST['id'] ), $_SERVER['REQUEST_URI'] ) );
195
  die();
196
  }
197
 
198
+ if ( isset( $_GET['token'] ) && isset( $_GET['page'] ) && isset( $_GET['sub'] ) && $_GET['token'] === $options['token'] && $_GET['page'] === 'redirection.php' ) {
199
  $exporter = Red_FileIO::create( $_GET['sub'] );
200
  if ( $exporter ) {
201
  $items = Red_Item::get_all_for_module( intval( $_GET['module'] ) );
205
  }
206
  }
207
  elseif ( isset( $_POST['export-csv'] ) && check_admin_referer( 'redirection-log_management' ) ) {
208
+ if ( isset( $_GET['sub'] ) && $_GET['sub'] === 'log' )
209
  RE_Log::export_to_csv();
210
  else
211
  RE_404::export_to_csv();
230
  $options['expire_redirect'] = min( intval( $_POST['expire_redirect'] ), 60 );
231
  $options['expire_404'] = min( intval( $_POST['expire_404'] ), 60 );
232
 
233
+ if ( trim( $options['token'] ) === '' )
234
  $options['token'] = md5( uniqid() );
235
 
236
  update_option( 'redirection_options', $options );
273
 
274
  if ( isset( $_GET['module'] ) )
275
  $table->prepare_items( 'module', intval( $_GET['module'] ) );
276
+ else if ( isset( $_GET['group'] ) )
277
  $table->prepare_items( 'group', intval( $_GET['group'] ) );
278
+ else if ( isset( $_GET['redirect'] ) )
279
  $table->prepare_items( 'redirect', intval( $_GET['redirect'] ) );
280
  else
281
  $table->prepare_items();
316
  $table = new Redirection_Table( Red_Group::get_for_select(), $group_id );
317
  $table->prepare_items();
318
 
319
+ $this->render( 'item-list', array( 'options' => red_get_options(), 'group' => $group_id, 'table' => $table, 'date_format' => get_option( 'date_format' ) ) );
320
  }
321
 
322
  function locales() {
338
  return $locales;
339
  }
340
 
341
+ public function ajax_log_delete() {
342
  if ( check_ajax_referer( 'redirection-items' ) ) {
343
+ if ( preg_match_all( '/=(\d*)/', $_POST['checked'], $items ) > 0 ) {
344
+ foreach ( $items[1] as $item ) {
345
  RE_Log::delete( intval( $item ) );
346
  }
347
  }
464
  $this->output_ajax_response( $json );
465
  }
466
 
467
+ public function ajax_redirect_add() {
468
  global $hook_suffix;
469
 
470
  $hook_suffix = '';
518
 
519
  private function output_ajax_response( array $data ) {
520
  header( 'Content-Type: application/json' );
521
+ echo wp_json_encode( $data );
522
  die();
523
  }
524
  }
redirection.php CHANGED
@@ -3,9 +3,10 @@
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.4.3
7
  Author: John Godley
8
  Author URI: http://urbangiraffe.com
 
9
  ============================================================================================================
10
  This software is provided "as is" and any express or implied warranties, including, but not limited to, the
11
  implied warranties of merchantibility and fitness for a particular purpose are disclaimed. In no event shall
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.4.4
7
  Author: John Godley
8
  Author URI: http://urbangiraffe.com
9
+ Text Domain: redirection
10
  ============================================================================================================
11
  This software is provided "as is" and any express or implied warranties, including, but not limited to, the
12
  implied warranties of merchantibility and fitness for a particular purpose are disclaimed. In no event shall
view/item-edit.php CHANGED
@@ -5,8 +5,6 @@
5
  <td>
6
  <input style="width: 85%" type="text" name="old" value="<?php echo esc_attr( $redirect->get_url() ); ?>" id="original"/>
7
  <label><?php _e( 'Regex', 'redirection' ); ?>: <input type="checkbox" name="regex" <?php if ( $redirect->is_regex() ) echo ' checked="checked"' ?>/></label>
8
-
9
- <a href="#" class="advanced-toggle">&#9881;</a>
10
  </td>
11
  </tr>
12
  <tr class="advanced">
@@ -34,6 +32,10 @@
34
  <input class="button-primary" type="submit" name="save" value="<?php _e( 'Save', 'redirection' ); ?>"/>
35
  <input class="button-secondary" type="submit" name="cancel" value="<?php _e( 'Cancel', 'redirection' ); ?>"/>
36
 
 
 
 
 
37
  <input type="hidden" name="action" value="red_redirect_save"/>
38
  <input type="hidden" name="id" value="<?php echo esc_attr( $redirect->get_id() ); ?>"/>
39
  <?php wp_nonce_field( 'redirection-redirect_save_'.$redirect->get_id() ) ?>
5
  <td>
6
  <input style="width: 85%" type="text" name="old" value="<?php echo esc_attr( $redirect->get_url() ); ?>" id="original"/>
7
  <label><?php _e( 'Regex', 'redirection' ); ?>: <input type="checkbox" name="regex" <?php if ( $redirect->is_regex() ) echo ' checked="checked"' ?>/></label>
 
 
8
  </td>
9
  </tr>
10
  <tr class="advanced">
32
  <input class="button-primary" type="submit" name="save" value="<?php _e( 'Save', 'redirection' ); ?>"/>
33
  <input class="button-secondary" type="submit" name="cancel" value="<?php _e( 'Cancel', 'redirection' ); ?>"/>
34
 
35
+ <a href="#" class="advanced-toggle" title="<?php esc_attr_e( 'Advanced Settings' ); ?>">
36
+ <img src="https://s.w.org/images/core/emoji/72x72/2699.png"/>
37
+ </a>
38
+
39
  <input type="hidden" name="action" value="red_redirect_save"/>
40
  <input type="hidden" name="id" value="<?php echo esc_attr( $redirect->get_id() ); ?>"/>
41
  <?php wp_nonce_field( 'redirection-redirect_save_'.$redirect->get_id() ) ?>
view/options.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php if( !defined( 'ABSPATH' ) ) die( 'No direct access allowed' ); ?>
2
 
3
  <?php
4
 
@@ -62,14 +62,14 @@ $expiry = array(
62
  <tr>
63
  <th align="right"><?php _e( 'RSS Token', 'redirection' ); ?>:</th>
64
  <td>
65
- <input class="regular-text" size="5" type="text" name="token" value="<?php echo esc_attr( $options['token'] ) ?>"/><br/>
66
  <span class="sub"><?php _e( 'A unique token allowing feed readers access to Redirection log RSS (leave blank to auto-generate)', 'redirection' ); ?></span>
67
  </td>
68
  </tr>
69
  <tr>
70
  <th valign="top" align="right"><?php _e( 'Auto-generate URL', 'redirection' ) ?>:</th>
71
  <td>
72
- <input type="text" name="auto_target" style="width: 65%" value="<?php echo esc_attr( $options['auto_target'] ) ?>"/>
73
  <br/>
74
  <span class="sub"><?php _e( '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)', 'redirection' ); ?></span>
75
  </td>
@@ -105,6 +105,6 @@ $expiry = array(
105
  <form action="" method="post" accept-charset="utf-8">
106
  <?php wp_nonce_field( 'redirection-delete_plugin' ); ?>
107
 
108
- <input class="button-primary" type="submit" name="delete" value="<?php _e( 'Delete', 'redirection' ) ?>"/>
109
  </form>
110
  </div>
1
+ <?php if ( ! defined( 'ABSPATH' ) ) die( 'No direct access allowed' ); ?>
2
 
3
  <?php
4
 
62
  <tr>
63
  <th align="right"><?php _e( 'RSS Token', 'redirection' ); ?>:</th>
64
  <td>
65
+ <input class="regular-text" size="5" type="text" name="token" value="<?php echo esc_attr( $options['token'] ) ?>"/><br/>
66
  <span class="sub"><?php _e( 'A unique token allowing feed readers access to Redirection log RSS (leave blank to auto-generate)', 'redirection' ); ?></span>
67
  </td>
68
  </tr>
69
  <tr>
70
  <th valign="top" align="right"><?php _e( 'Auto-generate URL', 'redirection' ) ?>:</th>
71
  <td>
72
+ <input type="text" name="auto_target" style="width: 65%" value="<?php echo esc_attr( $options['auto_target'] ) ?>"/>
73
  <br/>
74
  <span class="sub"><?php _e( '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)', 'redirection' ); ?></span>
75
  </td>
105
  <form action="" method="post" accept-charset="utf-8">
106
  <?php wp_nonce_field( 'redirection-delete_plugin' ); ?>
107
 
108
+ <input class="button-primary" type="submit" name="delete" value="<?php _e( 'Delete', 'redirection' ) ?>" onclick="return confirm( '<?php esc_attr_e( "Are you sure you want to delete everything?" );?>')"/>
109
  </form>
110
  </div>